From patchwork Wed Jul 6 07:52:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aman Kumar X-Patchwork-Id: 113731 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 52203A0540; Wed, 6 Jul 2022 09:57:30 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8C9134282E; Wed, 6 Jul 2022 09:56:47 +0200 (CEST) Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by mails.dpdk.org (Postfix) with ESMTP id 2BFEE42B8C for ; Wed, 6 Jul 2022 09:56:44 +0200 (CEST) Received: by mail-pj1-f45.google.com with SMTP id a15so7769305pjs.0 for ; Wed, 06 Jul 2022 00:56:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vvdntech-in.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=X5CFPp9dyVHI2xRMsUIYAvqj+tJz0TbHmo/cqQGXnqE=; b=IGtS8QyoHGrQdKlAdo756aNNoc5bXbjOj84guqPORdwolluHKE9RW0Cur2kgIIP1BD Soup4QtIOn6bddw7+x+FBy31o3It5jnibs7pNrMWqyLHWQ9mPpLGTKg9FA5bdx/1nhjn w9OU1/fjpkElg2///85ZgE0zXHZP8EsHbUu+sua21pB1FDQ47A2QV1NSF7bbB6hi/GMB Gr/daHIMAn1UarvHRLspIRXa7uJ0TUN1jDHAyFmi7YirrTAUofmnca0xu0d3GQv52x7c SumRXaVwbRTTJvx3tfhhU8peFDFXNBY2UYtaoXgNFf80+2RX4eb583qES4ACdHPWV3O6 hCVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=X5CFPp9dyVHI2xRMsUIYAvqj+tJz0TbHmo/cqQGXnqE=; b=RNQyKEG1o/p5xPNU8embHKXTjSqlFQYH+gzOVLF5kp1sUWK/YPkgGBt8vG53RrgD1a z5gBusV6Qa/aNJuAMy2No72u+WIGvqba5ZKlA6xrI6JImSO5h9Ht7j9pWmP2opB3snvw EQTS32tBqVDbRKUt+9MMuzahRKQmgBZ/t/fHZgVz7lddQM55G53FR8smuGXdxquV4FuU SrT5jQ5uGv7K0SGONaxeJvM0VG9Ad5vVdp9NCjd8tSflashQ/gUtQv9ZJk75NJCJ+65w PUkR4Bg1ZLsqAXS/o++VO2cQMz17NONKdPUCI4n57RgweHiFKqPmQEci2Vjc7KGZh2o0 3Etg== X-Gm-Message-State: AJIora+IZmiveUI0h5Jnwyr2iSN4U10Aw7YLj97I0x11bSYheUDJPsL+ xQtiupgZWuSi27IZD4itr5fmYR4jDqUVYR+J X-Google-Smtp-Source: AGRyM1vU2LTZviPpHy1QdMmqErp/0gaauxTli6MWNKj/gIukVV0+9xzRIobUuWFJxXELL98mBZ9Nbg== X-Received: by 2002:a17:90a:890e:b0:1ef:85d5:515d with SMTP id u14-20020a17090a890e00b001ef85d5515dmr20123346pjn.109.1657094203241; Wed, 06 Jul 2022 00:56:43 -0700 (PDT) Received: from 470--5GDC--BLR.blore.vvdntech.com ([106.51.39.131]) by smtp.gmail.com with ESMTPSA id r4-20020a17090a438400b001ef81574355sm7378805pjg.12.2022.07.06.00.56.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 00:56:43 -0700 (PDT) From: Aman Kumar To: dev@dpdk.org Cc: maxime.coquelin@redhat.com, david.marchand@redhat.com, aman.kumar@vvdntech.in Subject: [RFC PATCH 13/29] net/qdma: add callback support for Rx queue count Date: Wed, 6 Jul 2022 13:22:03 +0530 Message-Id: <20220706075219.517046-14-aman.kumar@vvdntech.in> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220706075219.517046-1-aman.kumar@vvdntech.in> References: <20220706075219.517046-1-aman.kumar@vvdntech.in> MIME-Version: 1.0 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 this patch implements callback support to read rx_desc and fetch rx_queue_count info. Signed-off-by: Aman Kumar --- drivers/net/qdma/qdma_devops.c | 2 + drivers/net/qdma/qdma_devops.h | 6 +- drivers/net/qdma/qdma_rxtx.c | 120 +++++++++++++++++++++++++++++++++ 3 files changed, 124 insertions(+), 4 deletions(-) diff --git a/drivers/net/qdma/qdma_devops.c b/drivers/net/qdma/qdma_devops.c index 017dcf39ff..fefbbda012 100644 --- a/drivers/net/qdma/qdma_devops.c +++ b/drivers/net/qdma/qdma_devops.c @@ -1399,4 +1399,6 @@ void qdma_dev_ops_init(struct rte_eth_dev *dev) dev->dev_ops = &qdma_eth_dev_ops; dev->rx_pkt_burst = &qdma_recv_pkts; dev->tx_pkt_burst = &qdma_xmit_pkts; + dev->rx_queue_count = &qdma_dev_rx_queue_count; + dev->rx_descriptor_status = &qdma_dev_rx_descriptor_status; } diff --git a/drivers/net/qdma/qdma_devops.h b/drivers/net/qdma/qdma_devops.h index c0f903f1cf..0014f4b0c9 100644 --- a/drivers/net/qdma/qdma_devops.h +++ b/drivers/net/qdma/qdma_devops.h @@ -294,9 +294,7 @@ int qdma_dev_queue_stats_mapping(struct rte_eth_dev *dev, /** * DPDK callback to get the number of used descriptors of a rx queue * - * @param dev - * Pointer to Ethernet device structure - * @param rx_queue_id + * @param rxq * The RX queue on the Ethernet device for which information will be * retrieved * @@ -305,7 +303,7 @@ int qdma_dev_queue_stats_mapping(struct rte_eth_dev *dev, * @ingroup dpdk_devops_func */ uint32_t -qdma_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id); +qdma_dev_rx_queue_count(void *rxq); /** * DPDK callback to check the status of a Rx descriptor in the queue diff --git a/drivers/net/qdma/qdma_rxtx.c b/drivers/net/qdma/qdma_rxtx.c index 15f6661cbf..102671e16f 100644 --- a/drivers/net/qdma/qdma_rxtx.c +++ b/drivers/net/qdma/qdma_rxtx.c @@ -206,3 +206,123 @@ static void adapt_update_counter(struct qdma_rx_queue *rxq, } } #endif /* QDMA_LATENCY_OPTIMIZED */ + +static uint32_t rx_queue_count(void *rx_queue) +{ + struct qdma_rx_queue *rxq = rx_queue; + struct wb_status *wb_status; + uint16_t pkt_length; + uint16_t nb_pkts_avail = 0; + uint16_t rx_cmpt_tail = 0; + uint16_t cmpt_pidx; + uint32_t nb_desc_used = 0, count = 0; + union qdma_ul_st_cmpt_ring *user_cmpt_entry; + union qdma_ul_st_cmpt_ring cmpt_data; + + wb_status = rxq->wb_status; + rx_cmpt_tail = rxq->cmpt_cidx_info.wrb_cidx; + cmpt_pidx = wb_status->pidx; + + if (rx_cmpt_tail < cmpt_pidx) + nb_pkts_avail = cmpt_pidx - rx_cmpt_tail; + else if (rx_cmpt_tail > cmpt_pidx) + nb_pkts_avail = rxq->nb_rx_cmpt_desc - 1 - rx_cmpt_tail + + cmpt_pidx; + + if (nb_pkts_avail == 0) + return 0; + + while (count < nb_pkts_avail) { + user_cmpt_entry = + (union qdma_ul_st_cmpt_ring *)((uint64_t)rxq->cmpt_ring + + ((uint64_t)rx_cmpt_tail * rxq->cmpt_desc_len)); + + if (qdma_ul_extract_st_cmpt_info(user_cmpt_entry, + &cmpt_data)) { + break; + } + + pkt_length = qdma_ul_get_cmpt_pkt_len(&cmpt_data); + if (unlikely(!pkt_length)) { + count++; + continue; + } + + nb_desc_used += ((pkt_length / rxq->rx_buff_size) + 1); + rx_cmpt_tail++; + if (unlikely(rx_cmpt_tail >= (rxq->nb_rx_cmpt_desc - 1))) + rx_cmpt_tail -= (rxq->nb_rx_cmpt_desc - 1); + count++; + } + PMD_DRV_LOG(DEBUG, "%s: nb_desc_used = %d", + __func__, nb_desc_used); + return nb_desc_used; +} + +/** + * DPDK callback to get the number of used descriptors of a rx queue. + * + * @param dev + * Pointer to Ethernet device structure. + * @param rx_queue_id + * The RX queue on the Ethernet device for which information will be + * retrieved + * + * @return + * The number of used descriptors in the specific queue. + */ +uint32_t +qdma_dev_rx_queue_count(void *rxq) +{ + return rx_queue_count(rxq); +} +/** + * DPDK callback to check the status of a Rx descriptor in the queue. + * + * @param rx_queue + * Pointer to Rx queue specific data structure. + * @param offset + * The offset of the descriptor starting from tail (0 is the next + * packet to be received by the driver). + * + * @return + * - (RTE_ETH_RX_DESC_AVAIL): Descriptor is available for the hardware to + * receive a packet. + * - (RTE_ETH_RX_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_RX_DESC_UNAVAIL): Descriptor is unavailable, either hold by + * the driver and not yet returned to hw, or reserved by the hw. + * - (-EINVAL) bad descriptor offset. + */ +int +qdma_dev_rx_descriptor_status(void *rx_queue, uint16_t offset) +{ + struct qdma_rx_queue *rxq = rx_queue; + uint32_t desc_used_count; + uint16_t rx_tail, c2h_pidx, pending_desc; + + if (unlikely(offset >= (rxq->nb_rx_desc - 1))) + return -EINVAL; + + /* One descriptor is reserved so that pidx is not same as tail */ + if (offset == (rxq->nb_rx_desc - 2)) + return RTE_ETH_RX_DESC_UNAVAIL; + + desc_used_count = rx_queue_count(rxq); + if (offset < desc_used_count) + return RTE_ETH_RX_DESC_DONE; + + /* If Tail is not same as PIDX, descriptors are held by the driver */ + rx_tail = rxq->rx_tail; + c2h_pidx = rxq->q_pidx_info.pidx; + + pending_desc = rx_tail - c2h_pidx - 1; + if (rx_tail < (c2h_pidx + 1)) + pending_desc = rxq->nb_rx_desc - 2 + rx_tail - + c2h_pidx; + + if (offset < (desc_used_count + pending_desc)) + return RTE_ETH_RX_DESC_UNAVAIL; + + return RTE_ETH_RX_DESC_AVAIL; +}