Skip to content

Commit 1078029

Browse files
committed
Merge tag 'mlx5-tls-2020-06-26' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
Saeed Mahameed says: ==================== mlx5-tls-2020-06-26 1) Improve hardware layouts and structure for kTLS support 2) Generalize ICOSQ (Internal Channel Operations Send Queue) Due to the asynchronous nature of adding new kTLS flows and handling HW asynchronous kTLS resync requests, the XSK ICOSQ was extended to support generic async operations, such as kTLS add flow and resync, in addition to the existing XSK usages. 3) kTLS hardware flow steering and classification: The driver already has the means to classify TCP ipv4/6 flows to send them to the corresponding RSS HW engine, as reflected in patches 3 through 5, the series will add a steering layer that will hook to the driver's TCP classifiers and will match on well known kTLS connection, in case of a match traffic will be redirected to the kTLS decryption engine, otherwise traffic will continue flowing normally to the TCP RSS engine. 3) kTLS add flow RX HW offload support New offload contexts post their static/progress params WQEs (Work Queue Element) to communicate the newly added kTLS contexts over the per-channel async ICOSQ. The Channel/RQ is selected according to the socket's rxq index. A new TLS-RX workqueue is used to allow asynchronous addition of steering rules, out of the NAPI context. It will be also used in a downstream patch in the resync procedure. Feature is OFF by default. Can be turned on by: $ ethtool -K <if> tls-hw-rx-offload on 4) Added mlx5 kTLS sw stats and new counters are documented in Documentation/networking/tls-offload.rst rx_tls_ctx - number of TLS RX HW offload contexts added to device for decryption. rx_tls_ooo - number of RX packets which were part of a TLS stream but did not arrive in the expected order and triggered the resync procedure. rx_tls_del - number of TLS RX HW offload contexts deleted from device (connection has finished). rx_tls_err - number of RX packets which were part of a TLS stream but were not decrypted due to unexpected error in the state machine. 5) Asynchronous RX resync a. The NIC driver indicates that it would like to resync on some TLS record within the received packet (P), but the driver does not know (yet) which of the TLS records within the packet. At this stage, the NIC driver will query the device to find the exact TCP sequence for resync (tcpsn), however, the driver does not wait for the device to provide the response. b. Eventually, the device responds, and the driver provides the tcpsn within the resync packet to KTLS. Now, KTLS can check the tcpsn against any processed TLS records within packet P, and also against any record that is processed in the future within packet P. The asynchronous resync path simplifies the device driver, as it can save bits on the packet completion (32-bit TCP sequence), and pass this information on an asynchronous command instead. Performance: CPU: Intel(R) Xeon(R) CPU E5-2687W v4 @ 3.00GHz, 24 cores, HT off NIC: ConnectX-6 Dx 100GbE dual port Goodput (app-layer throughput) comparison: +---------------+-------+-------+---------+ | # connections | 1 | 4 | 8 | +---------------+-------+-------+---------+ | SW (Gbps) | 7.26 | 24.70 | 50.30 | +---------------+-------+-------+---------+ | HW (Gbps) | 18.50 | 64.30 | 92.90 | +---------------+-------+-------+---------+ | Speedup | 2.55x | 2.56x | 1.85x * | +---------------+-------+-------+---------+ * After linerate is reached, diff is observed in CPU util ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 989d957 + a290743 commit 1078029

File tree

43 files changed

+2128
-493
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2128
-493
lines changed

Documentation/networking/tls-offload.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,24 @@ by the driver:
428428
which were part of a TLS stream.
429429
* ``rx_tls_decrypted_bytes`` - number of TLS payload bytes in RX packets
430430
which were successfully decrypted.
431+
* ``rx_tls_ctx`` - number of TLS RX HW offload contexts added to device for
432+
decryption.
433+
* ``rx_tls_del`` - number of TLS RX HW offload contexts deleted from device
434+
(connection has finished).
435+
* ``rx_tls_resync_req_pkt`` - number of received TLS packets with a resync
436+
request.
437+
* ``rx_tls_resync_req_start`` - number of times the TLS async resync request
438+
was started.
439+
* ``rx_tls_resync_req_end`` - number of times the TLS async resync request
440+
properly ended with providing the HW tracked tcp-seq.
441+
* ``rx_tls_resync_req_skip`` - number of times the TLS async resync request
442+
procedure was started by not properly ended.
443+
* ``rx_tls_resync_res_ok`` - number of times the TLS resync response call to
444+
the driver was successfully handled.
445+
* ``rx_tls_resync_res_skip`` - number of times the TLS resync response call to
446+
the driver was terminated unsuccessfully.
447+
* ``rx_tls_err`` - number of RX packets which were part of a TLS stream
448+
but were not decrypted due to unexpected error in the state machine.
431449
* ``tx_tls_encrypted_packets`` - number of TX packets passed to the device
432450
for encryption of their TLS payload.
433451
* ``tx_tls_encrypted_bytes`` - number of TLS payload bytes in TX packets

