From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id A37A98E71 for ; Wed, 30 Sep 2015 11:41:05 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP; 30 Sep 2015 02:41:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,611,1437462000"; d="scan'208";a="571198150" Received: from sie-lab-212-222.ir.intel.com (HELO silpixa00366884.ir.intel.com) ([10.237.212.222]) by FMSMGA003.fm.intel.com with ESMTP; 30 Sep 2015 02:41:02 -0700 From: Harry van Haaren To: dev@dpdk.org Date: Wed, 30 Sep 2015 10:40:22 +0100 Message-Id: <1443606022-13581-12-git-send-email-harry.van.haaren@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1443606022-13581-1-git-send-email-harry.van.haaren@intel.com> References: <1443606022-13581-1-git-send-email-harry.van.haaren@intel.com> Subject: [dpdk-dev] [PATCH v2 11/11] fm10k: add xstats() implementation 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: Wed, 30 Sep 2015 09:41:06 -0000 Add xstats() functions and statistic strings. Signed-off-by: Harry van Haaren --- drivers/net/fm10k/fm10k_ethdev.c | 69 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index a69c990..2d92fd3 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -68,6 +68,37 @@ fm10k_MACVLAN_remove_all(struct rte_eth_dev *dev); static void fm10k_tx_queue_release(void *queue); static void fm10k_rx_queue_release(void *queue); +struct rte_fm10k_xstats_name_off { + char name[RTE_ETH_XSTATS_NAME_SIZE]; + unsigned offset; +}; + +struct rte_fm10k_xstats_name_off rte_fm10k_hw_stats_strings[] = { + {"completion_timeout_count", offsetof(struct fm10k_hw_stats, timeout)}, + {"unsupported_requests_count", offsetof(struct fm10k_hw_stats, ur)}, + {"completer_abort_count", offsetof(struct fm10k_hw_stats, ca)}, + {"unsupported_message_count", offsetof(struct fm10k_hw_stats, um)}, + {"checksum_error_count", offsetof(struct fm10k_hw_stats, xec)}, + {"vlan_dropped", offsetof(struct fm10k_hw_stats, vlan_drop)}, + {"loopback_dropped", offsetof(struct fm10k_hw_stats, loopback_drop)}, + {"no_descriptor_dropped", offsetof(struct fm10k_hw_stats, nodesc_drop)}, +}; + +struct rte_fm10k_xstats_name_off rte_fm10k_hw_stats_q_strings[] = { + {"tx_q_bytes", offsetof(struct fm10k_hw_stats_q, tx_bytes)}, + {"tx_q_packets", offsetof(struct fm10k_hw_stats_q, tx_packets)}, + {"rx_q_bytes", offsetof(struct fm10k_hw_stats_q, rx_bytes)}, + {"rx_q_packets", offsetof(struct fm10k_hw_stats_q, rx_packets)}, + {"rx_q_dropped", offsetof(struct fm10k_hw_stats_q, rx_drops)}, +}; + +#define FM10K_NB_HW_XSTATS (sizeof(rte_fm10k_hw_stats_strings) / \ + sizeof(rte_fm10k_hw_stats_strings[0])) +#define FM10K_NB_Q_XSTATS (sizeof(rte_fm10k_hw_stats_q_strings) / \ + sizeof(rte_fm10k_hw_stats_q_strings[0])) +#define FM10K_NB_XSTATS (FM10K_NB_HW_XSTATS + FM10K_NB_Q_XSTATS * \ + FM10K_MAX_QUEUES_PF) + static void fm10k_mbx_initlock(struct fm10k_hw *hw) { @@ -867,6 +898,42 @@ fm10k_link_update(struct rte_eth_dev *dev, return 0; } +static int +fm10k_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats, + unsigned n) +{ + struct fm10k_hw_stats *hw_stats = + FM10K_DEV_PRIVATE_TO_STATS(dev->data->dev_private); + unsigned i, q, count = 0; + + if(n < FM10K_NB_XSTATS) + return FM10K_NB_XSTATS; + + /* Global stats */ + for(i = 0; i < FM10K_NB_HW_XSTATS; i++) { + snprintf(xstats[count].name, sizeof(xstats[count].name), + "%s", rte_fm10k_hw_stats_strings[count].name); + xstats[count].value = *(uint64_t *)(((char *)hw_stats) + + rte_fm10k_hw_stats_strings[count].offset); + count++; + } + + /* PF queue stats */ + for(q = 0; q < FM10K_MAX_QUEUES_PF; q++) { + for(i = 0; i < FM10K_NB_Q_XSTATS; i++) { + snprintf(xstats[count].name, sizeof(xstats[count].name), + "rx_q%u_%s", q, + rte_fm10k_hw_stats_q_strings[i].name); + xstats[count].value = + *(uint64_t *)(((char *)&hw_stats->q[q]) + + rte_fm10k_hw_stats_q_strings[i].offset); + count++; + } + } + + return FM10K_NB_XSTATS; +} + static void fm10k_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { @@ -2034,7 +2101,9 @@ static const struct eth_dev_ops fm10k_eth_dev_ops = { .allmulticast_enable = fm10k_dev_allmulticast_enable, .allmulticast_disable = fm10k_dev_allmulticast_disable, .stats_get = fm10k_stats_get, + .xstats_get = fm10k_xstats_get, .stats_reset = fm10k_stats_reset, + .xstats_reset = fm10k_stats_reset, .link_update = fm10k_link_update, .dev_infos_get = fm10k_dev_infos_get, .vlan_filter_set = fm10k_vlan_filter_set, -- 1.9.1