net/mlx5: use portable version of __builtin_ffsl

Message ID 1746457492-10012-1-git-send-email-andremue@linux.microsoft.com (mailing list archive)
State Awaiting Upstream
Delegated to: Raslan Darawsheh
Headers
Series net/mlx5: use portable version of __builtin_ffsl |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/github-robot: build success github build: passed
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/aws-unit-testing success Unit Testing PASS
ci/iol-unit-amd64-testing pending Testing pending
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS

Commit Message

Andre Muezerie May 5, 2025, 3:04 p.m. UTC
Builtin __builtin_ffsl is not available with MSVC therefore a
portable replacement should be used.

Function rte_ffs32 is already available in eal and should be used
instead.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 drivers/net/mlx5/mlx5_tx.c    | 4 ++--
 drivers/net/mlx5/mlx5_utils.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
  

Comments

Andre Muezerie June 3, 2025, 1:10 a.m. UTC | #1
On Mon, May 05, 2025 at 08:04:52AM -0700, Andre Muezerie wrote:
> Builtin __builtin_ffsl is not available with MSVC therefore a
> portable replacement should be used.
> 
> Function rte_ffs32 is already available in eal and should be used
> instead.
> 
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> ---
>  drivers/net/mlx5/mlx5_tx.c    | 4 ++--
>  drivers/net/mlx5/mlx5_utils.c | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_tx.c b/drivers/net/mlx5/mlx5_tx.c
> index 39afca3d64..b2522e7170 100644
> --- a/drivers/net/mlx5/mlx5_tx.c
> +++ b/drivers/net/mlx5/mlx5_tx.c
> @@ -629,8 +629,8 @@ mlx5_select_tx_function(struct rte_eth_dev *dev)
>  		}
>  		if (tmp == diff) {
>  			tmp = txoff_func[i].olx ^ txoff_func[m].olx;
> -			if (__builtin_ffsl(txoff_func[i].olx & ~tmp) <
> -			    __builtin_ffsl(txoff_func[m].olx & ~tmp)) {
> +			if (rte_ffs32(txoff_func[i].olx & ~tmp) <
> +			    rte_ffs32(txoff_func[m].olx & ~tmp)) {
>  				/* Lighter not requested offload. */
>  				m = i;
>  			}
> diff --git a/drivers/net/mlx5/mlx5_utils.c b/drivers/net/mlx5/mlx5_utils.c
> index d882af6047..645bb118fb 100644
> --- a/drivers/net/mlx5/mlx5_utils.c
> +++ b/drivers/net/mlx5/mlx5_utils.c
> @@ -84,7 +84,7 @@ mlx5_ipool_create(struct mlx5_indexed_pool_config *cfg)
>  	if (!cfg || (!cfg->malloc ^ !cfg->free) ||
>  	    (cfg->per_core_cache && cfg->release_mem_en) ||
>  	    (cfg->trunk_size && ((cfg->trunk_size & (cfg->trunk_size - 1)) ||
> -	    ((__builtin_ffs(cfg->trunk_size) + TRUNK_IDX_BITS) > 32))))
> +	    ((rte_ffs32(cfg->trunk_size) + TRUNK_IDX_BITS) > 32))))
>  		return NULL;
>  	pool = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*pool) + cfg->grow_trunk *
>  			   sizeof(pool->grow_tbl[0]), RTE_CACHE_LINE_SIZE,
> -- 
> 2.49.0.vfs.0.2

Would someone be able to review this patchset?
Thanks,

Andre Muezerie
  
Dariusz Sosnowski June 3, 2025, 3:23 p.m. UTC | #2
Hi,

On Mon, May 05, 2025 at 08:04:52AM -0700, Andre Muezerie wrote:
> Builtin __builtin_ffsl is not available with MSVC therefore a
> portable replacement should be used.
> 
> Function rte_ffs32 is already available in eal and should be used
> instead.
> 
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>

Acked-by: Dariusz Sosnowski <dsosnowski@nvidia.com>

Best regards,
Dariusz Sosnowski
  
Raslan Darawsheh June 4, 2025, 3:02 p.m. UTC | #3
Hi,


On 05/05/2025 6:04 PM, Andre Muezerie wrote:
> Builtin __builtin_ffsl is not available with MSVC therefore a
> portable replacement should be used.
> 
> Function rte_ffs32 is already available in eal and should be used
> instead.
> 
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>

Patch applied to next-net-mlx,

Kindest regards
Raslan Darawsheh
  

Patch

diff --git a/drivers/net/mlx5/mlx5_tx.c b/drivers/net/mlx5/mlx5_tx.c
index 39afca3d64..b2522e7170 100644
--- a/drivers/net/mlx5/mlx5_tx.c
+++ b/drivers/net/mlx5/mlx5_tx.c
@@ -629,8 +629,8 @@  mlx5_select_tx_function(struct rte_eth_dev *dev)
 		}
 		if (tmp == diff) {
 			tmp = txoff_func[i].olx ^ txoff_func[m].olx;
-			if (__builtin_ffsl(txoff_func[i].olx & ~tmp) <
-			    __builtin_ffsl(txoff_func[m].olx & ~tmp)) {
+			if (rte_ffs32(txoff_func[i].olx & ~tmp) <
+			    rte_ffs32(txoff_func[m].olx & ~tmp)) {
 				/* Lighter not requested offload. */
 				m = i;
 			}
diff --git a/drivers/net/mlx5/mlx5_utils.c b/drivers/net/mlx5/mlx5_utils.c
index d882af6047..645bb118fb 100644
--- a/drivers/net/mlx5/mlx5_utils.c
+++ b/drivers/net/mlx5/mlx5_utils.c
@@ -84,7 +84,7 @@  mlx5_ipool_create(struct mlx5_indexed_pool_config *cfg)
 	if (!cfg || (!cfg->malloc ^ !cfg->free) ||
 	    (cfg->per_core_cache && cfg->release_mem_en) ||
 	    (cfg->trunk_size && ((cfg->trunk_size & (cfg->trunk_size - 1)) ||
-	    ((__builtin_ffs(cfg->trunk_size) + TRUNK_IDX_BITS) > 32))))
+	    ((rte_ffs32(cfg->trunk_size) + TRUNK_IDX_BITS) > 32))))
 		return NULL;
 	pool = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*pool) + cfg->grow_trunk *
 			   sizeof(pool->grow_tbl[0]), RTE_CACHE_LINE_SIZE,