Skip to content

Commit 95cfe23

Browse files
Jianbo Liuklassert
authored andcommitted
xfrm: Skip redundant statistics update for crypto offload
In the crypto offload path, every packet is still processed by the software stack. The state's statistics required for the expiration check are being updated in software. However, the code also calls xfrm_dev_state_update_stats(), which triggers a query to the hardware device to fetch statistics. This hardware query is redundant and introduces unnecessary performance overhead. Skip this call when it's crypto offload (not packet offload) to avoid the unnecessary hardware access, thereby improving performance. Signed-off-by: Jianbo Liu <jianbol@nvidia.com> Reviewed-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
1 parent 94f3980 commit 95cfe23

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

net/xfrm/xfrm_state.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2282,7 +2282,12 @@ EXPORT_SYMBOL(xfrm_state_update);
22822282

22832283
int xfrm_state_check_expire(struct xfrm_state *x)
22842284
{
2285-
xfrm_dev_state_update_stats(x);
2285+
/* All counters which are needed to decide if state is expired
2286+
* are handled by SW for non-packet offload modes. Simply skip
2287+
* the following update and save extra boilerplate in drivers.
2288+
*/
2289+
if (x->xso.type == XFRM_DEV_OFFLOAD_PACKET)
2290+
xfrm_dev_state_update_stats(x);
22862291

22872292
if (!READ_ONCE(x->curlft.use_time))
22882293
WRITE_ONCE(x->curlft.use_time, ktime_get_real_seconds());

0 commit comments

Comments
 (0)