diff mbox series

[net-next,02/15] net/mlx5: Change parameters for PTP internal functions

Message ID 20250203213516.227902-3-tariqt@nvidia.com (mailing list archive)
State Needs ACK
Delegated to: Netdev Maintainers
Headers show
Series Support one PTP device per hardware clock | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 4 maintainers not CCed: vadim.fedorenko@linux.dev richardcochran@gmail.com linux-rdma@vger.kernel.org rrameshbabu@nvidia.com
netdev/build_clang success Errors and warnings before: 2 this patch: 2
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch warning WARNING: line length of 84 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2025-02-04--00-00 (tests: 886)

Commit Message

Tariq Toukan Feb. 3, 2025, 9:35 p.m. UTC
From: Jianbo Liu <jianbol@nvidia.com>

In later patch, the mlx5_clock will be allocated dynamically, its
address can be obtained from mlx5_core_dev struct, but mdev can't be
obtained from mlx5_clock because it can be shared by multiple
interfaces. So change the parameter for such internal functions, only
mdev is passed down from the callers.

Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
Reviewed-by: Carolina Jubran <cjubran@nvidia.com>
Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
 .../ethernet/mellanox/mlx5/core/lib/clock.c   | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

Comments

Mateusz Polchlopek Feb. 4, 2025, 8:51 a.m. UTC | #1
On 2/3/2025 10:35 PM, Tariq Toukan wrote:
> From: Jianbo Liu <jianbol@nvidia.com>
> 
> In later patch, the mlx5_clock will be allocated dynamically, its
> address can be obtained from mlx5_core_dev struct, but mdev can't be
> obtained from mlx5_clock because it can be shared by multiple
> interfaces. So change the parameter for such internal functions, only
> mdev is passed down from the callers.
> 
> Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
> Reviewed-by: Carolina Jubran <cjubran@nvidia.com>
> Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
> Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
> ---
>   .../ethernet/mellanox/mlx5/core/lib/clock.c   | 19 ++++++++-----------
>   1 file changed, 8 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
> index eaf343756026..e7e4bdba02a3 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
> @@ -878,10 +878,8 @@ static int mlx5_query_mtpps_pin_mode(struct mlx5_core_dev *mdev, u8 pin,
>   				    mtpps_size, MLX5_REG_MTPPS, 0, 0);
>   }
>   
> -static int mlx5_get_pps_pin_mode(struct mlx5_clock *clock, u8 pin)
> +static int mlx5_get_pps_pin_mode(struct mlx5_core_dev *mdev, u8 pin)
>   {
> -	struct mlx5_core_dev *mdev = container_of(clock, struct mlx5_core_dev, clock);
> -
>   	u32 out[MLX5_ST_SZ_DW(mtpps_reg)] = {};
>   	u8 mode;
>   	int err;
> @@ -900,8 +898,9 @@ static int mlx5_get_pps_pin_mode(struct mlx5_clock *clock, u8 pin)
>   	return PTP_PF_NONE;
>   }
>   
> -static void mlx5_init_pin_config(struct mlx5_clock *clock)
> +static void mlx5_init_pin_config(struct mlx5_core_dev *mdev)
>   {
> +	struct mlx5_clock *clock = &mdev->clock;
>   	int i;
>   
>   	if (!clock->ptp_info.n_pins)
> @@ -922,7 +921,7 @@ static void mlx5_init_pin_config(struct mlx5_clock *clock)
>   			 sizeof(clock->ptp_info.pin_config[i].name),
>   			 "mlx5_pps%d", i);
>   		clock->ptp_info.pin_config[i].index = i;
> -		clock->ptp_info.pin_config[i].func = mlx5_get_pps_pin_mode(clock, i);
> +		clock->ptp_info.pin_config[i].func = mlx5_get_pps_pin_mode(mdev, i);
>   		clock->ptp_info.pin_config[i].chan = 0;
>   	}
>   }
> @@ -1041,10 +1040,10 @@ static void mlx5_timecounter_init(struct mlx5_core_dev *mdev)
>   			 ktime_to_ns(ktime_get_real()));
>   }
>   
> -static void mlx5_init_overflow_period(struct mlx5_clock *clock)
> +static void mlx5_init_overflow_period(struct mlx5_core_dev *mdev)
>   {
> -	struct mlx5_core_dev *mdev = container_of(clock, struct mlx5_core_dev, clock);
>   	struct mlx5_ib_clock_info *clock_info = mdev->clock_info;
> +	struct mlx5_clock *clock = &mdev->clock;
>   	struct mlx5_timer *timer = &clock->timer;

It seems that because of the refactor the RCT rule has been violated.
I think you have to split *timer into two lines.

>   	u64 overflow_cycles;
>   	u64 frac = 0;
> @@ -1135,7 +1134,7 @@ static void mlx5_init_timer_clock(struct mlx5_core_dev *mdev)
>   
>   	mlx5_timecounter_init(mdev);
>   	mlx5_init_clock_info(mdev);
> -	mlx5_init_overflow_period(clock);
> +	mlx5_init_overflow_period(mdev);
>   
>   	if (mlx5_real_time_mode(mdev)) {
>   		struct timespec64 ts;
> @@ -1147,13 +1146,11 @@ static void mlx5_init_timer_clock(struct mlx5_core_dev *mdev)
>   
>   static void mlx5_init_pps(struct mlx5_core_dev *mdev)
>   {
> -	struct mlx5_clock *clock = &mdev->clock;
> -
>   	if (!MLX5_PPS_CAP(mdev))
>   		return;
>   
>   	mlx5_get_pps_caps(mdev);
> -	mlx5_init_pin_config(clock);
> +	mlx5_init_pin_config(mdev);
>   }
>   
>   void mlx5_init_clock(struct mlx5_core_dev *mdev)

Overall if you fix that RCT issue then feel free to add my RB tag,
thanks.
Tariq Toukan Feb. 5, 2025, 6:08 a.m. UTC | #2
On 04/02/2025 10:51, Mateusz Polchlopek wrote:
> 
> 
> On 2/3/2025 10:35 PM, Tariq Toukan wrote:
>> From: Jianbo Liu <jianbol@nvidia.com>
>>
>> In later patch, the mlx5_clock will be allocated dynamically, its
>> address can be obtained from mlx5_core_dev struct, but mdev can't be
>> obtained from mlx5_clock because it can be shared by multiple
>> interfaces. So change the parameter for such internal functions, only
>> mdev is passed down from the callers.
>>
>> Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
>> Reviewed-by: Carolina Jubran <cjubran@nvidia.com>
>> Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
>> Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
>> ---
>>   .../ethernet/mellanox/mlx5/core/lib/clock.c   | 19 ++++++++-----------
>>   1 file changed, 8 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/ 
>> drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
>> index eaf343756026..e7e4bdba02a3 100644
>> --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
>> +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
>> @@ -878,10 +878,8 @@ static int mlx5_query_mtpps_pin_mode(struct 
>> mlx5_core_dev *mdev, u8 pin,
>>                       mtpps_size, MLX5_REG_MTPPS, 0, 0);
>>   }
>> -static int mlx5_get_pps_pin_mode(struct mlx5_clock *clock, u8 pin)
>> +static int mlx5_get_pps_pin_mode(struct mlx5_core_dev *mdev, u8 pin)
>>   {
>> -    struct mlx5_core_dev *mdev = container_of(clock, struct 
>> mlx5_core_dev, clock);
>> -
>>       u32 out[MLX5_ST_SZ_DW(mtpps_reg)] = {};
>>       u8 mode;
>>       int err;
>> @@ -900,8 +898,9 @@ static int mlx5_get_pps_pin_mode(struct mlx5_clock 
>> *clock, u8 pin)
>>       return PTP_PF_NONE;
>>   }
>> -static void mlx5_init_pin_config(struct mlx5_clock *clock)
>> +static void mlx5_init_pin_config(struct mlx5_core_dev *mdev)
>>   {
>> +    struct mlx5_clock *clock = &mdev->clock;
>>       int i;
>>       if (!clock->ptp_info.n_pins)
>> @@ -922,7 +921,7 @@ static void mlx5_init_pin_config(struct mlx5_clock 
>> *clock)
>>                sizeof(clock->ptp_info.pin_config[i].name),
>>                "mlx5_pps%d", i);
>>           clock->ptp_info.pin_config[i].index = i;
>> -        clock->ptp_info.pin_config[i].func = 
>> mlx5_get_pps_pin_mode(clock, i);
>> +        clock->ptp_info.pin_config[i].func = 
>> mlx5_get_pps_pin_mode(mdev, i);
>>           clock->ptp_info.pin_config[i].chan = 0;
>>       }
>>   }
>> @@ -1041,10 +1040,10 @@ static void mlx5_timecounter_init(struct 
>> mlx5_core_dev *mdev)
>>                ktime_to_ns(ktime_get_real()));
>>   }
>> -static void mlx5_init_overflow_period(struct mlx5_clock *clock)
>> +static void mlx5_init_overflow_period(struct mlx5_core_dev *mdev)
>>   {
>> -    struct mlx5_core_dev *mdev = container_of(clock, struct 
>> mlx5_core_dev, clock);
>>       struct mlx5_ib_clock_info *clock_info = mdev->clock_info;
>> +    struct mlx5_clock *clock = &mdev->clock;
>>       struct mlx5_timer *timer = &clock->timer;
> 
> It seems that because of the refactor the RCT rule has been violated.
> I think you have to split *timer into two lines.
> 

This is an existing line of code.
Due to dependency, clock had to come before.
I wouldn't split 'timer' just for this reason. Readability is not hurt.
Let's keep it as is.

>>       u64 overflow_cycles;
>>       u64 frac = 0;
>> @@ -1135,7 +1134,7 @@ static void mlx5_init_timer_clock(struct 
>> mlx5_core_dev *mdev)
>>       mlx5_timecounter_init(mdev);
>>       mlx5_init_clock_info(mdev);
>> -    mlx5_init_overflow_period(clock);
>> +    mlx5_init_overflow_period(mdev);
>>       if (mlx5_real_time_mode(mdev)) {
>>           struct timespec64 ts;
>> @@ -1147,13 +1146,11 @@ static void mlx5_init_timer_clock(struct 
>> mlx5_core_dev *mdev)
>>   static void mlx5_init_pps(struct mlx5_core_dev *mdev)
>>   {
>> -    struct mlx5_clock *clock = &mdev->clock;
>> -
>>       if (!MLX5_PPS_CAP(mdev))
>>           return;
>>       mlx5_get_pps_caps(mdev);
>> -    mlx5_init_pin_config(clock);
>> +    mlx5_init_pin_config(mdev);
>>   }
>>   void mlx5_init_clock(struct mlx5_core_dev *mdev)
> 
> Overall if you fix that RCT issue then feel free to add my RB tag,
> thanks.
> 

Thanks for your review.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
index eaf343756026..e7e4bdba02a3 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
@@ -878,10 +878,8 @@  static int mlx5_query_mtpps_pin_mode(struct mlx5_core_dev *mdev, u8 pin,
 				    mtpps_size, MLX5_REG_MTPPS, 0, 0);
 }
 
-static int mlx5_get_pps_pin_mode(struct mlx5_clock *clock, u8 pin)
+static int mlx5_get_pps_pin_mode(struct mlx5_core_dev *mdev, u8 pin)
 {
-	struct mlx5_core_dev *mdev = container_of(clock, struct mlx5_core_dev, clock);
-
 	u32 out[MLX5_ST_SZ_DW(mtpps_reg)] = {};
 	u8 mode;
 	int err;
@@ -900,8 +898,9 @@  static int mlx5_get_pps_pin_mode(struct mlx5_clock *clock, u8 pin)
 	return PTP_PF_NONE;
 }
 
-static void mlx5_init_pin_config(struct mlx5_clock *clock)
+static void mlx5_init_pin_config(struct mlx5_core_dev *mdev)
 {
+	struct mlx5_clock *clock = &mdev->clock;
 	int i;
 
 	if (!clock->ptp_info.n_pins)
@@ -922,7 +921,7 @@  static void mlx5_init_pin_config(struct mlx5_clock *clock)
 			 sizeof(clock->ptp_info.pin_config[i].name),
 			 "mlx5_pps%d", i);
 		clock->ptp_info.pin_config[i].index = i;
-		clock->ptp_info.pin_config[i].func = mlx5_get_pps_pin_mode(clock, i);
+		clock->ptp_info.pin_config[i].func = mlx5_get_pps_pin_mode(mdev, i);
 		clock->ptp_info.pin_config[i].chan = 0;
 	}
 }
