Message ID | 1462963714-21022-1-git-send-email-zr@semihalf.com (mailing list archive) |
---|---|
State | Superseded, archived |
Delegated to: | Thomas Monjalon |
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 10B7DC43C; Wed, 11 May 2016 12:48:38 +0200 (CEST) Received: from mail-lf0-f51.google.com (mail-lf0-f51.google.com [209.85.215.51]) by dpdk.org (Postfix) with ESMTP id C4022C43A for <dev@dpdk.org>; Wed, 11 May 2016 12:48:36 +0200 (CEST) Received: by mail-lf0-f51.google.com with SMTP id u64so45027848lff.3 for <dev@dpdk.org>; Wed, 11 May 2016 03:48:36 -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; bh=j68CQZic9LxXFSYrqus06+eFadJU9vleV3qwzBtLaa8=; b=QfZmijkiLladND+Bsl72b2D0TQT7TelalFCatP0qZjDgkILqKx2vEDuiRmfn0sX4NQ I++VizTF66qzK+AvohKfeem80cVC+nqZQ6YRuF3R+dQyZ1NN5vWVI8SEDvLj4qjihRgT YiZq0JOsglpwMC4C8s7aRnimZuvNd+3GRu0MChyyCADpjrCllH6FXmL/Y9Qk/jGkX91o vqiw9yhvkOoUshpuo98lBcM4/WPYvnZY3eElDFS5C66SozFyoxfMqz3hv3A+mdCr++Za S87AEUn3+eq2Lm2N5hecSODW/69hkPzHZC+W7ZLyESdgSUA2zlQBwBsBaq/lla9Hm05d gSMw== 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; bh=j68CQZic9LxXFSYrqus06+eFadJU9vleV3qwzBtLaa8=; b=G9G/dfMbNuF9BMfI9OZ7Y6U7mIuLb5EQGwzdxeJ0D8fvEtRoTdoyrAhkfjRtr4EHDG aSdFh2JaB7t/osBWQ5R7QtuMQKpvmopT79tG3dYubxgeuIdV4aPH5Jr6rHUeQ+68xMc7 qjKD0DLwQxdMTicVygFjmzd1p/4+dhRoz4jfrf3lyJXs2Xu7gZTVi4H2O6F+4D2lx+Gj kzkerXxCVobidyzZ7jxCPMGq7c2qeDvTNSXPFyP1OsHh6+Y+u4u0E/8scEy+xLVvgnWg B8UMJoPv7/EIhJKLvIva1sKgSrFDWF9JcIiAuVKVjnHT8p+r6iXZ2XbxFf6+/BNySaZh cwgw== X-Gm-Message-State: AOPr4FV15XQPpREV93jBp0Pnrud1yWiJIaDo1B6DZqQn5EpwY/2oevHv/VPeTI3zol1TuA== X-Received: by 10.25.136.137 with SMTP id k131mr1182625lfd.88.1462963716417; Wed, 11 May 2016 03:48:36 -0700 (PDT) Received: from zr-HP-Pro-3500-Series.semihalf.local (cardhu.semihalf.com. [213.17.239.108]) by smtp.gmail.com with ESMTPSA id i6sm1202745lbc.8.2016.05.11.03.48.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 May 2016 03:48:35 -0700 (PDT) From: zr@semihalf.com To: remy.horton@intel.com Cc: dev@dpdk.org, Zyta Szpak <zyta.szpak@semihalf.com>, Zyta Szpak <zr@semihalf.com> Date: Wed, 11 May 2016 12:48:34 +0200 Message-Id: <1462963714-21022-1-git-send-email-zr@semihalf.com> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-dev] [PATCH] examples/ethtool: include case for 64-bit registers X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK <dev.dpdk.org> List-Unsubscribe: <http://dpdk.org/ml/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://dpdk.org/ml/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <http://dpdk.org/ml/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org Sender: "dev" <dev-bounces@dpdk.org> |
Commit Message
Zyta Szpak
May 11, 2016, 10:48 a.m. UTC
From: Zyta Szpak <zyta.szpak@semihalf.com> rte_eth_dev_get_reg_length and rte_eth_dev_get_reg callbacks do not provide register size to the app in any way. Example assuming they are 32-bit wide always allocates not enough memory if the registers are 64-bit wide. It results in memory corruption. This commit is a quick fix to make enough room for 64-bit register values when this returned value is given to malloc. Signed-off-by: Zyta Szpak <zr@semihalf.com> --- examples/ethtool/lib/rte_ethtool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
Morning, On 11/05/2016 11:48, zr@semihalf.com wrote: > From: Zyta Szpak <zyta.szpak@semihalf.com> > > rte_eth_dev_get_reg_length and rte_eth_dev_get_reg callbacks > do not provide register size to the app in any way. Example assuming > they are 32-bit wide always allocates not enough memory if the > registers are 64-bit wide. It results in memory corruption. > This commit is a quick fix to make enough room for 64-bit > register values when this returned value is given to malloc. [..] This is a loose end that needs to be fixed but my feeling is that it ought to be done via querying the driver rather than overstating register bank size. My suggestion would be to add something like get_reg_wordsize to struct eth_dev_ops and then to use sizeof(uint32) as fallback for drivers that don't implement the callback. Regards, ..Rémy
Hi, sorry on my late reply I was on sick leave. Sure I can do that. This fix was the fastest possible without interfering with DPDK API. I will add the callback then. Regards, Zyta Szpak On 20.05.2016 10:25, Remy Horton wrote: > Morning, > > On 11/05/2016 11:48, zr@semihalf.com wrote: >> From: Zyta Szpak <zyta.szpak@semihalf.com> >> >> rte_eth_dev_get_reg_length and rte_eth_dev_get_reg callbacks >> do not provide register size to the app in any way. Example assuming >> they are 32-bit wide always allocates not enough memory if the >> registers are 64-bit wide. It results in memory corruption. >> This commit is a quick fix to make enough room for 64-bit >> register values when this returned value is given to malloc. > [..] > > This is a loose end that needs to be fixed but my feeling is that it > ought to be done via querying the driver rather than overstating > register bank size. My suggestion would be to add something like > get_reg_wordsize to struct eth_dev_ops and then to use sizeof(uint32) > as fallback for drivers that don't implement the callback. > > Regards, > > ..Rémy
diff --git a/examples/ethtool/lib/rte_ethtool.c b/examples/ethtool/lib/rte_ethtool.c index 42e05f1..bf0a6ac 100644 --- a/examples/ethtool/lib/rte_ethtool.c +++ b/examples/ethtool/lib/rte_ethtool.c @@ -91,7 +91,7 @@ rte_ethtool_get_regs_len(uint8_t port_id) count_regs = rte_eth_dev_get_reg_length(port_id); if (count_regs > 0) - return count_regs * sizeof(uint32_t); + return count_regs * sizeof(uint64_t); return count_regs; }