From: Intel Date: Mon, 22 Jul 2013 22:00:00 +0000 (+0200) Subject: ixgbe: use DD bit to count RX available descriptors X-Git-Tag: spdx-start~11174 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=90b2eeb80aa537108f4ad7ddbc0fdeeaa9f7ce90;p=dpdk.git ixgbe: use DD bit to count RX available descriptors Signed-off-by: Intel --- diff --git a/lib/librte_pmd_ixgbe/ixgbe_rxtx.c b/lib/librte_pmd_ixgbe/ixgbe_rxtx.c index e9eb83b4f7..8e7cb2693a 100644 --- a/lib/librte_pmd_ixgbe/ixgbe_rxtx.c +++ b/lib/librte_pmd_ixgbe/ixgbe_rxtx.c @@ -2271,29 +2271,32 @@ ixgbe_dev_rx_queue_setup(struct rte_eth_dev *dev, return 0; } -uint32_t ixgbe_dev_rx_queue_count(struct rte_eth_dev *dev, - uint16_t rx_queue_id) +uint32_t +ixgbe_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id) { +#define IXGBE_RXQ_SCAN_INTERVAL 4 + volatile union ixgbe_adv_rx_desc *rxdp; struct igb_rx_queue *rxq; - uint32_t nb_pkts_available; - uint32_t rx_rdh; - uint32_t rx_id; + uint32_t desc = 0; if (rx_queue_id >= dev->data->nb_rx_queues) { - PMD_RX_LOG(DEBUG,"Invalid RX queue_id=%d\n", rx_queue_id); - return 0; + PMD_RX_LOG(ERR, "Invalid RX queue id=%d\n", rx_queue_id); + return 0; } rxq = dev->data->rx_queues[rx_queue_id]; - rx_id = (uint16_t)((rxq->rx_tail == 0) ? - (rxq->nb_rx_desc - 1) : (rxq->rx_tail - 1)); - rx_rdh = IXGBE_PCI_REG(rxq->rdh_reg_addr); - if (rx_rdh > rx_id) - nb_pkts_available = rx_rdh - rx_id; - else - nb_pkts_available = rx_rdh - rx_id + rxq->nb_rx_desc; - - return (nb_pkts_available); + rxdp = &(rxq->rx_ring[rxq->rx_tail]); + + while ((desc < rxq->nb_rx_desc) && + (rxdp->wb.upper.status_error & IXGBE_RXDADV_STAT_DD)) { + desc += IXGBE_RXQ_SCAN_INTERVAL; + rxdp += IXGBE_RXQ_SCAN_INTERVAL; + if (rxq->rx_tail + desc >= rxq->nb_rx_desc) + rxdp = &(rxq->rx_ring[rxq->rx_tail + + desc - rxq->nb_rx_desc]); + } + + return desc; } void