summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorZyta Szpak <zyta.szpak@semihalf.com>2016-07-04 13:36:46 +0200
committerThomas Monjalon <thomas.monjalon@6wind.com>2016-07-10 14:55:42 +0200
commit001a1c0f98f4e3ac19c26515892e2448a7547c38 (patch)
tree7aa89b76abf7115098ced53f9e92d31db9e2a8fe /examples
parenta50eb8685508a9540d15d7ea3f0e5533bed12527 (diff)
downloaddpdk-001a1c0f98f4e3ac19c26515892e2448a7547c38.zip
dpdk-001a1c0f98f4e3ac19c26515892e2448a7547c38.tar.gz
dpdk-001a1c0f98f4e3ac19c26515892e2448a7547c38.tar.xz
ethdev: get registers width
The ethtool app was allocating too little space for 64-bit registers which resulted in memory corruption. Removes hard-coded assumption that device registers are always 32 bits wide. The rte_eth_dev_get_reg_length and rte_eth_dev_get_reg_info callbacks did not provide register size to the app in any way while is needed to allocate correct number of bytes before retrieving registers using rte_eth_dev_get_reg. This commit changes rte_eth_dev_get_reg_info so that it can be used to retrieve both the number of registers and their width, and removes the now-redundant rte_eth_dev_get_reg_length. Signed-off-by: Zyta Szpak <zyta.szpak@semihalf.com> Acked-by: Remy Horton <remy.horton@intel.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/ethtool/lib/rte_ethtool.c19
1 files 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(&reg_info, 0, sizeof(reg_info));
+ rte_eth_dev_get_reg_info(port_id, &reg_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(&reg_info, 0, sizeof(reg_info));
+
+ ret = rte_eth_dev_get_reg_info(port_id, &reg_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