DPDK patches and discussions
 help / color / mirror / Atom feed
From: zr@semihalf.com
To: remy.horton@intel.com, thomas.monjalon@6wind.com,
	wenzhuo.lu@intel.com, helin.zhang@intel.com,
	konstantin.ananyev@intel.com, jingjing.wu@intel.com
Cc: dev@dpdk.org, Zyta Szpak <zr@semihalf.com>
Subject: [dpdk-dev] [PATCH v4 2/2] examples/ethtool: use rte_eth_dev_get_reg_info for reg params
Date: Thu, 23 Jun 2016 15:26:50 +0200	[thread overview]
Message-ID: <1466688410-13826-2-git-send-email-zr@semihalf.com> (raw)
In-Reply-To: <1466688410-13826-1-git-send-email-zr@semihalf.com>

From: Zyta Szpak <zr@semihalf.com>

Version 4 of fixing the fixed register width assumption.
The app was allocating too little space for 64-bit registers
which resulted in memory corruption. This commit resolves
this by getting the number of registers and size of register
by rte_eth_dev_get_reg_info function called first time
with data=NULL.

Signed-off-by: Zyta Szpak <zr@semihalf.com>
---
 examples/ethtool/lib/rte_ethtool.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/examples/ethtool/lib/rte_ethtool.c b/examples/ethtool/lib/rte_ethtool.c
index 54391f2..a1f91d4 100644
--- a/examples/ethtool/lib/rte_ethtool.c
+++ b/examples/ethtool/lib/rte_ethtool.c
@@ -46,6 +46,7 @@ int
 rte_ethtool_get_drvinfo(uint8_t port_id, struct ethtool_drvinfo *drvinfo)
 {
 	struct rte_eth_dev_info dev_info;
+	struct rte_dev_reg_info reg_info;
 	int n;
 
 	if (drvinfo == NULL)
@@ -65,7 +66,9 @@ rte_ethtool_get_drvinfo(uint8_t port_id, struct ethtool_drvinfo *drvinfo)
 		dev_info.pci_dev->addr.domain, dev_info.pci_dev->addr.bus,
 		dev_info.pci_dev->addr.devid, dev_info.pci_dev->addr.function);
 
-	n = rte_eth_dev_get_reg_length(port_id);
+	memset(&reg_info, 0, sizeof(reg_info));
+	rte_eth_dev_get_reg_info(port_id, &reg_info);
+	n = reg_info.length;
 	if (n > 0)
 		drvinfo->regdump_len = n;
 	else
@@ -86,12 +89,16 @@ rte_ethtool_get_drvinfo(uint8_t port_id, struct ethtool_drvinfo *drvinfo)
 int
 rte_ethtool_get_regs_len(uint8_t port_id)
 {
-	int count_regs;
+	struct rte_dev_reg_info reg_info;
+	int ret;
+
+	memset(&reg_info, 0, sizeof(reg_info));
+
+	ret = rte_eth_dev_get_reg_info(port_id, &reg_info);
+	if (ret)
+		return ret;
 
-	count_regs = rte_eth_dev_get_reg_length(port_id);
-	if (count_regs > 0)
-		return count_regs * sizeof(uint32_t);
-	return count_regs;
+	return reg_info.length * reg_info.width;
 }
 
 int
-- 
1.9.1

  reply	other threads:[~2016-06-23 13:26 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-23 13:26 [dpdk-dev] [PATCH v4 1/2] ethdev: remove get_reg_length callback zr
2016-06-23 13:26 ` zr [this message]
2016-06-27 10:46   ` [dpdk-dev] [PATCH v4 2/2] examples/ethtool: use rte_eth_dev_get_reg_info for reg params Remy Horton
2016-06-27 10:46 ` [dpdk-dev] [PATCH v4 1/2] ethdev: remove get_reg_length callback Remy Horton
2016-06-28 16:05   ` Zyta Szpak
2016-06-27 15:19 ` Thomas Monjalon
2016-06-28 16:05   ` Zyta Szpak
2016-07-04  6:51 ` [dpdk-dev] [PATCH v5 " Zyta Szpak
2016-07-04  6:51   ` [dpdk-dev] [PATCH v5 2/2] examples/ethtool: use rte_eth_dev_get_reg_info for reg params Zyta Szpak
2016-07-04 10:39     ` Remy Horton
2016-07-04 10:38   ` [dpdk-dev] [PATCH v5 1/2] ethdev: remove get_reg_length callback Remy Horton
2016-07-04 11:34     ` Zyta Szpak
2016-07-04 11:36 ` [dpdk-dev] [PATCH v6 " Zyta Szpak
2016-07-04 11:36   ` [dpdk-dev] [PATCH v6 2/2] examples/ethtool: use rte_eth_dev_get_reg_info for reg params Zyta Szpak
2016-07-04 13:24     ` Remy Horton
2016-07-08 17:02       ` Thomas Monjalon
2016-07-04 13:24   ` [dpdk-dev] [PATCH v6 1/2] ethdev: remove get_reg_length callback Remy Horton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1466688410-13826-2-git-send-email-zr@semihalf.com \
    --to=zr@semihalf.com \
    --cc=dev@dpdk.org \
    --cc=helin.zhang@intel.com \
    --cc=jingjing.wu@intel.com \
    --cc=konstantin.ananyev@intel.com \
    --cc=remy.horton@intel.com \
    --cc=thomas.monjalon@6wind.com \
    --cc=wenzhuo.lu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).