drivers/net/ethernet/mellanox/mlx5/core/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ config MLX5_TLS
173173
config MLX5_EN_TLS
174174
bool "TLS cryptography-offload accelaration"
175175
depends on MLX5_CORE_EN
176+
depends on XPS
176177
depends on MLX5_FPGA_TLS || MLX5_TLS
177178
default y
178179
help

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ mlx5_core-$(CONFIG_MLX5_EN_IPSEC) += en_accel/ipsec.o en_accel/ipsec_rxtx.o \
7474
en_accel/ipsec_stats.o
7575

7676
mlx5_core-$(CONFIG_MLX5_EN_TLS) += en_accel/tls.o en_accel/tls_rxtx.o en_accel/tls_stats.o \
77-
en_accel/ktls.o en_accel/ktls_tx.o
77+
en_accel/fs_tcp.o en_accel/ktls.o en_accel/ktls_txrx.o \
78+
en_accel/ktls_tx.o en_accel/ktls_rx.o
7879

7980
mlx5_core-$(CONFIG_MLX5_SW_STEERING) += steering/dr_domain.o steering/dr_table.o \
8081
steering/dr_matcher.o steering/dr_rule.o \

drivers/net/ethernet/mellanox/mlx5/core/accel/tls.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,20 @@ int mlx5_ktls_create_key(struct mlx5_core_dev *mdev,
4343
u32 *p_key_id);
4444
void mlx5_ktls_destroy_key(struct mlx5_core_dev *mdev, u32 key_id);
4545

