Skip to content

Commit a8d5dd1

Browse files
committed
Merge tag 'mlx5-updates-2020-12-01' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
mlx5-updates-2020-12-01 mlx5e port TX timestamping support and MISC updates 1) Add support for port TX timestamping, for better PTP accuracy. Currently in mlx5 HW TX timestamping is done on CQE (TX completion) generation, which much earlier than when the packet actually goes out to the wire, in this series Eran implements the option to do timestamping on the port using a special SQ (Send Queue), such Send Queue will generate 2 CQEs (TX completions), the original one and a new one when the packet leaves the port, due to the nature of this special handling, such mechanism is an opt-in only and it is off by default to avoid any performance degradation on normal traffic flows. This patchset improves TX Hardware timestamping offset to be less than 40ns at a 100Gbps line rate, compared to 600ns before. With that, making our HW compliant with G.8273.2 class C, and allow Linux systems to be deployed in the 5G telco edge, where this standard is a must. 2) Misc updates and trivial improvements. Signed-off-by: David S. Miller <[email protected]>
2 parents c22c0d5 + 2f6b379 commit a8d5dd1

27 files changed

+1493
-350
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: 55 additions & 8 deletions
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

@@ -282,10 +283,12 @@ struct mlx5e_cq {
282283
u16 event_ctr;
283284
struct napi_struct *napi;
284285
struct mlx5_core_cq mcq;
285-
struct mlx5e_channel *channel;
286+
struct mlx5e_ch_stats *ch_stats;
286287

287288
/* control */
289+
struct net_device *netdev;
288290
struct mlx5_core_dev *mdev;
291+
struct mlx5e_priv *priv;
289292
struct mlx5_wq_ctrl wq_ctrl;
290293
} ____cacheline_aligned_in_smp;
291294

@@ -329,6 +332,15 @@ struct mlx5e_tx_mpwqe {
329332
u8 inline_on;
330333
};
331334

