Skip to content

Commit 43585a4

Browse files
Ilya Lesokhindavem330
authored andcommitted
net/mlx5e: TLS, Add error statistics
Add statistics for rare TLS related errors. Since the errors are rare we have a counter per netdev rather then per SQ. Signed-off-by: Ilya Lesokhin <[email protected]> Signed-off-by: Boris Pismenny <[email protected]> Acked-by: Saeed Mahameed <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent bf23974 commit 43585a4

File tree

8 files changed

+178
-10
lines changed

8 files changed

+178
-10
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ mlx5_core-$(CONFIG_MLX5_CORE_IPOIB) += ipoib/ipoib.o ipoib/ethtool.o ipoib/ipoib
2828
mlx5_core-$(CONFIG_MLX5_EN_IPSEC) += en_accel/ipsec.o en_accel/ipsec_rxtx.o \
2929
en_accel/ipsec_stats.o
3030

31-
mlx5_core-$(CONFIG_MLX5_EN_TLS) += en_accel/tls.o en_accel/tls_rxtx.o
31+
mlx5_core-$(CONFIG_MLX5_EN_TLS) += en_accel/tls.o en_accel/tls_rxtx.o en_accel/tls_stats.o
3232

3333
CFLAGS_tracepoint.o := -I$(src)

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,9 @@ struct mlx5e_priv {
801801
#ifdef CONFIG_MLX5_EN_IPSEC
802802
struct mlx5e_ipsec *ipsec;
803803
#endif
804+
#ifdef CONFIG_MLX5_EN_TLS
805+
struct mlx5e_tls *tls;
806+
#endif
804807
};
805808

806809
struct mlx5e_profile {

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,25 @@ void mlx5e_tls_build_netdev(struct mlx5e_priv *priv)
173173
netdev->hw_features |= NETIF_F_HW_TLS_TX;
174174
netdev->tlsdev_ops = &mlx5e_tls_ops;
175175
}
176+
177+
int mlx5e_tls_init(struct mlx5e_priv *priv)
178+
{
179+
struct mlx5e_tls *tls = kzalloc(sizeof(*tls), GFP_KERNEL);
180+
181+
if (!tls)
182+
return -ENOMEM;
183+
184+
priv->tls = tls;
185+
return 0;
186+
}
187+
188+
void mlx5e_tls_cleanup(struct mlx5e_priv *priv)
189+
{
190+
struct mlx5e_tls *tls = priv->tls;
191+
192+
if (!tls)
193+
return;
194+
195+
kfree(tls);
196+
priv->tls = NULL;
197+
}

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@
3838
#include <net/tls.h>
3939
#include "en.h"
4040

41+
struct mlx5e_tls_sw_stats {
42+
atomic64_t tx_tls_drop_metadata;
43+
atomic64_t tx_tls_drop_resync_alloc;
44+
atomic64_t tx_tls_drop_no_sync_data;
45+
atomic64_t tx_tls_drop_bypass_required;
46+
};
47+
48+
struct mlx5e_tls {
49+
struct mlx5e_tls_sw_stats sw_stats;
50+
};
51+
4152
struct mlx5e_tls_offload_context {
4253
struct tls_offload_context base;
4354
u32 expected_seq;
@@ -55,10 +66,21 @@ mlx5e_get_tls_tx_context(struct tls_context *tls_ctx)
5566
}
5667

5768
void mlx5e_tls_build_netdev(struct mlx5e_priv *priv);
69+
int mlx5e_tls_init(struct mlx5e_priv *priv);
70+
void mlx5e_tls_cleanup(struct mlx5e_priv *priv);
71+
72+
int mlx5e_tls_get_count(struct mlx5e_priv *priv);
73+
int mlx5e_tls_get_strings(struct mlx5e_priv *priv, uint8_t *data);
74+
int mlx5e_tls_get_stats(struct mlx5e_priv *priv, u64 *data);
5875

5976
#else
6077

6178
static inline void mlx5e_tls_build_netdev(struct mlx5e_priv *priv) { }
79+
static inline int mlx5e_tls_init(struct mlx5e_priv *priv) { return 0; }
80+
static inline void mlx5e_tls_cleanup(struct mlx5e_priv *priv) { }
81+
static inline int mlx5e_tls_get_count(struct mlx5e_priv *priv) { return 0; }
82+
static inline int mlx5e_tls_get_strings(struct mlx5e_priv *priv, uint8_t *data) { return 0; }
83+
static inline int mlx5e_tls_get_stats(struct mlx5e_priv *priv, u64 *data) { return 0; }
6284

