All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Simon Horman <simon.horman@corigine.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Steffen Klassert <steffen.klassert@secunet.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	netdev@vger.kernel.org, Saeed Mahameed <saeedm@nvidia.com>,
	Raed Salem <raeds@nvidia.com>, Emeel Hakim <ehakim@nvidia.com>
Subject: Re: [PATCH net-next 05/10] net/mlx5e: Support IPsec RX packet offload in tunnel mode
Date: Thu, 13 Apr 2023 14:46:36 +0300	[thread overview]
Message-ID: <20230413114636.GL17993@unreal> (raw)
In-Reply-To: <ZDWMr/CTs5kqzcNV@corigine.com>

On Tue, Apr 11, 2023 at 06:37:03PM +0200, Simon Horman wrote:
> On Mon, Apr 10, 2023 at 09:19:07AM +0300, Leon Romanovsky wrote:
> > From: Leon Romanovsky <leonro@nvidia.com>
> > 
> > Extend mlx5 driver with logic to support IPsec RX packet offload
> > in tunnel mode.
> > 
> > Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> 
> ...
> 
> > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c
> > index 980583fb1e52..8ecaf4100b9c 100644
> > --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c
> > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c
> > @@ -836,6 +836,60 @@ static int setup_modify_header(struct mlx5_core_dev *mdev, u32 val, u8 dir,
> >  	return 0;
> >  }
> >  
> > +static int
> > +setup_pkt_tunnel_reformat(struct mlx5_core_dev *mdev,
> > +			  struct mlx5_accel_esp_xfrm_attrs *attrs,
> > +			  struct mlx5_pkt_reformat_params *reformat_params)
> > +{
> > +	union {
> > +		struct {
> > +			u8 dmac[6];
> > +			u8 smac[6];
> > +			__be16 ethertype;
> > +		} __packed;
> > +		u8 raw[ETH_HLEN];
> > +	} __packed *mac_hdr;
> 
> Can struct ethhrd be used here?
> I think it has the same layout as the fields of the inner structure above.

Yes, it can, will change.

> And I don't think the union is giving us much: the raw field seems unused.

Thanks, it isn't needed here.

> 
> > +	char *reformatbf;
> > +	size_t bfflen;
> > +
> > +	bfflen = sizeof(*mac_hdr);
> > +
> > +	reformatbf = kzalloc(bfflen, GFP_KERNEL);
> 
> I'm not sure that reformatbf is providing much value.

It is more useful in next patch, where reformatbf will hold ESP, ipv4/6 and ETH
headers.

> Perhaps:
> 
> 	mac_hdr = kzalloc(bfflen, GFP_KERNEL);
> 
> > +	if (!reformatbf)
> > +		return -ENOMEM;
> > +
> > +	mac_hdr = (void *)reformatbf;
> 
> If you must cast, perhaps to the type of mac_hdr, which is not void *.

I'll change.

> 
> > +	switch (attrs->family) {
> > +	case AF_INET:
> > +		mac_hdr->ethertype = htons(ETH_P_IP);
> > +		break;
> > +	case AF_INET6:
> > +		mac_hdr->ethertype = htons(ETH_P_IPV6);
> > +		break;
> > +	default:
> > +		goto free_reformatbf;
> > +	}
> > +
> > +	ether_addr_copy(mac_hdr->dmac, attrs->dmac);
> > +	ether_addr_copy(mac_hdr->smac, attrs->smac);
> > +
> > +	switch (attrs->dir) {
> > +	case XFRM_DEV_OFFLOAD_IN:
> > +		reformat_params->type = MLX5_REFORMAT_TYPE_L3_ESP_TUNNEL_TO_L2;
> > +		break;
> > +	default:
> > +		goto free_reformatbf;
> > +	}
> > +
> > +	reformat_params->size = bfflen;
> > +	reformat_params->data = reformatbf;
> > +	return 0;
> > +
> > +free_reformatbf:
> > +	kfree(reformatbf);
> > +	return -EINVAL;
> > +}
> 
> ...

  reply	other threads:[~2023-04-13 11:46 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-10  6:19 [PATCH net-next 00/10] Support tunnel mode in mlx5 IPsec packet offload Leon Romanovsky
2023-04-10  6:19 ` [PATCH net-next 01/10] net/mlx5e: Add IPsec packet offload tunnel bits Leon Romanovsky
2023-04-11 16:39   ` Simon Horman
2023-04-10  6:19 ` [PATCH net-next 02/10] net/mlx5e: Check IPsec packet offload tunnel capabilities Leon Romanovsky
2023-04-11 16:39   ` Simon Horman
2023-04-10  6:19 ` [PATCH net-next 03/10] net/mlx5e: Configure IPsec SA tables to support tunnel mode Leon Romanovsky
2023-04-11 16:40   ` Simon Horman
2023-04-10  6:19 ` [PATCH net-next 04/10] net/mlx5e: Prepare IPsec packet reformat code for " Leon Romanovsky
2023-04-11 16:00   ` Simon Horman
2023-04-11 16:37     ` Leon Romanovsky
2023-04-11 17:38       ` Simon Horman
2023-04-13 12:07     ` Leon Romanovsky
2023-04-10  6:19 ` [PATCH net-next 05/10] net/mlx5e: Support IPsec RX packet offload in " Leon Romanovsky
2023-04-11 16:37   ` Simon Horman
2023-04-13 11:46     ` Leon Romanovsky [this message]
2023-04-10  6:19 ` [PATCH net-next 06/10] net/mlx5e: Support IPsec TX " Leon Romanovsky
2023-04-10  6:19 ` [PATCH net-next 07/10] net/mlx5e: Listen to ARP events to update IPsec L2 headers " Leon Romanovsky
2023-04-10  6:19 ` [PATCH net-next 08/10] net/mlx5: Allow blocking encap changes in eswitch Leon Romanovsky
2023-04-10  6:19 ` [PATCH net-next 09/10] net/mlx5e: Create IPsec table with tunnel support only when encap is disabled Leon Romanovsky
2023-04-10 14:29   ` Simon Horman
2023-04-10 16:49     ` Leon Romanovsky
2023-04-10 18:10       ` Simon Horman
2023-04-11 12:47         ` Leon Romanovsky
2023-04-13 11:21           ` Leon Romanovsky
2023-04-10  6:19 ` [PATCH net-next 10/10] net/mlx5e: Accept tunnel mode for IPsec packet offload Leon Romanovsky

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=20230413114636.GL17993@unreal \
    --to=leon@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=ehakim@nvidia.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=raeds@nvidia.com \
    --cc=saeedm@nvidia.com \
    --cc=simon.horman@corigine.com \
    --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.