From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from proxy.6wind.com (host.76.145.23.62.rev.coltfrance.com [62.23.145.76]) by dpdk.org (Postfix) with ESMTP id 1B8B22C2B for ; Wed, 1 Mar 2017 18:20:03 +0100 (CET) Received: from glumotte.dev.6wind.com (unknown [10.16.0.195]) by proxy.6wind.com (Postfix) with ESMTP id 12F5A25327; Wed, 1 Mar 2017 18:19:58 +0100 (CET) From: Olivier Matz To: dev@dpdk.org, thomas.monjalon@6wind.com, konstantin.ananyev@intel.com, wenzhuo.lu@intel.com, helin.zhang@intel.com, jingjing.wu@intel.com, adrien.mazarguil@6wind.com, nelio.laranjeiro@6wind.com Cc: ferruh.yigit@intel.com, bruce.richardson@intel.com Date: Wed, 1 Mar 2017 18:19:07 +0100 Message-Id: <1488388752-1819-2-git-send-email-olivier.matz@6wind.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1488388752-1819-1-git-send-email-olivier.matz@6wind.com> References: <1479981261-19512-1-git-send-email-olivier.matz@6wind.com> <1488388752-1819-1-git-send-email-olivier.matz@6wind.com> Subject: [dpdk-dev] [PATCH 1/6] ethdev: add descriptor status API X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Mar 2017 17:20:03 -0000 Introduce a new API to get the status of a descriptor. For Rx, it is almost similar to rx_descriptor_done API, except it differentiates "used" descriptors (which are hold by the driver and not returned to the hardware). For Tx, it is a new API. The descriptor_done() API, and probably the rx_queue_count() API could be replaced by this new API as soon as it is implemented on all PMDs. Signed-off-by: Olivier Matz --- lib/librte_ether/rte_ethdev.h | 86 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 97f3e2d..9ac9c61 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1179,6 +1179,14 @@ typedef uint32_t (*eth_rx_queue_count_t)(struct rte_eth_dev *dev, typedef int (*eth_rx_descriptor_done_t)(void *rxq, uint16_t offset); /**< @internal Check DD bit of specific RX descriptor */ +typedef int (*eth_rx_descriptor_status_t)(struct rte_eth_dev *dev, + uint16_t rx_queue_id, uint16_t offset); +/**< @internal Check the status of a Rx descriptor */ + +typedef int (*eth_tx_descriptor_status_t)(struct rte_eth_dev *dev, + uint16_t tx_queue_id, uint16_t offset); +/**< @internal Check the status of a Tx descriptor */ + typedef int (*eth_fw_version_get_t)(struct rte_eth_dev *dev, char *fw_version, size_t fw_size); /**< @internal Get firmware information of an Ethernet device. */ @@ -1483,6 +1491,10 @@ struct eth_dev_ops { 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_rx_descriptor_status_t rx_descriptor_status; + /**< Check the status of a Rx descriptor. */ + eth_tx_descriptor_status_t tx_descriptor_status; + /**< Check the status of a Tx descriptor. */ eth_rx_enable_intr_t rx_queue_intr_enable; /**< Enable Rx queue interrupt. */ eth_rx_disable_intr_t rx_queue_intr_disable; /**< Disable Rx queue interrupt. */ eth_tx_queue_setup_t tx_queue_setup;/**< Set up device TX queue. */ @@ -2768,6 +2780,80 @@ rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset) dev->data->rx_queues[queue_id], offset); } +#define RTE_ETH_RX_DESC_AVAIL 0 /**< Desc available for hw. */ +#define RTE_ETH_RX_DESC_DONE 1 /**< Desc done, filled by hw. */ +#define RTE_ETH_RX_DESC_USED 2 /**< Desc used by driver. */ + +/** + * Check the status of a Rx descriptor in the queue + * + * @param port_id + * The port identifier of the Ethernet device. + * @param queue_id + * The Rx queue identifier on this port. + * @param offset + * The offset of the descriptor starting from tail (0 is the next + * packet to be received by the driver). + * + * @return + * - (RTE_ETH_DESC_AVAIL): Descriptor is available for the hardware to + * receive a packet. + * - (RTE_ETH_DESC_DONE): Descriptor is done, it is filled by hw, but + * not yet processed by the driver (i.e. in the receive queue). + * - (RTE_ETH_DESC_USED): Descriptor is unavailable (hold by driver, + * not yet returned to hw). + * - (-ENODEV) if *port_id* invalid. + * - (-EINVAL) bad descriptor offset. + * - (-ENOTSUP) if the device does not support this function. + */ +static inline int +rte_eth_rx_descriptor_status(uint8_t port_id, uint16_t queue_id, + uint16_t offset) +{ + struct rte_eth_dev *dev; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + dev = &rte_eth_devices[port_id]; + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_status, -ENOTSUP); + + return (*dev->dev_ops->rx_descriptor_status)(dev, queue_id, offset); +} + +#define RTE_ETH_TX_DESC_FULL 0 /**< Desc filled by pmd for hw, waiting xmit. */ +#define RTE_ETH_TX_DESC_DONE 1 /**< Desc done, packet is transmitted. */ + +/** + * Check the status of a Tx descriptor in the queue. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param queue_id + * The Tx queue identifier on this port. + * @param offset + * The offset of the descriptor starting from tail (0 is the place where + * the next packet will be send). + * + * @return + * - (RTE_ETH_DESC_FULL) Descriptor is being processed by the hw, i.e. + * in the transmit queue. + * - (RTE_ETH_DESC_DONE) Hardware is done with this descriptor, it can be + * reused by the driver. + * - (-ENODEV) if *port_id* invalid. + * - (-EINVAL) bad descriptor offset. + * - (-ENOTSUP) if the device does not support this function. + */ +static inline int rte_eth_tx_descriptor_status(uint8_t port_id, + uint16_t queue_id, uint16_t offset) +{ + struct rte_eth_dev *dev; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + dev = &rte_eth_devices[port_id]; + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_descriptor_status, -ENOTSUP); + + return (*dev->dev_ops->tx_descriptor_status)(dev, queue_id, offset); +} + /** * Send a burst of output packets on a transmit queue of an Ethernet device. * -- 2.8.1