vdpa/mlx5: fix PCI address comparison

Message ID 1588576329-15792-1-git-send-email-matan@mellanox.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers
Series vdpa/mlx5: fix PCI address comparison |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-nxp-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/travis-robot warning Travis build: failed
ci/Intel-compilation fail Compilation issues
ci/iol-testing success Testing PASS

Commit Message

Matan Azrad May 4, 2020, 7:12 a.m. UTC
  A regular memcmp function was used to compare between two objects of
type `struct rte_pci_addr`.

Due to the alignment rules of compiler structure builders, some memory
is not initiated in the structure even though all the fields were
initiated.

Therefore, the comparison may fail even though the PCI addresses are
identical and to cause false failure in probe.

Use the dedicated API to compare 2 PCI addresses.

Fixes: 75dd0ae91765 ("vdpa/mlx5: disable RoCE")
Cc: stable@dpdk.org

Signed-off-by: Matan Azrad <matan@mellanox.com>
Tested-by: Noa Ezra <noae@mellanox.com>
---
 drivers/vdpa/mlx5/mlx5_vdpa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Maxime Coquelin May 4, 2020, 9:15 a.m. UTC | #1
On 5/4/20 9:12 AM, Matan Azrad wrote:
> A regular memcmp function was used to compare between two objects of
> type `struct rte_pci_addr`.
> 
> Due to the alignment rules of compiler structure builders, some memory
> is not initiated in the structure even though all the fields were
> initiated.
> 
> Therefore, the comparison may fail even though the PCI addresses are
> identical and to cause false failure in probe.
> 
> Use the dedicated API to compare 2 PCI addresses.
> 
> Fixes: 75dd0ae91765 ("vdpa/mlx5: disable RoCE")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Matan Azrad <matan@mellanox.com>
> Tested-by: Noa Ezra <noae@mellanox.com>
> ---
>  drivers/vdpa/mlx5/mlx5_vdpa.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime
  
Maxime Coquelin May 4, 2020, 10:05 a.m. UTC | #2
On 5/4/20 9:12 AM, Matan Azrad wrote:
> A regular memcmp function was used to compare between two objects of
> type `struct rte_pci_addr`.
> 
> Due to the alignment rules of compiler structure builders, some memory
> is not initiated in the structure even though all the fields were
> initiated.
> 
> Therefore, the comparison may fail even though the PCI addresses are
> identical and to cause false failure in probe.
> 
> Use the dedicated API to compare 2 PCI addresses.
> 
> Fixes: 75dd0ae91765 ("vdpa/mlx5: disable RoCE")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Matan Azrad <matan@mellanox.com>
> Tested-by: Noa Ezra <noae@mellanox.com>
> ---
>  drivers/vdpa/mlx5/mlx5_vdpa.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied to dpdk-next-virtio/master.

Thanks,
Maxime
  

Patch

diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c
index 9f7353d..1113d6c 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa.c
@@ -305,7 +305,7 @@ 
 		DRV_LOG(DEBUG, "Checking device \"%s\"..", ibv_list[n]->name);
 		if (mlx5_dev_to_pci_addr(ibv_list[n]->ibdev_path, &pci_addr))
 			continue;
-		if (memcmp(addr, &pci_addr, sizeof(pci_addr)))
+		if (rte_pci_addr_cmp(addr, &pci_addr))
 			continue;
 		ibv_match = ibv_list[n];
 		break;