6385
#endif
6486

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

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ static struct sk_buff *
164164
mlx5e_tls_handle_ooo(struct mlx5e_tls_offload_context *context,
165165
struct mlx5e_txqsq *sq, struct sk_buff *skb,
166166
struct mlx5e_tx_wqe **wqe,
167-
u16 *pi)
167+
u16 *pi,
168+
struct mlx5e_tls *tls)
168169
{
169170
u32 tcp_seq = ntohl(tcp_hdr(skb)->seq);
170171
struct sync_info info;
@@ -175,12 +176,14 @@ mlx5e_tls_handle_ooo(struct mlx5e_tls_offload_context *context,
175176

176177
sq->stats.tls_ooo++;
177178

178-
if (mlx5e_tls_get_sync_data(context, tcp_seq, &info))
179+
if (mlx5e_tls_get_sync_data(context, tcp_seq, &info)) {
179180
/* We might get here if a retransmission reaches the driver
180181
* after the relevant record is acked.
181182
* It should be safe to drop the packet in this case
182183
*/
184+
atomic64_inc(&tls->sw_stats.tx_tls_drop_no_sync_data);
183185
goto err_out;
186+
}
184187

185188
if (unlikely(info.sync_len < 0)) {
186189
u32 payload;
@@ -192,21 +195,22 @@ mlx5e_tls_handle_ooo(struct mlx5e_tls_offload_context *context,
192195
*/
193196
return skb;
194197

195-
netdev_err(skb->dev,
196-
"Can't offload from the middle of an SKB [seq: %X, offload_seq: %X, end_seq: %X]\n",
197-
tcp_seq, tcp_seq + payload + info.sync_len,
198-
tcp_seq + payload);
198+
atomic64_inc(&tls->sw_stats.tx_tls_drop_bypass_required);
199199
goto err_out;
200200
}
201201

202-
if (unlikely(mlx5e_tls_add_metadata(skb, context->swid)))
202+
if (unlikely(mlx5e_tls_add_metadata(skb, context->swid))) {
203+
atomic64_inc(&tls->sw_stats.tx_tls_drop_metadata);
203204
goto err_out;
205+
}
204206

205207
headln = skb_transport_offset(skb) + tcp_hdrlen(skb);
206208
linear_len += headln + sizeof(info.rcd_sn);
207209
nskb = alloc_skb(linear_len, GFP_ATOMIC);
208-
if (unlikely(!nskb))
210+
if (unlikely(!nskb)) {
211+
atomic64_inc(&tls->sw_stats.tx_tls_drop_resync_alloc);
209212
goto err_out;
213+
}
210214

211215
context->expected_seq = tcp_seq + skb->len - headln;
212216
skb_put(nskb, linear_len);
@@ -234,6 +238,7 @@ struct sk_buff *mlx5e_tls_handle_tx_skb(struct net_device *netdev,
234238
struct mlx5e_tx_wqe **wqe,
235239
u16 *pi)
236240
{
241+
struct mlx5e_priv *priv = netdev_priv(netdev);
237242
struct mlx5e_tls_offload_context *context;
238243
struct tls_context *tls_ctx;
239244
u32 expected_seq;
@@ -256,11 +261,12 @@ struct sk_buff *mlx5e_tls_handle_tx_skb(struct net_device *netdev,
256261
expected_seq = context->expected_seq;
257262

258263
if (unlikely(expected_seq != skb_seq)) {
259-
skb = mlx5e_tls_handle_ooo(context, sq, skb, wqe, pi);
264+
skb = mlx5e_tls_handle_ooo(context, sq, skb, wqe, pi, priv->tls);
260265
goto out;
261266
}
262267

263268
if (unlikely(mlx5e_tls_add_metadata(skb, context->swid))) {
269+
atomic64_inc(&priv->tls->sw_stats.tx_tls_drop_metadata);
264270
dev_kfree_skb_any(skb);
265271
skb = NULL;
266272
goto out;
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
* Copyright (c) 2018 Mellanox Technologies. All rights reserved.
3+
*
4+
* This software is available to you under a choice of one of two
5+
* licenses. You may choose to be licensed under the terms of the GNU
6+
* General Public License (GPL) Version 2, available from the file
7+
* COPYING in the main directory of this source tree, or the
8+
* OpenIB.org BSD license below:
9+
*
10+
* Redistribution and use in source and binary forms, with or
11+
* without modification, are permitted provided that the following
12+
* conditions are met:
13+
*
14+
* - Redistributions of source code must retain the above
15+
* copyright notice, this list of conditions and the following
16+
* disclaimer.
17+
*
18+
* - Redistributions in binary form must reproduce the above
19+
* copyright notice, this list of conditions and the following
20+
* disclaimer in the documentation and/or other materials
21+
* provided with the distribution.
22+
*
23+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27+
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28+
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30+
* SOFTWARE.
31+
*
32+
*/
33+
34+
#include <linux/ethtool.h>
35+
#include <net/sock.h>
36+
37+
#include "en.h"
38+
#include "accel/tls.h"
39+
#include "fpga/sdk.h"
40+
#include "en_accel/tls.h"
41+
42+
static const struct counter_desc mlx5e_tls_sw_stats_desc[] = {
43+
{ MLX5E_DECLARE_STAT(struct mlx5e_tls_sw_stats, tx_tls_drop_metadata) },
44+
{ MLX5E_DECLARE_STAT(struct mlx5e_tls_sw_stats, tx_tls_drop_resync_alloc) },
45+
{ MLX5E_DECLARE_STAT(struct mlx5e_tls_sw_stats, tx_tls_drop_no_sync_data) },
46+
{ MLX5E_DECLARE_STAT(struct mlx5e_tls_sw_stats, tx_tls_drop_bypass_required) },
47+
};
48+
49+
#define MLX5E_READ_CTR_ATOMIC64(ptr, dsc, i) \
50+
atomic64_read((atomic64_t *)((char *)(ptr) + (dsc)[i].offset))
51+
52+
#define NUM_TLS_SW_COUNTERS ARRAY_SIZE(mlx5e_tls_sw_stats_desc)
53+
54+
int mlx5e_tls_get_count(struct mlx5e_priv *priv)
55+
{
56+
if (!priv->tls)
57+
return 0;
58+
59+
return NUM_TLS_SW_COUNTERS;
60+
}
61+
62+
int mlx5e_tls_get_strings(struct mlx5e_priv *priv, uint8_t *data)
63+
{
64+
unsigned int i, idx = 0;
65+
66+
if (!priv->tls)
67+
return 0;
68+
69+
for (i = 0; i < NUM_TLS_SW_COUNTERS; i++)
70+
strcpy(data + (idx++) * ETH_GSTRING_LEN,
71+
mlx5e_tls_sw_stats_desc[i].format);
72+
73+
return NUM_TLS_SW_COUNTERS;
74+
}
75+
76+
int mlx5e_tls_get_stats(struct mlx5e_priv *priv, u64 *data)
77+
{
78+
int i, idx = 0;
79+
80+
if (!priv->tls)
81+
return 0;
82+
83+
for (i = 0; i < NUM_TLS_SW_COUNTERS; i++)
84+
data[idx++] =
85+
MLX5E_READ_CTR_ATOMIC64(&priv->tls->sw_stats,
86+
mlx5e_tls_sw_stats_desc, i);
87+
88+
return NUM_TLS_SW_COUNTERS;
89+
}

drivers/net/ethernet/mellanox/mlx5/core/en_main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4422,12 +4422,16 @@ static void mlx5e_nic_init(struct mlx5_core_dev *mdev,
44224422
err = mlx5e_ipsec_init(priv);
44234423
if (err)
44244424
mlx5_core_err(mdev, "IPSec initialization failed, %d\n", err);
4425+
err = mlx5e_tls_init(priv);
4426+
if (err)
4427+
mlx5_core_err(mdev, "TLS initialization failed, %d\n", err);
44254428
mlx5e_build_nic_netdev(netdev);
44264429
mlx5e_vxlan_init(priv);
44274430
}
44284431

44294432
static void mlx5e_nic_cleanup(struct mlx5e_priv *priv)
44304433
{
4434+
mlx5e_tls_cleanup(priv);
44314435
mlx5e_ipsec_cleanup(priv);
44324436
mlx5e_vxlan_cleanup(priv);
44334437
}

drivers/net/ethernet/mellanox/mlx5/core/en_stats.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
#include "en.h"
3434
#include "en_accel/ipsec.h"
35+
#include "en_accel/tls.h"
3536

3637
static const struct counter_desc sw_stats_desc[] = {
3738
{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_packets) },
@@ -1075,6 +1076,22 @@ static void mlx5e_grp_ipsec_update_stats(struct mlx5e_priv *priv)
10751076
mlx5e_ipsec_update_stats(priv);
10761077
}
10771078

1079+
static int mlx5e_grp_tls_get_num_stats(struct mlx5e_priv *priv)
1080+
{
1081+
return mlx5e_tls_get_count(priv);
1082+
}
1083+
1084+
static int mlx5e_grp_tls_fill_strings(struct mlx5e_priv *priv, u8 *data,
1085+
int idx)
1086+
{
1087+
return idx + mlx5e_tls_get_strings(priv, data + idx * ETH_GSTRING_LEN);
1088+
}
1089+
1090+
static int mlx5e_grp_tls_fill_stats(struct mlx5e_priv *priv, u64 *data, int idx)
1091+
{
1092+
return idx + mlx5e_tls_get_stats(priv, data + idx);
1093+
}
1094+
10781095
static const struct counter_desc rq_stats_desc[] = {
10791096
{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, packets) },
10801097
{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, bytes) },
@@ -1277,6 +1294,11 @@ const struct mlx5e_stats_grp mlx5e_stats_grps[] = {
12771294
.fill_stats = mlx5e_grp_ipsec_fill_stats,
12781295
.update_stats = mlx5e_grp_ipsec_update_stats,
12791296
},
1297+
{
1298+
.get_num_stats = mlx5e_grp_tls_get_num_stats,
1299+
.fill_strings = mlx5e_grp_tls_fill_strings,
1300+
.fill_stats = mlx5e_grp_tls_fill_stats,
1301+
},
12801302
{
12811303
.get_num_stats = mlx5e_grp_channels_get_num_stats,
12821304
.fill_strings = mlx5e_grp_channels_fill_strings,

0 commit comments

Comments
 (0)