summaryrefslogtreecommitdiff
path: root/lib/librte_pmd_e1000
diff options
context:
space:
mode:
authorIntel <intel.com>2013-06-03 02:00:00 +0200
committerThomas Monjalon <thomas.monjalon@6wind.com>2013-09-17 14:16:07 +0200
commit23a666011347efdae8e8fa4a432d3393419a02d0 (patch)
treea70f2e1505c346036c6d6233b53bb9005a368d4d /lib/librte_pmd_e1000
parent6acc6176c43cb6b06e8c30331ee433bc0a389b7b (diff)
downloaddpdk-23a666011347efdae8e8fa4a432d3393419a02d0.zip
dpdk-23a666011347efdae8e8fa4a432d3393419a02d0.tar.gz
dpdk-23a666011347efdae8e8fa4a432d3393419a02d0.tar.xz
igb: retrieve RX available descriptors
Signed-off-by: Intel
Diffstat (limited to 'lib/librte_pmd_e1000')
-rw-r--r--lib/librte_pmd_e1000/e1000_ethdev.h3
-rw-r--r--lib/librte_pmd_e1000/igb_ethdev.c1
-rw-r--r--lib/librte_pmd_e1000/igb_rxtx.c27
3 files changed, 31 insertions, 0 deletions
diff --git a/lib/librte_pmd_e1000/e1000_ethdev.h b/lib/librte_pmd_e1000/e1000_ethdev.h
index 6acac23..af75290 100644
--- a/lib/librte_pmd_e1000/e1000_ethdev.h
+++ b/lib/librte_pmd_e1000/e1000_ethdev.h
@@ -97,6 +97,9 @@ int eth_igb_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
const struct rte_eth_rxconf *rx_conf,
struct rte_mempool *mb_pool);
+uint32_t eth_igb_rx_queue_count(struct rte_eth_dev *dev,
+ uint16_t rx_queue_id);
+
int eth_igb_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
uint16_t nb_tx_desc, unsigned int socket_id,
const struct rte_eth_txconf *tx_conf);
diff --git a/lib/librte_pmd_e1000/igb_ethdev.c b/lib/librte_pmd_e1000/igb_ethdev.c
index c91881b..735c968 100644
--- a/lib/librte_pmd_e1000/igb_ethdev.c
+++ b/lib/librte_pmd_e1000/igb_ethdev.c
@@ -181,6 +181,7 @@ static struct eth_dev_ops eth_igb_ops = {
.vlan_offload_set = eth_igb_vlan_offload_set,
.rx_queue_setup = eth_igb_rx_queue_setup,
.rx_queue_release = eth_igb_rx_queue_release,
+ .rx_queue_count = eth_igb_rx_queue_count,
.tx_queue_setup = eth_igb_tx_queue_setup,
.tx_queue_release = eth_igb_tx_queue_release,
.dev_led_on = eth_igb_led_on,
diff --git a/lib/librte_pmd_e1000/igb_rxtx.c b/lib/librte_pmd_e1000/igb_rxtx.c
index 28fe163..3dd5156 100644
--- a/lib/librte_pmd_e1000/igb_rxtx.c
+++ b/lib/librte_pmd_e1000/igb_rxtx.c
@@ -117,6 +117,7 @@ struct igb_rx_queue {
volatile union e1000_adv_rx_desc *rx_ring; /**< RX ring virtual address. */
uint64_t rx_ring_phys_addr; /**< RX ring DMA address. */
volatile uint32_t *rdt_reg_addr; /**< RDT register address. */
+ volatile uint32_t *rdh_reg_addr; /**< RDH register address. */
struct igb_rx_entry *sw_ring; /**< address of RX software ring. */
struct rte_mbuf *pkt_first_seg; /**< First segment of current packet. */
struct rte_mbuf *pkt_last_seg; /**< Last segment of current packet. */
@@ -1360,6 +1361,7 @@ eth_igb_rx_queue_setup(struct rte_eth_dev *dev,
return (-ENOMEM);
}
rxq->rdt_reg_addr = E1000_PCI_REG_ADDR(hw, E1000_RDT(queue_idx));
+ rxq->rdh_reg_addr = E1000_PCI_REG_ADDR(hw, E1000_RDH(queue_idx));
rxq->rx_ring_phys_addr = (uint64_t) rz->phys_addr;
rxq->rx_ring = (union e1000_adv_rx_desc *) rz->addr;
@@ -1380,6 +1382,31 @@ eth_igb_rx_queue_setup(struct rte_eth_dev *dev,
return 0;
}
+uint32_t
+eth_igb_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id)
+{
+ struct igb_rx_queue *rxq;
+ uint32_t nb_pkts_available;
+ uint32_t rx_rdh;
+ uint32_t rx_id;
+
+ if (rx_queue_id >= dev->data->nb_rx_queues) {
+ PMD_RX_LOG(DEBUG,"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 = E1000_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);
+}
+
void
igb_dev_clear_queues(struct rte_eth_dev *dev)
{