diff options
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-helpers.h')
| -rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-helpers.h | 95 |
1 files changed, 35 insertions, 60 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-helpers.h b/drivers/net/wireless/iwlwifi/iwl-helpers.h index 621abe3c5afc..41207a3645b8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-helpers.h +++ b/drivers/net/wireless/iwlwifi/iwl-helpers.h | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /****************************************************************************** | 1 | /****************************************************************************** |
| 2 | * | 2 | * |
| 3 | * Copyright(c) 2003 - 2010 Intel Corporation. All rights reserved. | 3 | * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. |
| 4 | * | 4 | * |
| 5 | * Portions of this file are derived from the ipw3945 project, as well | 5 | * Portions of this file are derived from the ipw3945 project, as well |
| 6 | * as portions of the ieee80211 subsystem header files. | 6 | * as portions of the ieee80211 subsystem header files. |
| @@ -44,20 +44,6 @@ static inline struct ieee80211_conf *ieee80211_get_hw_conf( | |||
| 44 | return &hw->conf; | 44 | return &hw->conf; |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | static inline int iwl_check_bits(unsigned long field, unsigned long mask) | ||
| 48 | { | ||
| 49 | return ((field & mask) == mask) ? 1 : 0; | ||
| 50 | } | ||
| 51 | |||
| 52 | static inline unsigned long elapsed_jiffies(unsigned long start, | ||
| 53 | unsigned long end) | ||
| 54 | { | ||
| 55 | if (end >= start) | ||
| 56 | return end - start; | ||
| 57 | |||
| 58 | return end + (MAX_JIFFY_OFFSET - start) + 1; | ||
| 59 | } | ||
| 60 | |||
| 61 | /** | 47 | /** |
| 62 | * iwl_queue_inc_wrap - increment queue index, wrap back to beginning | 48 | * iwl_queue_inc_wrap - increment queue index, wrap back to beginning |
| 63 | * @index -- current index | 49 | * @index -- current index |
| @@ -78,30 +64,6 @@ static inline int iwl_queue_dec_wrap(int index, int n_bd) | |||
| 78 | return --index & (n_bd - 1); | 64 | return --index & (n_bd - 1); |
| 79 | } | 65 | } |
| 80 | 66 | ||
| 81 | /* TODO: Move fw_desc functions to iwl-pci.ko */ | ||
| 82 | static inline void iwl_free_fw_desc(struct pci_dev *pci_dev, | ||
| 83 | struct fw_desc *desc) | ||
| 84 | { | ||
| 85 | if (desc->v_addr) | ||
| 86 | dma_free_coherent(&pci_dev->dev, desc->len, | ||
| 87 | desc->v_addr, desc->p_addr); | ||
| 88 | desc->v_addr = NULL; | ||
| 89 | desc->len = 0; | ||
| 90 | } | ||
| 91 | |||
| 92 | static inline int iwl_alloc_fw_desc(struct pci_dev *pci_dev, | ||
| 93 | struct fw_desc *desc) | ||
| 94 | { | ||
| 95 | if (!desc->len) { | ||
| 96 | desc->v_addr = NULL; | ||
| 97 | return -EINVAL; | ||
| 98 | } | ||
| 99 | |||
| 100 | desc->v_addr = dma_alloc_coherent(&pci_dev->dev, desc->len, | ||
| 101 | &desc->p_addr, GFP_KERNEL); | ||
| 102 | return (desc->v_addr != NULL) ? 0 : -ENOMEM; | ||
| 103 | } | ||
| 104 | |||
| 105 | /* | 67 | /* |
| 106 | * we have 8 bits used like this: | 68 | * we have 8 bits used like this: |
| 107 | * | 69 | * |
| @@ -109,48 +71,55 @@ static inline int iwl_alloc_fw_desc(struct pci_dev *pci_dev, | |||
| 109 | * | | | | | | | | | 71 | * | | | | | | | | |
| 110 | * | | | | | | +-+-------- AC queue (0-3) | 72 | * | | | | | | +-+-------- AC queue (0-3) |
| 111 | * | | | | | | | 73 | * | | | | | | |
| 112 | * | +-+-+-+-+------------ HW A-MPDU queue | 74 | * | +-+-+-+-+------------ HW queue ID |
| 113 | * | | 75 | * | |
| 114 | * +---------------------- indicates agg queue | 76 | * +---------------------- unused |
| 115 | */ | 77 | */ |
| 116 | static inline u8 iwl_virtual_agg_queue_num(u8 ac, u8 hwq) | 78 | static inline void iwl_set_swq_id(struct iwl_tx_queue *txq, u8 ac, u8 hwq) |
| 117 | { | 79 | { |
| 118 | BUG_ON(ac > 3); /* only have 2 bits */ | 80 | BUG_ON(ac > 3); /* only have 2 bits */ |
| 119 | BUG_ON(hwq > 31); /* only have 5 bits */ | 81 | BUG_ON(hwq > 31); /* only use 5 bits */ |
| 120 | 82 | ||
| 121 | return 0x80 | (hwq << 2) | ac; | 83 | txq->swq_id = (hwq << 2) | ac; |
| 122 | } | 84 | } |
| 123 | 85 | ||
| 124 | static inline void iwl_wake_queue(struct iwl_priv *priv, u8 queue) | 86 | static inline void iwl_wake_queue(struct iwl_priv *priv, |
| 87 | struct iwl_tx_queue *txq) | ||
| 125 | { | 88 | { |
| 126 | u8 ac = queue; | 89 | u8 queue = txq->swq_id; |
| 127 | u8 hwq = queue; | 90 | u8 ac = queue & 3; |
| 128 | 91 | u8 hwq = (queue >> 2) & 0x1f; | |
| 129 | if (queue & 0x80) { | ||
| 130 | ac = queue & 3; | ||
| 131 | hwq = (queue >> 2) & 0x1f; | ||
| 132 | } | ||
| 133 | 92 | ||
| 134 | if (test_and_clear_bit(hwq, priv->queue_stopped)) | 93 | if (test_and_clear_bit(hwq, priv->queue_stopped)) |
| 135 | if (atomic_dec_return(&priv->queue_stop_count[ac]) <= 0) | 94 | if (atomic_dec_return(&priv->queue_stop_count[ac]) <= 0) |
| 136 | ieee80211_wake_queue(priv->hw, ac); | 95 | ieee80211_wake_queue(priv->hw, ac); |
| 137 | } | 96 | } |
| 138 | 97 | ||
| 139 | static inline void iwl_stop_queue(struct iwl_priv *priv, u8 queue) | 98 | static inline void iwl_stop_queue(struct iwl_priv *priv, |
| 99 | struct iwl_tx_queue *txq) | ||
| 140 | { | 100 | { |
| 141 | u8 ac = queue; | 101 | u8 queue = txq->swq_id; |
| 142 | u8 hwq = queue; | 102 | u8 ac = queue & 3; |
| 143 | 103 | u8 hwq = (queue >> 2) & 0x1f; | |
| 144 | if (queue & 0x80) { | ||
| 145 | ac = queue & 3; | ||
| 146 | hwq = (queue >> 2) & 0x1f; | ||
| 147 | } | ||
| 148 | 104 | ||
| 149 | if (!test_and_set_bit(hwq, priv->queue_stopped)) | 105 | if (!test_and_set_bit(hwq, priv->queue_stopped)) |
| 150 | if (atomic_inc_return(&priv->queue_stop_count[ac]) > 0) | 106 | if (atomic_inc_return(&priv->queue_stop_count[ac]) > 0) |
| 151 | ieee80211_stop_queue(priv->hw, ac); | 107 | ieee80211_stop_queue(priv->hw, ac); |
| 152 | } | 108 | } |
| 153 | 109 | ||
| 110 | static inline void iwl_wake_any_queue(struct iwl_priv *priv, | ||
| 111 | struct iwl_rxon_context *ctx) | ||
| 112 | { | ||
| 113 | u8 ac; | ||
| 114 | |||
| 115 | for (ac = 0; ac < AC_NUM; ac++) { | ||
| 116 | IWL_DEBUG_INFO(priv, "Queue Status: Q[%d] %s\n", | ||
| 117 | ac, (atomic_read(&priv->queue_stop_count[ac]) > 0) | ||
| 118 | ? "stopped" : "awake"); | ||
| 119 | iwl_wake_queue(priv, &priv->txq[ctx->ac_to_queue[ac]]); | ||
| 120 | } | ||
| 121 | } | ||
| 122 | |||
| 154 | #define ieee80211_stop_queue DO_NOT_USE_ieee80211_stop_queue | 123 | #define ieee80211_stop_queue DO_NOT_USE_ieee80211_stop_queue |
| 155 | #define ieee80211_wake_queue DO_NOT_USE_ieee80211_wake_queue | 124 | #define ieee80211_wake_queue DO_NOT_USE_ieee80211_wake_queue |
| 156 | 125 | ||
| @@ -168,6 +137,12 @@ static inline void iwl_disable_interrupts(struct iwl_priv *priv) | |||
| 168 | IWL_DEBUG_ISR(priv, "Disabled interrupts\n"); | 137 | IWL_DEBUG_ISR(priv, "Disabled interrupts\n"); |
| 169 | } | 138 | } |
| 170 | 139 | ||
| 140 | static inline void iwl_enable_rfkill_int(struct iwl_priv *priv) | ||
| 141 | { | ||
| 142 | IWL_DEBUG_ISR(priv, "Enabling rfkill interrupt\n"); | ||
| 143 | iwl_write32(priv, CSR_INT_MASK, CSR_INT_BIT_RF_KILL); | ||
| 144 | } | ||
| 145 | |||
| 171 | static inline void iwl_enable_interrupts(struct iwl_priv *priv) | 146 | static inline void iwl_enable_interrupts(struct iwl_priv *priv) |
| 172 | { | 147 | { |
| 173 | IWL_DEBUG_ISR(priv, "Enabling interrupts\n"); | 148 | IWL_DEBUG_ISR(priv, "Enabling interrupts\n"); |
