All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Steffen Klassert <steffen.klassert@secunet.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, Bharat Bhushan <bbhushan2@marvell.com>
Subject: Re: [PATCH xfrm-next v9 4/8] xfrm: add TX datapath support for IPsec packet offload mode
Date: Fri, 2 Dec 2022 19:59:30 +0200	[thread overview]
Message-ID: <Y4o9As2tt5RxoDgP@unreal> (raw)
In-Reply-To: <20221202093028.GZ704954@gauss3.secunet.de>

On Fri, Dec 02, 2022 at 10:30:28AM +0100, Steffen Klassert wrote:
> On Sun, Nov 27, 2022 at 01:18:14PM +0200, Leon Romanovsky wrote:
> > From: Leon Romanovsky <leonro@nvidia.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@nvidia.com>
> > Signed-off-by: Huy Nguyen <huyn@nvidia.com>
> > Signed-off-by: Leon Romanovsky <leonro@nvidia.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.

Absolutely. Thanks

> 
> > +#endif
> >  			x->km.state = XFRM_STATE_DEAD;
> >  			to_put = x;
> >  			x = NULL;
> > -- 
> > 2.38.1

  reply	other threads:[~2022-12-02 17:59 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-27 11:18 [PATCH xfrm-next v9 0/8] Extend XFRM core to allow packet offload configuration Leon Romanovsky
2022-11-27 11:18 ` [PATCH xfrm-next v9 1/8] xfrm: add new packet offload flag Leon Romanovsky
2022-11-27 11:18 ` [PATCH xfrm-next v9 2/8] xfrm: allow state packet offload mode Leon Romanovsky
2022-11-27 11:18 ` [PATCH xfrm-next v9 3/8] xfrm: add an interface to offload policy Leon Romanovsky
2022-11-27 11:18 ` [PATCH xfrm-next v9 4/8] xfrm: add TX datapath support for IPsec packet offload mode Leon Romanovsky
2022-12-02  9:30   ` Steffen Klassert
2022-12-02 17:59     ` Leon Romanovsky [this message]
2022-11-27 11:18 ` [PATCH xfrm-next v9 5/8] xfrm: add RX datapath protection " Leon Romanovsky
2022-11-27 11:18 ` [PATCH xfrm-next v9 6/8] xfrm: speed-up lookup of HW policies Leon Romanovsky
2022-11-27 11:18 ` [PATCH xfrm-next v9 7/8] xfrm: add support to HW update soft and hard limits Leon Romanovsky
2022-11-27 11:18 ` [PATCH xfrm-next v9 8/8] xfrm: document IPsec packet offload mode Leon Romanovsky
2022-12-02  9:42 ` [PATCH xfrm-next v9 0/8] Extend XFRM core to allow packet offload configuration Steffen Klassert
2022-12-02 18:05   ` Leon Romanovsky
2022-12-02 18:10     ` Jakub Kicinski
2022-12-02 18:31       ` Leon Romanovsky
2022-12-02 19:26         ` Jakub Kicinski
2022-12-02 19:45           ` Leon Romanovsky
2022-12-02 19:52             ` Jakub Kicinski
2022-12-05  9:23               ` Steffen Klassert
2022-12-06  0:09                 ` Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y4o9As2tt5RxoDgP@unreal \
    --to=leon@kernel.org \
    --cc=bbhushan2@marvell.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=steffen.klassert@secunet.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.