Skip to content

Commit e562f2d

Browse files
rleondavem330
authored andcommitted
net/mlx5e: Approximate IPsec per-SA payload data bytes count
ConnectX devices lack ability to count payload data byte size which is needed for SA to return to libreswan for rekeying. As a solution let's approximate that by decreasing headers size from total size counted by flow steering. The calculation doesn't take into account any other headers which can be in the packet (e.g. IP extensions). Fixes: 5a6cddb ("net/mlx5e: Update IPsec per SA packets/bytes count") Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2d9dac5 commit e562f2d

File tree

1 file changed

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

1 file changed

+13
-1
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,7 @@ static void mlx5e_xfrm_update_stats(struct xfrm_state *x)
994994
u64 auth_packets = 0, auth_bytes = 0;
995995
u64 success_packets, success_bytes;
996996
u64 packets, bytes, lastuse;
997+
size_t headers;
997998

998999
lockdep_assert(lockdep_is_held(&x->lock) ||
9991000
lockdep_is_held(&dev_net(x->xso.real_dev)->xfrm.xfrm_cfg_mutex) ||
@@ -1026,9 +1027,20 @@ static void mlx5e_xfrm_update_stats(struct xfrm_state *x)
10261027
mlx5_fc_query_cached(ipsec_rule->fc, &bytes, &packets, &lastuse);
10271028
success_packets = packets - auth_packets - trailer_packets - replay_packets;
10281029
x->curlft.packets += success_packets;
1030+
/* NIC counts all bytes passed through flow steering and doesn't have
1031+
* an ability to count payload data size which is needed for SA.
1032+
*
1033+
* To overcome HW limitestion, let's approximate the payload size
1034+
* by removing always available headers.
1035+
*/
1036+
headers = sizeof(struct ethhdr);
1037+
if (sa_entry->attrs.family == AF_INET)
1038+
headers += sizeof(struct iphdr);
1039+
else
1040+
headers += sizeof(struct ipv6hdr);
10291041

10301042
success_bytes = bytes - auth_bytes - trailer_bytes - replay_bytes;
1031-
x->curlft.bytes += success_bytes;
1043+
x->curlft.bytes += success_bytes - headers * success_packets;
10321044
}
10331045

10341046
static int mlx5e_xfrm_validate_policy(struct mlx5_core_dev *mdev,

0 commit comments

Comments
 (0)