Subject: Re: [PATCH xfrm-next v2 0/6] Extend XFRM core to allow full offload configuration

From: Jakub Kicinski <[email-masked]>
Date: Wed, 17 Aug 2022 11:10:52 -0700

On Wed, 17 Aug 2022 08:22:02 +0300 Leon Romanovsky wrote:
> On Tue, Aug 16, 2022 at 07:54:08PM -0700, Jakub Kicinski wrote:
> > This is making a precedent for full tunnel offload in netdev, right?  
> 
> Not really. SW IPsec supports two modes: tunnel and transport.
> 
> However HW and SW stack supports only offload of transport mode.
> This is the case for already merged IPsec crypto offload mode and
> the case for this full offload.

My point is on what you called "full offload" vs "crypto offload".
The policy so far has always been that Linux networking stack should
populate all the headers and instruct the device to do crypto, no
header insertion. Obviously we do header insertion in switch/router
offloads but that's different and stateless.

I believe the reasoning was to provide as much flexibility and control
to the software as possible while retaining most of the performance
gains.

You must provide a clear analysis (as in examination in data) and
discussion (as in examination in writing) if you're intending to 
change the "let's keep packet formation in the SW" policy. What you 
got below is a good start but not sufficient.

> > Could you indulge us with a more detailed description, motivation,
> > performance results, where the behavior of offload may differ (if at
> > all), what visibility users have, how SW and HW work together on the
> > datapath? Documentation would be great.  
> 
> IPsec full offload is actually improved version of IPsec crypto mode,
> In full mode, HW is responsible to trim/add headers in addition to
> decrypt/encrypt. In this mode, the packet arrives to the stack as already
> decrypted and vice versa for TX (exits to HW as not-encrypted).
> 
> My main motivation is to perform IPsec on RoCE traffic and in our
> preliminary results, we are able to do IPsec full offload in line
> rate. The same goes for ETH traffic.

If the motivation is RoCE I personally see no reason to provide the
configuration of this functionality via netdev interfaces, but I'll
obviously leave the final decision to Steffen.

> Regarding behavior differences - they are not expected.
> 
> We (Raed and me) tried very hard to make sure that IPsec full offload
> will behave exactly as SW path.
> 
> There are some limitations to reduce complexity, but they can be removed
> later if needs will arise. Right now, none of them are "real" limitations
> for various *swarn forks, which we extend as well.
> 
> Some of them:
> 1. Request to have reqid for policy and state. I use reqid for HW
> matching between policy and state.

reqid?

> 2. Automatic separation between HW and SW priorities, because HW sees
> packet first.

More detail needed on that.

> 3. Only main template is supported.
> 4. No fallback to SW if IPsec HW failed to handle packet. HW should drop
> such packet.

Not great for debug.

> Visibility:
> Users can see the mode through iproute2
> https://lore.kernel.org/netdev/[email-masked]/
> and see statistics through ethtool.

Custom vendor stats?

> Documentation will come as well. I assume that IPsec folks are familiar
> with this topic as it was discussed in IPsec coffee hour.