diff options
author | Stanislaw Gruszka <sgruszka@redhat.com> | 2012-02-13 05:23:28 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2012-02-22 14:51:17 -0500 |
commit | d87c771f47460f7ca943942d508f2b9bd223a7e0 (patch) | |
tree | c0f78228a28123beafcfe501f661d64653f65c74 /drivers/net/wireless/iwlegacy | |
parent | 3976b4519458b27753196e63c89b2a774129e19a (diff) |
iwlegacy: small queue initializations cleanup
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlegacy')
-rw-r--r-- | drivers/net/wireless/iwlegacy/3945.c | 9 | ||||
-rw-r--r-- | drivers/net/wireless/iwlegacy/4965-mac.c | 18 | ||||
-rw-r--r-- | drivers/net/wireless/iwlegacy/common.c | 66 | ||||
-rw-r--r-- | 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) | |||
790 | static int | 790 | static int |
791 | il3945_tx_reset(struct il_priv *il) | 791 | il3945_tx_reset(struct il_priv *il) |
792 | { | 792 | { |
793 | |||
794 | /* bypass mode */ | 793 | /* bypass mode */ |
795 | il_wr_prph(il, ALM_SCD_MODE_REG, 0x2); | 794 | il_wr_prph(il, ALM_SCD_MODE_REG, 0x2); |
796 | 795 | ||
@@ -827,8 +826,7 @@ il3945_tx_reset(struct il_priv *il) | |||
827 | static int | 826 | static int |
828 | il3945_txq_ctx_reset(struct il_priv *il) | 827 | il3945_txq_ctx_reset(struct il_priv *il) |
829 | { | 828 | { |
830 | int rc; | 829 | int rc, txq_id; |
831 | int txq_id, slots_num; | ||
832 | 830 | ||
833 | il3945_hw_txq_ctx_free(il); | 831 | il3945_hw_txq_ctx_free(il); |
834 | 832 | ||
@@ -844,10 +842,7 @@ il3945_txq_ctx_reset(struct il_priv *il) | |||
844 | 842 | ||
845 | /* Tx queue(s) */ | 843 | /* Tx queue(s) */ |
846 | for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { | 844 | for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { |
847 | slots_num = | 845 | rc = il_tx_queue_init(il, txq_id); |
848 | (txq_id == | ||
849 | IL39_CMD_QUEUE_NUM) ? TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; | ||
850 | rc = il_tx_queue_init(il, &il->txq[txq_id], slots_num, txq_id); | ||
851 | if (rc) { | 846 | if (rc) { |
852 | IL_ERR("Tx %d queue init failed\n", txq_id); | 847 | IL_ERR("Tx %d queue init failed\n", txq_id); |
853 | goto error; | 848 | 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) | |||
1952 | int | 1952 | int |
1953 | il4965_txq_ctx_alloc(struct il_priv *il) | 1953 | il4965_txq_ctx_alloc(struct il_priv *il) |
1954 | { | 1954 | { |
1955 | int ret; | 1955 | int ret, txq_id; |
1956 | int txq_id, slots_num; | ||
1957 | unsigned long flags; | 1956 | unsigned long flags; |
1958 | 1957 | ||
1959 | /* Free all tx/cmd queues and keep-warm buffer */ | 1958 | /* Free all tx/cmd queues and keep-warm buffer */ |
@@ -1990,10 +1989,7 @@ il4965_txq_ctx_alloc(struct il_priv *il) | |||
1990 | 1989 | ||
1991 | /* Alloc and init all Tx queues, including the command queue (#4/#9) */ | 1990 | /* Alloc and init all Tx queues, including the command queue (#4/#9) */ |
1992 | for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { | 1991 | for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { |
1993 | slots_num = | 1992 | ret = il_tx_queue_init(il, txq_id); |
1994 | (txq_id == | ||
1995 | il->cmd_queue) ? TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; | ||
1996 | ret = il_tx_queue_init(il, &il->txq[txq_id], slots_num, txq_id); | ||
1997 | if (ret) { | 1993 | if (ret) { |
1998 | IL_ERR("Tx %d queue init failed\n", txq_id); | 1994 | IL_ERR("Tx %d queue init failed\n", txq_id); |
1999 | goto error; | 1995 | goto error; |
@@ -2014,25 +2010,21 @@ error_bc_tbls: | |||
2014 | void | 2010 | void |
2015 | il4965_txq_ctx_reset(struct il_priv *il) | 2011 | il4965_txq_ctx_reset(struct il_priv *il) |
2016 | { | 2012 | { |
2017 | int txq_id, slots_num; | 2013 | int txq_id; |
2018 | unsigned long flags; | 2014 | unsigned long flags; |
2019 | 2015 | ||
2020 | spin_lock_irqsave(&il->lock, flags); | 2016 | spin_lock_irqsave(&il->lock, flags); |
2021 | 2017 | ||
2022 | /* Turn off all Tx DMA fifos */ | 2018 | /* Turn off all Tx DMA fifos */ |
2023 | il4965_txq_set_sched(il, 0); | 2019 | il4965_txq_set_sched(il, 0); |
2024 | |||
2025 | /* Tell NIC where to find the "keep warm" buffer */ | 2020 | /* Tell NIC where to find the "keep warm" buffer */ |
2026 | il_wr(il, FH49_KW_MEM_ADDR_REG, il->kw.dma >> 4); | 2021 | il_wr(il, FH49_KW_MEM_ADDR_REG, il->kw.dma >> 4); |
2027 | 2022 | ||
2028 | spin_unlock_irqrestore(&il->lock, flags); | 2023 | spin_unlock_irqrestore(&il->lock, flags); |
2029 | 2024 | ||
2030 | /* Alloc and init all Tx queues, including the command queue (#4) */ | 2025 | /* Alloc and init all Tx queues, including the command queue (#4) */ |
2031 | for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { | 2026 | for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) |
2032 | slots_num = | 2027 | il_tx_queue_reset(il, txq_id); |
2033 | txq_id == il->cmd_queue ? TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; | ||
2034 | il_tx_queue_reset(il, &il->txq[txq_id], slots_num, txq_id); | ||
2035 | } | ||
2036 | } | 2028 | } |
2037 | 2029 | ||
2038 | void | 2030 | 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); | |||
2887 | * il_queue_init - Initialize queue's high/low-water and read/write idxes | 2887 | * il_queue_init - Initialize queue's high/low-water and read/write idxes |
2888 | */ | 2888 | */ |
2889 | static int | 2889 | static int |
2890 | il_queue_init(struct il_priv *il, struct il_queue *q, int count, int slots_num, | 2890 | il_queue_init(struct il_priv *il, struct il_queue *q, int slots, u32 id) |
2891 | u32 id) | ||
2892 | { | 2891 | { |
2893 | q->n_bd = count; | 2892 | /* |
2894 | q->n_win = slots_num; | 2893 | * TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise |
2895 | q->id = id; | 2894 | * il_queue_inc_wrap and il_queue_dec_wrap are broken. |
2895 | */ | ||
2896 | BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1)); | ||
2897 | /* FIXME: remove q->n_bd */ | ||
2898 | q->n_bd = TFD_QUEUE_SIZE_MAX; | ||
2896 | 2899 | ||
2897 | /* count must be power-of-two size, otherwise il_queue_inc_wrap | 2900 | q->n_win = slots; |
2898 | * and il_queue_dec_wrap are broken. */ | 2901 | q->id = id; |
2899 | BUG_ON(!is_power_of_2(count)); | ||
2900 | 2902 | ||
2901 | /* slots_num must be power-of-two size, otherwise | 2903 | /* slots_must be power-of-two size, otherwise |
2902 | * il_get_cmd_idx is broken. */ | 2904 | * il_get_cmd_idx is broken. */ |
2903 | BUG_ON(!is_power_of_2(slots_num)); | 2905 | BUG_ON(!is_power_of_2(slots)); |
2904 | 2906 | ||
2905 | q->low_mark = q->n_win / 4; | 2907 | q->low_mark = q->n_win / 4; |
2906 | if (q->low_mark < 4) | 2908 | if (q->low_mark < 4) |
@@ -2959,12 +2961,11 @@ error: | |||
2959 | * il_tx_queue_init - Allocate and initialize one tx/cmd queue | 2961 | * il_tx_queue_init - Allocate and initialize one tx/cmd queue |
2960 | */ | 2962 | */ |
2961 | int | 2963 | int |
2962 | il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, int slots_num, | 2964 | il_tx_queue_init(struct il_priv *il, u32 txq_id) |
2963 | u32 txq_id) | ||
2964 | { | 2965 | { |
2965 | int i, len; | 2966 | int i, len, ret; |
2966 | int ret; | 2967 | int slots, actual_slots; |
2967 | int actual_slots = slots_num; | 2968 | struct il_tx_queue *txq = &il->txq[txq_id]; |
2968 | 2969 | ||
2969 | /* | 2970 | /* |
2970 | * Alloc buffer array for commands (Tx or other types of commands). | 2971 | * 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, | |||
2974 | * For normal Tx queues (all other queues), no super-size command | 2975 | * For normal Tx queues (all other queues), no super-size command |
2975 | * space is needed. | 2976 | * space is needed. |
2976 | */ | 2977 | */ |
2977 | if (txq_id == il->cmd_queue) | 2978 | if (txq_id == il->cmd_queue) { |
2978 | actual_slots++; | 2979 | slots = TFD_CMD_SLOTS; |
2980 | actual_slots = slots + 1; | ||
2981 | } else { | ||
2982 | slots = TFD_TX_CMD_SLOTS; | ||
2983 | actual_slots = slots; | ||
2984 | } | ||
2979 | 2985 | ||
2980 | txq->meta = | 2986 | txq->meta = |
2981 | kzalloc(sizeof(struct il_cmd_meta) * actual_slots, GFP_KERNEL); | 2987 | 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, | |||
2988 | len = sizeof(struct il_device_cmd); | 2994 | len = sizeof(struct il_device_cmd); |
2989 | for (i = 0; i < actual_slots; i++) { | 2995 | for (i = 0; i < actual_slots; i++) { |
2990 | /* only happens for cmd queue */ | 2996 | /* only happens for cmd queue */ |
2991 | if (i == slots_num) | 2997 | if (i == slots) |
2992 | len = IL_MAX_CMD_SIZE; | 2998 | len = IL_MAX_CMD_SIZE; |
2993 | 2999 | ||
2994 | txq->cmd[i] = kmalloc(len, GFP_KERNEL); | 3000 | 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, | |||
3011 | if (txq_id < 4) | 3017 | if (txq_id < 4) |
3012 | il_set_swq_id(txq, txq_id, txq_id); | 3018 | il_set_swq_id(txq, txq_id, txq_id); |
3013 | 3019 | ||
3014 | /* TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise | ||
3015 | * il_queue_inc_wrap and il_queue_dec_wrap are broken. */ | ||
3016 | BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1)); | ||
3017 | |||
3018 | /* Initialize queue's high/low-water marks, and head/tail idxes */ | 3020 | /* Initialize queue's high/low-water marks, and head/tail idxes */ |
3019 | il_queue_init(il, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); | 3021 | il_queue_init(il, &txq->q, slots, txq_id); |
3020 | 3022 | ||
3021 | /* Tell device where to find queue */ | 3023 | /* Tell device where to find queue */ |
3022 | il->ops->txq_init(il, txq); | 3024 | il->ops->txq_init(il, txq); |
@@ -3034,20 +3036,24 @@ out_free_arrays: | |||
3034 | EXPORT_SYMBOL(il_tx_queue_init); | 3036 | EXPORT_SYMBOL(il_tx_queue_init); |
3035 | 3037 | ||
3036 | void | 3038 | void |
3037 | il_tx_queue_reset(struct il_priv *il, struct il_tx_queue *txq, int slots_num, | 3039 | il_tx_queue_reset(struct il_priv *il, u32 txq_id) |
3038 | u32 txq_id) | ||
3039 | { | 3040 | { |
3040 | int actual_slots = slots_num; | 3041 | int slots, actual_slots; |
3042 | struct il_tx_queue *txq = &il->txq[txq_id]; | ||
3041 | 3043 | ||
3042 | if (txq_id == il->cmd_queue) | 3044 | if (txq_id == il->cmd_queue) { |
3043 | actual_slots++; | 3045 | slots = TFD_CMD_SLOTS; |
3046 | actual_slots = TFD_CMD_SLOTS + 1; | ||
3047 | } else { | ||
3048 | slots = TFD_TX_CMD_SLOTS; | ||
3049 | actual_slots = TFD_TX_CMD_SLOTS; | ||
3050 | } | ||
3044 | 3051 | ||
3045 | memset(txq->meta, 0, sizeof(struct il_cmd_meta) * actual_slots); | 3052 | memset(txq->meta, 0, sizeof(struct il_cmd_meta) * actual_slots); |
3046 | |||
3047 | txq->need_update = 0; | 3053 | txq->need_update = 0; |
3048 | 3054 | ||
3049 | /* Initialize queue's high/low-water marks, and head/tail idxes */ | 3055 | /* Initialize queue's high/low-water marks, and head/tail idxes */ |
3050 | il_queue_init(il, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); | 3056 | il_queue_init(il, &txq->q, slots, txq_id); |
3051 | 3057 | ||
3052 | /* Tell device where to find queue */ | 3058 | /* Tell device where to find queue */ |
3053 | il->ops->txq_init(il, txq); | 3059 | 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); | |||
1783 | /***************************************************** | 1783 | /***************************************************** |
1784 | * TX | 1784 | * TX |
1785 | ******************************************************/ | 1785 | ******************************************************/ |
1786 | void il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq); | 1786 | extern void il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq); |
1787 | int il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, int slots_num, | 1787 | extern int il_tx_queue_init(struct il_priv *il, u32 txq_id); |
1788 | u32 txq_id); | 1788 | extern void il_tx_queue_reset(struct il_priv *il, u32 txq_id); |
1789 | void il_tx_queue_reset(struct il_priv *il, struct il_tx_queue *txq, | 1789 | extern void il_tx_queue_unmap(struct il_priv *il, int txq_id); |
1790 | int slots_num, u32 txq_id); | 1790 | extern void il_tx_queue_free(struct il_priv *il, int txq_id); |
1791 | void il_tx_queue_unmap(struct il_priv *il, int txq_id); | 1791 | extern void il_setup_watchdog(struct il_priv *il); |
1792 | void il_tx_queue_free(struct il_priv *il, int txq_id); | ||
1793 | void il_setup_watchdog(struct il_priv *il); | ||
1794 | /***************************************************** | 1792 | /***************************************************** |
1795 | * TX power | 1793 | * TX power |
1796 | ****************************************************/ | 1794 | ****************************************************/ |
@@ -2405,10 +2403,10 @@ struct il_rb_status { | |||
2405 | __le32 __unused; /* 3945 only */ | 2403 | __le32 __unused; /* 3945 only */ |
2406 | } __packed; | 2404 | } __packed; |
2407 | 2405 | ||
2408 | #define TFD_QUEUE_SIZE_MAX (256) | 2406 | #define TFD_QUEUE_SIZE_MAX 256 |
2409 | #define TFD_QUEUE_SIZE_BC_DUP (64) | 2407 | #define TFD_QUEUE_SIZE_BC_DUP 64 |
2410 | #define TFD_QUEUE_BC_SIZE (TFD_QUEUE_SIZE_MAX + TFD_QUEUE_SIZE_BC_DUP) | 2408 | #define TFD_QUEUE_BC_SIZE (TFD_QUEUE_SIZE_MAX + TFD_QUEUE_SIZE_BC_DUP) |
2411 | #define IL_TX_DMA_MASK DMA_BIT_MASK(36) | 2409 | #define IL_TX_DMA_MASK DMA_BIT_MASK(36) |
2412 | #define IL_NUM_OF_TBS 20 | 2410 | #define IL_NUM_OF_TBS 20 |
2413 | 2411 | ||
2414 | static inline u8 | 2412 | static inline u8 |