From: Simon Horman <simon.horman@corigine.com>
To: Leon Romanovsky <leon@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Leon Romanovsky <leonro@nvidia.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 04/10] net/mlx5e: Prepare IPsec packet reformat code for tunnel mode
Date: Tue, 11 Apr 2023 18:00:00 +0200 [thread overview]
Message-ID: <ZDWEACmSLgk83pIw@corigine.com> (raw)
In-Reply-To: <2f80bcfa0f7afdfa65848de9ddcba2c4c09cfe32.1681106636.git.leonro@nvidia.com>
On Mon, Apr 10, 2023 at 09:19:06AM +0300, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@nvidia.com>
>
> Refactor setup_pkt_reformat() function to accommodate future extension
> to support 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 060be020ca64..980583fb1e52 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,40 +836,78 @@ static int setup_modify_header(struct mlx5_core_dev *mdev, u32 val, u8 dir,
> return 0;
> }
>
> +static int
> +setup_pkt_transport_reformat(struct mlx5_accel_esp_xfrm_attrs *attrs,
> + struct mlx5_pkt_reformat_params *reformat_params)
> +{
> + u8 *reformatbf;
> + __be32 spi;
> +
> + switch (attrs->dir) {
> + case XFRM_DEV_OFFLOAD_IN:
> + reformat_params->type = MLX5_REFORMAT_TYPE_DEL_ESP_TRANSPORT;
> + break;
> + case XFRM_DEV_OFFLOAD_OUT:
> + if (attrs->family == AF_INET)
> + reformat_params->type =
> + MLX5_REFORMAT_TYPE_ADD_ESP_TRANSPORT_OVER_IPV4;
> + else
> + reformat_params->type =
> + MLX5_REFORMAT_TYPE_ADD_ESP_TRANSPORT_OVER_IPV6;
Maybe this is nicer? Maybe not.
reformat_params->type = attrs->family == AF_INET ?
MLX5_REFORMAT_TYPE_ADD_ESP_TRANSPORT_OVER_IPV4 :
MLX5_REFORMAT_TYPE_ADD_ESP_TRANSPORT_OVER_IPV6;
> +
> + reformatbf = kzalloc(16, GFP_KERNEL);
I know you are just moving code around.
But 16 is doing a lot of work in this function.
Could it be a #define ?
> + if (!reformatbf)
> + return -ENOMEM;
> +
> + /* convert to network format */
> + spi = htonl(attrs->spi);
> + memcpy(reformatbf, &spi, 4);
This seems to be a lot of work to copy a word.
But anyway, maybe:
memcpy(reformatbf, &spi, sizeof(spi));
> +
> + reformat_params->param_0 = attrs->authsize;
> + reformat_params->size = 16;
> + reformat_params->data = reformatbf;
> + break;
> + default:
> + return -EINVAL;
> + }
> +
> + return 0;
> +}
> +
...
next prev parent reply other threads:[~2023-04-11 16:00 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 [this message]
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
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=ZDWEACmSLgk83pIw@corigine.com \
--to=simon.horman@corigine.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=ehakim@nvidia.com \
--cc=herbert@gondor.apana.org.au \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=leonro@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=raeds@nvidia.com \
--cc=saeedm@nvidia.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).