From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f45.google.com (mail-lf0-f45.google.com [209.85.215.45]) by dpdk.org (Postfix) with ESMTP id D169E3990 for ; Mon, 4 Jul 2016 08:51:35 +0200 (CEST) Received: by mail-lf0-f45.google.com with SMTP id h129so111091498lfh.1 for ; Sun, 03 Jul 2016 23:51:35 -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=iYhqfJR3g3eU0x1+Yra/u9CSGkNoXBxI6TKp1m1QbU4=; b=aMkrpFAmYKKILmNIdTsFgd4x/ijj6vD/Aqto86zSYf4C5DPI6ia7sppOE0ikHgYKkw u0MsGVYyRGRpig5PAz9qOq2/FV/4YGLH8xDJBHWJXEr48zg134x2hYLLocBazYDeCv9W sNVX27WRZBEWh0SUCdSL0YeaFbzzLGiBcJkqfXbw+B+/ZhIbAwdeepSmWim57MCF1t+d RWPOLcbMkkflmo/J8/B4vCGRmWLs9hIhM1O4byNhuAL7QZUdEEVNhRKFGPw64p2cmKVz BRgo5vxl5VBNu2uW1X6/nJhXsFyeU93TebqJMimvVLVAD/Gg47E2ICp3Pa8ouXA+y7Er HwdA== 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=iYhqfJR3g3eU0x1+Yra/u9CSGkNoXBxI6TKp1m1QbU4=; b=Kv8d0IMog9IG1NadfczlmSj/ydq/vX1jPdrFNLC+H6NDCLbbi/n7NjJM9ivAr2DPXW VQ9A5wqarTGNtQUZ+nU0iADVq2sbIlM7d/qrzpGXD1NTOpwjDG3PEFt2qWcy/vBjm5lP 2SDk0TB5m9Hb0VW37Q+ZsPg41d4mJjRxaHMlqk66ekDW/jmg8nY6p/cLt7bMmLsUDWSX KlyBu6xgmknH3cYAf1f8zxiIGi+Sk6BuVdd9z0KPdkBiN0KQ107Hu3OhHxDlIhfVjmVD DaQ8VixrIW/l5jYhF3rVhkNO+9AHRGUKDmOQvFy4NqXGDjQ3bQCMZRGzYgLtWoWCIEqe p8wg== X-Gm-Message-State: ALyK8tJTQhxHbySOJD4nOTEfYhLfd9GIf8Shh0aXgyqtPdf6NbZ1jWvBLdkw9iKNwIdnJQ== X-Received: by 10.46.0.159 with SMTP id e31mr2262705lji.54.1467615095560; Sun, 03 Jul 2016 23:51:35 -0700 (PDT) Received: from zr.semihalf.local ([109.197.174.206]) by smtp.gmail.com with ESMTPSA id 72sm4426974ljj.2.2016.07.03.23.51.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 03 Jul 2016 23:51:35 -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 08:51:27 +0200 Message-Id: <1467615087-20510-2-git-send-email-zr@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1467615087-20510-1-git-send-email-zr@semihalf.com> References: <1466688410-13826-1-git-send-email-zr@semihalf.com> <1467615087-20510-1-git-send-email-zr@semihalf.com> Subject: [dpdk-dev] [PATCH v5 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 06:51:36 -0000 From: Zyta Szpak 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 --- 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