Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp1350902lqb; Thu, 30 May 2024 07:51:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW476ttV+/msrC07ysDKZOTrZpuGs2+9fsrZlu2aBVl8mZAgAorSQ+9oug8gjOTIjwHOY2xlr3B1QoMK3A8hSjGMczNPibRCHTMY/hGDQ== X-Google-Smtp-Source: AGHT+IGexOVCgy5T9vawSL+0KRAbf0Owcotyn0k5kAiUaGPYS1gqxd7PT+CWvBJNTlVl1baHioZt X-Received: by 2002:a05:6e02:1d0b:b0:36c:546c:ccf6 with SMTP id e9e14a558f8ab-3747dfc4d6dmr23922245ab.16.1717080673965; Thu, 30 May 2024 07:51:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717080673; cv=pass; d=google.com; s=arc-20160816; b=otJ6MFI7JBxRUFN53boDsNWAsBNUK24FGquOOWG23mFdYmo4//apvG3X7F9jxPUrZy WiGbvlOLyM5dH0SW4yPoN+LfLajb/zr2mH2t80wBJdIZZ3tMFBc3QyCkPZ/g+9RRT1oS 89ptVKztQjdByhUrfRw1gFVTS4HcO6nuwjAhM54FPQZQFzn+uwPKRRh28Sl8Yjtq58iM MPY3tpwhbK05dnHfsy0ihkJaOtsJhKA7DYoIZKdS3IxEcAhM5pdCjE5qZaQsoOHznWyY W5Ua/Dp//WmtKrQKhxC9iotBtcZKsF3HlyBDpjWwj5+4nzvlG2BW3nafo6WTNHBv/RVX hb4g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=K2Hoa5Gu2HxYtDNHwi3O1qkHhNjLmtHRYUgJzKnqN5s=; fh=nfeNlPgxECSr4XGd3Ztrgiwx7uI5ZLZuJ2Fky0L9+4Q=; b=upaCA6z9W3lJiqmv4BtYmKlu71HNklm9QnqNa4zG/ouACPukc0tnqc4dEd3EWDx7ji uXdaI/28LX1qj2hehFtEXlJb2S3ZpvQB7F4rBBu+rA31cakIkzf6Zp27B+fnvJzp8qxj 4s8/9PdtnaEU4u7XngE0IqbcJIVo6CujUpjQj5FLqMjcU3eZmY/SnnVjZtyD4SKjfNd9 xs/cxc1vG0dU9dNQ7PkkFhcXEgnJr+OJs/qSiiSsDcG0JtGrhO0aKmfkH1OrBaB16Wx8 LQSEYQQoWVctGuKc3cyX7Kby1wm9Not+Vi+vveZ2cmGYlnnaURGhnORlSXiOq2qEtu8q LFPw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QwT4UPMa; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-195552-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195552-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6bce39033c0si2056157a12.453.2024.05.30.07.51.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 07:51:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-195552-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QwT4UPMa; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-195552-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195552-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 62C92282E31 for ; Thu, 30 May 2024 14:50:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4937817F50C; Thu, 30 May 2024 14:50:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QwT4UPMa" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 709DF17D8BC; Thu, 30 May 2024 14:50:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717080627; cv=none; b=uWw3Gk+prYbPAJ+VdOn825hSZqZZiQz2Dq4ZYS4pFcbaJPmI8vx+Jgzbyw3PzTLJQ9J3gb1c2Soi1zOdEkK1EairPQVy+FI1Ym03lzAy+iKbbVKc2YVKUZIad8Y80R7ExW9BC0wJRkv/U+p2V7Xh2OLLYzSV8YFOw7eOwo8Zogk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717080627; c=relaxed/simple; bh=prxNjWcocA1xfeZ7ScnSmd77MXh4m2kvHooi1WN7euE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=q5lZBJImWNzKBAoNNo2pFn8ti02HCZ4j6tsfRwsohR0nqJFx+xmNrnysKtFMHsaIabkvhBmHEeW0PsDW/SOtssR+vvyOxtgJTGhCS2woVWIQl4JvxdX/+/H3xa6SJL1ef4Vmksbrhaaq/Ucy83xPeRawrb/FpwDJbzNyHZPucsc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QwT4UPMa; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B722FC32781; Thu, 30 May 2024 14:50:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717080627; bh=prxNjWcocA1xfeZ7ScnSmd77MXh4m2kvHooi1WN7euE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=QwT4UPMaJuQ/heKtWMpOUvSL1X8vkyCwSBGw93uC47juM1xpIzMmM5UBHX29dBNj8 1YovjBI0ayS/MdIfZe6mjOINDM6wClHOdJ6JeqzwqKY+Ep/bXZOu8S3mUHeN5JsGSb 9vKot8OxUBW+M4V34CJZVLpnCCWe0CtSarAsStqTOlD612CPlX4rtRs9eSdMuovoqU dsxYcEj1K2AUXSsEJgpeDWTnwRncXCs13xqWs239orTbguXBShIrZ+xX1q5w27/rnv e24U8jr8ggj7YW8H1DAQY81lhYtRLVjKWeUgMNXLv1qTNBVM++mTqTGT2ptsMrNkHr fNSw5INnqt2kA== Date: Thu, 30 May 2024 17:49:59 +0300 From: Leon Romanovsky To: Bharat Bhushan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, sgoutham@marvell.com, gakula@marvell.com, sbhatta@marvell.com, hkelam@marvell.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jerinj@marvell.com, lcherian@marvell.com, richardcochran@gmail.com Subject: Re: [net-next,v3 5/8] cn10k-ipsec: Add SA add/delete support for outb inline ipsec Message-ID: <20240530144959.GC3884@unreal> References: <20240528135349.932669-1-bbhushan2@marvell.com> <20240528135349.932669-6-bbhushan2@marvell.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240528135349.932669-6-bbhushan2@marvell.com> On Tue, May 28, 2024 at 07:23:46PM +0530, Bharat Bhushan wrote: > This patch adds support to add and delete Security Association > (SA) xfrm ops. Hardware maintains SA context in memory allocated > by software. Each SA context is 128 byte aligned and size of > each context is multiple of 128-byte. Add support for transport > and tunnel ipsec mode, ESP protocol, aead aes-gcm-icv16, key size > 128/192/256-bits with 32bit salt. > > Signed-off-by: Bharat Bhushan > --- > v2->v3: > - Removed memset to zero wherever possible > (comment from Kalesh Anakkur Purayil) > - Corrected error hanlding when setting SA for inbound > (comment from Kalesh Anakkur Purayil) > - Move "netdev->xfrmdev_ops = &cn10k_ipsec_xfrmdev_ops;" to this patch > This fix build error with W=1 > > .../marvell/octeontx2/nic/cn10k_ipsec.c | 452 ++++++++++++++++++ > .../marvell/octeontx2/nic/cn10k_ipsec.h | 114 +++++ > 2 files changed, 566 insertions(+) <...> > +static int cn10k_ipsec_validate_state(struct xfrm_state *x) > +{ > + struct net_device *netdev = x->xso.dev; > + > + if (x->props.aalgo != SADB_AALG_NONE) { > + netdev_err(netdev, "Cannot offload authenticated xfrm states\n"); > + return -EINVAL; > + } > + if (x->props.ealgo != SADB_X_EALG_AES_GCM_ICV16) { > + netdev_err(netdev, "Only AES-GCM-ICV16 xfrm state may be offloaded\n"); > + return -EINVAL; > + } > + if (x->props.calgo != SADB_X_CALG_NONE) { > + netdev_err(netdev, "Cannot offload compressed xfrm states\n"); > + return -EINVAL; > + } > + if (x->props.flags & XFRM_STATE_ESN) { > + netdev_err(netdev, "Cannot offload ESN xfrm states\n"); > + return -EINVAL; > + } I afraid that this check will cause for this offload to be unusable in real life scenarios. It is hard to imagine that someone will use offload which requires rekeying every 2^32 packets. > + if (x->props.family != AF_INET && x->props.family != AF_INET6) { > + netdev_err(netdev, "Only IPv4/v6 xfrm states may be offloaded\n"); > + return -EINVAL; > + } > + if (x->props.mode != XFRM_MODE_TRANSPORT && > + x->props.mode != XFRM_MODE_TUNNEL) { > + dev_info(&netdev->dev, "Only tunnel/transport xfrm states may be offloaded\n"); > + return -EINVAL; > + } > + if (x->id.proto != IPPROTO_ESP) { > + netdev_err(netdev, "Only ESP xfrm state may be offloaded\n"); > + return -EINVAL; > + } > + if (x->encap) { > + netdev_err(netdev, "Encapsulated xfrm state may not be offloaded\n"); > + return -EINVAL; > + } > + if (!x->aead) { > + netdev_err(netdev, "Cannot offload xfrm states without aead\n"); > + return -EINVAL; > + } > + > + if (x->aead->alg_icv_len != 128) { > + netdev_err(netdev, "Cannot offload xfrm states with AEAD ICV length other than 128bit\n"); > + return -EINVAL; > + } > + if (x->aead->alg_key_len != 128 + 32 && > + x->aead->alg_key_len != 192 + 32 && > + x->aead->alg_key_len != 256 + 32) { > + netdev_err(netdev, "Cannot offload xfrm states with AEAD key length other than 128/192/256bit\n"); > + return -EINVAL; > + } > + if (x->tfcpad) { > + netdev_err(netdev, "Cannot offload xfrm states with tfc padding\n"); > + return -EINVAL; > + } > + if (!x->geniv) { > + netdev_err(netdev, "Cannot offload xfrm states without geniv\n"); > + return -EINVAL; > + } > + if (strcmp(x->geniv, "seqiv")) { > + netdev_err(netdev, "Cannot offload xfrm states with geniv other than seqiv\n"); > + return -EINVAL; > + } > + return 0; > +} I don't see check for supported offload type among these checks. if (x->xso.type != XFRM_DEV_OFFLOAD_CRYPTO) { ....