From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f54.google.com (mail-lf0-f54.google.com [209.85.215.54]) by dpdk.org (Postfix) with ESMTP id 1D72D1B22B for ; Mon, 9 Oct 2017 17:01:24 +0200 (CEST) Received: by mail-lf0-f54.google.com with SMTP id d10so25344788lfg.11 for ; Mon, 09 Oct 2017 08:01:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8HNXXMnEUXCbcuULGX/al5zzcH1lNTtEmo2KTzJVYpw=; b=FlN/DMiaDzyV+PY/VUSc0KFfBJrHA8DgI3zHt19MbFSVjxo9UBujvMraLMy+SF7Cic AKEZEGZy+KyquqG1qP1xgaI8CsxFiTVEQAV1hNpWaAw9iZfeX5+YGaAiBmxEvZe2cPyg gzxohP7TvfXvajp4guren30BCFuAg23S3i9X849RspYiFA1aGZqECzCqW4/D1eFcj7ci 11cQ66m48dRwZfLvdVIFj7Vj+wubAWjn39O3udA/FRLO6NJF6Pqp3jEmgEwloEt800dm 7v4XoLF1uJMgMW0nL35iAYBdS6R44OUVrhirI569Bn/Ir0kYaBr4u1lS1B14nR+6MMaz llfw== 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; bh=8HNXXMnEUXCbcuULGX/al5zzcH1lNTtEmo2KTzJVYpw=; b=nN34Nl+rFNoxJJw64PB7ypUbk2XtIm+unry1I70yIisv+GMW6I0Mk9CXBIkYzhjbXV cGxMpWq5eolwItLD61bCskf8hYox/o19C283D2QzYVnLA9/Kcpt/Rg4PSBmFKQzLx2VV 6m5DYgF6EhByfp0rFV3ciz2IVqwf45egago/Nq/0N0rvu/khT2uJrqsCzj5dAiUfQYV7 NEkxpP4zRiWI0wubpWp4zQXitXq3FIRY0TUclIUky6ZcL04nVe1BzT9IWe9Ka+RnGImA VVTC8PAfjDpRANY4rqPeKizfzoJmVUertgda6PPM3vISqNdD0LLHcw7t7F/AUuRubz6h Z+UQ== X-Gm-Message-State: AMCzsaWfupPFl/oNI1adjvDdPWI2CVfl+mP1Co8UHb/vuNcmcY8xKFJg huEwDAb5FKoAX2vrAJTvegysFtwMflI= X-Google-Smtp-Source: AOwi7QAUCPwgT285spdCY9AKE94dt1Fk5eUGzC6LaNkzjsEG4VF5e7zX5jT6hd8xrY/LDyZQa2xSBg== X-Received: by 10.46.9.142 with SMTP id 136mr4537211ljj.175.1507561282835; Mon, 09 Oct 2017 08:01:22 -0700 (PDT) Received: from tdu.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id z64sm1352637lfa.91.2017.10.09.08.01.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Oct 2017 08:01:21 -0700 (PDT) From: Tomasz Duszynski To: dev@dpdk.org Cc: mw@semihalf.com, dima@marvell.com, nsamsono@marvell.com, Jianbo.liu@linaro.org, Tomasz Duszynski , Jacek Siuda Date: Mon, 9 Oct 2017 17:00:42 +0200 Message-Id: <1507561244-20115-15-git-send-email-tdu@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507561244-20115-1-git-send-email-tdu@semihalf.com> References: <1507031500-11473-1-git-send-email-tdu@semihalf.com> <1507561244-20115-1-git-send-email-tdu@semihalf.com> Subject: [dpdk-dev] [PATCH v4 14/16] net/mrvl: add basic stats support 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: , X-List-Received-Date: Mon, 09 Oct 2017 15:01:24 -0000 Add support for both per queue and overall basic statistics. Signed-off-by: Jacek Siuda Signed-off-by: Tomasz Duszynski --- doc/guides/nics/features/mrvl.ini | 1 + drivers/net/mrvl/mrvl_ethdev.c | 142 +++++++++++++++++++++++++++++++++++++- 2 files changed, 142 insertions(+), 1 deletion(-) diff --git a/doc/guides/nics/features/mrvl.ini b/doc/guides/nics/features/mrvl.ini index 31b8a9c..3643b8b 100644 --- a/doc/guides/nics/features/mrvl.ini +++ b/doc/guides/nics/features/mrvl.ini @@ -18,3 +18,4 @@ CRC offload = Y L3 checksum offload = Y L4 checksum offload = Y Packet type parsing = Y +Basic stats = Y diff --git a/drivers/net/mrvl/mrvl_ethdev.c b/drivers/net/mrvl/mrvl_ethdev.c index d7a8527..46879a4 100644 --- a/drivers/net/mrvl/mrvl_ethdev.c +++ b/drivers/net/mrvl/mrvl_ethdev.c @@ -135,12 +135,15 @@ struct mrvl_rxq { int queue_id; int port_id; int cksum_enabled; + uint64_t bytes_recv; + uint64_t drop_mac; }; struct mrvl_txq { struct mrvl_priv *priv; int queue_id; int port_id; + uint64_t bytes_sent; }; /* @@ -280,6 +283,7 @@ mrvl_dev_configure(struct rte_eth_dev *dev) return ret; priv->ppio_params.outqs_params.num_outqs = dev->data->nb_tx_queues; + priv->ppio_params.maintain_stats = 1; priv->nb_rx_queues = dev->data->nb_rx_queues; if (dev->data->nb_rx_queues == 1 && @@ -835,6 +839,131 @@ mrvl_mac_addr_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr) } /** + * DPDK callback to get device statistics. + * + * @param dev + * Pointer to Ethernet device structure. + * @param stats + * Stats structure output buffer. + */ +static void +mrvl_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) +{ + struct mrvl_priv *priv = dev->data->dev_private; + struct pp2_ppio_statistics ppio_stats; + uint64_t drop_mac = 0; + unsigned int i, idx, ret; + + for (i = 0; i < dev->data->nb_rx_queues; i++) { + struct mrvl_rxq *rxq = dev->data->rx_queues[i]; + struct pp2_ppio_inq_statistics rx_stats; + + if (!rxq) + continue; + + idx = rxq->queue_id; + if (unlikely(idx >= RTE_ETHDEV_QUEUE_STAT_CNTRS)) { + RTE_LOG(ERR, PMD, + "rx queue %d stats out of range (0 - %d)\n", + idx, RTE_ETHDEV_QUEUE_STAT_CNTRS - 1); + continue; + } + + ret = pp2_ppio_inq_get_statistics(priv->ppio, + priv->rxq_map[idx].tc, + priv->rxq_map[idx].inq, + &rx_stats, 0); + if (unlikely(ret)) { + RTE_LOG(ERR, PMD, + "Failed to update rx queue %d stats\n", idx); + break; + } + + stats->q_ibytes[idx] = rxq->bytes_recv; + stats->q_ipackets[idx] = rx_stats.enq_desc - rxq->drop_mac; + stats->q_errors[idx] = rx_stats.drop_early + + rx_stats.drop_fullq + + rx_stats.drop_bm + + rxq->drop_mac; + stats->ibytes += rxq->bytes_recv; + drop_mac += rxq->drop_mac; + } + + for (i = 0; i < dev->data->nb_tx_queues; i++) { + struct mrvl_txq *txq = dev->data->tx_queues[i]; + struct pp2_ppio_outq_statistics tx_stats; + + if (!txq) + continue; + + idx = txq->queue_id; + if (unlikely(idx >= RTE_ETHDEV_QUEUE_STAT_CNTRS)) { + RTE_LOG(ERR, PMD, + "tx queue %d stats out of range (0 - %d)\n", + idx, RTE_ETHDEV_QUEUE_STAT_CNTRS - 1); + } + + ret = pp2_ppio_outq_get_statistics(priv->ppio, idx, + &tx_stats, 0); + if (unlikely(ret)) { + RTE_LOG(ERR, PMD, + "Failed to update tx queue %d stats\n", idx); + break; + } + + stats->q_opackets[idx] = tx_stats.deq_desc; + stats->q_obytes[idx] = txq->bytes_sent; + stats->obytes += txq->bytes_sent; + } + + ret = pp2_ppio_get_statistics(priv->ppio, &ppio_stats, 0); + if (unlikely(ret)) { + RTE_LOG(ERR, PMD, "Failed to update port statistics\n"); + return; + } + + stats->ipackets += ppio_stats.rx_packets - drop_mac; + stats->opackets += ppio_stats.tx_packets; + stats->imissed += ppio_stats.rx_fullq_dropped + + ppio_stats.rx_bm_dropped + + ppio_stats.rx_early_dropped + + ppio_stats.rx_fifo_dropped + + ppio_stats.rx_cls_dropped; + stats->ierrors = drop_mac; +} + +/** + * DPDK callback to clear device statistics. + * + * @param dev + * Pointer to Ethernet device structure. + */ +static void +mrvl_stats_reset(struct rte_eth_dev *dev) +{ + struct mrvl_priv *priv = dev->data->dev_private; + int i; + + for (i = 0; i < dev->data->nb_rx_queues; i++) { + struct mrvl_rxq *rxq = dev->data->rx_queues[i]; + + pp2_ppio_inq_get_statistics(priv->ppio, priv->rxq_map[i].tc, + priv->rxq_map[i].inq, NULL, 1); + rxq->bytes_recv = 0; + rxq->drop_mac = 0; + } + + for (i = 0; i < dev->data->nb_tx_queues; i++) { + struct mrvl_txq *txq = dev->data->tx_queues[i]; + + pp2_ppio_outq_get_statistics(priv->ppio, i, NULL, 1); + txq->bytes_sent = 0; + } + + pp2_ppio_get_statistics(priv->ppio, NULL, 1); +} + +/** * DPDK callback to get information about the device. * * @param dev @@ -1281,6 +1410,8 @@ static const struct eth_dev_ops mrvl_ops = { .mac_addr_add = mrvl_mac_addr_add, .mac_addr_set = mrvl_mac_addr_set, .mtu_set = mrvl_mtu_set, + .stats_get = mrvl_stats_get, + .stats_reset = mrvl_stats_reset, .dev_infos_get = mrvl_dev_infos_get, .dev_supported_ptypes_get = mrvl_dev_supported_ptypes_get, .rxq_info_get = mrvl_rxq_info_get, @@ -1464,6 +1595,7 @@ mrvl_rx_pkt_burst(void *rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) pp2_bpool_put_buff(hifs[core_id], bpool, &binf); mrvl_port_bpool_size [bpool->pp2_id][bpool->id][core_id]++; + q->drop_mac++; continue; } @@ -1482,6 +1614,7 @@ mrvl_rx_pkt_burst(void *rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) mbuf->ol_flags = mrvl_desc_to_ol_flags(&descs[i]); rx_pkts[rx_done++] = mbuf; + q->bytes_recv += mbuf->pkt_len; } if (rte_spinlock_trylock(&q->priv->lock) == 1) { @@ -1677,8 +1810,9 @@ mrvl_tx_pkt_burst(void *txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) struct mrvl_shadow_txq *sq = &shadow_txqs[q->port_id][rte_lcore_id()]; struct pp2_hif *hif = hifs[rte_lcore_id()]; struct pp2_ppio_desc descs[nb_pkts]; - int i, ret; + int i, ret, bytes_sent = 0; uint16_t num, sq_free_size; + uint64_t addr; if (unlikely(!q->priv->ppio)) return 0; @@ -1724,6 +1858,7 @@ mrvl_tx_pkt_burst(void *txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) pp2_ppio_outq_desc_set_pkt_len(&descs[i], rte_pktmbuf_pkt_len(mbuf)); + bytes_sent += rte_pktmbuf_pkt_len(mbuf); /* * in case unsupported ol_flags were passed * do not update descriptor offload information @@ -1747,10 +1882,15 @@ mrvl_tx_pkt_burst(void *txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) for (i = nb_pkts; i < num; i++) { sq->head = (MRVL_PP2_TX_SHADOWQ_SIZE + sq->head - 1) & MRVL_PP2_TX_SHADOWQ_MASK; + addr = cookie_addr_high | sq->ent[sq->head].buff.cookie; + bytes_sent -= + rte_pktmbuf_pkt_len((struct rte_mbuf *)addr); } sq->size -= num - nb_pkts; } + q->bytes_sent += bytes_sent; + return nb_pkts; } -- 2.7.4