linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net/mlx5: IPSec, fix 64-bit division correctly
@ 2017-07-10  9:37 Arnd Bergmann
  2017-07-10  9:57 ` Ilan Tayari
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Arnd Bergmann @ 2017-07-10  9:37 UTC (permalink / raw)
  To: Saeed Mahameed, Ilan Tayari
  Cc: Arnd Bergmann, Matan Barak, Leon Romanovsky, Yossi Kuperman,
	Yevgeny Kliteynik, Boris Pismenny, netdev, linux-rdma,
	linux-kernel

The new IPSec offload code introduced a build error:

drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.o: In function `mlx5e_ipsec_build_inverse_table':
ipsec_rxtx.c:(.text+0x556): undefined reference

Another patch was added on top to fix the build error, but
that introduced a new bug, as we now use the remainder of
the division rather than the result.

This makes it use the correct helper function instead.

Fixes: 5dfd87b67cd9 ("net/mlx5: IPSec, Fix 64-bit division on 32-bit builds")
Fixes: 2ac9cfe78223 ("net/mlx5e: IPSec, Add Innova IPSec offload TX data path")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.c
index 7d06c673851a..4614ddfa91eb 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.c
@@ -363,7 +363,6 @@ void mlx5e_ipsec_build_inverse_table(void)
 {
 	u16 mss_inv;
 	u32 mss;
-	u64 n;
 
 	/* Calculate 1/x inverse table for use in GSO data path.
 	 * Using this table, we provide the IPSec accelerator with the value of
@@ -373,8 +372,7 @@ void mlx5e_ipsec_build_inverse_table(void)
 	 */
 	mlx5e_ipsec_inverse_table[1] = htons(0xFFFF);
 	for (mss = 2; mss < MAX_LSO_MSS; mss++) {
-		n = 1ULL << 32;
-		mss_inv = do_div(n, mss) >> 16;
+		mss_inv = div_u64(1ULL << 32, mss) >> 16;
 		mlx5e_ipsec_inverse_table[mss] = htons(mss_inv);
 	}
 }
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: [PATCH] net/mlx5: IPSec, fix 64-bit division correctly
  2017-07-10  9:37 [PATCH] net/mlx5: IPSec, fix 64-bit division correctly Arnd Bergmann
