aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-tx.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-tx.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-tx.c49
1 files changed, 10 insertions, 39 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c
index 83e9f32cbd8e..58118c8224cf 100644
--- a/drivers/net/wireless/iwlwifi/iwl-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-tx.c
@@ -131,7 +131,7 @@ EXPORT_SYMBOL(iwl_txq_update_write_ptr);
131 * Free all buffers. 131 * Free all buffers.
132 * 0-fill, but do not free "txq" descriptor structure. 132 * 0-fill, but do not free "txq" descriptor structure.
133 */ 133 */
134static void iwl_tx_queue_free(struct iwl_priv *priv, int txq_id) 134void iwl_tx_queue_free(struct iwl_priv *priv, int txq_id)
135{ 135{
136 struct iwl_tx_queue *txq = &priv->txq[txq_id]; 136 struct iwl_tx_queue *txq = &priv->txq[txq_id];
137 struct iwl_queue *q = &txq->q; 137 struct iwl_queue *q = &txq->q;
@@ -154,7 +154,7 @@ static void iwl_tx_queue_free(struct iwl_priv *priv, int txq_id)
154 154
155 /* De-alloc circular buffer of TFDs */ 155 /* De-alloc circular buffer of TFDs */
156 if (txq->q.n_bd) 156 if (txq->q.n_bd)
157 pci_free_consistent(dev, sizeof(struct iwl_tfd) * 157 pci_free_consistent(dev, priv->hw_params.tfd_size *
158 txq->q.n_bd, txq->tfds, txq->q.dma_addr); 158 txq->q.n_bd, txq->tfds, txq->q.dma_addr);
159 159
160 /* De-alloc array of per-TFD driver data */ 160 /* De-alloc array of per-TFD driver data */
@@ -164,7 +164,7 @@ static void iwl_tx_queue_free(struct iwl_priv *priv, int txq_id)
164 /* 0-fill queue descriptor structure */ 164 /* 0-fill queue descriptor structure */
165 memset(txq, 0, sizeof(*txq)); 165 memset(txq, 0, sizeof(*txq));
166} 166}
167 167EXPORT_SYMBOL(iwl_tx_queue_free);
168 168
169/** 169/**
170 * iwl_cmd_queue_free - Deallocate DMA queue. 170 * iwl_cmd_queue_free - Deallocate DMA queue.
@@ -295,12 +295,12 @@ static int iwl_tx_queue_alloc(struct iwl_priv *priv,
295 /* Circular buffer of transmit frame descriptors (TFDs), 295 /* Circular buffer of transmit frame descriptors (TFDs),
296 * shared with device */ 296 * shared with device */
297 txq->tfds = pci_alloc_consistent(dev, 297 txq->tfds = pci_alloc_consistent(dev,
298 sizeof(struct iwl_tfd) * TFD_QUEUE_SIZE_MAX, 298 priv->hw_params.tfd_size * TFD_QUEUE_SIZE_MAX,
299 &txq->q.dma_addr); 299 &txq->q.dma_addr);
300 300
301 if (!txq->tfds) { 301 if (!txq->tfds) {
302 IWL_ERR(priv, "pci_alloc_consistent(%zd) failed\n", 302 IWL_ERR(priv, "pci_alloc_consistent(%zd) failed\n",
303 sizeof(struct iwl_tfd) * TFD_QUEUE_SIZE_MAX); 303 priv->hw_params.tfd_size * TFD_QUEUE_SIZE_MAX);
304 goto error; 304 goto error;
305 } 305 }
306 txq->q.id = id; 306 txq->q.id = id;
@@ -314,42 +314,11 @@ static int iwl_tx_queue_alloc(struct iwl_priv *priv,
314 return -ENOMEM; 314 return -ENOMEM;
315} 315}
316 316
317/*
318 * Tell nic where to find circular buffer of Tx Frame Descriptors for
319 * given Tx queue, and enable the DMA channel used for that queue.
320 *
321 * 4965 supports up to 16 Tx queues in DRAM, mapped to up to 8 Tx DMA
322 * channels supported in hardware.
323 */
324static int iwl_hw_tx_queue_init(struct iwl_priv *priv,
325 struct iwl_tx_queue *txq)
326{
327 int ret;
328 unsigned long flags;
329 int txq_id = txq->q.id;
330
331 spin_lock_irqsave(&priv->lock, flags);
332 ret = iwl_grab_nic_access(priv);
333 if (ret) {
334 spin_unlock_irqrestore(&priv->lock, flags);
335 return ret;
336 }
337
338 /* Circular buffer (TFD queue in DRAM) physical base address */
339 iwl_write_direct32(priv, FH_MEM_CBBC_QUEUE(txq_id),
340 txq->q.dma_addr >> 8);
341
342 iwl_release_nic_access(priv);
343 spin_unlock_irqrestore(&priv->lock, flags);
344
345 return 0;
346}
347
348/** 317/**
349 * iwl_tx_queue_init - Allocate and initialize one tx/cmd queue 318 * iwl_tx_queue_init - Allocate and initialize one tx/cmd queue
350 */ 319 */
351static int iwl_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq, 320int iwl_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq,
352 int slots_num, u32 txq_id) 321 int slots_num, u32 txq_id)
353{ 322{
354 int i, len; 323 int i, len;
355 int ret; 324 int ret;
@@ -391,7 +360,7 @@ static int iwl_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq,
391 iwl_queue_init(priv, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); 360 iwl_queue_init(priv, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id);
392 361
393 /* Tell device where to find queue */ 362 /* Tell device where to find queue */
394 iwl_hw_tx_queue_init(priv, txq); 363 priv->cfg->ops->lib->txq_init(priv, txq);
395 364
396 return 0; 365 return 0;
397err: 366err:
@@ -406,6 +375,8 @@ err:
406 } 375 }
407 return -ENOMEM; 376 return -ENOMEM;
408} 377}
378EXPORT_SYMBOL(iwl_tx_queue_init);
379
409/** 380/**
410 * iwl_hw_txq_ctx_free - Free TXQ Context 381 * iwl_hw_txq_ctx_free - Free TXQ Context
411 * 382 *