Skip to content

Commit 40c5b2b

Browse files
committed
Merge tag 'mlx5-fixes-2019-10-18' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
Saeed Mahameed says: ==================== Mellanox, mlx5 kTLS fixes 18-10-2019 This series introduces kTLS related fixes to mlx5 driver from Tariq, and two misc memory leak fixes form Navid Emamdoost. Please pull and let me know if there is any problem. I would appreciate it if you queue up kTLS fixes from the list below to stable kernel v5.3 ! For -stable v4.13: nett/mlx5: prevent memory leak in mlx5_fpga_conn_create_cq ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 531e93d + c7ed6d0 commit 40c5b2b

File tree

11 files changed

+199
-118
lines changed

11 files changed

+199
-118
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ struct mlx5e_tx_wqe_info {
345345
u8 num_wqebbs;
346346
u8 num_dma;
347347
#ifdef CONFIG_MLX5_EN_TLS
348-
skb_frag_t *resync_dump_frag;
348+
struct page *resync_dump_frag_page;
349349
#endif
350350
};
351351

@@ -410,6 +410,7 @@ struct mlx5e_txqsq {
410410
struct device *pdev;
411411
__be32 mkey_be;
412412
unsigned long state;
413+
unsigned int hw_mtu;
413414
struct hwtstamp_config *tstamp;
414415
struct mlx5_clock *clock;
415416

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@
1515
#else
1616
/* TLS offload requires additional stop_room for:
1717
* - a resync SKB.
18-
* kTLS offload requires additional stop_room for:
19-
* - static params WQE,
20-
* - progress params WQE, and
21-
* - resync DUMP per frag.
18+
* kTLS offload requires fixed additional stop_room for:
19+
* - a static params WQE, and a progress params WQE.
20+
* The additional MTU-depending room for the resync DUMP WQEs
21+
* will be calculated and added in runtime.
2222
*/
2323
#define MLX5E_SQ_TLS_ROOM \
2424
(MLX5_SEND_WQE_MAX_WQEBBS + \
25-
MLX5E_KTLS_STATIC_WQEBBS + MLX5E_KTLS_PROGRESS_WQEBBS + \
26-
MAX_SKB_FRAGS * MLX5E_KTLS_MAX_DUMP_WQEBBS)
25+
MLX5E_KTLS_STATIC_WQEBBS + MLX5E_KTLS_PROGRESS_WQEBBS)
2726
#endif
2827

2928
#define INL_HDR_START_SZ (sizeof(((struct mlx5_wqe_eth_seg *)NULL)->inline_hdr.start))
@@ -92,7 +91,7 @@ mlx5e_fill_sq_frag_edge(struct mlx5e_txqsq *sq, struct mlx5_wq_cyc *wq,
9291

9392
/* fill sq frag edge with nops to avoid wqe wrapping two pages */
9493
for (; wi < edge_wi; wi++) {
95-
wi->skb = NULL;
94+
memset(wi, 0, sizeof(*wi));
9695
wi->num_wqebbs = 1;
9796
mlx5e_post_nop(wq, sq->sqn, &sq->pc);
9897
}

drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static int mlx5e_ktls_add(struct net_device *netdev, struct sock *sk,
3838
return -ENOMEM;
3939

4040
tx_priv->expected_seq = start_offload_tcp_sn;
41-
tx_priv->crypto_info = crypto_info;
41+
tx_priv->crypto_info = *(struct tls12_crypto_info_aes_gcm_128 *)crypto_info;
4242
mlx5e_set_ktls_tx_priv_ctx(tls_ctx, tx_priv);
4343

4444
/* tc and underlay_qpn values are not in use for tls tis */

drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.h

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,14 @@
2121
MLX5_ST_SZ_BYTES(tls_progress_params))
2222
#define MLX5E_KTLS_PROGRESS_WQEBBS \
2323
(DIV_ROUND_UP(MLX5E_KTLS_PROGRESS_WQE_SZ, MLX5_SEND_WQE_BB))
24-
#define MLX5E_KTLS_MAX_DUMP_WQEBBS 2
24+
25+
struct mlx5e_dump_wqe {
26+
struct mlx5_wqe_ctrl_seg ctrl;
27+
struct mlx5_wqe_data_seg data;
28+
};
29+
30+
#define MLX5E_KTLS_DUMP_WQEBBS \
31+
(DIV_ROUND_UP(sizeof(struct mlx5e_dump_wqe), MLX5_SEND_WQE_BB))
2532

2633
enum {
2734
MLX5E_TLS_PROGRESS_PARAMS_AUTH_STATE_NO_OFFLOAD = 0,
@@ -37,7 +44,7 @@ enum {
3744

3845
struct mlx5e_ktls_offload_context_tx {
3946
struct tls_offload_context_tx *tx_ctx;
40-
struct tls_crypto_info *crypto_info;
47+
struct tls12_crypto_info_aes_gcm_128 crypto_info;
4148
u32 expected_seq;
4249
u32 tisn;
4350
u32 key_id;
@@ -86,14 +93,28 @@ struct sk_buff *mlx5e_ktls_handle_tx_skb(struct net_device *netdev,
8693
struct mlx5e_tx_wqe **wqe, u16 *pi);
8794
void mlx5e_ktls_tx_handle_resync_dump_comp(struct mlx5e_txqsq *sq,
8895
struct mlx5e_tx_wqe_info *wi,
89-
struct mlx5e_sq_dma *dma);
90-
96+
u32 *dma_fifo_cc);
97+
static inline u8
98+
mlx5e_ktls_dumps_num_wqebbs(struct mlx5e_txqsq *sq, unsigned int nfrags,
99+
unsigned int sync_len)
100+
{
101+
/* Given the MTU and sync_len, calculates an upper bound for the
102+
* number of WQEBBs needed for the TX resync DUMP WQEs of a record.
103+
*/
104+
return MLX5E_KTLS_DUMP_WQEBBS *
105+
(nfrags + DIV_ROUND_UP(sync_len, sq->hw_mtu));
106+
}
91107
#else
92108

93109
static inline void mlx5e_ktls_build_netdev(struct mlx5e_priv *priv)
94110
{
95111
}
96112

113+
static inline void
114+
mlx5e_ktls_tx_handle_resync_dump_comp(struct mlx5e_txqsq *sq,
115+
struct mlx5e_tx_wqe_info *wi,
116+
u32 *dma_fifo_cc) {}
117+
97118
#endif
98119

99120
#endif /* __MLX5E_TLS_H__ */

0 commit comments

Comments
 (0)