From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com [209.85.217.172]) by dpdk.org (Postfix) with ESMTP id 124C468F8 for ; Mon, 30 May 2016 11:40:17 +0200 (CEST) Received: by mail-lb0-f172.google.com with SMTP id sh2so43850813lbb.1 for ; Mon, 30 May 2016 02:40:17 -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=vMoRI3K4mbKoozuvOJEjVBDqSwnH1A2wezCPvp9FJog=; b=WTDflvcnn2qZuAHe/cGoz0u/mQiy6dzkL7ctz9R1qNPV3WqzjCT8Zwt71Phbn8Ahdi C6zN0AxMA0vMxmVvzirbuLnRibbbFGAADGeAzySZtXYBuFG1Ci5a0dbC+mxPv3W/Ggdh 9o+yC0vQaG2RAHPqJjETNSKYi/oBaXqVj1tnBWMWThQMSuuJwrZh5EeA4auT+16JF7Ny IzTNbV5PjEouHFtC04kSz46pZOpnbmV7VfsKoKh+SDCRgfGHM0y4TN7U9u+9JsFAI9tb LFtE5uELg3XhlNNsF+3fb/lZ4Iw9CLOg7yj6jhKpLrvvcF49l/ZaG+NlBPGbZ5xSpMnj shbA== 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=vMoRI3K4mbKoozuvOJEjVBDqSwnH1A2wezCPvp9FJog=; b=LR/gULng8aRwY3i6aiznkpQBYwl+2aT9QRWHEj/T7VANWbqhdGkSdVyUZB8YyQXBH3 2Dj8KgU2v2JEGHtZvAyoOSGlvT/s/9QVMAkCE82VE0emRADvHMAggM+WOoVw3daFCxdw MxdHygv+xoNaWl0an8IyJOTyytZkwsAvgleSrJoe5icZ/j2yZAg3Rz98A6VyGUCY5i+M k8S+GWWiyYr9q4vnBkc5oeP3R5Zf4ATr+cLYniM0eFj+mYjDuzvM3DMURxmTS7pUsC8U kNcIgbOgQ42PtIDn7tRV3/nQGmwlWqm3MAdlGDGENOsCClMfuoK3cJMycjkoP7xWKawO tC0w== X-Gm-Message-State: ALyK8tJ+vSE9l4J9Kf4wnVfAj5gxhjQWJpgNWgofHZ/IkFh8FU5SnfZ8SIKj6dugDyuCag== X-Received: by 10.112.169.8 with SMTP id aa8mr7956699lbc.110.1464601216722; Mon, 30 May 2016 02:40:16 -0700 (PDT) Received: from zr-HP-Pro-3500-Series.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id 4sm2171401ljj.2.2016.05.30.02.40.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 30 May 2016 02:40:16 -0700 (PDT) From: zr@semihalf.com To: remy.horton@intel.com, thomas.monjalon@6wind.com Cc: dev@dpdk.org, Zyta Szpak Date: Mon, 30 May 2016 11:40:10 +0200 Message-Id: <1464601210-7372-2-git-send-email-zr@semihalf.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1464601210-7372-1-git-send-email-zr@semihalf.com> References: <1464601210-7372-1-git-send-email-zr@semihalf.com> Subject: [dpdk-dev] [PATCH v2 2/2] examples/ethtool: get reg width to allocate memory 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, 30 May 2016 09:40:17 -0000 From: Zyta Szpak 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 --- 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