diff options
author | David S. Miller <davem@davemloft.net> | 2018-10-16 00:51:28 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-10-16 00:51:28 -0400 |
commit | d0f068e5720ac4eea13e184bb7526848f189f909 (patch) | |
tree | 8f1199321444eedefa7b29561aed02664f418ae5 | |
parent | e331473fee3d500bb0d2582a1fe598df3326d8cd (diff) | |
parent | 37fdffb217a45609edccbb8b407d031143f551c0 (diff) |
Merge tag 'mlx5-fixes-2018-10-10' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
Saeed Mahameed says:
====================
Mellanox, mlx5 fixes 2018-10-10
This pull request includes some fixes to mlx5 driver,
Please pull and let me know if there's any problem.
For -stable v4.11:
('net/mlx5: Take only bit 24-26 of wqe.pftype_wq for page fault type')
For -stable v4.17:
('net/mlx5: Fix memory leak when setting fpga ipsec caps')
For -stable v4.18:
('net/mlx5: WQ, fixes for fragmented WQ buffers API')
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 12 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/en_tx.c | 22 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/eq.c | 2 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c | 9 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h | 5 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/wq.c | 5 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/wq.h | 11 | ||||
-rw-r--r-- | include/linux/mlx5/driver.h | 8 |
8 files changed, 36 insertions, 38 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c index 15d8ae28c040..00172dee5339 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | |||
@@ -432,10 +432,9 @@ static inline u16 mlx5e_icosq_wrap_cnt(struct mlx5e_icosq *sq) | |||
432 | 432 | ||
433 | static inline void mlx5e_fill_icosq_frag_edge(struct mlx5e_icosq *sq, | 433 | static inline void mlx5e_fill_icosq_frag_edge(struct mlx5e_icosq *sq, |
434 | struct mlx5_wq_cyc *wq, | 434 | struct mlx5_wq_cyc *wq, |
435 | u16 pi, u16 frag_pi) | 435 | u16 pi, u16 nnops) |
436 | { | 436 | { |
437 | struct mlx5e_sq_wqe_info *edge_wi, *wi = &sq->db.ico_wqe[pi]; | 437 | struct mlx5e_sq_wqe_info *edge_wi, *wi = &sq->db.ico_wqe[pi]; |
438 | u8 nnops = mlx5_wq_cyc_get_frag_size(wq) - frag_pi; | ||
439 | 438 | ||
440 | edge_wi = wi + nnops; | 439 | edge_wi = wi + nnops; |
441 | 440 | ||
@@ -454,15 +453,14 @@ static int mlx5e_alloc_rx_mpwqe(struct mlx5e_rq *rq, u16 ix) | |||
454 | struct mlx5_wq_cyc *wq = &sq->wq; | 453 | struct mlx5_wq_cyc *wq = &sq->wq; |
455 | struct mlx5e_umr_wqe *umr_wqe; | 454 | struct mlx5e_umr_wqe *umr_wqe; |
456 | u16 xlt_offset = ix << (MLX5E_LOG_ALIGNED_MPWQE_PPW - 1); | 455 | u16 xlt_offset = ix << (MLX5E_LOG_ALIGNED_MPWQE_PPW - 1); |
457 | u16 pi, frag_pi; | 456 | u16 pi, contig_wqebbs_room; |
458 | int err; | 457 | int err; |
459 | int i; | 458 | int i; |
460 | 459 | ||
461 | pi = mlx5_wq_cyc_ctr2ix(wq, sq->pc); | 460 | pi = mlx5_wq_cyc_ctr2ix(wq, sq->pc); |
462 | frag_pi = mlx5_wq_cyc_ctr2fragix(wq, sq->pc); | 461 | contig_wqebbs_room = mlx5_wq_cyc_get_contig_wqebbs(wq, pi); |
463 | 462 | if (unlikely(contig_wqebbs_room < MLX5E_UMR_WQEBBS)) { | |
464 | if (unlikely(frag_pi + MLX5E_UMR_WQEBBS > mlx5_wq_cyc_get_frag_size(wq))) { | 463 | mlx5e_fill_icosq_frag_edge(sq, wq, pi, contig_wqebbs_room); |
465 | mlx5e_fill_icosq_frag_edge(sq, wq, pi, frag_pi); | ||
466 | pi = mlx5_wq_cyc_ctr2ix(wq, sq->pc); | 464 | pi = mlx5_wq_cyc_ctr2ix(wq, sq->pc); |
467 | } | 465 | } |
468 | 466 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c index ae73ea992845..6dacaeba2fbf 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c | |||
@@ -290,10 +290,9 @@ dma_unmap_wqe_err: | |||
290 | 290 | ||
291 | static inline void mlx5e_fill_sq_frag_edge(struct mlx5e_txqsq *sq, | 291 | static inline void mlx5e_fill_sq_frag_edge(struct mlx5e_txqsq *sq, |
292 | struct mlx5_wq_cyc *wq, | 292 | struct mlx5_wq_cyc *wq, |
293 | u16 pi, u16 frag_pi) | 293 | u16 pi, u16 nnops) |
294 | { | 294 | { |
295 | struct mlx5e_tx_wqe_info *edge_wi, *wi = &sq->db.wqe_info[pi]; | 295 | struct mlx5e_tx_wqe_info *edge_wi, *wi = &sq->db.wqe_info[pi]; |
296 | u8 nnops = mlx5_wq_cyc_get_frag_size(wq) - frag_pi; | ||
297 | 296 | ||
298 | edge_wi = wi + nnops; | 297 | edge_wi = wi + nnops; |
299 | 298 | ||
@@ -348,8 +347,8 @@ netdev_tx_t mlx5e_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb, | |||
348 | struct mlx5e_tx_wqe_info *wi; | 347 | struct mlx5e_tx_wqe_info *wi; |
349 | 348 | ||
350 | struct mlx5e_sq_stats *stats = sq->stats; | 349 | struct mlx5e_sq_stats *stats = sq->stats; |
350 | u16 headlen, ihs, contig_wqebbs_room; | ||
351 | u16 ds_cnt, ds_cnt_inl = 0; | 351 | u16 ds_cnt, ds_cnt_inl = 0; |
352 | u16 headlen, ihs, frag_pi; | ||
353 | u8 num_wqebbs, opcode; | 352 | u8 num_wqebbs, opcode; |
354 | u32 num_bytes; | 353 | u32 num_bytes; |
355 | int num_dma; | 354 | int num_dma; |
@@ -386,9 +385,9 @@ netdev_tx_t mlx5e_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb, | |||
386 | } | 385 | } |
387 | 386 | ||
388 | num_wqebbs = DIV_ROUND_UP(ds_cnt, MLX5_SEND_WQEBB_NUM_DS); | 387 | num_wqebbs = DIV_ROUND_UP(ds_cnt, MLX5_SEND_WQEBB_NUM_DS); |
389 | frag_pi = mlx5_wq_cyc_ctr2fragix(wq, sq->pc); | 388 | contig_wqebbs_room = mlx5_wq_cyc_get_contig_wqebbs(wq, pi); |
390 | if (unlikely(frag_pi + num_wqebbs > mlx5_wq_cyc_get_frag_size(wq))) { | 389 | if (unlikely(contig_wqebbs_room < num_wqebbs)) { |
391 | mlx5e_fill_sq_frag_edge(sq, wq, pi, frag_pi); | 390 | mlx5e_fill_sq_frag_edge(sq, wq, pi, contig_wqebbs_room); |
392 | mlx5e_sq_fetch_wqe(sq, &wqe, &pi); | 391 | mlx5e_sq_fetch_wqe(sq, &wqe, &pi); |
393 | } | 392 | } |
394 | 393 | ||
@@ -636,7 +635,7 @@ netdev_tx_t mlx5i_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb, | |||
636 | struct mlx5e_tx_wqe_info *wi; | 635 | struct mlx5e_tx_wqe_info *wi; |
637 | 636 | ||
638 | struct mlx5e_sq_stats *stats = sq->stats; | 637 | struct mlx5e_sq_stats *stats = sq->stats; |
639 | u16 headlen, ihs, pi, frag_pi; | 638 | u16 headlen, ihs, pi, contig_wqebbs_room; |
640 | u16 ds_cnt, ds_cnt_inl = 0; | 639 | u16 ds_cnt, ds_cnt_inl = 0; |
641 | u8 num_wqebbs, opcode; | 640 | u8 num_wqebbs, opcode; |
642 | u32 num_bytes; | 641 | u32 num_bytes; |
@@ -672,13 +671,14 @@ netdev_tx_t mlx5i_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb, | |||
672 | } | 671 | } |
673 | 672 | ||
674 | num_wqebbs = DIV_ROUND_UP(ds_cnt, MLX5_SEND_WQEBB_NUM_DS); | 673 | num_wqebbs = DIV_ROUND_UP(ds_cnt, MLX5_SEND_WQEBB_NUM_DS); |
675 | frag_pi = mlx5_wq_cyc_ctr2fragix(wq, sq->pc); | 674 | pi = mlx5_wq_cyc_ctr2ix(wq, sq->pc); |
676 | if (unlikely(frag_pi + num_wqebbs > mlx5_wq_cyc_get_frag_size(wq))) { | 675 | contig_wqebbs_room = mlx5_wq_cyc_get_contig_wqebbs(wq, pi); |
676 | if (unlikely(contig_wqebbs_room < num_wqebbs)) { | ||
677 | mlx5e_fill_sq_frag_edge(sq, wq, pi, contig_wqebbs_room); | ||
677 | pi = mlx5_wq_cyc_ctr2ix(wq, sq->pc); | 678 | pi = mlx5_wq_cyc_ctr2ix(wq, sq->pc); |
678 | mlx5e_fill_sq_frag_edge(sq, wq, pi, frag_pi); | ||
679 | } | 679 | } |
680 | 680 | ||
681 | mlx5i_sq_fetch_wqe(sq, &wqe, &pi); | 681 | mlx5i_sq_fetch_wqe(sq, &wqe, pi); |
682 | 682 | ||
683 | /* fill wqe */ | 683 | /* fill wqe */ |
684 | wi = &sq->db.wqe_info[pi]; | 684 | wi = &sq->db.wqe_info[pi]; |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eq.c b/drivers/net/ethernet/mellanox/mlx5/core/eq.c index 48864f4988a4..c1e1a16a9b07 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eq.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eq.c | |||
@@ -273,7 +273,7 @@ static void eq_pf_process(struct mlx5_eq *eq) | |||
273 | case MLX5_PFAULT_SUBTYPE_WQE: | 273 | case MLX5_PFAULT_SUBTYPE_WQE: |
274 | /* WQE based event */ | 274 | /* WQE based event */ |
275 | pfault->type = | 275 | pfault->type = |
276 | be32_to_cpu(pf_eqe->wqe.pftype_wq) >> 24; | 276 | (be32_to_cpu(pf_eqe->wqe.pftype_wq) >> 24) & 0x7; |
277 | pfault->token = | 277 | pfault->token = |
278 | be32_to_cpu(pf_eqe->wqe.token); | 278 | be32_to_cpu(pf_eqe->wqe.token); |
279 | pfault->wqe.wq_num = | 279 | pfault->wqe.wq_num = |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c b/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c index 5645a4facad2..b8ee9101c506 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c | |||
@@ -245,7 +245,7 @@ static void *mlx5_fpga_ipsec_cmd_exec(struct mlx5_core_dev *mdev, | |||
245 | return ERR_PTR(res); | 245 | return ERR_PTR(res); |
246 | } | 246 | } |
247 | 247 | ||
248 | /* Context will be freed by wait func after completion */ | 248 | /* Context should be freed by the caller after completion. */ |
249 | return context; | 249 | return context; |
250 | } | 250 | } |
251 | 251 | ||
@@ -418,10 +418,8 @@ static int mlx5_fpga_ipsec_set_caps(struct mlx5_core_dev *mdev, u32 flags) | |||
418 | cmd.cmd = htonl(MLX5_FPGA_IPSEC_CMD_OP_SET_CAP); | 418 | cmd.cmd = htonl(MLX5_FPGA_IPSEC_CMD_OP_SET_CAP); |
419 | cmd.flags = htonl(flags); | 419 | cmd.flags = htonl(flags); |
420 | context = mlx5_fpga_ipsec_cmd_exec(mdev, &cmd, sizeof(cmd)); | 420 | context = mlx5_fpga_ipsec_cmd_exec(mdev, &cmd, sizeof(cmd)); |
421 | if (IS_ERR(context)) { | 421 | if (IS_ERR(context)) |
422 | err = PTR_ERR(context); | 422 | return PTR_ERR(context); |
423 | goto out; | ||
424 | } | ||
425 | 423 | ||
426 | err = mlx5_fpga_ipsec_cmd_wait(context); | 424 | err = mlx5_fpga_ipsec_cmd_wait(context); |
427 | if (err) | 425 | if (err) |
@@ -435,6 +433,7 @@ static int mlx5_fpga_ipsec_set_caps(struct mlx5_core_dev *mdev, u32 flags) | |||
435 | } | 433 | } |
436 | 434 | ||
437 | out: | 435 | out: |
436 | kfree(context); | ||
438 | return err; | 437 | return err; |
439 | } | 438 | } |
440 | 439 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h index 08eac92fc26c..0982c579ec74 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h | |||
@@ -109,12 +109,11 @@ struct mlx5i_tx_wqe { | |||
109 | 109 | ||
110 | static inline void mlx5i_sq_fetch_wqe(struct mlx5e_txqsq *sq, | 110 | static inline void mlx5i_sq_fetch_wqe(struct mlx5e_txqsq *sq, |
111 | struct mlx5i_tx_wqe **wqe, | 111 | struct mlx5i_tx_wqe **wqe, |
112 | u16 *pi) | 112 | u16 pi) |
113 | { | 113 | { |
114 | struct mlx5_wq_cyc *wq = &sq->wq; | 114 | struct mlx5_wq_cyc *wq = &sq->wq; |
115 | 115 | ||
116 | *pi = mlx5_wq_cyc_ctr2ix(wq, sq->pc); | 116 | *wqe = mlx5_wq_cyc_get_wqe(wq, pi); |
117 | *wqe = mlx5_wq_cyc_get_wqe(wq, *pi); | ||
118 | memset(*wqe, 0, sizeof(**wqe)); | 117 | memset(*wqe, 0, sizeof(**wqe)); |
119 | } | 118 | } |
120 | 119 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/wq.c b/drivers/net/ethernet/mellanox/mlx5/core/wq.c index 68e7f8df2a6d..ddca327e8950 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/wq.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/wq.c | |||
@@ -39,11 +39,6 @@ u32 mlx5_wq_cyc_get_size(struct mlx5_wq_cyc *wq) | |||
39 | return (u32)wq->fbc.sz_m1 + 1; | 39 | return (u32)wq->fbc.sz_m1 + 1; |
40 | } | 40 | } |
41 | 41 | ||
42 | u16 mlx5_wq_cyc_get_frag_size(struct mlx5_wq_cyc *wq) | ||
43 | { | ||
44 | return wq->fbc.frag_sz_m1 + 1; | ||
45 | } | ||
46 | |||
47 | u32 mlx5_cqwq_get_size(struct mlx5_cqwq *wq) | 42 | u32 mlx5_cqwq_get_size(struct mlx5_cqwq *wq) |
48 | { | 43 | { |
49 | return wq->fbc.sz_m1 + 1; | 44 | return wq->fbc.sz_m1 + 1; |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/wq.h b/drivers/net/ethernet/mellanox/mlx5/core/wq.h index 3a1a170bb2d7..b1293d153a58 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/wq.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/wq.h | |||
@@ -80,7 +80,6 @@ int mlx5_wq_cyc_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param, | |||
80 | void *wqc, struct mlx5_wq_cyc *wq, | 80 | void *wqc, struct mlx5_wq_cyc *wq, |
81 | struct mlx5_wq_ctrl *wq_ctrl); | 81 | struct mlx5_wq_ctrl *wq_ctrl); |
82 | u32 mlx5_wq_cyc_get_size(struct mlx5_wq_cyc *wq); | 82 | u32 mlx5_wq_cyc_get_size(struct mlx5_wq_cyc *wq); |
83 | u16 mlx5_wq_cyc_get_frag_size(struct mlx5_wq_cyc *wq); | ||
84 | 83 | ||
85 | int mlx5_wq_qp_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param, | 84 | int mlx5_wq_qp_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param, |
86 | void *qpc, struct mlx5_wq_qp *wq, | 85 | void *qpc, struct mlx5_wq_qp *wq, |
@@ -140,11 +139,6 @@ static inline u16 mlx5_wq_cyc_ctr2ix(struct mlx5_wq_cyc *wq, u16 ctr) | |||
140 | return ctr & wq->fbc.sz_m1; | 139 | return ctr & wq->fbc.sz_m1; |
141 | } | 140 | } |
142 | 141 | ||
143 | static inline u16 mlx5_wq_cyc_ctr2fragix(struct mlx5_wq_cyc *wq, u16 ctr) | ||
144 | { | ||
145 | return ctr & wq->fbc.frag_sz_m1; | ||
146 | } | ||
147 | |||
148 | static inline u16 mlx5_wq_cyc_get_head(struct mlx5_wq_cyc *wq) | 142 | static inline u16 mlx5_wq_cyc_get_head(struct mlx5_wq_cyc *wq) |
149 | { | 143 | { |
150 | return mlx5_wq_cyc_ctr2ix(wq, wq->wqe_ctr); | 144 | return mlx5_wq_cyc_ctr2ix(wq, wq->wqe_ctr); |
@@ -160,6 +154,11 @@ static inline void *mlx5_wq_cyc_get_wqe(struct mlx5_wq_cyc *wq, u16 ix) | |||
160 | return mlx5_frag_buf_get_wqe(&wq->fbc, ix); | 154 | return mlx5_frag_buf_get_wqe(&wq->fbc, ix); |
161 | } | 155 | } |
162 | 156 | ||
157 | static inline u16 mlx5_wq_cyc_get_contig_wqebbs(struct mlx5_wq_cyc *wq, u16 ix) | ||
158 | { | ||
159 | return mlx5_frag_buf_get_idx_last_contig_stride(&wq->fbc, ix) - ix + 1; | ||
160 | } | ||
161 | |||
163 | static inline int mlx5_wq_cyc_cc_bigger(u16 cc1, u16 cc2) | 162 | static inline int mlx5_wq_cyc_cc_bigger(u16 cc1, u16 cc2) |
164 | { | 163 | { |
165 | int equal = (cc1 == cc2); | 164 | int equal = (cc1 == cc2); |
diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h index 66d94b4557cf..88a041b73abf 100644 --- a/include/linux/mlx5/driver.h +++ b/include/linux/mlx5/driver.h | |||
@@ -1032,6 +1032,14 @@ static inline void *mlx5_frag_buf_get_wqe(struct mlx5_frag_buf_ctrl *fbc, | |||
1032 | ((fbc->frag_sz_m1 & ix) << fbc->log_stride); | 1032 | ((fbc->frag_sz_m1 & ix) << fbc->log_stride); |
1033 | } | 1033 | } |
1034 | 1034 | ||
1035 | static inline u32 | ||
1036 | mlx5_frag_buf_get_idx_last_contig_stride(struct mlx5_frag_buf_ctrl *fbc, u32 ix) | ||
1037 | { | ||
1038 | u32 last_frag_stride_idx = (ix + fbc->strides_offset) | fbc->frag_sz_m1; | ||
1039 | |||
1040 | return min_t(u32, last_frag_stride_idx - fbc->strides_offset, fbc->sz_m1); | ||
1041 | } | ||
1042 | |||
1035 | int mlx5_cmd_init(struct mlx5_core_dev *dev); | 1043 | int mlx5_cmd_init(struct mlx5_core_dev *dev); |
1036 | void mlx5_cmd_cleanup(struct mlx5_core_dev *dev); | 1044 | void mlx5_cmd_cleanup(struct mlx5_core_dev *dev); |
1037 | void mlx5_cmd_use_events(struct mlx5_core_dev *dev); | 1045 | void mlx5_cmd_use_events(struct mlx5_core_dev *dev); |