From: Tanmay Jagdale <tanmay@marvell.com>
To: Simon Horman <horms@kernel.org>
Cc: <davem@davemloft.net>, <leon@kernel.org>, <sgoutham@marvell.com>,
<bbhushan2@marvell.com>, <herbert@gondor.apana.org.au>,
<linux-crypto@vger.kernel.org>, <netdev@vger.kernel.org>
Subject: Re: [PATCH net-next v2 12/14] octeontx2-pf: ipsec: Process CPT metapackets
Date: Thu, 10 Jul 2025 14:14:45 +0530 [thread overview]
Message-ID: <aG99fdMVhJUNhxtZ@optiplex> (raw)
In-Reply-To: <20250620110657.GK194429@horms.kernel.org>
On 2025-06-20 at 16:36:57, Simon Horman (horms@kernel.org) wrote:
> On Wed, Jun 18, 2025 at 05:00:06PM +0530, Tanmay Jagdale wrote:
> > CPT hardware forwards decrypted IPsec packets to NIX via the X2P bus
> > as metapackets which are of 256 bytes in length. Each metapacket
> > contains CPT_PARSE_HDR_S and initial bytes of the decrypted packet
> > that helps NIX RX in classifying and submitting to CPU. Additionally,
> > CPT also sets BIT(11) of the channel number to indicate that it's a
> > 2nd pass packet from CPT.
> >
> > Since the metapackets are not complete packets, they don't have to go
> > through L3/L4 layer length and checksum verification so these are
> > disabled via the NIX_LF_INLINE_RQ_CFG mailbox during IPsec initialization.
> >
> > The CPT_PARSE_HDR_S contains a WQE pointer to the complete decrypted
> > packet. Add code in the rx NAPI handler to parse the header and extract
> > WQE pointer. Later, use this WQE pointer to construct the skb, set the
> > XFRM packet mode flags to indicate successful decryption before submitting
> > it to the network stack.
> >
> > Signed-off-by: Tanmay Jagdale <tanmay@marvell.com>
> > ---
> > Changes in V2:
> > - Removed unnecessary casts
> > - Don't convert complete cpt_parse_hdr from BE to LE and just
> > convert required fields
> > - Fixed logic to avoid repeated calculation for start and end in sg
> >
> > V1 Link: https://lore.kernel.org/netdev/20250502132005.611698-15-tanmay@marvell.com/
> >
> > .../marvell/octeontx2/nic/cn10k_ipsec.c | 52 +++++++++++++++++++
> > .../marvell/octeontx2/nic/cn10k_ipsec.h | 48 +++++++++++++++++
> > .../marvell/octeontx2/nic/otx2_common.h | 2 +
> > .../marvell/octeontx2/nic/otx2_struct.h | 16 ++++++
> > .../marvell/octeontx2/nic/otx2_txrx.c | 29 +++++++++--
> > 5 files changed, 144 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/cn10k_ipsec.c b/drivers/net/ethernet/marvell/octeontx2/nic/cn10k_ipsec.c
> > index 5cb6bc835e56..a95878378334 100644
> > --- a/drivers/net/ethernet/marvell/octeontx2/nic/cn10k_ipsec.c
> > +++ b/drivers/net/ethernet/marvell/octeontx2/nic/cn10k_ipsec.c
> > @@ -346,6 +346,58 @@ static int cn10k_outb_cpt_init(struct net_device *netdev)
> > return ret;
> > }
> >
> > +struct nix_wqe_rx_s *cn10k_ipsec_process_cpt_metapkt(struct otx2_nic *pfvf,
> > + struct nix_cqe_rx_s *cqe,
> > + struct sk_buff *skb,
> > + int qidx)
> > +{
> > + struct nix_rx_sg_s *sg = &cqe->sg;
> > + struct nix_wqe_rx_s *wqe = NULL;
> > + u64 *seg_addr = &sg->seg_addr;
> > + struct cpt_parse_hdr_s *cptp;
> > + struct xfrm_offload *xo;
> > + struct xfrm_state *xs;
> > + struct sec_path *sp;
> > + void *va;
> > +
> > + /* CPT_PARSE_HDR_S is present in the beginning of the buffer */
> > + va = phys_to_virt(otx2_iova_to_phys(pfvf->iommu_domain, *seg_addr));
> > +
> > + cptp = (struct cpt_parse_hdr_s *)va;
> > +
> > + /* Convert the wqe_ptr from CPT_PARSE_HDR_S to a CPU usable pointer */
> > + wqe = phys_to_virt(otx2_iova_to_phys(pfvf->iommu_domain,
> > + be64_to_cpu(cptp->wqe_ptr)));
>
> Hi Tanmay,
Hi Simon,
>
> be64_to_cpu expects a __be64 argument, but the type of cptp->wqe_ptr is u64.
> Or, IOW, be64_to_cpu expects to be based a big endian value but
> the type of it's argument is host byte order.
Okay. I will fix the structure definition to use __be types.
>
> > +
> > + /* Get the XFRM state pointer stored in SA context */
> > + xs = pfvf->ipsec.inb_sa->base +
> > + (be32_to_cpu(cptp->cookie) * pfvf->ipsec.sa_tbl_entry_sz) + 1024;
>
> Likewise with cookie here.
ACK.
>
> :Flagged by Sparse.
>
> ...
>
With Regards,
Tanmay
next prev parent reply other threads:[~2025-07-10 8:44 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-18 11:29 [PATCH net-next v2 00/14] Enable Inbound IPsec offload on Marvell CN10K SoC Tanmay Jagdale
2025-06-18 11:29 ` [PATCH net-next v2 01/14] crypto: octeontx2: Share engine group info with AF driver Tanmay Jagdale
2025-06-18 11:29 ` [PATCH net-next v2 02/14] octeontx2-af: Configure crypto hardware for inline ipsec Tanmay Jagdale
2025-06-18 11:29 ` [PATCH net-next v2 03/14] octeontx2-af: Setup Large Memory Transaction for crypto Tanmay Jagdale
2025-06-18 11:29 ` [PATCH net-next v2 04/14] octeontx2-af: Handle inbound inline ipsec config in AF Tanmay Jagdale
2025-06-18 11:29 ` [PATCH net-next v2 05/14] octeontx2-af: Add support for CPT second pass Tanmay Jagdale
2025-06-20 10:55 ` Simon Horman
2025-06-23 6:48 ` Tanmay Jagdale
2025-06-18 11:30 ` [PATCH net-next v2 06/14] octeontx2-af: Add support for SPI to SA index translation Tanmay Jagdale
2025-06-19 14:37 ` kernel test robot
2025-06-18 11:30 ` [PATCH net-next v2 07/14] octeontx2-af: Add mbox to alloc/free BPIDs Tanmay Jagdale
2025-06-18 11:30 ` [PATCH net-next v2 08/14] octeontx2-pf: ipsec: Allocate Ingress SA table Tanmay Jagdale
2025-06-18 11:30 ` [PATCH net-next v2 09/14] octeontx2-pf: ipsec: Setup NIX HW resources for inbound flows Tanmay Jagdale
2025-06-18 11:30 ` [PATCH net-next v2 10/14] octeontx2-pf: ipsec: Handle NPA threshold interrupt Tanmay Jagdale
2025-06-20 11:00 ` Simon Horman
2025-07-10 8:42 ` Tanmay Jagdale
2025-06-18 11:30 ` [PATCH net-next v2 11/14] octeontx2-pf: ipsec: Initialize ingress IPsec Tanmay Jagdale
2025-06-18 11:30 ` [PATCH net-next v2 12/14] octeontx2-pf: ipsec: Process CPT metapackets Tanmay Jagdale
2025-06-20 11:06 ` Simon Horman
2025-07-10 8:44 ` Tanmay Jagdale [this message]
2025-06-18 11:30 ` [PATCH net-next v2 13/14] octeontx2-pf: ipsec: Manage NPC rules and SPI-to-SA table entries Tanmay Jagdale
2025-06-19 23:19 ` kernel test robot
2025-06-18 11:30 ` [PATCH net-next v2 14/14] octeontx2-pf: ipsec: Add XFRM state and policy hooks for inbound flows Tanmay Jagdale
2025-06-20 11:22 ` Simon Horman
2025-07-10 8:40 ` Tanmay Jagdale
2025-06-25 14:38 ` kernel test robot
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=aG99fdMVhJUNhxtZ@optiplex \
--to=tanmay@marvell.com \
--cc=bbhushan2@marvell.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=horms@kernel.org \
--cc=leon@kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=sgoutham@marvell.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).