@ 2017-07-10  9:57 ` Ilan Tayari
  2017-07-10 10:24 ` Ilan Tayari
  2017-07-10 18:34 ` David Miller
  2 siblings, 0 replies; 5+ messages in thread
From: Ilan Tayari @ 2017-07-10  9:57 UTC (permalink / raw)
  To: Arnd Bergmann, Saeed Mahameed
  Cc: Matan Barak, Leon Romanovsky, Yossi Kuperman, Yevgeny Kliteynik,
	Boris Pismenny, netdev, linux-rdma, linux-kernel

> -----Original Message-----
> From: Arnd Bergmann [mailto:arnd@arndb.de]
> Subject: [PATCH] net/mlx5: IPSec, fix 64-bit division correctly
> 
> The new IPSec offload code introduced a build error:
> 
> drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.o: In function
> `mlx5e_ipsec_build_inverse_table':
> ipsec_rxtx.c:(.text+0x556): undefined reference
> 
> Another patch was added on top to fix the build error, but
> that introduced a new bug, as we now use the remainder of
> the division rather than the result.
> 
> This makes it use the correct helper function instead.
> 
> Fixes: 5dfd87b67cd9 ("net/mlx5: IPSec, Fix 64-bit division on 32-bit
> builds")
> Fixes: 2ac9cfe78223 ("net/mlx5e: IPSec, Add Innova IPSec offload TX data
> path")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.c
> b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.c
> index 7d06c673851a..4614ddfa91eb 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.c
> @@ -363,7 +363,6 @@ void mlx5e_ipsec_build_inverse_table(void)
>  {
>  	u16 mss_inv;
>  	u32 mss;
> -	u64 n;
> 
>  	/* Calculate 1/x inverse table for use in GSO data path.
>  	 * Using this table, we provide the IPSec accelerator with the value
> of
> @@ -373,8 +372,7 @@ void mlx5e_ipsec_build_inverse_table(void)
>  	 */
>  	mlx5e_ipsec_inverse_table[1] = htons(0xFFFF);
>  	for (mss = 2; mss < MAX_LSO_MSS; mss++) {
> -		n = 1ULL << 32;
> -		mss_inv = do_div(n, mss) >> 16;
> +		mss_inv = div_u64(1ULL << 32, mss) >> 16;

Thanks Arnd, 

:o
I'm surprised... let me check this...

>  		mlx5e_ipsec_inverse_table[mss] = htons(mss_inv);
>  	}
>  }
> --
> 2.9.0

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] net/mlx5: IPSec, fix 64-bit division correctly
  2017-07-10  9:37 [PATCH] net/mlx5: IPSec, fix 64-bit division correctly Arnd Bergmann
  2017-07-10  9:57 ` Ilan Tayari
@ 2017-07-10 10:24 ` Ilan Tayari
  2017-07-10 15:45   ` Joe Perches
  2017-07-10 18:34 ` David Miller
  2 siblings, 1 reply; 5+ messages in thread
From: Ilan Tayari @ 2017-07-10 10:24 UTC (permalink / raw)
  To: Arnd Bergmann, Saeed Mahameed
  Cc: Matan Barak, Leon Romanovsky, Yossi Kuperman, Yevgeny Kliteynik,
	Boris Pismenny, netdev, linux-rdma, linux-kernel

> -----Original Message-----
> From: Arnd Bergmann [mailto:arnd@arndb.de]
> Subject: [PATCH] net/mlx5: IPSec, fix 64-bit division correctly
> 
> The new IPSec offload code introduced a build error:
> 
> drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.o: In function
> `mlx5e_ipsec_build_inverse_table':
> ipsec_rxtx.c:(.text+0x556): undefined reference
> 
> Another patch was added on top to fix the build error, but
> that introduced a new bug, as we now use the remainder of
> the division rather than the result.
> 
> This makes it use the correct helper function instead.
> 
> Fixes: 5dfd87b67cd9 ("net/mlx5: IPSec, Fix 64-bit division on 32-bit
> builds")
> Fixes: 2ac9cfe78223 ("net/mlx5e: IPSec, Add Innova IPSec offload TX data
> path")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

This is a good fix. Values are now generated correctly.
Sorry for the mixup.

Thank you Arnd!

Reviewed-by: Ilan Tayari <ilant@mellanox.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] net/mlx5: IPSec, fix 64-bit division correctly
  2017-07-10 10:24 ` Ilan Tayari
@ 2017-07-10 15:45   ` Joe Perches
  0 siblings, 0 replies; 5+ messages in thread
From: Joe Perches @ 2017-07-10 15:45 UTC (permalink / raw)
  To: Ilan Tayari, Arnd Bergmann, Saeed Mahameed
  Cc: Matan Barak, Leon Romanovsky, Yossi Kuperman, Yevgeny Kliteynik,
	Boris Pismenny, netdev, linux-rdma, linux-kernel

On Mon, 2017-07-10 at 10:24 +0000, Ilan Tayari wrote:
> > -----Original Message-----
> > From: Arnd Bergmann [mailto:arnd@arndb.de]
> > Subject: [PATCH] net/mlx5: IPSec, fix 64-bit division correctly
> > 
> > The new IPSec offload code introduced a build error:
> > 
> > drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.o: In function
> > `mlx5e_ipsec_build_inverse_table':
> > ipsec_rxtx.c:(.text+0x556): undefined reference
> > 
> > Another patch was added on top to fix the build error, but
> > that introduced a new bug, as we now use the remainder of
> > the division rather than the result.

Is it possible to return noise in mlx5e_ipsec_mss_inv ?

What clamps skb_shinfo(skb)->gso_size to MAX_LSO
(the size of inverse_table)?

#define MAX_LSO_MSS 2048
static __be16 mlx5e_ipsec_inverse_table[MAX_LSO_MSS];

static inline __be16 mlx5e_ipsec_mss_inv(struct sk_buff *skb)
{
	return mlx5e_ipsec_inverse_table[skb_shinfo(skb)->gso_size];
}

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] net/mlx5: IPSec, fix 64-bit division correctly
  2017-07-10  9:37 [PATCH] net/mlx5: IPSec, fix 64-bit division correctly Arnd Bergmann
  2017-07-10  9:57 ` Ilan Tayari
  2017-07-10 10:24 ` Ilan Tayari
@ 2017-07-10 18:34 ` David Miller
  2 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2017-07-10 18:34 UTC (permalink / raw)
  To: arnd
  Cc: saeedm, ilant, matanb, leonro, yossiku, kliteyn, borisp, netdev,
	linux-rdma, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>
Date: Mon, 10 Jul 2017 11:37:51 +0200

> The new IPSec offload code introduced a build error:
> 
> drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.o: In function `mlx5e_ipsec_build_inverse_table':
> ipsec_rxtx.c:(.text+0x556): undefined reference
> 
> Another patch was added on top to fix the build error, but
> that introduced a new bug, as we now use the remainder of
> the division rather than the result.
> 
> This makes it use the correct helper function instead.
> 
> Fixes: 5dfd87b67cd9 ("net/mlx5: IPSec, Fix 64-bit division on 32-bit builds")
> Fixes: 2ac9cfe78223 ("net/mlx5e: IPSec, Add Innova IPSec offload TX data path")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied, thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-07-10 18:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-10  9:37 [PATCH] net/mlx5: IPSec, fix 64-bit division correctly Arnd Bergmann
2017-07-10  9:57 ` Ilan Tayari
2017-07-10 10:24 ` Ilan Tayari
2017-07-10 15:45   ` Joe Perches
2017-07-10 18:34 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).