- 论坛徽章:
- 4
|
有道理
- static void e100_rx_clean(struct nic *nic, unsigned int *work_done,
- unsigned int work_to_do)
- {
- struct rx *rx;
- int restart_required = 0, err = 0;
- struct rx *old_before_last_rx, *new_before_last_rx;
- struct rfd *old_before_last_rfd, *new_before_last_rfd;
- /* Indicate newly arrived packets */
- for(rx = nic->rx_to_clean; rx->skb; rx = nic->rx_to_clean = rx->next) {
- err = e100_rx_indicate(nic, rx, work_done, work_to_do);
- /* Hit quota or no more to clean */
- if (-EAGAIN == err || -ENODATA == err)
- break;
- }
- /* On EAGAIN, hit quota so have more work to do, restart once
- * cleanup is complete.
- * Else, are we already rnr? then pay attention!!! this ensures that
- * the state machine progression never allows a start with a
- * partially cleaned list, avoiding a race between hardware
- * and rx_to_clean when in NAPI mode */
- if (-EAGAIN != err && RU_SUSPENDED == nic->ru_running)
- restart_required = 1;
- old_before_last_rx = nic->rx_to_use->prev->prev;
- old_before_last_rfd = (struct rfd *)old_before_last_rx->skb->data;
- /* Alloc new skbs to refill list */
- for(rx = nic->rx_to_use; !rx->skb; rx = nic->rx_to_use = rx->next) {
- if(unlikely(e100_rx_alloc_skb(nic, rx)))
- break; /* Better luck next time (see watchdog) */
- }
- new_before_last_rx = nic->rx_to_use->prev->prev;
- if (new_before_last_rx != old_before_last_rx) {
- /* Set the el-bit on the buffer that is before the last buffer.
- * This lets us update the next pointer on the last buffer
- * without worrying about hardware touching it.
- * We set the size to 0 to prevent hardware from touching this
- * buffer.
- * When the hardware hits the before last buffer with el-bit
- * and size of 0, it will RNR interrupt, the RUS will go into
- * the No Resources state. It will not complete nor write to
- * this buffer. */
- new_before_last_rfd =
- (struct rfd *)new_before_last_rx->skb->data;
- new_before_last_rfd->size = 0;
- new_before_last_rfd->command |= cpu_to_le16(cb_el);
- pci_dma_sync_single_for_device(nic->pdev,
- new_before_last_rx->dma_addr, sizeof(struct rfd),
- PCI_DMA_TODEVICE);
- /* Now that we have a new stopping point, we can clear the old
- * stopping point. We must sync twice to get the proper
- * ordering on the hardware side of things. */
- old_before_last_rfd->command &= ~cpu_to_le16(cb_el);
- pci_dma_sync_single_for_device(nic->pdev,
- old_before_last_rx->dma_addr, sizeof(struct rfd),
- PCI_DMA_TODEVICE);
- old_before_last_rfd->size = cpu_to_le16(VLAN_ETH_FRAME_LEN);
- pci_dma_sync_single_for_device(nic->pdev,
- old_before_last_rx->dma_addr, sizeof(struct rfd),
- PCI_DMA_TODEVICE);
- }
- if(restart_required) {
- // ack the rnr?
- iowrite8(stat_ack_rnr, &nic->csr->scb.stat_ack);
- e100_start_receiver(nic, nic->rx_to_clean);
- if(work_done)
- (*work_done)++;
- }
- }
复制代码 old_before_last_rx和new_before_last_rx是什么关系? |
|