Skip to content

Commit 2d9dac5

Browse files
rleondavem330
authored andcommitted
net/mlx5e: Present succeeded IPsec SA bytes and packet
IPsec SA statistics presents successfully decrypted and encrypted packet and bytes, and not total handled by this SA. So update the calculation logic to take into account failures. Fixes: 6fb7f94 ("net/mlx5e: Connect mlx5 IPsec statistics with XFRM core") Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1da839e commit 2d9dac5

File tree

1 file changed

+23
-13
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/en_accel

1 file changed

+23
-13
lines changed

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

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,10 @@ static void mlx5e_xfrm_update_stats(struct xfrm_state *x)
989989
struct mlx5e_ipsec_sa_entry *sa_entry = to_ipsec_sa_entry(x);
990990
struct mlx5e_ipsec_rule *ipsec_rule = &sa_entry->ipsec_rule;
991991
struct net *net = dev_net(x->xso.dev);
992+
u64 trailer_packets = 0, trailer_bytes = 0;
993+
u64 replay_packets = 0, replay_bytes = 0;
994+
u64 auth_packets = 0, auth_bytes = 0;
995+
u64 success_packets, success_bytes;
992996
u64 packets, bytes, lastuse;
993997

994998
lockdep_assert(lockdep_is_held(&x->lock) ||
@@ -999,26 +1003,32 @@ static void mlx5e_xfrm_update_stats(struct xfrm_state *x)
9991003
return;
10001004

10011005
if (sa_entry->attrs.dir == XFRM_DEV_OFFLOAD_IN) {
1002-
mlx5_fc_query_cached(ipsec_rule->auth.fc, &bytes, &packets, &lastuse);
1003-
x->stats.integrity_failed += packets;
1004-
XFRM_ADD_STATS(net, LINUX_MIB_XFRMINSTATEPROTOERROR, packets);
1005-
1006-
mlx5_fc_query_cached(ipsec_rule->trailer.fc, &bytes, &packets, &lastuse);
1007-
XFRM_ADD_STATS(net, LINUX_MIB_XFRMINHDRERROR, packets);
1006+
mlx5_fc_query_cached(ipsec_rule->auth.fc, &auth_bytes,
1007+
&auth_packets, &lastuse);
1008+
x->stats.integrity_failed += auth_packets;
1009+
XFRM_ADD_STATS(net, LINUX_MIB_XFRMINSTATEPROTOERROR, auth_packets);
1010+
1011+
mlx5_fc_query_cached(ipsec_rule->trailer.fc, &trailer_bytes,
1012+
&trailer_packets, &lastuse);
1013+
XFRM_ADD_STATS(net, LINUX_MIB_XFRMINHDRERROR, trailer_packets);
10081014
}
10091015

10101016
if (x->xso.type != XFRM_DEV_OFFLOAD_PACKET)
10111017
return;
10121018

1013-
mlx5_fc_query_cached(ipsec_rule->fc, &bytes, &packets, &lastuse);
1014-
x->curlft.packets += packets;
1015-
x->curlft.bytes += bytes;
1016-
10171019
if (sa_entry->attrs.dir == XFRM_DEV_OFFLOAD_IN) {
1018-
mlx5_fc_query_cached(ipsec_rule->replay.fc, &bytes, &packets, &lastuse);
1019-
x->stats.replay += packets;
1020-
XFRM_ADD_STATS(net, LINUX_MIB_XFRMINSTATESEQERROR, packets);
1020+
mlx5_fc_query_cached(ipsec_rule->replay.fc, &replay_bytes,
1021+
&replay_packets, &lastuse);
1022+
x->stats.replay += replay_packets;
1023+
XFRM_ADD_STATS(net, LINUX_MIB_XFRMINSTATESEQERROR, replay_packets);
10211024
}
1025+
1026+
mlx5_fc_query_cached(ipsec_rule->fc, &bytes, &packets, &lastuse);
1027+
success_packets = packets - auth_packets - trailer_packets - replay_packets;
1028+
x->curlft.packets += success_packets;
1029+
1030+
success_bytes = bytes - auth_bytes - trailer_bytes - replay_bytes;
1031+
x->curlft.bytes += success_bytes;
10221032
}
10231033

10241034
static int mlx5e_xfrm_validate_policy(struct mlx5_core_dev *mdev,

0 commit comments

Comments
 (0)