ethdev: retrieve RX available descriptors
authorIntel <intel.com>
Mon, 3 Jun 2013 00:00:00 +0000 (00:00 +0000)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Tue, 17 Sep 2013 12:16:07 +0000 (14:16 +0200)
Signed-off-by: Intel
lib/librte_ether/rte_ethdev.c
lib/librte_ether/rte_ethdev.h

index 06fc251..f7535c8 100644 (file)
@@ -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
index 74b3a5b..64a2d57 100644 (file)
@@ -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.
  *