From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9FBCCA0093; Tue, 19 May 2020 18:53:09 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6F9701D638; Tue, 19 May 2020 18:52:57 +0200 (CEST) Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by dpdk.org (Postfix) with ESMTP id 328C11D62C for ; Tue, 19 May 2020 18:52:53 +0200 (CEST) Received: by mail-pf1-f196.google.com with SMTP id v63so171660pfb.10 for ; Tue, 19 May 2020 09:52:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=F7Ro+4D+/RChrVm48QmNXVHptqTiavagpbltI416tB4=; b=tfIv6IqYKlT9TCPVGRI7Hnz39QOdZO6RoIGj37KC8m1B7cjDJ4TansAMaASG+AuRWW 7X4qdyrXpS8AuO9DAY2oBVqGPzIvsIlKUoCcI3fWMkzkQDI5f5eqc9o4VmQRtc3oAPhx 5tXO/qA54TqIwXG28FMCtc3uYBpo+G5GaSib+cFs920clJK6nirK9gt7iNzwnOsBnS1H D/QuUpFdayZBKmxF44KgMVZCOJmHwNNPE2muAKKzj5gv/WQpP/QPqKp5oJeoRGMPqZm7 Fy4GRIWcRMdTscTceytUX4kOsgPzHt94J4cqXe7F8koYeuTIGnbk4FBSRscQ6hoCH9Mc 4LDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=F7Ro+4D+/RChrVm48QmNXVHptqTiavagpbltI416tB4=; b=gIJaU/QdJQy3PY7VgpqsT7IyfED994UYm++0/XxamOl94S5+aoE9O90Gmyv5gXnh+E IgN3RCUjTOtVvXIIm189ip0ydnqPqw1UflfVUYlOfgFWbZPmuzyZErDBoNPZTUlgGAT4 ezrQEiu4ID0J9qh7YFj/B2giOIoLXwlYIKgOwQ6RH1z6nyCbLGozZSd3JW412QR9bmRv ulEWptz54U12H3D/c0NSluIwfu3sJ5JjYFgk8c7XSgH2/IXYo77mhfwLndLJ2B0cqc1L QhcKQdc6GOFmlQGcbk9eqD92WPyMSkLgxOM/GQUiy424xyMMbTnNrpTgELF0kdF8MiEe CFVg== X-Gm-Message-State: AOAM53090nraCuVdrWk/lRLo7BCr6JvXlFKumF4a8fd91WVO60rQMUC2 4ttSeyOkA5mg+FQhhdflgowWQwWANwJCLA== X-Google-Smtp-Source: ABdhPJyw20v1qDvtH7310X3fuqczexkdhXf/XEskgvuYKBrifbeqcJlBZH40b7srE6exFmW3ndqrWA== X-Received: by 2002:a63:5d55:: with SMTP id o21mr154584pgm.58.1589907171620; Tue, 19 May 2020 09:52:51 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id c12sm107394pjm.46.2020.05.19.09.52.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 09:52:50 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 19 May 2020 09:52:25 -0700 Message-Id: <20200519165230.23306-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200519165230.23306-1-stephen@networkplumber.org> References: <20200506192730.21613-1-stephen@networkplumber.org> <20200519165230.23306-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 2/7] net/netvsc: implement rx/tx descriptor status functions 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" These functions are useful for applications and debugging. The netvsc PMD also transparently handles the rx/tx descriptor functions for underlying VF device. Signed-off-by: Stephen Hemminger --- drivers/net/netvsc/hn_ethdev.c | 3 ++ drivers/net/netvsc/hn_rxtx.c | 57 ++++++++++++++++++++++++++++++++++ drivers/net/netvsc/hn_var.h | 5 +++ 3 files changed, 65 insertions(+) diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c index b890fa3befa8..675a49e66a57 100644 --- a/drivers/net/netvsc/hn_ethdev.c +++ b/drivers/net/netvsc/hn_ethdev.c @@ -875,8 +875,11 @@ static const struct eth_dev_ops hn_eth_dev_ops = { .tx_queue_setup = hn_dev_tx_queue_setup, .tx_queue_release = hn_dev_tx_queue_release, .tx_done_cleanup = hn_dev_tx_done_cleanup, + .tx_descriptor_status = hn_dev_tx_descriptor_status, .rx_queue_setup = hn_dev_rx_queue_setup, .rx_queue_release = hn_dev_rx_queue_release, + .rx_queue_count = hn_dev_rx_queue_count, + .rx_descriptor_status = hn_dev_rx_queue_status, .link_update = hn_dev_link_update, .stats_get = hn_dev_stats_get, .stats_reset = hn_dev_stats_reset, diff --git a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c index 668f48fcbf15..b22d8ea7feb0 100644 --- a/drivers/net/netvsc/hn_rxtx.c +++ b/drivers/net/netvsc/hn_rxtx.c @@ -369,6 +369,29 @@ hn_dev_tx_queue_release(void *arg) rte_free(txq); } +/* + * Check the status of a Tx descriptor in the queue. + * + * returns: + * - -EINVAL - offset outside of tx_descriptor pool. + * - RTE_ETH_TX_DESC_FULL - descriptor is not acknowleged by host. + * - RTE_ETH_TX_DESC_DONE - descriptor is available. + */ +int hn_dev_tx_descriptor_status(void *arg, uint16_t offset) +{ + const struct hn_tx_queue *txq = arg; + + hn_process_events(txq->hv, txq->queue_id, 0); + + if (offset >= rte_mempool_avail_count(txq->txdesc_pool)) + return -EINVAL; + + if (offset < rte_mempool_in_use_count(txq->txdesc_pool)) + return RTE_ETH_TX_DESC_FULL; + else + return RTE_ETH_TX_DESC_DONE; +} + static void hn_nvs_send_completed(struct rte_eth_dev *dev, uint16_t queue_id, unsigned long xactid, const struct hn_nvs_rndis_ack *ack) @@ -966,6 +989,40 @@ hn_dev_rx_queue_release(void *arg) hn_rx_queue_free(rxq, true); } +/* + * Get the number of used descriptor in a rx queue + * For this device that means how many packets are pending in the ring. + */ +uint32_t +hn_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t queue_id) +{ + struct hn_rx_queue *rxq = dev->data->rx_queues[queue_id]; + + return rte_ring_count(rxq->rx_ring); +} + +/* + * Check the status of a Rx descriptor in the queue + * + * returns: + * - -EINVAL - offset outside of ring + * - RTE_ETH_RX_DESC_AVAIL - no data available yet + * - RTE_ETH_RX_DESC_DONE - data is waiting in stagin ring + */ +int hn_dev_rx_queue_status(void *arg, uint16_t offset) +{ + const struct hn_rx_queue *rxq = arg; + + hn_process_events(rxq->hv, rxq->queue_id, 0); + if (offset >= rxq->rx_ring->capacity) + return -EINVAL; + + if (offset < rte_ring_count(rxq->rx_ring)) + return RTE_ETH_RX_DESC_DONE; + else + return RTE_ETH_RX_DESC_AVAIL; +} + int hn_dev_tx_done_cleanup(void *arg, uint32_t free_cnt) { diff --git a/drivers/net/netvsc/hn_var.h b/drivers/net/netvsc/hn_var.h index 93168d2e0102..ded0d4c60a04 100644 --- a/drivers/net/netvsc/hn_var.h +++ b/drivers/net/netvsc/hn_var.h @@ -169,6 +169,7 @@ void hn_dev_tx_queue_release(void *arg); void hn_dev_tx_queue_info(struct rte_eth_dev *dev, uint16_t queue_idx, struct rte_eth_txq_info *qinfo); int hn_dev_tx_done_cleanup(void *arg, uint32_t free_cnt); +int hn_dev_tx_descriptor_status(void *arg, uint16_t offset); struct hn_rx_queue *hn_rx_queue_alloc(struct hn_data *hv, uint16_t queue_id, @@ -181,6 +182,8 @@ int hn_dev_rx_queue_setup(struct rte_eth_dev *dev, void hn_dev_rx_queue_info(struct rte_eth_dev *dev, uint16_t queue_id, struct rte_eth_rxq_info *qinfo); void hn_dev_rx_queue_release(void *arg); +uint32_t hn_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t queue_id); +int hn_dev_rx_queue_status(void *rxq, uint16_t offset); void hn_dev_free_queues(struct rte_eth_dev *dev); /* Check if VF is attached */ @@ -231,6 +234,8 @@ int hn_vf_tx_queue_setup(struct rte_eth_dev *dev, unsigned int socket_id, const struct rte_eth_txconf *tx_conf); void hn_vf_tx_queue_release(struct hn_data *hv, uint16_t queue_id); +int hn_vf_tx_queue_status(struct hn_data *hv, uint16_t queue_id, uint16_t offset); + int hn_vf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, uint16_t nb_desc, unsigned int socket_id, -- 2.26.2