From: "Samudrala, Sridhar" <sridhar.samudrala@intel.com>
To: Leon Romanovsky <leon@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: 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>,
Simon Horman <simon.horman@corigine.com>
Subject: Re: [PATCH net-next v1 04/10] net/mlx5e: Prepare IPsec packet reformat code for tunnel mode
Date: Fri, 14 Apr 2023 17:40:40 -0500 [thread overview]
Message-ID: <7815a749-f10a-ff5b-6050-6ca766a263b4@intel.com> (raw)
In-Reply-To: <f9e31cf8ff6a60ea4eb714c93e5fad7fbd56b860.1681388425.git.leonro@nvidia.com>
On 4/13/2023 7:29 AM, 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>
> ---
> .../mellanox/mlx5/core/en_accel/ipsec.c | 1 +
> .../mellanox/mlx5/core/en_accel/ipsec.h | 2 +-
> .../mellanox/mlx5/core/en_accel/ipsec_fs.c | 81 ++++++++++++++-----
> 3 files changed, 63 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c
> index def01bfde610..359da277c03a 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c
> @@ -297,6 +297,7 @@ void mlx5e_ipsec_build_accel_xfrm_attrs(struct mlx5e_ipsec_sa_entry *sa_entry,
> attrs->upspec.sport = ntohs(x->sel.sport);
> attrs->upspec.sport_mask = ntohs(x->sel.sport_mask);
> attrs->upspec.proto = x->sel.proto;
> + attrs->mode = x->props.mode;
>
> mlx5e_ipsec_init_limits(sa_entry, attrs);
> }
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.h b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.h
> index bb89e18b17b4..ae525420a492 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.h
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.h
> @@ -77,7 +77,7 @@ struct mlx5_replay_esn {
>
> struct mlx5_accel_esp_xfrm_attrs {
> u32 spi;
> - u32 flags;
> + u32 mode;
> struct aes_gcm_keymat aes_gcm;
>
> union {
> 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..6a1ed4114054 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
> @@ -10,6 +10,7 @@
> #include "lib/fs_chains.h"
>
> #define NUM_IPSEC_FTE BIT(15)
> +#define MLX5_REFORMAT_TYPE_ADD_ESP_TRANSPORT_SIZE 16
>
> struct mlx5e_ipsec_fc {
> struct mlx5_fc *cnt;
> @@ -836,40 +837,80 @@ 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;
Is it guaranteed that attrs->family will be either AF_INET or AF_INET6?
Later patches seem to indicate that this may not be true as they use
switch statement and includes default case
> +
> + reformatbf = kzalloc(MLX5_REFORMAT_TYPE_ADD_ESP_TRANSPORT_SIZE,
> + GFP_KERNEL);
> + if (!reformatbf)
> + return -ENOMEM;
> +
> + /* convert to network format */
> + spi = htonl(attrs->spi);
> + memcpy(reformatbf, &spi, sizeof(spi));
> +
> + reformat_params->param_0 = attrs->authsize;
> + reformat_params->size =
> + MLX5_REFORMAT_TYPE_ADD_ESP_TRANSPORT_SIZE;
> + reformat_params->data = reformatbf;
> + break;
> + default:
> + return -EINVAL;
> + }
> +
> + return 0;
> +}
> +
> static int setup_pkt_reformat(struct mlx5_core_dev *mdev,
> struct mlx5_accel_esp_xfrm_attrs *attrs,
> struct mlx5_flow_act *flow_act)
> {
> - enum mlx5_flow_namespace_type ns_type = MLX5_FLOW_NAMESPACE_EGRESS;
> struct mlx5_pkt_reformat_params reformat_params = {};
> struct mlx5_pkt_reformat *pkt_reformat;
> - u8 reformatbf[16] = {};
> - __be32 spi;
> + enum mlx5_flow_namespace_type ns_type;
> + int ret;
>
> - if (attrs->dir == XFRM_DEV_OFFLOAD_IN) {
> - reformat_params.type = MLX5_REFORMAT_TYPE_DEL_ESP_TRANSPORT;
> + switch (attrs->dir) {
> + case XFRM_DEV_OFFLOAD_IN:
> ns_type = MLX5_FLOW_NAMESPACE_KERNEL;
> - goto cmd;
> + break;
> + case XFRM_DEV_OFFLOAD_OUT:
> + ns_type = MLX5_FLOW_NAMESPACE_EGRESS;
> + break;
> + default:
> + return -EINVAL;
> }
>
> - 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;
same here
> -
> - /* convert to network format */
> - spi = htonl(attrs->spi);
> - memcpy(reformatbf, &spi, 4);
> + switch (attrs->mode) {
> + case XFRM_MODE_TRANSPORT:
> + ret = setup_pkt_transport_reformat(attrs, &reformat_params);
> + break;
> + default:
> + ret = -EINVAL;
> + }
>
> - reformat_params.param_0 = attrs->authsize;
> - reformat_params.size = sizeof(reformatbf);
> - reformat_params.data = &reformatbf;
> + if (ret)
> + return ret;
>
> -cmd:
> pkt_reformat =
> mlx5_packet_reformat_alloc(mdev, &reformat_params, ns_type);
> + kfree(reformat_params.data);
> if (IS_ERR(pkt_reformat))
> return PTR_ERR(pkt_reformat);
>
next prev parent reply other threads:[~2023-04-14 22:40 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-13 12:29 [PATCH net-next v1 00/10] Support tunnel mode in mlx5 IPsec packet offload Leon Romanovsky
2023-04-13 12:29 ` [PATCH net-next v1 01/10] net/mlx5e: Add IPsec packet offload tunnel bits Leon Romanovsky
2023-04-13 12:29 ` [PATCH net-next v1 02/10] net/mlx5e: Check IPsec packet offload tunnel capabilities Leon Romanovsky
2023-04-13 12:29 ` [PATCH net-next v1 03/10] net/mlx5e: Configure IPsec SA tables to support tunnel mode Leon Romanovsky
2023-04-13 12:29 ` [PATCH net-next v1 04/10] net/mlx5e: Prepare IPsec packet reformat code for " Leon Romanovsky
2023-04-14 22:40 ` Samudrala, Sridhar [this message]
2023-04-15 8:49 ` Leon Romanovsky
2023-04-17 13:32 ` Simon Horman
2023-04-13 12:29 ` [PATCH net-next v1 05/10] net/mlx5e: Support IPsec RX packet offload in " Leon Romanovsky
2023-04-17 13:33 ` Simon Horman
2023-04-13 12:29 ` [PATCH net-next v1 06/10] net/mlx5e: Support IPsec TX " Leon Romanovsky
2023-04-17 13:23 ` Simon Horman
2023-04-18 6:48 ` Leon Romanovsky
2023-04-18 7:09 ` Simon Horman
2023-04-18 7:58 ` Leon Romanovsky
2023-04-13 12:29 ` [PATCH net-next v1 07/10] net/mlx5e: Listen to ARP events to update IPsec L2 headers " Leon Romanovsky
2023-04-17 13:34 ` Simon Horman
2023-04-13 12:29 ` [PATCH net-next v1 08/10] net/mlx5: Allow blocking encap changes in eswitch Leon Romanovsky
2023-04-17 13:34 ` Simon Horman
2023-04-13 12:29 ` [PATCH net-next v1 09/10] net/mlx5e: Create IPsec table with tunnel support only when encap is disabled Leon Romanovsky
2023-04-17 13:35 ` Simon Horman
2023-04-13 12:29 ` [PATCH net-next v1 10/10] net/mlx5e: Accept tunnel mode for IPsec packet offload Leon Romanovsky
2023-04-17 13:36 ` Simon Horman
2023-04-16 14:41 ` [PATCH net-next v1 00/10] Support tunnel mode in mlx5 " Samudrala, Sridhar
2023-04-17 4:05 ` Jakub Kicinski
2023-04-17 13:10 ` Simon Horman
2023-04-17 13:38 ` Simon Horman
2023-04-17 17:58 ` Leon Romanovsky
2023-04-17 19:25 ` Jakub Kicinski
2023-04-18 2:00 ` patchwork-bot+netdevbpf
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=7815a749-f10a-ff5b-6050-6ca766a263b4@intel.com \
--to=sridhar.samudrala@intel.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=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 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).