335+
struct mlx5e_skb_fifo {
336+
struct sk_buff **fifo;
337+
u16 *pc;
338+
u16 *cc;
339+
u16 mask;
340+
};
341+
342+
struct mlx5e_ptpsq;
343+
332344
struct mlx5e_txqsq {
333345
/* data path */
334346

@@ -349,11 +361,10 @@ struct mlx5e_txqsq {
349361
/* read only */
350362
struct mlx5_wq_cyc wq;
351363
u32 dma_fifo_mask;
352-
u16 skb_fifo_mask;
353364
struct mlx5e_sq_stats *stats;
354365
struct {
355366
struct mlx5e_sq_dma *dma_fifo;
356-
struct sk_buff **skb_fifo;
367+
struct mlx5e_skb_fifo skb_fifo;
357368
struct mlx5e_tx_wqe_info *wqe_info;
358369
} db;
359370
void __iomem *uar_map;
@@ -367,14 +378,17 @@ struct mlx5e_txqsq {
367378
unsigned int hw_mtu;
368379
struct hwtstamp_config *tstamp;
369380
struct mlx5_clock *clock;
381+
struct net_device *netdev;
382+
struct mlx5_core_dev *mdev;
383+
struct mlx5e_priv *priv;
370384

371385
/* control path */
372386
struct mlx5_wq_ctrl wq_ctrl;
373-
struct mlx5e_channel *channel;
374387
int ch_ix;
375388
int txq_ix;
376389
u32 rate_limit;
377390
struct work_struct recover_work;
391+
struct mlx5e_ptpsq *ptpsq;
378392
} ____cacheline_aligned_in_smp;
379393

380394
struct mlx5e_dma_info {
@@ -593,7 +607,6 @@ struct mlx5e_rq {
593607
u8 map_dir; /* dma map direction */
594608
} buff;
595609

596-
struct mlx5e_channel *channel;
597610
struct device *pdev;
598611
struct net_device *netdev;
599612
struct mlx5e_rq_stats *stats;
@@ -602,6 +615,8 @@ struct mlx5e_rq {
602615
struct mlx5e_page_cache page_cache;
603616
struct hwtstamp_config *tstamp;
604617
struct mlx5_clock *clock;
618+
struct mlx5e_icosq *icosq;
619+
struct mlx5e_priv *priv;
605620

606621
mlx5e_fp_handle_rx_cqe handle_rx_cqe;
607622
mlx5e_fp_post_rx_wqes post_wqes;
@@ -681,8 +696,11 @@ struct mlx5e_channel {
681696
int cpu;
682697
};
683698

699+
struct mlx5e_port_ptp;
700+
684701
struct mlx5e_channels {
685702
struct mlx5e_channel **c;
703+
struct mlx5e_port_ptp *port_ptp;
686704
unsigned int num;
687705
struct mlx5e_params params;
688706
};
@@ -697,6 +715,12 @@ struct mlx5e_channel_stats {
697715
struct mlx5e_xdpsq_stats xsksq;
698716
} ____cacheline_aligned_in_smp;
699717

718+
struct mlx5e_port_ptp_stats {
719+
struct mlx5e_ch_stats ch;
720+
struct mlx5e_sq_stats sq[MLX5E_MAX_NUM_TC];
721+
struct mlx5e_ptp_cq_stats cq[MLX5E_MAX_NUM_TC];
722+
} ____cacheline_aligned_in_smp;
723+
700724
enum {
701725
MLX5E_STATE_OPENED,
702726
MLX5E_STATE_DESTROYING,
@@ -766,8 +790,10 @@ struct mlx5e_scratchpad {
766790

767791
struct mlx5e_priv {
768792
/* priv data path fields - start */
769-
struct mlx5e_txqsq *txq2sq[MLX5E_MAX_NUM_CHANNELS * MLX5E_MAX_NUM_TC];
793+
/* +1 for port ptp ts */
794+
struct mlx5e_txqsq *txq2sq[(MLX5E_MAX_NUM_CHANNELS + 1) * MLX5E_MAX_NUM_TC];
770795
int channel_tc2realtxq[MLX5E_MAX_NUM_CHANNELS][MLX5E_MAX_NUM_TC];
796+
int port_ptp_tc2realtxq[MLX5E_MAX_NUM_TC];
771797
#ifdef CONFIG_MLX5_CORE_EN_DCB
772798
struct mlx5e_dcbx_dp dcbx_dp;
773799
#endif
@@ -802,12 +828,15 @@ struct mlx5e_priv {
802828
struct net_device *netdev;
803829
struct mlx5e_stats stats;
804830
struct mlx5e_channel_stats channel_stats[MLX5E_MAX_NUM_CHANNELS];
831+
struct mlx5e_port_ptp_stats port_ptp_stats;
805832
u16 max_nch;
806833
u8 max_opened_tc;
834+
bool port_ptp_opened;
807835
struct hwtstamp_config tstamp;
808836
u16 q_counter;
809837
u16 drop_rq_q_counter;
810838
struct notifier_block events_nb;
839+
int num_tc_x_num_ch;
811840

812841
struct udp_tunnel_nic_info nic_info;
813842
#ifdef CONFIG_MLX5_CORE_EN_DCB
@@ -923,9 +952,17 @@ int mlx5e_open_xdpsq(struct mlx5e_channel *c, struct mlx5e_params *params,
923952
struct mlx5e_xdpsq *sq, bool is_redirect);
924953
void mlx5e_close_xdpsq(struct mlx5e_xdpsq *sq);
925954

955+
struct mlx5e_create_cq_param {
956+
struct napi_struct *napi;
957+
struct mlx5e_ch_stats *ch_stats;
958+
int node;
959+
int ix;
960+
};
961+
926962
struct mlx5e_cq_param;
927-
int mlx5e_open_cq(struct mlx5e_channel *c, struct dim_cq_moder moder,
928-
struct mlx5e_cq_param *param, struct mlx5e_cq *cq);
963+
int mlx5e_open_cq(struct mlx5e_priv *priv, struct dim_cq_moder moder,
964+
struct mlx5e_cq_param *param, struct mlx5e_create_cq_param *ccp,
965+
struct mlx5e_cq *cq);
929966
void mlx5e_close_cq(struct mlx5e_cq *cq);
930967

931968
int mlx5e_open_locked(struct net_device *netdev);
@@ -974,7 +1011,17 @@ void mlx5e_deactivate_icosq(struct mlx5e_icosq *icosq);
9741011
int mlx5e_modify_sq(struct mlx5_core_dev *mdev, u32 sqn,
9751012
struct mlx5e_modify_sq_param *p);
9761013
void mlx5e_activate_txqsq(struct mlx5e_txqsq *sq);
1014+
void mlx5e_deactivate_txqsq(struct mlx5e_txqsq *sq);
1015+
void mlx5e_free_txqsq(struct mlx5e_txqsq *sq);
9771016
void mlx5e_tx_disable_queue(struct netdev_queue *txq);
1017+
int mlx5e_alloc_txqsq_db(struct mlx5e_txqsq *sq, int numa);
1018+
void mlx5e_free_txqsq_db(struct mlx5e_txqsq *sq);
1019+
struct mlx5e_create_sq_param;
1020+
int mlx5e_create_sq_rdy(struct mlx5_core_dev *mdev,
1021+
struct mlx5e_sq_param *param,
1022+
struct mlx5e_create_sq_param *csp,
1023+
u32 *sqn);
1024+
void mlx5e_tx_err_cqe_work(struct work_struct *recover_work);
9781025

9791026
static inline bool mlx5_tx_swp_supported(struct mlx5_core_dev *mdev)
9801027
{

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,7 @@ void mlx5e_disable_cvlan_filter(struct mlx5e_priv *priv);
287287
int mlx5e_create_flow_steering(struct mlx5e_priv *priv);
288288
void mlx5e_destroy_flow_steering(struct mlx5e_priv *priv);
289289

290-
bool mlx5e_tunnel_proto_supported(struct mlx5_core_dev *mdev, u8 proto_type);
291-
bool mlx5e_any_tunnel_proto_supported(struct mlx5_core_dev *mdev);
290+
u8 mlx5e_get_proto_by_tunnel_type(enum mlx5e_tunnel_types tt);
292291

293292
#endif /* __MLX5E_FLOW_STEER_H__ */
294293

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,12 @@ int mlx5e_health_fmsg_named_obj_nest_end(struct devlink_fmsg *fmsg)
3737

3838
int mlx5e_health_cq_diag_fmsg(struct mlx5e_cq *cq, struct devlink_fmsg *fmsg)
3939
{
40-
struct mlx5e_priv *priv = cq->channel->priv;
4140
u32 out[MLX5_ST_SZ_DW(query_cq_out)] = {};
4241
u8 hw_status;
4342
void *cqc;
4443
int err;
4544

46-
err = mlx5_core_query_cq(priv->mdev, &cq->mcq, out);
45+
err = mlx5_core_query_cq(cq->mdev, &cq->mcq, out);
4746
if (err)
4847
return err;
4948

@@ -158,10 +157,8 @@ void mlx5e_health_channels_update(struct mlx5e_priv *priv)
158157
DEVLINK_HEALTH_REPORTER_STATE_HEALTHY);
159158
}
160159

161-
int mlx5e_health_sq_to_ready(struct mlx5e_channel *channel, u32 sqn)
160+
int mlx5e_health_sq_to_ready(struct mlx5_core_dev *mdev, struct net_device *dev, u32 sqn)
162161
{
163-
struct mlx5_core_dev *mdev = channel->mdev;
164-
struct net_device *dev = channel->netdev;
165162
struct mlx5e_modify_sq_param msp = {};
166163
int err;
167164

@@ -206,21 +203,22 @@ int mlx5e_health_recover_channels(struct mlx5e_priv *priv)
206203
return err;
207204
}
208205

209-
int mlx5e_health_channel_eq_recover(struct mlx5_eq_comp *eq, struct mlx5e_channel *channel)
206+
int mlx5e_health_channel_eq_recover(struct net_device *dev, struct mlx5_eq_comp *eq,
207+
struct mlx5e_ch_stats *stats)
210208
{
211209
u32 eqe_count;
212210

213-
netdev_err(channel->netdev, "EQ 0x%x: Cons = 0x%x, irqn = 0x%x\n",
211+
netdev_err(dev, "EQ 0x%x: Cons = 0x%x, irqn = 0x%x\n",
214212
eq->core.eqn, eq->core.cons_index, eq->core.irqn);
215213

216214
eqe_count = mlx5_eq_poll_irq_disabled(eq);
217215
if (!eqe_count)
218216
return -EIO;
219217

220-
netdev_err(channel->netdev, "Recovered %d eqes on EQ 0x%x\n",
218+
netdev_err(dev, "Recovered %d eqes on EQ 0x%x\n",
221219
eqe_count, eq->core.eqn);
222220

223-
channel->stats->eq_rearm++;
221+
stats->eq_rearm++;
224222
return 0;
225223
}
226224

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
#include "en.h"
88
#include "diag/rsc_dump.h"
99

10-
#define MLX5E_RX_ERR_CQE(cqe) (get_cqe_opcode(cqe) != MLX5_CQE_RESP_SEND)
11-
1210
static inline bool cqe_syndrome_needs_recover(u8 syndrome)
1311
{
1412
return syndrome == MLX5_CQE_SYNDROME_LOCAL_QP_OP_ERR ||
@@ -42,8 +40,9 @@ struct mlx5e_err_ctx {
4240
void *ctx;
4341
};
4442

45-
int mlx5e_health_sq_to_ready(struct mlx5e_channel *channel, u32 sqn);
46-
int mlx5e_health_channel_eq_recover(struct mlx5_eq_comp *eq, struct mlx5e_channel *channel);
43+
int mlx5e_health_sq_to_ready(struct mlx5_core_dev *mdev, struct net_device *dev, u32 sqn);
44+
int mlx5e_health_channel_eq_recover(struct net_device *dev, struct mlx5_eq_comp *eq,
45+
struct mlx5e_ch_stats *stats);
4746
int mlx5e_health_recover_channels(struct mlx5e_priv *priv);
4847
int mlx5e_health_report(struct mlx5e_priv *priv,
4948
struct devlink_health_reporter *reporter, char *err_str,

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ 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 ts_cqe_to_dest_cqn;
48+
u32 tisn;
49+
u8 tis_lst_sz;
50+
u8 min_inline_mode;
51+
};
52+
4453
static inline bool mlx5e_qid_get_ch_if_in_group(struct mlx5e_params *params,
4554
u16 qid,
4655
enum mlx5e_rq_group group,
@@ -102,6 +111,7 @@ u16 mlx5e_get_rq_headroom(struct mlx5_core_dev *mdev,
102111

103112
/* Build queue parameters */
104113

114+
void mlx5e_build_create_cq_param(struct mlx5e_create_cq_param *ccp, struct mlx5e_channel *c);
105115
void mlx5e_build_rq_param(struct mlx5e_priv *priv,
106116
struct mlx5e_params *params,
107117
struct mlx5e_xsk_param *xsk,

0 commit comments

Comments
 (0)