From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id AD36937AF for ; Thu, 30 Mar 2017 23:55:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490910950; x=1522446950; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=iWkk/KC3eecwjsIYAgZqtiNu+Kt91SdRlUOkcm3FS+c=; b=FceiVFeJWMw5Bg8/yTJcVppZbW5Ki7Y9yEYZmkfFQsylKncyN5AZDMKt ITJEzCc2sAcZBHrbHMX72Bd+fKU/Lg==; Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Mar 2017 14:55:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,248,1486454400"; d="scan'208";a="67119666" Received: from gklab-246-023.igk.intel.com (HELO Sent) ([10.217.246.23]) by orsmga002.jf.intel.com with SMTP; 30 Mar 2017 14:55:47 -0700 Received: by Sent (sSMTP sendmail emulation); Thu, 30 Mar 2017 23:51:04 +0200 From: Michal Jastrzebski To: dev@dpdk.org Cc: Jacek Piasecki , Kuba Kozak Date: Thu, 30 Mar 2017 23:50:37 +0200 Message-Id: <1490910640-244285-3-git-send-email-michalx.k.jastrzebski@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1490910640-244285-1-git-send-email-michalx.k.jastrzebski@intel.com> References: <1490910640-244285-1-git-send-email-michalx.k.jastrzebski@intel.com> Subject: [dpdk-dev] [PATCH v2 2/5] add new xstats API id support for e1000 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: Thu, 30 Mar 2017 21:55:51 -0000 Add new xstats API id support for e1000 Signed-off-by: Jacek Piasecki Signed-off-by: Kuba Kozak --- drivers/net/e1000/igb_ethdev.c | 92 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 90 insertions(+), 2 deletions(-) diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c index 71d05a9..d62cde7 100644 --- a/drivers/net/e1000/igb_ethdev.c +++ b/drivers/net/e1000/igb_ethdev.c @@ -115,9 +115,13 @@ static void eth_igb_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats); static int eth_igb_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, unsigned n); +static int eth_igb_xstats_get_by_ids(struct rte_eth_dev *dev, uint64_t *ids, + uint64_t *values, unsigned int n); static int eth_igb_xstats_get_names(struct rte_eth_dev *dev, - struct rte_eth_xstat_name *xstats_names, - unsigned limit); + struct rte_eth_xstat_name *xstats_names, unsigned int limit); +static int eth_igb_xstats_get_names_by_ids(struct rte_eth_dev *dev, + struct rte_eth_xstat_name *xstats_names, uint64_t *ids, + unsigned int limit); static void eth_igb_stats_reset(struct rte_eth_dev *dev); static void eth_igb_xstats_reset(struct rte_eth_dev *dev); static int eth_igb_fw_version_get(struct rte_eth_dev *dev, @@ -390,6 +394,8 @@ static void eth_igbvf_interrupt_handler(struct rte_intr_handle *handle, .link_update = eth_igb_link_update, .stats_get = eth_igb_stats_get, .xstats_get = eth_igb_xstats_get, + .xstats_get_by_ids = eth_igb_xstats_get_by_ids, + .xstats_get_names_by_ids = eth_igb_xstats_get_names_by_ids, .xstats_get_names = eth_igb_xstats_get_names, .stats_reset = eth_igb_stats_reset, .xstats_reset = eth_igb_xstats_reset, @@ -1846,6 +1852,42 @@ static int eth_igb_xstats_get_names(__rte_unused struct rte_eth_dev *dev, return IGB_NB_XSTATS; } +static int eth_igb_xstats_get_names_by_ids(struct rte_eth_dev *dev, + struct rte_eth_xstat_name *xstats_names, uint64_t *ids, + unsigned int limit) +{ + unsigned int i; + + if (!ids) { + + if (xstats_names == NULL) + return IGB_NB_XSTATS; + + for (i = 0; i < IGB_NB_XSTATS; i++) + snprintf(xstats_names[i].name, + sizeof(xstats_names[i].name), + "%s", rte_igb_stats_strings[i].name); + + return IGB_NB_XSTATS; + + } else { + struct rte_eth_xstat_name xstats_names_copy[IGB_NB_XSTATS]; + + eth_igb_xstats_get_names_by_ids(dev, xstats_names_copy, NULL, + IGB_NB_XSTATS); + + for (i = 0; i < limit; i++) { + if (ids[i] >= IGB_NB_XSTATS) { + printf("ERROR: id value isn't valid \n"); + return -1; + } + strcpy(xstats_names[i].name, + xstats_names_copy[ids[i]].name); + } + return limit; + } +} + static int eth_igb_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, unsigned n) @@ -1876,6 +1918,52 @@ static int eth_igb_xstats_get_names(__rte_unused struct rte_eth_dev *dev, return IGB_NB_XSTATS; } +static int +eth_igb_xstats_get_by_ids(struct rte_eth_dev *dev, uint64_t *ids, + uint64_t *values, unsigned int n) +{ + unsigned int i; + + if (!ids) { + struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct e1000_hw_stats *hw_stats = + E1000_DEV_PRIVATE_TO_STATS(dev->data->dev_private); + + if (n < IGB_NB_XSTATS) + return IGB_NB_XSTATS; + + igb_read_stats_registers(hw, hw_stats); + + /* If this is a reset xstats is NULL, and we have cleared the + * registers by reading them. + */ + if (!values) + return 0; + + /* Extended stats */ + for (i = 0; i < IGB_NB_XSTATS; i++) + values[i] = *(uint64_t *)(((char *)hw_stats) + + rte_igb_stats_strings[i].offset); + + return IGB_NB_XSTATS; + + } else { + uint64_t values_copy[IGB_NB_XSTATS]; + + eth_igb_xstats_get_by_ids(dev, NULL, values_copy, + IGB_NB_XSTATS); + + for (i = 0; i < n; i++) { + if (ids[i] >= IGB_NB_XSTATS) { + printf("ERROR: id value isn't valid \n"); + return -1; + } + values[i] = values_copy[ids[i]]; + } + return n; + } +} + static void igbvf_read_stats_registers(struct e1000_hw *hw, struct e1000_vf_stats *hw_stats) { -- 1.9.1