From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f66.google.com (mail-lf0-f66.google.com [209.85.215.66]) by dpdk.org (Postfix) with ESMTP id C0C7C1B29C for ; Wed, 21 Feb 2018 15:14:40 +0100 (CET) Received: by mail-lf0-f66.google.com with SMTP id l191so2567535lfe.1 for ; Wed, 21 Feb 2018 06:14:40 -0800 (PST) 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=Rt63bdRf7rQ/fAfWMqWhigEXhloKZsDAIS3x5Yy1edA=; b=zIFSk7At7Yqm7DLqU2ulEnuXGM/mIjyZrAEIbZfC4H1dhIrZWfkntxX1T9oDgk/JQC U3MQmzcRDVFkOTba+ds88ucqrhlEDCJsyXA4C1LLheAZmo3WmtTOqsSkADrZR283aunL FRLlTsoH8eUIgxkAtdoEfxT6llCsBeMVfkO9gVx/YUR6xVYCwlOF1ypX5SbK+lJQNU/Z w/QkyeQ6YmcMIUhheIkgFv+UW2k0dWjF21iozAvaKZdBdVVmd86g6QSo/5Av/2Tvyf8F ioqXgzoCrdfFtWJ6tuSb+hTyTq/RPHEOfX5kHbUwMHlZBj+9JoaMGRYqMd5Oz5MBQpE+ PsIA== 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=Rt63bdRf7rQ/fAfWMqWhigEXhloKZsDAIS3x5Yy1edA=; b=BOvZogRFgLM+xlv/3/OMHv5Hic0HkDjTPHqGcCvaGcgH/y1cPhXFMnEIKxjsKhIbRR /7Og5hCVnJ+LXTJcnBdBrZZvlEKsvrBUHJfPFV5tCXuc5bJziEOhr00+y8KbPmCQkySg hfsFccUy+Qlq6qt7YcR9tBlqtAE3J4sTWAICH1LzfEdgreIgcU6wJu1NHVAHmhhoG/2t Wt/GM/3Xw3A21Ynuuiu4uSUggod6w3wKuM8w8BNqcvBzi0bs8IVYztyLfQl1zkVwRfNi jKl/qJzaBBiHyqoI80X/g3f4wRmy6azFoH+/q0sk2YRlAhUAOTDvnA4XK2PsUC4LQDvo x95A== X-Gm-Message-State: APf1xPDe03ro2L8jY5IZ+pA8zs6ZdbF3ulgQIRUwVHmQof5i9G3iuh7z bdWK9SRndNbdw8lYkWXjIyY4TnsYO0I= X-Google-Smtp-Source: AH8x226xxm+gk7UP5T4Z3XkqA2H32vXl8kBMoDuPkJdAiZL6kBs4K2f1/aU3wb6NVmsysJ9nGENsFw== X-Received: by 10.25.193.23 with SMTP id r23mr2320070lff.45.1519222478834; Wed, 21 Feb 2018 06:14:38 -0800 (PST) Received: from sh.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id e27sm5038177lff.89.2018.02.21.06.14.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Feb 2018 06:14:38 -0800 (PST) From: Tomasz Duszynski To: dev@dpdk.org Cc: mw@semihalf.com, dima@marvell.com, nsamsono@marvell.com, jck@semihalf.com, Tomasz Duszynski Date: Wed, 21 Feb 2018 15:14:18 +0100 Message-Id: <1519222460-14605-7-git-send-email-tdu@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519222460-14605-1-git-send-email-tdu@semihalf.com> References: <1519222460-14605-1-git-send-email-tdu@semihalf.com> Subject: [dpdk-dev] [PATCH 6/8] net/mrvl: add extended statistics 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: Wed, 21 Feb 2018 14:14:41 -0000 Add extended statistics implementation. Signed-off-by: Natalie Samsonov Signed-off-by: Tomasz Duszynski --- doc/guides/nics/features/mrvl.ini | 1 + doc/guides/nics/mrvl.rst | 1 + drivers/net/mrvl/mrvl_ethdev.c | 205 +++++++++++++++++++++++++++++++++++++- 3 files changed, 206 insertions(+), 1 deletion(-) diff --git a/doc/guides/nics/features/mrvl.ini b/doc/guides/nics/features/mrvl.ini index 00d9621..120fd4d 100644 --- a/doc/guides/nics/features/mrvl.ini +++ b/doc/guides/nics/features/mrvl.ini @@ -19,5 +19,6 @@ L3 checksum offload = Y L4 checksum offload = Y Packet type parsing = Y Basic stats = Y +Extended stats = Y ARMv8 = Y Usage doc = Y diff --git a/doc/guides/nics/mrvl.rst b/doc/guides/nics/mrvl.rst index 9230d5e..7678265 100644 --- a/doc/guides/nics/mrvl.rst +++ b/doc/guides/nics/mrvl.rst @@ -70,6 +70,7 @@ Features of the MRVL PMD are: - L4 checksum offload - Packet type parsing - Basic stats +- Extended stats - QoS diff --git a/drivers/net/mrvl/mrvl_ethdev.c b/drivers/net/mrvl/mrvl_ethdev.c index 2536ee5..bccd2d0 100644 --- a/drivers/net/mrvl/mrvl_ethdev.c +++ b/drivers/net/mrvl/mrvl_ethdev.c @@ -173,6 +173,32 @@ static inline void mrvl_free_sent_buffers(struct pp2_ppio *ppio, struct pp2_hif *hif, unsigned int core_id, struct mrvl_shadow_txq *sq, int qid, int force); +#define MRVL_XSTATS_TBL_ENTRY(name) { \ + #name, offsetof(struct pp2_ppio_statistics, name), \ + sizeof(((struct pp2_ppio_statistics *)0)->name) \ +} + +/* Table with xstats data */ +static struct { + const char *name; + unsigned int offset; + unsigned int size; +} mrvl_xstats_tbl[] = { + MRVL_XSTATS_TBL_ENTRY(rx_bytes), + MRVL_XSTATS_TBL_ENTRY(rx_packets), + MRVL_XSTATS_TBL_ENTRY(rx_unicast_packets), + MRVL_XSTATS_TBL_ENTRY(rx_errors), + MRVL_XSTATS_TBL_ENTRY(rx_fullq_dropped), + MRVL_XSTATS_TBL_ENTRY(rx_bm_dropped), + MRVL_XSTATS_TBL_ENTRY(rx_early_dropped), + MRVL_XSTATS_TBL_ENTRY(rx_fifo_dropped), + MRVL_XSTATS_TBL_ENTRY(rx_cls_dropped), + MRVL_XSTATS_TBL_ENTRY(tx_bytes), + MRVL_XSTATS_TBL_ENTRY(tx_packets), + MRVL_XSTATS_TBL_ENTRY(tx_unicast_packets), + MRVL_XSTATS_TBL_ENTRY(tx_errors) +}; + static inline int mrvl_get_bpool_size(int pp2_id, int pool_id) { @@ -1138,6 +1164,90 @@ mrvl_stats_reset(struct rte_eth_dev *dev) } /** + * DPDK callback to get extended statistics. + * + * @param dev + * Pointer to Ethernet device structure. + * @param stats + * Pointer to xstats table. + * @param n + * Number of entries in xstats table. + * @return + * Negative value on error, number of read xstats otherwise. + */ +static int +mrvl_xstats_get(struct rte_eth_dev *dev, + struct rte_eth_xstat *stats, unsigned int n) +{ + struct mrvl_priv *priv = dev->data->dev_private; + struct pp2_ppio_statistics ppio_stats; + unsigned int i; + + if (!stats) + return 0; + + pp2_ppio_get_statistics(priv->ppio, &ppio_stats, 0); + for (i = 0; i < n && i < RTE_DIM(mrvl_xstats_tbl); i++) { + uint64_t val; + + if (mrvl_xstats_tbl[i].size == sizeof(uint32_t)) + val = *(uint32_t *)((uint8_t *)&ppio_stats + + mrvl_xstats_tbl[i].offset); + else if (mrvl_xstats_tbl[i].size == sizeof(uint64_t)) + val = *(uint64_t *)((uint8_t *)&ppio_stats + + mrvl_xstats_tbl[i].offset); + else + return -EINVAL; + + stats[i].id = i; + stats[i].value = val; + } + + return n; +} + +/** + * DPDK callback to reset extended statistics. + * + * @param dev + * Pointer to Ethernet device structure. + */ +static void +mrvl_xstats_reset(struct rte_eth_dev *dev) +{ + mrvl_stats_reset(dev); +} + +/** + * DPDK callback to get extended statistics names. + * + * @param dev (unused) + * Pointer to Ethernet device structure. + * @param xstats_names + * Pointer to xstats names table. + * @param size + * Size of the xstats names table. + * @return + * Number of read names. + */ +static int +mrvl_xstats_get_names(struct rte_eth_dev *dev __rte_unused, + struct rte_eth_xstat_name *xstats_names, + unsigned int size) +{ + unsigned int i; + + if (!xstats_names) + return RTE_DIM(mrvl_xstats_tbl); + + for (i = 0; i < size && i < RTE_DIM(mrvl_xstats_tbl); i++) + snprintf(xstats_names[i].name, RTE_ETH_XSTATS_NAME_SIZE, "%s", + mrvl_xstats_tbl[i].name); + + return size; +} + +/** * DPDK callback to get information about the device. * * @param dev @@ -1702,6 +1812,94 @@ mrvl_eth_filter_ctrl(struct rte_eth_dev *dev __rte_unused, } } +/** + * DPDK callback to get xstats by id. + * + * @param dev + * Pointer to the device structure. + * @param ids + * Pointer to the ids table. + * @param values + * Pointer to the values table. + * @param n + * Values table size. + * @returns + * Number of read values, negative value otherwise. + */ +static int +mrvl_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, + uint64_t *values, unsigned int n) +{ + unsigned int i, num = RTE_DIM(mrvl_xstats_tbl); + uint64_t vals[n]; + int ret; + + if (!ids) { + struct rte_eth_xstat xstats[num]; + int j; + + ret = mrvl_xstats_get(dev, xstats, num); + for (j = 0; j < ret; i++) + values[j] = xstats[j].value; + + return ret; + } + + ret = mrvl_xstats_get_by_id(dev, NULL, vals, n); + if (ret < 0) + return ret; + + for (i = 0; i < n; i++) { + if (ids[i] >= num) { + RTE_LOG(ERR, PMD, "id value is not valid\n"); + return -1; + } + + values[i] = vals[ids[i]]; + } + + return n; +} + +/** + * DPDK callback to get xstats names by ids. + * + * @param dev + * Pointer to the device structure. + * @param xstats_names + * Pointer to table with xstats names. + * @param ids + * Pointer to table with ids. + * @param size + * Xstats names table size. + * @returns + * Number of names read, negative value otherwise. + */ +static int +mrvl_xstats_get_names_by_id(struct rte_eth_dev *dev, + struct rte_eth_xstat_name *xstats_names, + const uint64_t *ids, unsigned int size) +{ + unsigned int i, num = RTE_DIM(mrvl_xstats_tbl); + struct rte_eth_xstat_name names[num]; + + if (!ids) + return mrvl_xstats_get_names(dev, xstats_names, size); + + mrvl_xstats_get_names(dev, names, size); + for (i = 0; i < size; i++) { + if (ids[i] >= num) { + RTE_LOG(ERR, PMD, "id value is not valid"); + return -1; + } + + snprintf(xstats_names[i].name, RTE_ETH_XSTATS_NAME_SIZE, + "%s", names[ids[i]].name); + } + + return size; +} + static const struct eth_dev_ops mrvl_ops = { .dev_configure = mrvl_dev_configure, .dev_start = mrvl_dev_start, @@ -1720,6 +1918,9 @@ static const struct eth_dev_ops mrvl_ops = { .mtu_set = mrvl_mtu_set, .stats_get = mrvl_stats_get, .stats_reset = mrvl_stats_reset, + .xstats_get = mrvl_xstats_get, + .xstats_reset = mrvl_xstats_reset, + .xstats_get_names = mrvl_xstats_get_names, .dev_infos_get = mrvl_dev_infos_get, .dev_supported_ptypes_get = mrvl_dev_supported_ptypes_get, .rxq_info_get = mrvl_rxq_info_get, @@ -1731,7 +1932,9 @@ static const struct eth_dev_ops mrvl_ops = { .tx_queue_release = mrvl_tx_queue_release, .rss_hash_update = mrvl_rss_hash_update, .rss_hash_conf_get = mrvl_rss_hash_conf_get, - .filter_ctrl = mrvl_eth_filter_ctrl + .filter_ctrl = mrvl_eth_filter_ctrl, + .xstats_get_by_id = mrvl_xstats_get_by_id, + .xstats_get_names_by_id = mrvl_xstats_get_names_by_id }; /** -- 2.7.4