From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 55021A0547; Thu, 21 Oct 2021 11:54:27 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2FDD1411DD; Thu, 21 Oct 2021 11:51:23 +0200 (CEST) Received: from smtpbg151.qq.com (smtpbg151.qq.com [18.169.211.239]) by mails.dpdk.org (Postfix) with ESMTP id 704464126A for ; Thu, 21 Oct 2021 11:51:19 +0200 (CEST) X-QQ-mid: bizesmtp38t1634809876trqf0478 Received: from jiawenwu.trustnetic.com (unknown [183.129.236.74]) by esmtp6.qq.com (ESMTP) with id ; Thu, 21 Oct 2021 17:51:16 +0800 (CST) X-QQ-SSF: 01400000000000E0I000000A0000000 X-QQ-FEAT: ZKIyA7viXp0Drt2A7N2laT2OTF15xzw/C/c7INSRbJiCvZDHZzadbcG9hXDDG J+1gq0zZ7TlMwKFLOD2BOeODfIBq1j4VJtHAoJDyPe6b89AbkHOj5rlhv4szDYvM5e4l4ge Xe+dNnB7HyE2g5rOFMw2YQXYxQUQDPNHWsLyJge/c/Zsc1jJ9Csj1PjO13GY7DZIwmTsXhw ijnF7ST0FS+EeqZP6U1jbGUkT4T4401BLQmGg9oh3pGaYNrtbGzGiGrobAtnruvWrLokpd3 FVJGP7t2PQRqKM3KmTKYyR2XMFFOBCFHfDt4bf5o12gIUb2mI5KAr18pYzii6HV6Eog+FBD QBnFveRisVGxAyuLyzs8BhHZblSWBfBRjj27SU5PIM9pfpwvMU= X-QQ-GoodBg: 2 From: Jiawen Wu To: dev@dpdk.org Cc: Jiawen Wu Date: Thu, 21 Oct 2021 17:50:22 +0800 Message-Id: <20211021095023.18288-26-jiawenwu@trustnetic.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20211021095023.18288-1-jiawenwu@trustnetic.com> References: <20211021095023.18288-1-jiawenwu@trustnetic.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:trustnetic.com:qybgforeign:qybgforeign5 X-QQ-Bgrelay: 1 Subject: [dpdk-dev] [PATCH v2 25/26] net/ngbe: add Rx and Tx descriptor status X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Supports to get the number of used Rx descriptos, and check the status of Rx and Tx descriptors. Signed-off-by: Jiawen Wu --- doc/guides/nics/features/ngbe.ini | 2 + drivers/net/ngbe/ngbe_ethdev.c | 3 ++ drivers/net/ngbe/ngbe_ethdev.h | 6 +++ drivers/net/ngbe/ngbe_rxtx.c | 73 +++++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+) diff --git a/doc/guides/nics/features/ngbe.ini b/doc/guides/nics/features/ngbe.ini index 03f0873443..38e8c7178d 100644 --- a/doc/guides/nics/features/ngbe.ini +++ b/doc/guides/nics/features/ngbe.ini @@ -32,6 +32,8 @@ Inner L3 checksum = Y Inner L4 checksum = Y Packet type parsing = Y Timesync = Y +Rx descriptor status = Y +Tx descriptor status = Y Basic stats = Y Extended stats = Y Stats per queue = Y diff --git a/drivers/net/ngbe/ngbe_ethdev.c b/drivers/net/ngbe/ngbe_ethdev.c index 2f83c2e2fc..706227339f 100644 --- a/drivers/net/ngbe/ngbe_ethdev.c +++ b/drivers/net/ngbe/ngbe_ethdev.c @@ -320,6 +320,9 @@ eth_ngbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused) PMD_INIT_FUNC_TRACE(); eth_dev->dev_ops = &ngbe_eth_dev_ops; + eth_dev->rx_queue_count = ngbe_dev_rx_queue_count; + eth_dev->rx_descriptor_status = ngbe_dev_rx_descriptor_status; + eth_dev->tx_descriptor_status = ngbe_dev_tx_descriptor_status; eth_dev->rx_pkt_burst = &ngbe_recv_pkts; eth_dev->tx_pkt_burst = &ngbe_xmit_pkts; eth_dev->tx_pkt_prepare = &ngbe_prep_pkts; diff --git a/drivers/net/ngbe/ngbe_ethdev.h b/drivers/net/ngbe/ngbe_ethdev.h index 527b0b3be0..02e9c1c913 100644 --- a/drivers/net/ngbe/ngbe_ethdev.h +++ b/drivers/net/ngbe/ngbe_ethdev.h @@ -202,6 +202,12 @@ int ngbe_dev_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); +uint32_t ngbe_dev_rx_queue_count(struct rte_eth_dev *dev, + uint16_t rx_queue_id); + +int ngbe_dev_rx_descriptor_status(void *rx_queue, uint16_t offset); +int ngbe_dev_tx_descriptor_status(void *tx_queue, uint16_t offset); + int ngbe_dev_rx_init(struct rte_eth_dev *dev); void ngbe_dev_tx_init(struct rte_eth_dev *dev); diff --git a/drivers/net/ngbe/ngbe_rxtx.c b/drivers/net/ngbe/ngbe_rxtx.c index 36d6ec1992..e1a999a470 100644 --- a/drivers/net/ngbe/ngbe_rxtx.c +++ b/drivers/net/ngbe/ngbe_rxtx.c @@ -2285,6 +2285,79 @@ ngbe_dev_rx_queue_setup(struct rte_eth_dev *dev, return 0; } +uint32_t +ngbe_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id) +{ +#define NGBE_RXQ_SCAN_INTERVAL 4 + volatile struct ngbe_rx_desc *rxdp; + struct ngbe_rx_queue *rxq; + uint32_t desc = 0; + + rxq = dev->data->rx_queues[rx_queue_id]; + rxdp = &rxq->rx_ring[rxq->rx_tail]; + + while ((desc < rxq->nb_rx_desc) && + (rxdp->qw1.lo.status & + rte_cpu_to_le_32(NGBE_RXD_STAT_DD))) { + desc += NGBE_RXQ_SCAN_INTERVAL; + rxdp += NGBE_RXQ_SCAN_INTERVAL; + if (rxq->rx_tail + desc >= rxq->nb_rx_desc) + rxdp = &(rxq->rx_ring[rxq->rx_tail + + desc - rxq->nb_rx_desc]); + } + + return desc; +} + +int +ngbe_dev_rx_descriptor_status(void *rx_queue, uint16_t offset) +{ + struct ngbe_rx_queue *rxq = rx_queue; + volatile uint32_t *status; + uint32_t nb_hold, desc; + + if (unlikely(offset >= rxq->nb_rx_desc)) + return -EINVAL; + + nb_hold = rxq->nb_rx_hold; + if (offset >= rxq->nb_rx_desc - nb_hold) + return RTE_ETH_RX_DESC_UNAVAIL; + + desc = rxq->rx_tail + offset; + if (desc >= rxq->nb_rx_desc) + desc -= rxq->nb_rx_desc; + + status = &rxq->rx_ring[desc].qw1.lo.status; + if (*status & rte_cpu_to_le_32(NGBE_RXD_STAT_DD)) + return RTE_ETH_RX_DESC_DONE; + + return RTE_ETH_RX_DESC_AVAIL; +} + +int +ngbe_dev_tx_descriptor_status(void *tx_queue, uint16_t offset) +{ + struct ngbe_tx_queue *txq = tx_queue; + volatile uint32_t *status; + uint32_t desc; + + if (unlikely(offset >= txq->nb_tx_desc)) + return -EINVAL; + + desc = txq->tx_tail + offset; + if (desc >= txq->nb_tx_desc) { + desc -= txq->nb_tx_desc; + if (desc >= txq->nb_tx_desc) + desc -= txq->nb_tx_desc; + } + + status = &txq->tx_ring[desc].dw3; + if (*status & rte_cpu_to_le_32(NGBE_TXD_DD)) + return RTE_ETH_TX_DESC_DONE; + + return RTE_ETH_TX_DESC_FULL; +} + void ngbe_dev_clear_queues(struct rte_eth_dev *dev) { -- 2.21.0.windows.1