iwlwifi: refactor PCI-E RX path
Just make the code easier to read with less indentation. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
committed by
John W. Linville
parent
48a2d66f58
commit
df2f3216cc
@@ -358,63 +358,23 @@ void iwl_bg_rx_replenish(struct work_struct *data)
|
||||
iwlagn_rx_replenish(trans_pcie->trans);
|
||||
}
|
||||
|
||||
/**
|
||||
* iwl_rx_handle - Main entry function for receiving responses from uCode
|
||||
*
|
||||
* Uses the priv->rx_handlers callback function array to invoke
|
||||
* the appropriate handlers, including command responses,
|
||||
* frame-received notifications, and other notifications.
|
||||
*/
|
||||
static void iwl_rx_handle(struct iwl_trans *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_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). */
|
||||
r = le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF;
|
||||
i = rxq->read;
|
||||
|
||||
/* Rx interrupt, but nothing sent from uCode */
|
||||
if (i == r)
|
||||
IWL_DEBUG_RX(trans, "r = %d, i = %d\n", r, i);
|
||||
|
||||
/* calculate total frames need to be restock after handling RX */
|
||||
total_empty = r - rxq->write_actual;
|
||||
if (total_empty < 0)
|
||||
total_empty += RX_QUEUE_SIZE;
|
||||
|
||||
if (total_empty > (RX_QUEUE_SIZE / 2))
|
||||
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;
|
||||
bool reclaim;
|
||||
int index, cmd_index;
|
||||
|
||||
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;
|
||||
if (WARN_ON(!rxb))
|
||||
return;
|
||||
|
||||
dma_unmap_page(trans->dev, rxb->page_dma,
|
||||
PAGE_SIZE << hw_params(trans).rx_page_order,
|
||||
@@ -423,8 +383,9 @@ static void iwl_rx_handle(struct iwl_trans *trans)
|
||||
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);
|
||||
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 */
|
||||
@@ -493,16 +454,59 @@ 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(trans->dev, rxb->page,
|
||||
0, PAGE_SIZE <<
|
||||
hw_params(trans).rx_page_order,
|
||||
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
|
||||
*
|
||||
* Uses the priv->rx_handlers callback function array to invoke
|
||||
* the appropriate handlers, including command responses,
|
||||
* frame-received notifications, and other notifications.
|
||||
*/
|
||||
static void iwl_rx_handle(struct iwl_trans *trans)
|
||||
{
|
||||
struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
|
||||
struct iwl_rx_queue *rxq = &trans_pcie->rxq;
|
||||
u32 r, i;
|
||||
u8 fill_rx = 0;
|
||||
u32 count = 8;
|
||||
int total_empty;
|
||||
|
||||
/* uCode's read index (stored in shared DRAM) indicates the last Rx
|
||||
* buffer that the driver may process (last buffer filled by ucode). */
|
||||
r = le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF;
|
||||
i = rxq->read;
|
||||
|
||||
/* Rx interrupt, but nothing sent from uCode */
|
||||
if (i == r)
|
||||
IWL_DEBUG_RX(trans, "r = %d, i = %d\n", r, i);
|
||||
|
||||
/* calculate total frames need to be restock after handling RX */
|
||||
total_empty = r - rxq->write_actual;
|
||||
if (total_empty < 0)
|
||||
total_empty += RX_QUEUE_SIZE;
|
||||
|
||||
if (total_empty > (RX_QUEUE_SIZE / 2))
|
||||
fill_rx = 1;
|
||||
|
||||
while (i != r) {
|
||||
struct iwl_rx_mem_buffer *rxb;
|
||||
|
||||
rxb = rxq->queue[i];
|
||||
rxq->queue[i] = NULL;
|
||||
|
||||
IWL_DEBUG_RX(trans, "rxbuf: r = %d, i = %d (%p)\n", rxb);
|
||||
|
||||
iwl_rx_handle_rxbuf(trans, rxb);
|
||||
|
||||
i = (i + 1) & RX_QUEUE_MASK;
|
||||
/* If there are a lot of unused frames,
|
||||
|
Reference in New Issue
Block a user