[dpdk-dev] [PATCH v6 2/2] examples/ethtool: use rte_eth_dev_get_reg_info for reg params

2016-07-08 Thread Thomas Monjalon
2016-07-04 14:24, Remy Horton:
> On 04/07/2016 12:36, Zyta Szpak wrote:
> > 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 
> 
> Acked-by: Remy Horton 

Series squashed (to avoid breaking example build) and applied, thanks



[dpdk-dev] [PATCH v6 2/2] examples/ethtool: use rte_eth_dev_get_reg_info for reg params

2016-07-04 Thread Remy Horton

On 04/07/2016 12:36, Zyta Szpak wrote:
> 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 

Acked-by: Remy Horton 


[dpdk-dev] [PATCH v6 2/2] examples/ethtool: use rte_eth_dev_get_reg_info for reg params

2016-07-04 Thread Zyta Szpak
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