From: Intel Date: Mon, 3 Jun 2013 00:00:00 +0000 (+0000) Subject: ethdev: retrieve RX available descriptors X-Git-Tag: spdx-start~11223 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=bc355ebf4f7b1810fc732c3c02010a75ff486842;p=dpdk.git ethdev: retrieve RX available descriptors Signed-off-by: Intel --- diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 06fc25106b..f7535c828d 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -1649,6 +1649,20 @@ rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id, return (*dev->tx_pkt_burst)(dev->data->tx_queues[queue_id], tx_pkts, nb_pkts); } + +uint32_t +rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id) +{ + struct rte_eth_dev *dev; + + if (port_id >= nb_ports) { + PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); + return 0; + } + dev = &rte_eth_devices[port_id]; + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, -ENOTSUP); + return (*dev->dev_ops->rx_queue_count)(dev, queue_id); +} #endif int diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 74b3a5b60b..64a2d57c61 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -754,6 +754,10 @@ typedef int (*eth_tx_queue_setup_t)(struct rte_eth_dev *dev, typedef void (*eth_queue_release_t)(void *queue); /**< @internal Release memory resources allocated by given RX/TX queue. */ +typedef uint32_t (*eth_rx_queue_count_t)(struct rte_eth_dev *dev, + uint16_t rx_queue_id); +/**< Get number of available descriptors on a receive queue of an Ethernet device. */ + typedef int (*vlan_filter_set_t)(struct rte_eth_dev *dev, uint16_t vlan_id, int on); @@ -875,6 +879,7 @@ struct eth_dev_ops { vlan_offload_set_t vlan_offload_set; /**< Set VLAN Offload. */ eth_rx_queue_setup_t rx_queue_setup;/**< Set up device RX queue.*/ eth_queue_release_t rx_queue_release;/**< Release RX queue.*/ + eth_rx_queue_count_t rx_queue_count; /**< Get Rx queue count. */ eth_tx_queue_setup_t tx_queue_setup;/**< Set up device TX queue.*/ eth_queue_release_t tx_queue_release;/**< Release TX queue.*/ eth_dev_led_on_t dev_led_on; /**< Turn on LED. */ @@ -1672,6 +1677,19 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id, } #endif +#ifdef RTE_LIBRTE_ETHDEV_DEBUG +extern uint32_t rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id); +#else +static inline uint32_t +rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id) +{ + struct rte_eth_dev *dev; + + dev = &rte_eth_devices[port_id]; + return (*dev->dev_ops->rx_queue_count)(dev, queue_id); +} +#endif + /** * Send a burst of output packets on a transmit queue of an Ethernet device. *