@@ -1041,10 +1040,10 @@  static void mlx5_timecounter_init(struct mlx5_core_dev *mdev)
 			 ktime_to_ns(ktime_get_real()));
 }
 
-static void mlx5_init_overflow_period(struct mlx5_clock *clock)
+static void mlx5_init_overflow_period(struct mlx5_core_dev *mdev)
 {
-	struct mlx5_core_dev *mdev = container_of(clock, struct mlx5_core_dev, clock);
 	struct mlx5_ib_clock_info *clock_info = mdev->clock_info;
+	struct mlx5_clock *clock = &mdev->clock;
 	struct mlx5_timer *timer = &clock->timer;
 	u64 overflow_cycles;
 	u64 frac = 0;
@@ -1135,7 +1134,7 @@  static void mlx5_init_timer_clock(struct mlx5_core_dev *mdev)
 
 	mlx5_timecounter_init(mdev);
 	mlx5_init_clock_info(mdev);
-	mlx5_init_overflow_period(clock);
+	mlx5_init_overflow_period(mdev);
 
 	if (mlx5_real_time_mode(mdev)) {
 		struct timespec64 ts;
@@ -1147,13 +1146,11 @@  static void mlx5_init_timer_clock(struct mlx5_core_dev *mdev)
 
 static void mlx5_init_pps(struct mlx5_core_dev *mdev)
 {
-	struct mlx5_clock *clock = &mdev->clock;
-
 	if (!MLX5_PPS_CAP(mdev))
 		return;
 
 	mlx5_get_pps_caps(mdev);
-	mlx5_init_pin_config(clock);
+	mlx5_init_pin_config(mdev);
 }
 
 void mlx5_init_clock(struct mlx5_core_dev *mdev)