46+
static inline bool mlx5_accel_is_ktls_tx(struct mlx5_core_dev *mdev)
47+
{
48+
return MLX5_CAP_GEN(mdev, tls_tx);
49+
}
50+
51+
static inline bool mlx5_accel_is_ktls_rx(struct mlx5_core_dev *mdev)
52+
{
53+
return MLX5_CAP_GEN(mdev, tls_rx);
54+
}
55+
4656
static inline bool mlx5_accel_is_ktls_device(struct mlx5_core_dev *mdev)
4757
{
48-
if (!MLX5_CAP_GEN(mdev, tls_tx))
58+
if (!mlx5_accel_is_ktls_tx(mdev) &&
59+
!mlx5_accel_is_ktls_rx(mdev))
4960
return false;
5061

5162
if (!MLX5_CAP_GEN(mdev, log_max_dek))
@@ -67,6 +78,12 @@ static inline bool mlx5e_ktls_type_check(struct mlx5_core_dev *mdev,
6778
return false;
6879
}
6980
#else
81+
static inline bool mlx5_accel_is_ktls_tx(struct mlx5_core_dev *mdev)
82+
{ return false; }
83+
84+
static inline bool mlx5_accel_is_ktls_rx(struct mlx5_core_dev *mdev)
85+
{ return false; }
86+
7087
static inline int
7188
mlx5_ktls_create_key(struct mlx5_core_dev *mdev,
7289
struct tls_crypto_info *crypto_info,

drivers/net/ethernet/mellanox/mlx5/core/diag/rsc_dump.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ static const char *const mlx5_rsc_sgmt_name[] = {
2323
MLX5_SGMT_STR_ASSING(SX_SLICE_ALL),
2424
MLX5_SGMT_STR_ASSING(RDB),
2525
MLX5_SGMT_STR_ASSING(RX_SLICE_ALL),
26+
MLX5_SGMT_STR_ASSING(PRM_QUERY_QP),
27+
MLX5_SGMT_STR_ASSING(PRM_QUERY_CQ),
28+
MLX5_SGMT_STR_ASSING(PRM_QUERY_MKEY),
2629
};
2730

2831
struct mlx5_rsc_dump {
@@ -130,11 +133,13 @@ struct mlx5_rsc_dump_cmd *mlx5_rsc_dump_cmd_create(struct mlx5_core_dev *dev,
130133
cmd->mem_size = key->size;
131134
return cmd;
132135
}
136+
EXPORT_SYMBOL(mlx5_rsc_dump_cmd_create);
133137

134138
void mlx5_rsc_dump_cmd_destroy(struct mlx5_rsc_dump_cmd *cmd)
135139
{
136140
kfree(cmd);
137141
}
142+
EXPORT_SYMBOL(mlx5_rsc_dump_cmd_destroy);
138143

139144
int mlx5_rsc_dump_next(struct mlx5_core_dev *dev, struct mlx5_rsc_dump_cmd *cmd,
140145
struct page *page, int *size)
@@ -155,6 +160,7 @@ int mlx5_rsc_dump_next(struct mlx5_core_dev *dev, struct mlx5_rsc_dump_cmd *cmd,
155160

156161
return more_dump;
157162
}
163+
EXPORT_SYMBOL(mlx5_rsc_dump_next);
158164

159165
#define MLX5_RSC_DUMP_MENU_SEGMENT 0xffff
160166
static int mlx5_rsc_dump_menu(struct mlx5_core_dev *dev)

drivers/net/ethernet/mellanox/mlx5/core/diag/rsc_dump.h

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,10 @@
44
#ifndef __MLX5_RSC_DUMP_H
55
#define __MLX5_RSC_DUMP_H
66

7+
#include <linux/mlx5/rsc_dump.h>
78
#include <linux/mlx5/driver.h>
89
#include "mlx5_core.h"
910

10-
enum mlx5_sgmt_type {
11-
MLX5_SGMT_TYPE_HW_CQPC,
12-
MLX5_SGMT_TYPE_HW_SQPC,
13-
MLX5_SGMT_TYPE_HW_RQPC,
14-
MLX5_SGMT_TYPE_FULL_SRQC,
15-
MLX5_SGMT_TYPE_FULL_CQC,
16-
MLX5_SGMT_TYPE_FULL_EQC,
17-
MLX5_SGMT_TYPE_FULL_QPC,
18-
MLX5_SGMT_TYPE_SND_BUFF,
19-
MLX5_SGMT_TYPE_RCV_BUFF,
20-
MLX5_SGMT_TYPE_SRQ_BUFF,
21-
MLX5_SGMT_TYPE_CQ_BUFF,
22-
MLX5_SGMT_TYPE_EQ_BUFF,
23-
MLX5_SGMT_TYPE_SX_SLICE,
24-
MLX5_SGMT_TYPE_SX_SLICE_ALL,
25-
MLX5_SGMT_TYPE_RDB,
26-
MLX5_SGMT_TYPE_RX_SLICE_ALL,
27-
MLX5_SGMT_TYPE_MENU,
28-
MLX5_SGMT_TYPE_TERMINATE,
29-
30-
MLX5_SGMT_TYPE_NUM, /* Keep last */
31-
};
32-
33-
struct mlx5_rsc_key {
34-
enum mlx5_sgmt_type rsc;
35-
int index1;
36-
int index2;
37-
int num_of_obj1;
38-
int num_of_obj2;
39-
int size;
40-
};
41-
4211
#define MLX5_RSC_DUMP_ALL 0xFFFF
4312
struct mlx5_rsc_dump_cmd;
4413
struct mlx5_rsc_dump;

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

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,8 @@ static inline int mlx5e_get_max_num_channels(struct mlx5_core_dev *mdev)
191191

192192
struct mlx5e_tx_wqe {
193193
struct mlx5_wqe_ctrl_seg ctrl;
194-
union {
195-
struct {
196-
struct mlx5_wqe_eth_seg eth;
197-
struct mlx5_wqe_data_seg data[0];
198-
};
199-
u8 tls_progress_params_ctx[0];
200-
};
194+
struct mlx5_wqe_eth_seg eth;
195+
struct mlx5_wqe_data_seg data[0];
201196
};
202197

203198
struct mlx5e_rx_wqe_ll {
@@ -213,10 +208,7 @@ struct mlx5e_umr_wqe {
213208
struct mlx5_wqe_ctrl_seg ctrl;
214209
struct mlx5_wqe_umr_ctrl_seg uctrl;
215210
struct mlx5_mkey_seg mkc;
216-
union {
217-
struct mlx5_mtt inline_mtts[0];
218-
u8 tls_static_params_ctx[0];
219-
};
211+
struct mlx5_mtt inline_mtts[0];
220212
};
221213

222214
extern const char mlx5e_self_tests[][ETH_GSTRING_LEN];
@@ -271,6 +263,7 @@ enum {
271263
MLX5E_RQ_STATE_AM,
272264
MLX5E_RQ_STATE_NO_CSUM_COMPLETE,
273265
MLX5E_RQ_STATE_CSUM_FULL, /* cqe_csum_full hw bit is set */
266+
MLX5E_RQ_STATE_FPGA_TLS, /* FPGA TLS enabled */
274267
};
275268

276269
struct mlx5e_cq {
@@ -651,9 +644,11 @@ struct mlx5e_channel {
651644
/* AF_XDP zero-copy */
652645
struct mlx5e_rq xskrq;
653646
struct mlx5e_xdpsq xsksq;
654-
struct mlx5e_icosq xskicosq;
655-
/* xskicosq can be accessed from any CPU - the spinlock protects it. */
656-
spinlock_t xskicosq_lock;
647+
648+
/* Async ICOSQ */
649+
struct mlx5e_icosq async_icosq;
650+
/* async_icosq can be accessed from any CPU - the spinlock protects it. */
651+
spinlock_t async_icosq_lock;
657652

658653
/* data path - accessed per napi poll */
659654
struct irq_desc *irq_desc;

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

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,16 @@ enum mlx5e_tunnel_types {
105105

106106
bool mlx5e_tunnel_inner_ft_supported(struct mlx5_core_dev *mdev);
107107

108+
struct mlx5e_ttc_rule {
109+
struct mlx5_flow_handle *rule;
110+
struct mlx5_flow_destination default_dest;
111+
};
112+
108113
/* L3/L4 traffic type classifier */
109114
struct mlx5e_ttc_table {
110-
struct mlx5e_flow_table ft;
111-
struct mlx5_flow_handle *rules[MLX5E_NUM_TT];
112-
struct mlx5_flow_handle *tunnel_rules[MLX5E_NUM_TUNNEL_TT];
115+
struct mlx5e_flow_table ft;
116+
struct mlx5e_ttc_rule rules[MLX5E_NUM_TT];
117+
struct mlx5_flow_handle *tunnel_rules[MLX5E_NUM_TUNNEL_TT];
113118
};
114119

115120
/* NIC prio FTS */
@@ -118,6 +123,9 @@ enum {
118123
MLX5E_L2_FT_LEVEL,
119124
MLX5E_TTC_FT_LEVEL,
120125
MLX5E_INNER_TTC_FT_LEVEL,
126+
#ifdef CONFIG_MLX5_EN_TLS
127+
MLX5E_ACCEL_FS_TCP_FT_LEVEL,
128+
#endif
121129
#ifdef CONFIG_MLX5_EN_ARFS
122130
MLX5E_ARFS_FT_LEVEL
123131
#endif
@@ -211,6 +219,10 @@ static inline int mlx5e_arfs_enable(struct mlx5e_priv *priv) { return -EOPNOTSUP
211219
static inline int mlx5e_arfs_disable(struct mlx5e_priv *priv) { return -EOPNOTSUPP; }
212220
#endif
213221

222+
#ifdef CONFIG_MLX5_EN_TLS
223+
struct mlx5e_accel_fs_tcp;
224+
#endif
225+
214226
struct mlx5e_flow_steering {
215227
struct mlx5_flow_namespace *ns;
216228
#ifdef CONFIG_MLX5_EN_RXNFC
@@ -224,6 +236,9 @@ struct mlx5e_flow_steering {
224236
#ifdef CONFIG_MLX5_EN_ARFS
225237
struct mlx5e_arfs_tables arfs;
226238
#endif
239+
#ifdef CONFIG_MLX5_EN_TLS
240+
struct mlx5e_accel_fs_tcp *accel_tcp;
241+
#endif
227242
};
228243

229244
struct ttc_params {
@@ -248,6 +263,11 @@ void mlx5e_destroy_inner_ttc_table(struct mlx5e_priv *priv,
248263
struct mlx5e_ttc_table *ttc);
249264

250265
void mlx5e_destroy_flow_table(struct mlx5e_flow_table *ft);
266+
int mlx5e_ttc_fwd_dest(struct mlx5e_priv *priv, enum mlx5e_traffic_types type,
267+
struct mlx5_flow_destination *new_dest);
268+
struct mlx5_flow_destination
269+
mlx5e_ttc_get_default_dest(struct mlx5e_priv *priv, enum mlx5e_traffic_types type);
270+
int mlx5e_ttc_fwd_default_dest(struct mlx5e_priv *priv, enum mlx5e_traffic_types type);
251271

252272
void mlx5e_enable_cvlan_filter(struct mlx5e_priv *priv);
253273
void mlx5e_disable_cvlan_filter(struct mlx5e_priv *priv);

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,33 @@ struct mlx5e_xsk_param {
1111
u16 chunk_size;
1212
};
1313

14+
struct mlx5e_cq_param {
15+
u32 cqc[MLX5_ST_SZ_DW(cqc)];
16+
struct mlx5_wq_param wq;
17+
u16 eq_ix;
18+
u8 cq_period_mode;
19+
};
20+
1421
struct mlx5e_rq_param {
22+
struct mlx5e_cq_param cqp;
1523
u32 rqc[MLX5_ST_SZ_DW(rqc)];
1624
struct mlx5_wq_param wq;
1725
struct mlx5e_rq_frags_info frags_info;
1826
};
1927

2028
struct mlx5e_sq_param {
29+
struct mlx5e_cq_param cqp;
2130
u32 sqc[MLX5_ST_SZ_DW(sqc)];
2231
struct mlx5_wq_param wq;
2332
bool is_mpw;
2433
};
2534

26-
struct mlx5e_cq_param {
27-
u32 cqc[MLX5_ST_SZ_DW(cqc)];
28-
struct mlx5_wq_param wq;
29-
u16 eq_ix;
30-
u8 cq_period_mode;
31-
};
32-
3335
struct mlx5e_channel_param {
3436
struct mlx5e_rq_param rq;
35-
struct mlx5e_sq_param sq;
37+
struct mlx5e_sq_param txq_sq;
3638
struct mlx5e_sq_param xdp_sq;
3739
struct mlx5e_sq_param icosq;
38-
struct mlx5e_cq_param rx_cq;
39-
struct mlx5e_cq_param tx_cq;
40-
struct mlx5e_cq_param icosq_cq;
40+
struct mlx5e_sq_param async_icosq;
4141
};
4242

4343
static inline bool mlx5e_qid_get_ch_if_in_group(struct mlx5e_params *params,

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
enum mlx5e_icosq_wqe_type {
1212
MLX5E_ICOSQ_WQE_NOP,
1313
MLX5E_ICOSQ_WQE_UMR_RX,
14+
#ifdef CONFIG_MLX5_EN_TLS
15+
MLX5E_ICOSQ_WQE_UMR_TLS,
16+
MLX5E_ICOSQ_WQE_SET_PSV_TLS,
17+
MLX5E_ICOSQ_WQE_GET_PSV_TLS,
18+
#endif
1419
};
1520

1621
static inline bool
@@ -114,9 +119,19 @@ struct mlx5e_icosq_wqe_info {
114119
struct {
115120
struct mlx5e_rq *rq;
116121
} umr;
122+
#ifdef CONFIG_MLX5_EN_TLS
123+
struct {
124+
struct mlx5e_ktls_offload_context_rx *priv_rx;
125+
} tls_set_params;
126+
struct {
127+
struct mlx5e_ktls_rx_resync_buf *buf;
128+
} tls_get_params;
129+
#endif
117130
};
118131
};
119132

133+
void mlx5e_free_icosq_descs(struct mlx5e_icosq *sq);
134+
120135
static inline u16 mlx5e_icosq_get_next_pi(struct mlx5e_icosq *sq, u16 size)
121136
{
122137
struct mlx5_wq_cyc *wq = &sq->wq;
@@ -182,7 +197,7 @@ mlx5e_notify_hw(struct mlx5_wq_cyc *wq, u16 pc, void __iomem *uar_map,
182197

183198
static inline bool mlx5e_transport_inline_tx_wqe(struct mlx5_wqe_ctrl_seg *cseg)
184199
{
185-
return cseg && !!cseg->tisn;
200+
return cseg && !!cseg->tis_tir_num;
186201
}
187202

188203
static inline u8

0 commit comments

Comments
 (0)