[dpdk-dev,2/3] net/mlx5: fix wrong htons

Message ID 92fae1c8490a9dfa782bbd62bac21076832d4cee.1479376117.git.nelio.laranjeiro@6wind.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
checkpatch/checkpatch warning coding style issues

Commit Message

Nélio Laranjeiro Nov. 17, 2016, 9:49 a.m. UTC
  Completion queue entry data uses network endian, to access them we should use
ntoh*().

Fixes: c305090bbaf8 ("net/mlx5: replace countdown with threshold for Tx completions")

CC: stable@dpdk.org
Reported-by: Liming Sun <lsun@mellanox.com>
Signed-off-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
---
 drivers/net/mlx5/mlx5_rxtx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Adrien Mazarguil Nov. 17, 2016, 10:38 a.m. UTC | #1
On Thu, Nov 17, 2016 at 10:49:55AM +0100, Nelio Laranjeiro wrote:
> Completion queue entry data uses network endian, to access them we should use
> ntoh*().
> 
> Fixes: c305090bbaf8 ("net/mlx5: replace countdown with threshold for Tx completions")
> 
> CC: stable@dpdk.org
> Reported-by: Liming Sun <lsun@mellanox.com>
> Signed-off-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
> ---
>  drivers/net/mlx5/mlx5_rxtx.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c
> index 9bd4d80..04860bb 100644
> --- a/drivers/net/mlx5/mlx5_rxtx.c
> +++ b/drivers/net/mlx5/mlx5_rxtx.c
> @@ -201,7 +201,7 @@ txq_complete(struct txq *txq)
>  	} while (1);
>  	if (unlikely(cqe == NULL))
>  		return;
> -	wqe = &(*txq->wqes)[htons(cqe->wqe_counter) &
> +	wqe = &(*txq->wqes)[ntohs(cqe->wqe_counter) &
>  			    ((1 << txq->wqe_n) - 1)].hdr;
>  	elts_tail = wqe->ctrl[3];
>  	assert(elts_tail < (1 << txq->wqe_n));
> -- 
> 2.1.4

Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
  
Ferruh Yigit Nov. 18, 2016, 9:55 a.m. UTC | #2
On 11/17/2016 10:38 AM, Adrien Mazarguil wrote:
> On Thu, Nov 17, 2016 at 10:49:55AM +0100, Nelio Laranjeiro wrote:
>> Completion queue entry data uses network endian, to access them we should use
>> ntoh*().
>>
>> Fixes: c305090bbaf8 ("net/mlx5: replace countdown with threshold for Tx completions")
>>
>> CC: stable@dpdk.org
>> Reported-by: Liming Sun <lsun@mellanox.com>
>> Signed-off-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
<...>
> Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c
index 9bd4d80..04860bb 100644
--- a/drivers/net/mlx5/mlx5_rxtx.c
+++ b/drivers/net/mlx5/mlx5_rxtx.c
@@ -201,7 +201,7 @@  txq_complete(struct txq *txq)
 	} while (1);
 	if (unlikely(cqe == NULL))
 		return;
-	wqe = &(*txq->wqes)[htons(cqe->wqe_counter) &
+	wqe = &(*txq->wqes)[ntohs(cqe->wqe_counter) &
 			    ((1 << txq->wqe_n) - 1)].hdr;
 	elts_tail = wqe->ctrl[3];
 	assert(elts_tail < (1 << txq->wqe_n));