From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f44.google.com (mail-lf0-f44.google.com [209.85.215.44]) by dpdk.org (Postfix) with ESMTP id 35E8347D0 for ; Mon, 4 Jul 2016 13:36:54 +0200 (CEST) Received: by mail-lf0-f44.google.com with SMTP id h129so115528419lfh.1 for ; Mon, 04 Jul 2016 04:36:54 -0700 (PDT) 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=+HAR5eaJe6Ia434nOFvxj811lrbEnFQl8g4YDDKQraE=; b=NdanXrplWIg+R2NGZrT85YO2L/Ci/RS7wi8//j36RzaTy4G7hE/tF5Sovs87YdCmWA msWnRaj9yXBPZX0xwyYGIBe2wUQo2r9ZyBVeAjXAUyywYOfFhXz4gnx/cOBBNrxo7Yr9 mmheg6oR04x9JYjmOKRDV5b6f5UxvKCwsk8DQ4ic0NkXXDKFN/9PQSOcTZmoZuvOLyTw myCxWTu6i7BuR8atMy46tgzIgDBWE1BM0pZZodAHgSa033Jyy+KXbJPekq37mAHhA8h3 v9vX2cHPOyVWraBZ6AeNk0TQ5X49+aQIVWcaInaBX7QbhC8DuMWqmelkLJYJB/CLoDDT 2GNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+HAR5eaJe6Ia434nOFvxj811lrbEnFQl8g4YDDKQraE=; b=Oj8ZYqnBvRT56E9x2bMdIubNWSQN4uKxMZlhYC57r+Apg4RAFIZ4W8z1dWDv8DKgQc kNLRW8tWQPnJ4c/YzAUfomdOkYJvCkvjdhGl+SDLvihVTHmvff0/h4sEVXN0SZ+C3e+N Th5+dsOvaPlnc2f3JGDFxDVVG7U/SfwEZFQ5a5OTlVe9wUpou3H0wXhBKbPTs6Aa/uVE tPvzk8NoFiXQQy4e9NZN+RMECzYpswQIf67OLCS7ex0Be9BlxV9Sr+CBKe4Icjqw/9j5 hLXnnnx/qd+JYo8nFfL/Bh+GrLEQCyeuc9lBXPBMzIbP31wQGLBFi7yXGhPtsSV91BBn WCrA== X-Gm-Message-State: ALyK8tK7wOqblDLKUWlye3tOt0nMwZq/mEi50XWOijzHllsmGtN24YA7vHlxh9LirRUFcg== X-Received: by 10.46.71.3 with SMTP id u3mr2885914lja.67.1467632213956; Mon, 04 Jul 2016 04:36:53 -0700 (PDT) Received: from zr.semihalf.local ([109.197.174.206]) by smtp.gmail.com with ESMTPSA id 5sm4437856lja.34.2016.07.04.04.36.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Jul 2016 04:36:53 -0700 (PDT) From: Zyta Szpak X-Google-Original-From: Zyta Szpak 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, jerin.jacob@caviumnetworks.com, rahul.lakkireddy@chelsio.com Cc: dev@dpdk.org, Zyta Szpak Date: Mon, 4 Jul 2016 13:36:47 +0200 Message-Id: <1467632207-13809-2-git-send-email-zr@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1467632207-13809-1-git-send-email-zr@semihalf.com> References: <1466688410-13826-1-git-send-email-zr@semihalf.com> <1467632207-13809-1-git-send-email-zr@semihalf.com> Subject: [dpdk-dev] [PATCH v6 2/2] examples/ethtool: use rte_eth_dev_get_reg_info for reg params 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: Mon, 04 Jul 2016 11:36:54 -0000 From: Zyta Szpak This change deals with hard-coded register width. 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 --- 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(®_info, 0, sizeof(reg_info)); + rte_eth_dev_get_reg_info(port_id, ®_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(®_info, 0, sizeof(reg_info)); + + ret = rte_eth_dev_get_reg_info(port_id, ®_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 -- 2.7.4