Skip to content

Commit

Permalink
xfrm: add new full offload flag
Browse files Browse the repository at this point in the history
In the next patches, the xfrm core code will be extended to support
new type of offload - full offload. In that mode, both policy and state
should be specially configured in order to perform whole offloaded data
path.

Full offload takes care of encryption, decryption, encapsulation and
other operations with headers.

As this mode is new for XFRM policy flow, we can "start fresh" with flag
bits and release first and second bit for future use.

Reviewed-by: Raed Salem <raeds@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
  • Loading branch information
rleon committed Jun 28, 2022
1 parent f41b284 commit 0a1347c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
7 changes: 7 additions & 0 deletions include/net/xfrm.h
Expand Up @@ -131,12 +131,19 @@ enum {
XFRM_DEV_OFFLOAD_OUT,
};

enum {
XFRM_DEV_OFFLOAD_UNSPECIFIED,
XFRM_DEV_OFFLOAD_CRYPTO,
XFRM_DEV_OFFLOAD_FULL,
};

struct xfrm_dev_offload {
struct net_device *dev;
netdevice_tracker dev_tracker;
struct net_device *real_dev;
unsigned long offload_handle;
u8 dir : 2;
u8 type : 2;
};

struct xfrm_mode {
Expand Down
6 changes: 6 additions & 0 deletions include/uapi/linux/xfrm.h
Expand Up @@ -519,6 +519,12 @@ struct xfrm_user_offload {
*/
#define XFRM_OFFLOAD_IPV6 1
#define XFRM_OFFLOAD_INBOUND 2
/* Two bits above are relevant for state path only, while
* offload is used for both policy and state flows.
*
* In policy offload mode, they are free and can be safely reused.
*/
#define XFRM_OFFLOAD_FULL 4

struct xfrm_userpolicy_default {
#define XFRM_USERPOLICY_UNSPEC 0
Expand Down
5 changes: 4 additions & 1 deletion net/xfrm/xfrm_device.c
Expand Up @@ -270,12 +270,15 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
else
xso->dir = XFRM_DEV_OFFLOAD_OUT;

xso->type = XFRM_DEV_OFFLOAD_CRYPTO;

err = dev->xfrmdev_ops->xdo_dev_state_add(x);
if (err) {
xso->dev = NULL;
xso->dir = 0;
xso->real_dev = NULL;
netdev_put(dev, &xso->dev_tracker);
dev_put_track(dev, &xso->dev_tracker);
xso->type = XFRM_DEV_OFFLOAD_UNSPECIFIED;

if (err != -EOPNOTSUPP)
return err;
Expand Down
2 changes: 2 additions & 0 deletions net/xfrm/xfrm_user.c
Expand Up @@ -854,6 +854,8 @@ static int copy_user_offload(struct xfrm_dev_offload *xso, struct sk_buff *skb)
xuo->ifindex = xso->dev->ifindex;
if (xso->dir == XFRM_DEV_OFFLOAD_IN)
xuo->flags = XFRM_OFFLOAD_INBOUND;
if (xso->type == XFRM_DEV_OFFLOAD_FULL)
xuo->flags |= XFRM_OFFLOAD_FULL;

return 0;
}
Expand Down

0 comments on commit 0a1347c

Please sign in to comment.