[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZDWMr/CTs5kqzcNV@corigine.com>
Date: Tue, 11 Apr 2023 18:37:03 +0200
From: Simon Horman <simon.horman@...igine.com>
To: Leon Romanovsky <leon@...nel.org>
Cc: "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Leon Romanovsky <leonro@...dia.com>,
Steffen Klassert <steffen.klassert@...unet.com>,
Herbert Xu <herbert@...dor.apana.org.au>,
netdev@...r.kernel.org, Saeed Mahameed <saeedm@...dia.com>,
Raed Salem <raeds@...dia.com>, Emeel Hakim <ehakim@...dia.com>
Subject: Re: [PATCH net-next 05/10] net/mlx5e: Support IPsec RX packet
offload in tunnel mode
On Mon, Apr 10, 2023 at 09:19:07AM +0300, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@...dia.com>
>
> Extend mlx5 driver with logic to support IPsec RX packet offload
> in tunnel mode.
>
> Signed-off-by: Leon Romanovsky <leonro@...dia.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.
And I don't think the union is giving us much: the raw field seems unused.
> + char *reformatbf;
> + size_t bfflen;
> +
> + bfflen = sizeof(*mac_hdr);
> +
> + reformatbf = kzalloc(bfflen, GFP_KERNEL);
I'm not sure that reformatbf is providing much value.
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 *.
> + 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;
> +}
...
Powered by blists - more mailing lists