From 6a6f2b57a3bc484771a7aea8f1695e3e172cd688 Mon Sep 17 00:00:00 2001 From: Intel Date: Tue, 23 Jul 2013 00:00:00 +0200 Subject: [PATCH] ethdev: check DD bit of specific RX descriptor Signed-off-by: Intel --- lib/librte_ether/rte_ethdev.c | 15 +++++++++++++++ lib/librte_ether/rte_ethdev.h | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index afc9b7284d..2e85ab7a0f 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -1739,6 +1739,21 @@ rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id) FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, -ENOTSUP); return (*dev->dev_ops->rx_queue_count)(dev, queue_id); } + +int +rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset) +{ + struct rte_eth_dev *dev; + + if (port_id >= nb_ports) { + PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); + return (-ENODEV); + } + dev = &rte_eth_devices[port_id]; + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP); + return (*dev->dev_ops->rx_descriptor_done)( \ + dev->data->rx_queues[queue_id], offset); +} #endif int diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 3509aeabc8..253a47c24b 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -782,6 +782,9 @@ 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 (*eth_rx_descriptor_done_t)(void *rxq, uint16_t offset); +/**< @Check DD bit of specific RX descriptor */ + typedef int (*vlan_filter_set_t)(struct rte_eth_dev *dev, uint16_t vlan_id, int on); @@ -904,6 +907,7 @@ struct eth_dev_ops { 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_rx_descriptor_done_t rx_descriptor_done; /**< Check rxd DD bit */ 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. */ @@ -1734,6 +1738,36 @@ rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id) } #endif +/** + * Check if the DD bit of the specific RX descriptor in the queue has been set + * + * @param port_id + * The port identifier of the Ethernet device. + * @param queue_id + * The queue id on the specific port. + * @offset + * The offset of the descriptor ID from tail. + * @return + * - (1) if the specific DD bit is set. + * - (0) if the specific DD bit is not set. + * - (-ENODEV) if *port_id* invalid. + */ +#ifdef RTE_LIBRTE_ETHDEV_DEBUG +extern int rte_eth_rx_descriptor_done(uint8_t port_id, + uint16_t queue_id, + uint16_t offset); +#else +static inline int +rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset) +{ + struct rte_eth_dev *dev; + + dev = &rte_eth_devices[port_id]; + return (*dev->dev_ops->rx_descriptor_done)( \ + dev->data->rx_queues[queue_id], offset); +} +#endif + /** * Send a burst of output packets on a transmit queue of an Ethernet device. * -- 2.20.1