From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-000f0801.pphosted.com (mx0a-000f0801.pphosted.com [67.231.144.122]) by dpdk.org (Postfix) with ESMTP id 8DC4BC72E for ; Fri, 29 Jan 2016 17:18:38 +0100 (CET) Received: from pps.filterd (m0048193.ppops.net [127.0.0.1]) by mx0a-000f0801.pphosted.com (8.15.0.59/8.15.0.59) with SMTP id u0TGE0IL011026 for ; Fri, 29 Jan 2016 08:18:37 -0800 Received: from brmwp-exmb11.corp.brocade.com ([208.47.132.227]) by mx0a-000f0801.pphosted.com with ESMTP id 20qrv02gdg-2 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Fri, 29 Jan 2016 08:18:37 -0800 Received: from EMEAWP-EXMB11.corp.brocade.com (172.29.11.85) by BRMWP-EXMB11.corp.brocade.com (172.16.59.77) with Microsoft SMTP Server (TLS) id 15.0.1104.5; Fri, 29 Jan 2016 09:18:35 -0700 Received: from BRA-GXP4P12.brocade.com (10.252.48.16) by EMEAWP-EXMB11.corp.brocade.com (172.29.11.85) with Microsoft SMTP Server (TLS) id 15.0.1104.5; Fri, 29 Jan 2016 17:18:34 +0100 From: Paul Atkins To: Date: Fri, 29 Jan 2016 16:18:13 +0000 Message-ID: <1454084293-5722-4-git-send-email-patkins@brocade.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1454084293-5722-1-git-send-email-patkins@brocade.com> References: <1454084293-5722-1-git-send-email-patkins@brocade.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.252.48.16] X-ClientProxiedBy: hq1wp-excas11.corp.brocade.com (10.70.36.102) To EMEAWP-EXMB11.corp.brocade.com (172.29.11.85) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-01-29_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1601100000 definitions=main-1601290272 Subject: [dpdk-dev] [PATCH 3/3] null: add xstats to provide the number of rx polls X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jan 2016 16:18:39 -0000 When using the null driver and passing in packets via the rx ring, it is useful to know that the driver has polled the ring. Add a count of rx polls to the xstats to provide this information. Signed-off-by: Paul Atkins --- drivers/net/null/rte_eth_null.c | 70 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c index 176f477..3feab44 100644 --- a/drivers/net/null/rte_eth_null.c +++ b/drivers/net/null/rte_eth_null.c @@ -65,6 +65,15 @@ static const char *valid_arguments[] = { struct pmd_internals; +struct eth_null_xstats { + rte_atomic64_t rx_polls; + rte_atomic64_t tx_polls; +}; + +struct eth_null_hw_stats { + uint64_t rx_polls; +}; + struct null_queue { struct pmd_internals *internals; @@ -74,6 +83,7 @@ struct null_queue { rte_atomic64_t rx_pkts; rte_atomic64_t tx_pkts; rte_atomic64_t err_pkts; + struct eth_null_xstats xstats; }; struct pmd_internals { @@ -109,6 +119,19 @@ static struct rte_eth_link pmd_link = { .link_status = 0 }; +/* store statistics names and its offset in stats structure */ +struct eth_null_xstats_name_off { + char name[RTE_ETH_XSTATS_NAME_SIZE]; + unsigned offset; +}; + +static const struct eth_null_xstats_name_off eth_null_stats_strings[] = { + {"rx_polls", offsetof(struct eth_null_xstats, rx_polls)}, +}; + +#define ETH_NULL_NB_XSTATS_PER_Q (sizeof(eth_null_stats_strings) / \ + sizeof(eth_null_stats_strings[0])) + static uint16_t eth_null_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) { @@ -175,6 +198,7 @@ eth_null_copy_rx_from_ring(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) i = rte_ring_mc_dequeue_burst(h->internals->rx_ring, (void **)bufs, nb_bufs); rte_atomic64_add(&h->rx_pkts, 1); + rte_atomic64_add(&h->xstats.rx_polls, 1); return i; } @@ -231,6 +255,7 @@ eth_null_copy_tx_to_ring(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) nb_bufs); rte_atomic64_add(&h->tx_pkts, 1); + rte_atomic64_add(&h->tx_pkts, i); return i; } @@ -410,6 +435,49 @@ eth_stats_reset(struct rte_eth_dev *dev) } } +static int +eth_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats, + unsigned n) +{ + struct pmd_internals *internal; + unsigned count = ETH_NULL_NB_XSTATS_PER_Q * dev->data->nb_rx_queues; + unsigned q, i = 0; + uint64_t val, *stats_ptr; + + if (n < count) + return count; + + internal = dev->data->dev_private; + + /* Extended stats */ + count = 0; + for (q = 0; q < ETH_NULL_NB_XSTATS_PER_Q; q++) { + for (i = 0; i < dev->data->nb_rx_queues; i++) { + stats_ptr = RTE_PTR_ADD( + &internal->rx_null_queues[q].xstats, + eth_null_stats_strings[i].offset + + q * sizeof(uint64_t)); + val = *stats_ptr; + snprintf(xstats[count].name, sizeof(xstats[count].name), + "rx_queue_%u_%s", q, + eth_null_stats_strings[count].name); + xstats[count++].value = val; + } + } + return count; +} + +static void +eth_xstats_reset(struct rte_eth_dev *dev) +{ + struct pmd_internals *internal; + unsigned i; + + internal = dev->data->dev_private; + for (i = 0; i < dev->data->nb_rx_queues; i++) + internal->rx_null_queues[i].xstats.rx_polls.cnt = 0; +} + static void eth_queue_release(void *q) { @@ -523,6 +591,8 @@ static const struct eth_dev_ops ops = { .link_update = eth_link_update, .stats_get = eth_stats_get, .stats_reset = eth_stats_reset, + .xstats_get = eth_xstats_get, + .xstats_reset = eth_xstats_reset, .reta_update = eth_rss_reta_update, .reta_query = eth_rss_reta_query, .rss_hash_update = eth_rss_hash_update, -- 1.7.10.4