Skip to content

Commit 145e563

Browse files
Eran Ben ElishaSaeed Mahameed
authored andcommitted
net/mlx5e: Add TX PTP port object support
Add TX PTP port object support for better TX timestamping accuracy. Currently, driver supports CQE based TX port timestamp. Device also offers TX port timestamp, which has less jitter and better reflects the actual time of a packet's transmit. Define new driver layout called ptpsq, on which driver will create SQs that will support TX port timestamp for their transmitted packets. Driver to identify PTP TX skbs and steer them to these dedicated SQs as part of the select queue ndo. Driver to hold ptpsq per TC and report them at netif_set_real_num_tx_queues(). Add support for all needed functionality in order to xmit and poll completions received via ptpsq. Add ptpsq to the TX reporter recover, diagnose and dump methods. Creation of ptpsqs is disabled by default, and can be enabled via tx_port_ts private flag. This patch steer all timestamp related packets to a ptpsq, but it does not open the port timestamp support for it. The support will be added in the following patch. Signed-off-by: Eran Ben Elisha <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent cecaa6a commit 145e563

File tree

11 files changed

+831
-60
lines changed

11 files changed

+831
-60
lines changed

drivers/net/ethernet/mellanox/mlx5/core/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ mlx5_core-$(CONFIG_MLX5_CORE_EN) += en_main.o en_common.o en_fs.o en_ethtool.o \
2525
en_tx.o en_rx.o en_dim.o en_txrx.o en/xdp.o en_stats.o \
2626
en_selftest.o en/port.o en/monitor_stats.o en/health.o \
2727
en/reporter_tx.o en/reporter_rx.o en/params.o en/xsk/pool.o \
28-
en/xsk/setup.o en/xsk/rx.o en/xsk/tx.o en/devlink.o
28+
en/xsk/setup.o en/xsk/rx.o en/xsk/tx.o en/devlink.o en/ptp.o
2929

3030
#
3131
# Netdev extra

drivers/net/ethernet/mellanox/mlx5/core/en.h

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ enum mlx5e_priv_flag {
227227
MLX5E_PFLAG_RX_NO_CSUM_COMPLETE,
228228
MLX5E_PFLAG_XDP_TX_MPWQE,
229229
MLX5E_PFLAG_SKB_TX_MPWQE,
230+
MLX5E_PFLAG_TX_PORT_TS,
230231
MLX5E_NUM_PFLAGS, /* Keep last */
231232
};
232233

@@ -338,6 +339,8 @@ struct mlx5e_skb_fifo {
338339
u16 mask;
339340
};
340341

342+
struct mlx5e_ptpsq;
343+
341344
struct mlx5e_txqsq {
342345
/* data path */
343346

@@ -385,6 +388,7 @@ struct mlx5e_txqsq {
385388
int txq_ix;
386389
u32 rate_limit;
387390
struct work_struct recover_work;
391+
struct mlx5e_ptpsq *ptpsq;
388392
} ____cacheline_aligned_in_smp;
389393

390394
struct mlx5e_dma_info {
@@ -692,8 +696,11 @@ struct mlx5e_channel {
692696
int cpu;
693697
};
694698

699+
struct mlx5e_port_ptp;
700+
695701
struct mlx5e_channels {
696702
struct mlx5e_channel **c;
703+
struct mlx5e_port_ptp *port_ptp;
697704
unsigned int num;
698705
struct mlx5e_params params;
699706
};
@@ -708,6 +715,11 @@ struct mlx5e_channel_stats {
708715
struct mlx5e_xdpsq_stats xsksq;
709716
} ____cacheline_aligned_in_smp;
710717

718+
struct mlx5e_port_ptp_stats {
719+
struct mlx5e_ch_stats ch;
720+
struct mlx5e_sq_stats sq[MLX5E_MAX_NUM_TC];
721+
} ____cacheline_aligned_in_smp;
722+
711723
enum {
712724
MLX5E_STATE_OPENED,
713725
MLX5E_STATE_DESTROYING,
@@ -777,8 +789,10 @@ struct mlx5e_scratchpad {
777789

778790
struct mlx5e_priv {
779791
/* priv data path fields - start */
780-
struct mlx5e_txqsq *txq2sq[MLX5E_MAX_NUM_CHANNELS * MLX5E_MAX_NUM_TC];
792+
/* +1 for port ptp ts */
793+
struct mlx5e_txqsq *txq2sq[(MLX5E_MAX_NUM_CHANNELS + 1) * MLX5E_MAX_NUM_TC];
781794
int channel_tc2realtxq[MLX5E_MAX_NUM_CHANNELS][MLX5E_MAX_NUM_TC];
795+
int port_ptp_tc2realtxq[MLX5E_MAX_NUM_TC];
782796
#ifdef CONFIG_MLX5_CORE_EN_DCB
783797
struct mlx5e_dcbx_dp dcbx_dp;
784798
#endif
@@ -813,12 +827,15 @@ struct mlx5e_priv {
813827
struct net_device *netdev;
814828
struct mlx5e_stats stats;
815829
struct mlx5e_channel_stats channel_stats[MLX5E_MAX_NUM_CHANNELS];
830+
struct mlx5e_port_ptp_stats port_ptp_stats;
816831
u16 max_nch;
817832
u8 max_opened_tc;
833+
bool port_ptp_opened;
818834
struct hwtstamp_config tstamp;
819835
u16 q_counter;
820836
u16 drop_rq_q_counter;
821837
struct notifier_block events_nb;
838+
int num_tc_x_num_ch;
822839

823840
struct udp_tunnel_nic_info nic_info;
824841
#ifdef CONFIG_MLX5_CORE_EN_DCB
@@ -993,7 +1010,17 @@ void mlx5e_deactivate_icosq(struct mlx5e_icosq *icosq);
9931010
int mlx5e_modify_sq(struct mlx5_core_dev *mdev, u32 sqn,
9941011
struct mlx5e_modify_sq_param *p);
9951012
void mlx5e_activate_txqsq(struct mlx5e_txqsq *sq);
1013+
void mlx5e_deactivate_txqsq(struct mlx5e_txqsq *sq);
1014+
void mlx5e_free_txqsq(struct mlx5e_txqsq *sq);
9961015
void mlx5e_tx_disable_queue(struct netdev_queue *txq);
1016+
int mlx5e_alloc_txqsq_db(struct mlx5e_txqsq *sq, int numa);
1017+
void mlx5e_free_txqsq_db(struct mlx5e_txqsq *sq);
1018+
struct mlx5e_create_sq_param;
1019+
int mlx5e_create_sq_rdy(struct mlx5_core_dev *mdev,
1020+
struct mlx5e_sq_param *param,
1021+
struct mlx5e_create_sq_param *csp,
1022+
u32 *sqn);
1023+
void mlx5e_tx_err_cqe_work(struct work_struct *recover_work);
9971024

9981025
static inline bool mlx5_tx_swp_supported(struct mlx5_core_dev *mdev)
9991026
{

drivers/net/ethernet/mellanox/mlx5/core/en/params.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ struct mlx5e_channel_param {
4141
struct mlx5e_sq_param async_icosq;
4242
};
4343

44+
struct mlx5e_create_sq_param {
45+
struct mlx5_wq_ctrl *wq_ctrl;
46+
u32 cqn;
47+
u32 tisn;
48+
u8 tis_lst_sz;
49+
u8 min_inline_mode;
50+
};
51+
4452
static inline bool mlx5e_qid_get_ch_if_in_group(struct mlx5e_params *params,
4553
u16 qid,
4654
enum mlx5e_rq_group group,

0 commit comments

Comments
 (0)