DPDK patches and discussions
 help / color / mirror / Atom feed
From: zr@semihalf.com
To: remy.horton@intel.com, thomas.monjalon@6wind.com
Cc: dev@dpdk.org, Zyta Szpak <zr@semihalf.com>
Subject: [dpdk-dev] [PATCH 2/2] examples/ethtool: get reg width to allocate memory
Date: Wed, 25 May 2016 08:36:54 +0200	[thread overview]
Message-ID: <1464158214-24733-2-git-send-email-zr@semihalf.com> (raw)
In-Reply-To: <1464158214-24733-1-git-send-email-zr@semihalf.com>

From: Zyta Szpak <zr@semihalf.com>

Version 2 of fixing the fixed register width assumption.
Not every device uses 32-bit wide register. The app was allocating too
little space for 64-bit registers which resulted in memory corruption.
This commit resolves this by getting the size of register in bytes for
a specific device. If the device does not implement this function, it
fallsback to sizeof(uint32_t)

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

diff --git a/examples/ethtool/lib/rte_ethtool.c b/examples/ethtool/lib/rte_ethtool.c
index 42e05f1..59191ca 100644
--- a/examples/ethtool/lib/rte_ethtool.c
+++ b/examples/ethtool/lib/rte_ethtool.c
@@ -88,10 +88,14 @@ int
 rte_ethtool_get_regs_len(uint8_t port_id)
 {
 	int count_regs;
+	int reg_width;
 
 	count_regs = rte_eth_dev_get_reg_length(port_id);
+	reg_width = rte_eth_dev_get_reg_width(port_id);
+	if (reg_width < 0)
+		reg_width = sizeof(uint32_t);
 	if (count_regs > 0)
-		return count_regs * sizeof(uint32_t);
+		return count_regs * reg_width;
 	return count_regs;
 }
 
-- 
1.9.1

  reply	other threads:[~2016-05-25  6:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-11 10:48 [dpdk-dev] [PATCH] examples/ethtool: include case for 64-bit registers zr
2016-05-20  8:25 ` Remy Horton
2016-05-23  5:11   ` Zyta Szpak
2016-05-25  6:36 ` [dpdk-dev] [PATCH 1/2] ethdev: add callback to get register size in bytes zr
2016-05-25  6:36   ` zr [this message]
2016-05-25 13:14     ` [dpdk-dev] [PATCH 2/2] examples/ethtool: get reg width to allocate memory Remy Horton
2016-05-25 13:14   ` [dpdk-dev] [PATCH 1/2] ethdev: add callback to get register size in bytes Remy Horton
2016-05-30  9:00     ` Zyta Szpak
2016-05-27 10:28   ` Panu Matilainen
2016-05-27 14:43     ` Thomas Monjalon
2016-05-30  9:32     ` Zyta Szpak

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=1464158214-24733-2-git-send-email-zr@semihalf.com \
    --to=zr@semihalf.com \
    --cc=dev@dpdk.org \
    --cc=remy.horton@intel.com \
    --cc=thomas.monjalon@6wind.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).