DPDK patches and discussions
 help / color / mirror / Atom feed
From: Matej Vido <vido@cesnet.cz>
To: dev@dpdk.org
Cc: remes@netcope.com
Subject: [dpdk-dev] [PATCH 3/4] net/szedata2: add stat of mbuf allocation failures
Date: Wed,  4 Apr 2018 15:42:20 +0200	[thread overview]
Message-ID: <1522849341-49049-4-git-send-email-vido@cesnet.cz> (raw)
In-Reply-To: <1522849341-49049-1-git-send-email-vido@cesnet.cz>

Signed-off-by: Matej Vido <vido@cesnet.cz>
---
 drivers/net/szedata2/rte_eth_szedata2.c | 31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/drivers/net/szedata2/rte_eth_szedata2.c b/drivers/net/szedata2/rte_eth_szedata2.c
index f41716d..8278780 100644
--- a/drivers/net/szedata2/rte_eth_szedata2.c
+++ b/drivers/net/szedata2/rte_eth_szedata2.c
@@ -67,7 +67,16 @@
 
 #define SZEDATA2_DEV_PATH_FMT "/dev/szedataII%u"
 
+struct pmd_internals {
+	struct rte_eth_dev *dev;
+	uint16_t max_rx_queues;
+	uint16_t max_tx_queues;
+	char sze_dev[PATH_MAX];
+	struct rte_mem_resource *pci_rsc;
+};
+
 struct szedata2_rx_queue {
+	struct pmd_internals *priv;
 	struct szedata *sze;
 	uint8_t rx_channel;
 	uint16_t in_port;
@@ -78,6 +87,7 @@ struct szedata2_rx_queue {
 };
 
 struct szedata2_tx_queue {
+	struct pmd_internals *priv;
 	struct szedata *sze;
 	uint8_t tx_channel;
 	volatile uint64_t tx_pkts;
@@ -85,13 +95,6 @@ struct szedata2_tx_queue {
 	volatile uint64_t err_pkts;
 };
 
-struct pmd_internals {
-	uint16_t max_rx_queues;
-	uint16_t max_tx_queues;
-	char sze_dev[PATH_MAX];
-	struct rte_mem_resource *pci_rsc;
-};
-
 static struct ether_addr eth_addr = {
 	.addr_bytes = { 0x00, 0x11, 0x17, 0x00, 0x00, 0x00 }
 };
@@ -130,8 +133,10 @@ struct pmd_internals {
 	for (i = 0; i < nb_pkts; i++) {
 		mbuf = rte_pktmbuf_alloc(sze_q->mb_pool);
 
-		if (unlikely(mbuf == NULL))
+		if (unlikely(mbuf == NULL)) {
+			sze_q->priv->dev->data->rx_mbuf_alloc_failed++;
 			break;
+		}
 
 		/* get the next sze packet */
 		if (sze->ct_rx_lck != NULL && !sze->ct_rx_rem_bytes &&
@@ -351,6 +356,8 @@ struct pmd_internals {
 	uint16_t packet_len1 = 0;
 	uint16_t packet_len2 = 0;
 	uint16_t hw_data_align;
+	uint64_t *mbuf_failed_ptr =
+		&sze_q->priv->dev->data->rx_mbuf_alloc_failed;
 
 	if (unlikely(sze_q->sze == NULL || nb_pkts == 0))
 		return 0;
@@ -538,6 +545,7 @@ struct pmd_internals {
 			sze->ct_rx_lck = ct_rx_lck_backup;
 			sze->ct_rx_rem_bytes = ct_rx_rem_bytes_backup;
 			sze->ct_rx_cur_ptr = ct_rx_cur_ptr_backup;
+			sze_q->priv->dev->data->rx_mbuf_alloc_failed++;
 			break;
 		}
 
@@ -587,6 +595,7 @@ struct pmd_internals {
 						ct_rx_rem_bytes_backup;
 					sze->ct_rx_cur_ptr =
 						ct_rx_cur_ptr_backup;
+					(*mbuf_failed_ptr)++;
 					goto finish;
 				}
 
@@ -630,6 +639,7 @@ struct pmd_internals {
 							ct_rx_rem_bytes_backup;
 						sze->ct_rx_cur_ptr =
 							ct_rx_cur_ptr_backup;
+						(*mbuf_failed_ptr)++;
 						goto finish;
 					}
 
@@ -1086,6 +1096,7 @@ struct pmd_internals {
 	stats->ibytes = rx_total_bytes;
 	stats->obytes = tx_total_bytes;
 	stats->oerrors = tx_err_total;
+	stats->rx_nombuf = dev->data->rx_mbuf_alloc_failed;
 
 	return 0;
 }
@@ -1290,6 +1301,7 @@ struct pmd_internals {
 		return -ENOMEM;
 	}
 
+	rxq->priv = internals;
 	rxq->sze = szedata_open(internals->sze_dev);
 	if (rxq->sze == NULL) {
 		RTE_LOG(ERR, PMD, "szedata_open() failed for rx queue id "
@@ -1346,6 +1358,7 @@ struct pmd_internals {
 		return -ENOMEM;
 	}
 
+	txq->priv = internals;
 	txq->sze = szedata_open(internals->sze_dev);
 	if (txq->sze == NULL) {
 		RTE_LOG(ERR, PMD, "szedata_open() failed for tx queue id "
@@ -1543,6 +1556,8 @@ struct pmd_internals {
 			pci_addr->domain, pci_addr->bus, pci_addr->devid,
 			pci_addr->function);
 
+	internals->dev = dev;
+
 	/* Get index of szedata2 device file and create path to device file */
 	ret = get_szedata2_index(pci_addr, &szedata2_index);
 	if (ret != 0) {
-- 
1.8.3.1

  parent reply	other threads:[~2018-04-04 13:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-04 13:42 [dpdk-dev] [PATCH 0/4] net/szedata2: fixes or improvements Matej Vido
2018-04-04 13:42 ` [dpdk-dev] [PATCH 1/4] net/szedata2: fix total stats Matej Vido
2018-04-04 13:42 ` [dpdk-dev] [PATCH 2/4] net/szedata2: use dynamically allocated queues Matej Vido
2018-04-06 13:20   ` Ferruh Yigit
2018-04-06 13:51     ` Ferruh Yigit
2018-04-04 13:42 ` Matej Vido [this message]
2018-04-04 13:42 ` [dpdk-dev] [PATCH 4/4] net/szedata2: fix format string for pci address Matej Vido
2018-04-06 13:53 ` [dpdk-dev] [PATCH 0/4] net/szedata2: fixes or improvements 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=1522849341-49049-4-git-send-email-vido@cesnet.cz \
    --to=vido@cesnet.cz \
    --cc=dev@dpdk.org \
    --cc=remes@netcope.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).