From e1d531196f9dfca5b13c3b00efae4bfb222b46cb Mon Sep 17 00:00:00 2001 From: Lior Cohen Date: Wed, 16 Nov 2011 15:16:07 +0200 Subject: [PATCH] wl18xx: add debugfs support to tx_ba_win_size & hw_tx_extra_mem_blk tx_ba_win_size default val is 10 hw_tx_extra_mem_blk default val is 1 signed-off-by: Lior Cohen --- drivers/net/wireless/wl12xx/acx.c | 2 +- drivers/net/wireless/wl12xx/boot.c | 23 ++++--- drivers/net/wireless/wl12xx/conf.h | 1 + drivers/net/wireless/wl12xx/debugfs.c | 94 ++++++++++++++++++++++++++- drivers/net/wireless/wl12xx/main.c | 3 +- drivers/net/wireless/wl12xx/tx.c | 6 +- drivers/net/wireless/wl12xx/tx.h | 4 +- drivers/net/wireless/wl12xx/wl12xx.h | 2 +- 8 files changed, 115 insertions(+), 20 deletions(-) diff --git a/drivers/net/wireless/wl12xx/acx.c b/drivers/net/wireless/wl12xx/acx.c index f5843bc7681b..7c657dbcd60e 100755 --- a/drivers/net/wireless/wl12xx/acx.c +++ b/drivers/net/wireless/wl12xx/acx.c @@ -1064,7 +1064,7 @@ int wl1271_acx_host_if_cfg_bitmap(struct wl1271 *wl, u32 host_cfg_bitmap) bitmap_conf->host_cfg_bitmap = cpu_to_le32(host_cfg_bitmap); bitmap_conf->host_sdio_block_size = cpu_to_le32(WL12XX_BUS_BLOCK_SIZE); - bitmap_conf->extra_mem_blocks = cpu_to_le32(TX_HW_EXTRA_MEM_BLKS_DEF); + bitmap_conf->extra_mem_blocks = cpu_to_le32(wl->conf.hw_tx_extra_mem_blk); bitmap_conf->length_field_size = cpu_to_le32(HOST_IF_CFG_LEN_FIELD_SIZE); ret = wl1271_cmd_configure(wl, ACX_HOST_IF_CFG_BITMAP, diff --git a/drivers/net/wireless/wl12xx/boot.c b/drivers/net/wireless/wl12xx/boot.c index dd7c535d5357..98d15e84e03d 100644 --- a/drivers/net/wireless/wl12xx/boot.c +++ b/drivers/net/wireless/wl12xx/boot.c @@ -473,7 +473,6 @@ static int wl1271_boot_run_firmware(struct wl1271 *wl) int loop, ret; u32 chip_id, intr; - /* Orit - added */ wl1271_set_partition(wl, &part_table[PART_BOOT]); wl1271_boot_set_ecpu_ctrl(wl, ECPU_CONTROL_HALT); @@ -512,7 +511,7 @@ static int wl1271_boot_run_firmware(struct wl1271 *wl) return -EIO; } - wl1271_info("Orit WL18xx - Init Complete!!!"); + wl1271_info("WL18xx - Init Complete!!!"); /* get hardware config command mail box */ wl->cmd_box_addr = wl1271_read32(wl, REG_COMMAND_MAILBOX_PTR); @@ -761,10 +760,10 @@ static int wl18xx_boot_clk(struct wl1271 *wl, int *selected_clock) } /* 2. CLK detection */ - wl1271_debug(DEBUG_BOOT, "Orit Wl18xx - CLK detection"); + wl1271_debug(DEBUG_BOOT, "Wl18xx - CLK detection"); /* Read CLK type from detection (for PG2) - TCXO/FREF or XTAL */ osc_en = wl1271_top_reg_read(wl, OSC_EN); - wl1271_debug(DEBUG_BOOT, "Orit Wl18xx - osc_en = 0x%x", osc_en); + wl1271_debug(DEBUG_BOOT, "Wl18xx - osc_en = 0x%x", osc_en); /* Check the clock source in bit 3 from OSC_EN */ if (!(osc_en & PRCM_WLAN_CLK_DETECTION_MASK)) { @@ -783,10 +782,10 @@ static int wl18xx_boot_clk(struct wl1271 *wl, int *selected_clock) /* Read freq from detection */ clk_freq = wl1271_top_reg_read(wl, PRIMARY_CLK_DETECT); - wl1271_debug(DEBUG_BOOT, "Orit Wl18xx - Read from addr 0x%x clock freq %d", PRIMARY_CLK_DETECT, clk_freq); + wl1271_debug(DEBUG_BOOT, "Wl18xx - Read from addr 0x%x clock freq %d", PRIMARY_CLK_DETECT, clk_freq); /* 3. WCS PLL Config */ - wl1271_debug(DEBUG_BOOT, "Orit Wl18xx - WCS PLL Config"); + wl1271_debug(DEBUG_BOOT, "Wl18xx - WCS PLL Config"); switch (clk_freq) { case CLOCK_CONFIG_16_2_M: @@ -836,11 +835,11 @@ static int wl18xx_boot_clk(struct wl1271 *wl, int *selected_clock) } /* Config N (pre divider) parameters according to the input frequency */ - wl1271_debug(DEBUG_BOOT, "Orit Wl18xx - write to addr 0x%x Config N %d", PLLSH_WCS_PLL_N, pllsh_wcs_pll_N); + wl1271_debug(DEBUG_BOOT, "Wl18xx - write to addr 0x%x Config N %d", PLLSH_WCS_PLL_N, pllsh_wcs_pll_N); wl1271_top_reg_write(wl, PLLSH_WCS_PLL_N, pllsh_wcs_pll_N); /* Config M (divider) parameters according to the input frequency */ - wl1271_debug(DEBUG_BOOT, "Orit Wl18xx - write to addr 0x%x Config M %d", PLLSH_WCS_PLL_M, pllsh_wcs_pll_M); + wl1271_debug(DEBUG_BOOT, "Wl18xx - write to addr 0x%x Config M %d", PLLSH_WCS_PLL_M, pllsh_wcs_pll_M); wl1271_top_reg_write(wl, PLLSH_WCS_PLL_M, pllsh_wcs_pll_M); /* Swallowing is only needed for the following CLK frequencies: @@ -859,17 +858,17 @@ static int wl18xx_boot_clk(struct wl1271 *wl, int *selected_clock) ((pllsh_wcs_pll_P >> REG_16_SHIFT) & PLLSH_WCS_PLL_P_FACTOR_CFG_2_MASK)); /* Activate swallowing mechanism if needed */ - wl1271_debug(DEBUG_BOOT, "Orit Wl18xx - Activate swallowing mechanism %d", PLLSH_WCS_PLL_SWALLOW_EN_VAL1); + wl1271_debug(DEBUG_BOOT, "Wl18xx - Activate swallowing mechanism %d", PLLSH_WCS_PLL_SWALLOW_EN_VAL1); wl1271_top_reg_write(wl, PLLSH_WCS_PLL_SWALLOW_EN, PLLSH_WCS_PLL_SWALLOW_EN_VAL1); } else { /* Activate swallowing mechanism if needed */ - wl1271_debug(DEBUG_BOOT, "Orit Wl18xx - Activate swallowing mechanism %d in addr 0x%x", + wl1271_debug(DEBUG_BOOT, "Wl18xx - Activate swallowing mechanism %d in addr 0x%x", PLLSH_WCS_PLL_SWALLOW_EN_VAL2, PLLSH_WCS_PLL_SWALLOW_EN); wl1271_top_reg_write(wl, PLLSH_WCS_PLL_SWALLOW_EN, PLLSH_WCS_PLL_SWALLOW_EN_VAL2); } - wl1271_debug(DEBUG_BOOT, "Orit Wl18xx - HW TOP init is done!!!"); + wl1271_debug(DEBUG_BOOT, "Wl18xx - HW TOP init is done!!!"); } return 0; @@ -1004,7 +1003,7 @@ int wl1271_load_firmware(struct wl1271 *wl) } /* Continue the ELP wake up sequence */ - wl1271_info("Orit Wl18xx - write to WELP_ARM_COMMAND 0x%x val 0x%x", + wl1271_info("Wl18xx - write to WELP_ARM_COMMAND 0x%x val 0x%x", WELP_ARM_COMMAND, WELP_ARM_COMMAND_VAL); wl1271_write32(wl, WELP_ARM_COMMAND, WELP_ARM_COMMAND_VAL); udelay(500); diff --git a/drivers/net/wireless/wl12xx/conf.h b/drivers/net/wireless/wl12xx/conf.h index 49f97128d1d6..a26c39f95985 100644 --- a/drivers/net/wireless/wl12xx/conf.h +++ b/drivers/net/wireless/wl12xx/conf.h @@ -1388,6 +1388,7 @@ struct conf_drv_settings { struct conf_hangover_settings hangover; struct conf_hw_checksum hw_checksum; u8 sleep_auth; + u8 hw_tx_extra_mem_blk; /* the structure is 4-bytes aligned due to sdio mem copy constraint */ struct conf_mac_and_phy_params mac_and_phy_params __aligned(4); }; diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index f8554bac29ce..d3d0c7dc611d 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -33,8 +33,6 @@ #include "tx.h" - -/* ****** 888 ********** */ #define DEBUGFS_SINGLE_PARAM_ADD(parent, name, base) \ static ssize_t name ##_read(struct file *file, char __user *user_buf, \ size_t count, loff_t *ppos) \ @@ -1181,6 +1179,95 @@ static const struct file_operations tx_frag_thld_ops = { .llseek = default_llseek, }; +static ssize_t tx_ba_win_size_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.ht.tx_ba_win_size); +} + +static ssize_t tx_ba_win_size_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct wl1271 *wl = file->private_data; + char buf[10]; + size_t len; + unsigned long value; + 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, &value); + if (ret < 0) { + wl1271_warning("illegal value for tx_ba_win_size"); + return -EINVAL; + } + + mutex_lock(&wl->mutex); + wl->conf.ht.tx_ba_win_size = value; + mutex_unlock(&wl->mutex); + + return count; +} + +static const struct file_operations tx_ba_win_size_ops = { + .read = tx_ba_win_size_read, + .write = tx_ba_win_size_write, + .open = wl1271_open_file_generic, + .llseek = default_llseek, +}; + +static ssize_t hw_tx_extra_mem_blk_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.hw_tx_extra_mem_blk); +} + +static ssize_t hw_tx_extra_mem_blk_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct wl1271 *wl = file->private_data; + char buf[10]; + size_t len; + unsigned long value; + 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, &value); + if (ret < 0) { + wl1271_warning("illegal value for hw_tx_extra_mem_blk"); + return -EINVAL; + } + + mutex_lock(&wl->mutex); + wl->conf.hw_tx_extra_mem_blk = value; + mutex_unlock(&wl->mutex); + + return count; +} + +static const struct file_operations hw_tx_extra_mem_blk_ops = { + .read = hw_tx_extra_mem_blk_read, + .write = hw_tx_extra_mem_blk_write, + .open = wl1271_open_file_generic, + .llseek = default_llseek, +}; + + static ssize_t tx_compl_timeout_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { @@ -1943,6 +2030,9 @@ static int wl1271_debugfs_add_files(struct wl1271 *wl, DEBUGFS_ADD(srf2, phy_mac_params) DEBUGFS_ADD(srf3, phy_mac_params) DEBUGFS_ADD(hw_board_type, phy_mac_params) + DEBUGFS_ADD(hw_tx_extra_mem_blk, phy_mac_params) + DEBUGFS_ADD(tx_ba_win_size, rootdir); + #endif diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 288adba1b684..2203bcaa0716 100755 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -293,7 +293,7 @@ static struct conf_drv_settings default_conf = { }, }, .ht = { - .tx_ba_win_size = 8, + .tx_ba_win_size = 10, .inactivity_timeout = 10000, .tx_ba_tid_bitmap = CONF_TX_BA_ENABLED_TID_BITMAP, }, @@ -437,6 +437,7 @@ static struct conf_drv_settings default_conf = { .hw_board_type = BOARD_TYPE_HDK_18XX }, .sleep_auth = WL1271_PSM_CAM, + .hw_tx_extra_mem_blk = TX_HW_BLOCK_SPARE_DEFAULT }; static char *fwlog_param; diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 0a2e5ecd1c1e..757a9e9c4fe7 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -201,7 +201,7 @@ static int wl1271_tx_allocate(struct wl1271 *wl, struct sk_buff *skb, u32 extra, if ((wl->chip.id == CHIP_ID_185x_PG10) || (wl->chip.id == CHIP_ID_185x_PG20)) { - spare_blocks = TX_HW_EXTRA_MEM_BLKS_DEF; + spare_blocks = wl->conf.hw_tx_extra_mem_blk; } else { /* we use 1 spare block */ @@ -224,9 +224,13 @@ static int wl1271_tx_allocate(struct wl1271 *wl, struct sk_buff *skb, u32 extra, else len = wl12xx_calc_packet_alignment(wl, total_len); +/* LiorC: ToDo: verify whether the FW can handle the change in the spare blocks during traffic */ +#ifndef TNETW18xx /* in case of a dummy packet, use default amount of spare mem blocks */ if (unlikely(wl12xx_is_dummy_packet(wl, skb))) spare_blocks = TX_HW_BLOCK_SPARE_DEFAULT; +#endif + total_blocks = (len + TX_HW_BLOCK_SIZE - 1) / TX_HW_BLOCK_SIZE + spare_blocks; diff --git a/drivers/net/wireless/wl12xx/tx.h b/drivers/net/wireless/wl12xx/tx.h index 86ceae29ad51..c7769bead008 100644 --- a/drivers/net/wireless/wl12xx/tx.h +++ b/drivers/net/wireless/wl12xx/tx.h @@ -25,9 +25,9 @@ #ifndef __TX_H__ #define __TX_H__ -#define TX_HW_BLOCK_SPARE_DEFAULT 1 #define TX_HW_BLOCK_SIZE 268 -#define TX_HW_EXTRA_MEM_BLKS_DEF 2 +#define TX_HW_BLOCK_SPARE_DEFAULT 1 + #define TX_HW_MGMT_PKT_LIFETIME_TU 2000 #define TX_HW_AP_MODE_PKT_LIFETIME_TU 8000 diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 1a598ef519b8..2130c6cbb7f1 100755 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -40,7 +40,7 @@ #define DRIVER_NAME "wl18xx" #define DRIVER_PREFIX DRIVER_NAME ": " -#define DRIVER_VERSION "WL18XX_A1.12" +#define DRIVER_VERSION "WL18XX_A1.13" /* * FW versions support BA 11n