[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221202093028.GZ704954@gauss3.secunet.de>
Date: Fri, 2 Dec 2022 10:30:28 +0100
From: Steffen Klassert <steffen.klassert@...unet.com>
To: Leon Romanovsky <leon@...nel.org>
CC: Leon Romanovsky <leonro@...dia.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Herbert Xu <herbert@...dor.apana.org.au>,
Jakub Kicinski <kuba@...nel.org>, <netdev@...r.kernel.org>,
Bharat Bhushan <bbhushan2@...vell.com>
Subject: Re: [PATCH xfrm-next v9 4/8] xfrm: add TX datapath support for IPsec
packet offload mode
On Sun, Nov 27, 2022 at 01:18:14PM +0200, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@...dia.com>
>
> In IPsec packet mode, the device is going to encrypt and encapsulate
> packets that are associated with offloaded policy. After successful
> policy lookup to indicate if packets should be offloaded or not,
> the stack forwards packets to the device to do the magic.
>
> Signed-off-by: Raed Salem <raeds@...dia.com>
> Signed-off-by: Huy Nguyen <huyn@...dia.com>
> Signed-off-by: Leon Romanovsky <leonro@...dia.com>
> ---
> net/xfrm/xfrm_device.c | 15 +++++-
> net/xfrm/xfrm_output.c | 12 ++++-
> net/xfrm/xfrm_state.c | 120 +++++++++++++++++++++++++++++++++++++++--
> 3 files changed, 141 insertions(+), 6 deletions(-)
...
> @@ -1161,7 +1240,31 @@ xfrm_state_find(const xfrm_address_t *daddr, const xfrm_address_t *saddr,
> x = NULL;
> goto out;
> }
> -
> +#ifdef CONFIG_XFRM_OFFLOAD
> + if (pol->xdo.type == XFRM_DEV_OFFLOAD_PACKET) {
> + struct xfrm_dev_offload *xdo = &pol->xdo;
> + struct xfrm_dev_offload *xso = &x->xso;
> +
> + xso->type = XFRM_DEV_OFFLOAD_PACKET;
> + xso->dir = xdo->dir;
> + xso->dev = xdo->dev;
> + xso->real_dev = xdo->real_dev;
> + netdev_tracker_alloc(xso->dev, &xso->dev_tracker,
> + GFP_ATOMIC);
> + error = xso->dev->xfrmdev_ops->xdo_dev_state_add(x);
> + if (error) {
> + xso->dir = 0;
> + netdev_put(xso->dev, &xso->dev_tracker);
> + xso->dev = NULL;
> + xso->real_dev = NULL;
> + xso->type = XFRM_DEV_OFFLOAD_UNSPECIFIED;
> + x->km.state = XFRM_STATE_DEAD;
> + to_put = x;
> + x = NULL;
> + goto out;
> + }
> + }
> +#endif
> if (km_query(x, tmpl, pol) == 0) {
> spin_lock_bh(&net->xfrm.xfrm_state_lock);
> x->km.state = XFRM_STATE_ACQ;
> @@ -1185,6 +1288,17 @@ xfrm_state_find(const xfrm_address_t *daddr, const xfrm_address_t *saddr,
> xfrm_hash_grow_check(net, x->bydst.next != NULL);
> spin_unlock_bh(&net->xfrm.xfrm_state_lock);
> } else {
> +#ifdef CONFIG_XFRM_OFFLOAD
> + struct xfrm_dev_offload *xso = &x->xso;
> +
> + if (xso->type == XFRM_DEV_OFFLOAD_PACKET) {
> + xso->dir = 0;
> + netdev_put(xso->dev, &xso->dev_tracker);
> + xso->dev = NULL;
> + xso->real_dev = NULL;
> + xso->type = XFRM_DEV_OFFLOAD_UNSPECIFIED;
> + }
You do a xdo_dev_state_add call to add an acquire state to HW above.
Maybe we should do a xdo_dev_state_del call here when deleting the
acquire state.
> +#endif
> x->km.state = XFRM_STATE_DEAD;
> to_put = x;
> x = NULL;
> --
> 2.38.1
Powered by blists - more mailing lists