From: Olivier Matz <olivier.matz@6wind.com>
To: dev@dpdk.org
Cc: thomas.monjalon@6wind.com, konstantin.ananyev@intel.com,
wenzhuo.lu@intel.com, helin.zhang@intel.com
Subject: [dpdk-dev] [RFC 5/9] net/ixgbe: add handler for Tx queue descriptor count
Date: Thu, 24 Nov 2016 10:54:17 +0100 [thread overview]
Message-ID: <1479981261-19512-6-git-send-email-olivier.matz@6wind.com> (raw)
In-Reply-To: <1479981261-19512-1-git-send-email-olivier.matz@6wind.com>
Like for TX, use a binary search algorithm to get the number of used Tx
descriptors.
PR=52423
Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Ivan Boule <ivan.boule@6wind.com>
---
drivers/net/ixgbe/ixgbe_ethdev.c | 1 +
drivers/net/ixgbe/ixgbe_ethdev.h | 4 ++-
drivers/net/ixgbe/ixgbe_rxtx.c | 57 ++++++++++++++++++++++++++++++++++++++++
drivers/net/ixgbe/ixgbe_rxtx.h | 2 ++
4 files changed, 63 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index baffc71..0ba098a 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -553,6 +553,7 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {
.rx_queue_intr_disable = ixgbe_dev_rx_queue_intr_disable,
.rx_queue_release = ixgbe_dev_rx_queue_release,
.rx_queue_count = ixgbe_dev_rx_queue_count,
+ .tx_queue_count = ixgbe_dev_tx_queue_count,
.rx_descriptor_done = ixgbe_dev_rx_descriptor_done,
.tx_queue_setup = ixgbe_dev_tx_queue_setup,
.tx_queue_release = ixgbe_dev_tx_queue_release,
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index 4ff6338..e060c3d 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
@@ -348,7 +348,9 @@ int ixgbe_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
const struct rte_eth_txconf *tx_conf);
uint32_t ixgbe_dev_rx_queue_count(struct rte_eth_dev *dev,
- uint16_t rx_queue_id);
+ uint16_t rx_queue_id);
+uint32_t ixgbe_dev_tx_queue_count(struct rte_eth_dev *dev,
+ uint16_t tx_queue_id);
int ixgbe_dev_rx_descriptor_done(void *rx_queue, uint16_t offset);
int ixgbevf_dev_rx_descriptor_done(void *rx_queue, uint16_t offset);
diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
index 07509b4..5bf6b1a 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx.c
@@ -2437,6 +2437,7 @@ ixgbe_dev_tx_queue_setup(struct rte_eth_dev *dev,
txq->nb_tx_desc = nb_desc;
txq->tx_rs_thresh = tx_rs_thresh;
+ txq->tx_rs_thresh_div = nb_desc / tx_rs_thresh;
txq->tx_free_thresh = tx_free_thresh;
txq->pthresh = tx_conf->tx_thresh.pthresh;
txq->hthresh = tx_conf->tx_thresh.hthresh;
@@ -2906,6 +2907,62 @@ ixgbe_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id)
return offset;
}
+uint32_t
+ixgbe_dev_tx_queue_count(struct rte_eth_dev *dev, uint16_t tx_queue_id)
+{
+ struct ixgbe_tx_queue *txq;
+ uint32_t status;
+ int32_t offset, interval, idx = 0;
+ int32_t max_offset, used_desc;
+
+ txq = dev->data->tx_queues[tx_queue_id];
+
+ /* if DD on next threshold desc is not set, assume used packets
+ * are pending.
+ */
+ status = txq->tx_ring[txq->tx_next_dd].wb.status;
+ if (!(status & rte_cpu_to_le_32(IXGBE_ADVTXD_STAT_DD)))
+ return txq->nb_tx_desc - txq->nb_tx_free - 1;
+
+ /* browse DD bits between tail starting from tx_next_dd: we have
+ * to be careful since DD bits are only set every tx_rs_thresh
+ * descriptor.
+ */
+ interval = txq->tx_rs_thresh_div >> 1;
+ offset = interval * txq->tx_rs_thresh;
+
+ /* don't go beyond tail */
+ max_offset = txq->tx_tail - txq->tx_next_dd;
+ if (max_offset < 0)
+ max_offset += txq->nb_tx_desc;
+
+ do {
+ interval >>= 1;
+
+ if (offset >= max_offset) {
+ offset -= (interval * txq->tx_rs_thresh);
+ continue;
+ }
+
+ idx = txq->tx_next_dd + offset;
+ if (idx >= txq->nb_tx_desc)
+ idx -= txq->nb_tx_desc;
+
+ status = txq->tx_ring[idx].wb.status;
+ if (status & rte_cpu_to_le_32(IXGBE_ADVTXD_STAT_DD))
+ offset += (interval * txq->tx_rs_thresh);
+ else
+ offset -= (interval * txq->tx_rs_thresh);
+ } while (interval > 0);
+
+ /* idx is now the index of the head */
+ used_desc = txq->tx_tail - idx;
+ if (used_desc < 0)
+ used_desc += txq->nb_tx_desc;
+
+ return used_desc;
+}
+
int
ixgbe_dev_rx_descriptor_done(void *rx_queue, uint16_t offset)
{
diff --git a/drivers/net/ixgbe/ixgbe_rxtx.h b/drivers/net/ixgbe/ixgbe_rxtx.h
index 2608b36..f69b5de 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.h
+++ b/drivers/net/ixgbe/ixgbe_rxtx.h
@@ -221,6 +221,8 @@ struct ixgbe_tx_queue {
uint16_t tx_free_thresh;
/** Number of TX descriptors to use before RS bit is set. */
uint16_t tx_rs_thresh;
+ /** Number of TX descriptors divided by tx_rs_thresh. */
+ uint16_t tx_rs_thresh_div;
/** Number of TX descriptors used since RS bit was set. */
uint16_t nb_tx_used;
/** Index to last TX descriptor to have been cleaned. */
--
2.8.1
next prev parent reply other threads:[~2016-11-24 9:59 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-24 9:54 [dpdk-dev] [RFC 0/9] get Rx and Tx used descriptors Olivier Matz
2016-11-24 9:54 ` [dpdk-dev] [RFC 1/9] ethdev: clarify api comments of rx queue count Olivier Matz
2016-11-24 10:52 ` Ferruh Yigit
2016-11-24 11:13 ` Olivier Matz
2016-11-24 9:54 ` [dpdk-dev] [RFC 2/9] ethdev: move queue id check in generic layer Olivier Matz
2016-11-24 10:59 ` Ferruh Yigit
2016-11-24 13:05 ` Olivier Matz
2016-11-24 9:54 ` [dpdk-dev] [RFC 3/9] ethdev: add handler for Tx queue descriptor count Olivier Matz
2016-11-24 9:54 ` [dpdk-dev] [RFC 4/9] net/ixgbe: optimize Rx " Olivier Matz
2016-11-24 9:54 ` Olivier Matz [this message]
2016-11-24 9:54 ` [dpdk-dev] [RFC 6/9] net/igb: optimize rx " Olivier Matz
2016-11-24 9:54 ` [dpdk-dev] [RFC 7/9] net/igb: add handler for tx " Olivier Matz
2016-11-24 9:54 ` [dpdk-dev] [RFC 8/9] net/e1000: optimize rx " Olivier Matz
2016-11-24 9:54 ` [dpdk-dev] [RFC 9/9] net/e1000: add handler for tx " Olivier Matz
2017-01-13 16:44 ` [dpdk-dev] [RFC 0/9] get Rx and Tx used descriptors Olivier Matz
2017-01-13 17:32 ` Richardson, Bruce
2017-01-17 8:24 ` Olivier Matz
2017-01-17 13:56 ` Bruce Richardson
2017-03-01 17:19 ` [dpdk-dev] [PATCH 0/6] get status of Rx and Tx descriptors Olivier Matz
2017-03-01 17:19 ` [dpdk-dev] [PATCH 1/6] ethdev: add descriptor status API Olivier Matz
2017-03-01 18:22 ` Andrew Rybchenko
2017-03-02 13:57 ` Olivier Matz
2017-03-02 14:19 ` Andrew Rybchenko
2017-03-02 14:54 ` Olivier Matz
2017-03-02 15:05 ` Andrew Rybchenko
2017-03-02 15:14 ` Olivier Matz
2017-03-01 17:19 ` [dpdk-dev] [PATCH 2/6] net/ixgbe: implement " Olivier Matz
2017-03-01 17:19 ` [dpdk-dev] [PATCH 3/6] net/e1000: implement descriptor status API (igb) Olivier Matz
2017-03-02 1:28 ` Lu, Wenzhuo
2017-03-02 13:58 ` Olivier Matz
2017-03-01 17:19 ` [dpdk-dev] [PATCH 4/6] net/e1000: implement descriptor status API (em) Olivier Matz
2017-03-02 1:22 ` Lu, Wenzhuo
2017-03-02 14:46 ` Olivier Matz
2017-03-03 1:15 ` Lu, Wenzhuo
2017-03-01 17:19 ` [dpdk-dev] [PATCH 5/6] net/mlx5: implement descriptor status API Olivier Matz
2017-03-02 7:56 ` Nélio Laranjeiro
2017-03-01 17:19 ` [dpdk-dev] [PATCH 6/6] net/i40e: " Olivier Matz
2017-03-01 18:02 ` [dpdk-dev] [PATCH 0/6] get status of Rx and Tx descriptors Andrew Rybchenko
2017-03-02 13:40 ` Olivier Matz
2017-03-06 10:41 ` Thomas Monjalon
2017-03-01 18:07 ` Stephen Hemminger
2017-03-02 13:43 ` Olivier Matz
2017-03-06 10:41 ` Thomas Monjalon
2017-03-02 15:32 ` Bruce Richardson
2017-03-02 16:14 ` Olivier Matz
2017-03-03 16:18 ` Venkatesan, Venky
2017-03-03 16:45 ` Olivier Matz
2017-03-03 18:46 ` Venkatesan, Venky
2017-03-04 20:45 ` Olivier Matz
2017-03-06 11:02 ` Thomas Monjalon
2017-03-07 15:59 ` [dpdk-dev] [PATCH v2 " Olivier Matz
2017-03-07 15:59 ` [dpdk-dev] [PATCH v2 1/6] ethdev: add descriptor status API Olivier Matz
2017-03-09 11:49 ` Andrew Rybchenko
2017-03-21 8:32 ` Yang, Qiming
2017-03-24 12:49 ` Olivier Matz
2017-03-27 1:28 ` Yang, Qiming
2017-03-07 15:59 ` [dpdk-dev] [PATCH v2 2/6] net/ixgbe: implement " Olivier Matz
2017-03-07 15:59 ` [dpdk-dev] [PATCH v2 3/6] net/e1000: implement descriptor status API (igb) Olivier Matz
2017-03-08 1:17 ` Lu, Wenzhuo
2017-03-07 15:59 ` [dpdk-dev] [PATCH v2 4/6] net/e1000: implement descriptor status API (em) Olivier Matz
2017-03-07 15:59 ` [dpdk-dev] [PATCH v2 5/6] net/mlx5: implement descriptor status API Olivier Matz
2017-03-07 15:59 ` [dpdk-dev] [PATCH v2 6/6] net/i40e: " Olivier Matz
2017-03-08 1:17 ` Lu, Wenzhuo
2017-03-29 8:36 ` [dpdk-dev] [PATCH v3 0/6] get status of Rx and Tx descriptors Olivier Matz
2017-03-29 8:36 ` [dpdk-dev] [PATCH v3 1/6] ethdev: add descriptor status API Olivier Matz
2017-03-29 8:36 ` [dpdk-dev] [PATCH v3 2/6] net/ixgbe: implement " Olivier Matz
2017-03-29 8:36 ` [dpdk-dev] [PATCH v3 3/6] net/e1000: implement descriptor status API (igb) Olivier Matz
2017-03-29 8:36 ` [dpdk-dev] [PATCH v3 4/6] net/e1000: implement descriptor status API (em) Olivier Matz
2017-03-29 8:36 ` [dpdk-dev] [PATCH v3 5/6] net/mlx5: implement descriptor status API Olivier Matz
2017-03-29 8:36 ` [dpdk-dev] [PATCH v3 6/6] net/i40e: " Olivier Matz
2017-03-30 13:30 ` [dpdk-dev] [PATCH v3 0/6] get status of Rx and Tx descriptors Thomas Monjalon
2017-04-19 15:50 ` Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1479981261-19512-6-git-send-email-olivier.matz@6wind.com \
--to=olivier.matz@6wind.com \
--cc=dev@dpdk.org \
--cc=helin.zhang@intel.com \
--cc=konstantin.ananyev@intel.com \
--cc=thomas.monjalon@6wind.com \
--cc=wenzhuo.lu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).