Skip to content

Commit 183532b

Browse files
ayalevinSaeed Mahameed
authored andcommitted
net/mlx5: Add helper to set time-stamp translator on a queue
Translation method on the time-stamp is set by the capabilities. Avoid code duplication by using a helper to set ptp_cyc2time callback on a queue. Signed-off-by: Aya Levin <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent ea88600 commit 183532b

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,7 @@ static int mlx5e_ptp_alloc_txqsq(struct mlx5e_port_ptp *c, int txq_ix,
183183
if (!MLX5_CAP_ETH(mdev, wqe_vlan_insert))
184184
set_bit(MLX5E_SQ_STATE_VLAN_NEED_L2_INLINE, &sq->state);
185185
sq->stop_room = param->stop_room;
186-
sq->ptp_cyc2time = mlx5_is_real_time_sq(mdev) ?
187-
mlx5_real_time_cyc2time :
188-
mlx5_timecounter_cyc2time;
186+
sq->ptp_cyc2time = mlx5_sq_ts_translator(mdev);
189187

190188
node = dev_to_node(mlx5_core_dma_dev(mdev));
191189

drivers/net/ethernet/mellanox/mlx5/core/en_main.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -404,9 +404,7 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c,
404404
rq->hw_mtu = MLX5E_SW2HW_MTU(params, params->sw_mtu);
405405
rq->xdpsq = &c->rq_xdpsq;
406406
rq->xsk_pool = xsk_pool;
407-
rq->ptp_cyc2time = mlx5_is_real_time_rq(mdev) ?
408-
mlx5_real_time_cyc2time :
409-
mlx5_timecounter_cyc2time;
407+
rq->ptp_cyc2time = mlx5_rq_ts_translator(mdev);
410408

411409
if (rq->xsk_pool)
412410
rq->stats = &c->priv->channel_stats[c->ix].xskrq;
@@ -1141,9 +1139,7 @@ static int mlx5e_alloc_txqsq(struct mlx5e_channel *c,
11411139
if (param->is_mpw)
11421140
set_bit(MLX5E_SQ_STATE_MPWQE, &sq->state);
11431141
sq->stop_room = param->stop_room;
1144-
sq->ptp_cyc2time = mlx5_is_real_time_sq(mdev) ?
1145-
mlx5_real_time_cyc2time :
1146-
mlx5_timecounter_cyc2time;
1142+
sq->ptp_cyc2time = mlx5_sq_ts_translator(mdev);
11471143

11481144
param->wq.db_numa_node = cpu_to_node(c->cpu);
11491145
err = mlx5_wq_cyc_create(mdev, &param->wq, sqc_wq, wq, &sq->wq_ctrl);

drivers/net/ethernet/mellanox/mlx5/core/lib/clock.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,15 @@ static inline ktime_t mlx5_real_time_cyc2time(struct mlx5_clock *clock,
105105
}
106106
#endif
107107

108+
static inline cqe_ts_to_ns mlx5_rq_ts_translator(struct mlx5_core_dev *mdev)
109+
{
110+
return mlx5_is_real_time_rq(mdev) ? mlx5_real_time_cyc2time :
111+
mlx5_timecounter_cyc2time;
112+
}
113+
114+
static inline cqe_ts_to_ns mlx5_sq_ts_translator(struct mlx5_core_dev *mdev)
115+
{
116+
return mlx5_is_real_time_sq(mdev) ? mlx5_real_time_cyc2time :
117+
mlx5_timecounter_cyc2time;
118+
}
108119
#endif

0 commit comments

Comments
 (0)