From: Srujana Challa <schalla@marvell.com>
To: <virtio-comment@lists.linux.dev>
Cc: <mst@redhat.com>, <cohuck@redhat.com>, <mvaralar@redhat.com>,
<parav@nvidia.com>, <sburla@marvell.com>,
<ndabilpuram@marvell.com>, <jerinj@marvell.com>,
<anoobj@marvell.com>, <schalla@marvell.com>
Subject: [PATCH RFC v3 3/4] virtio-crypto: Add new IPsec opcodes to data request
Date: Wed, 22 Jan 2025 11:46:43 +0530 [thread overview]
Message-ID: <20250122061644.266560-4-schalla@marvell.com> (raw)
In-Reply-To: <20250122061644.266560-1-schalla@marvell.com>
Adds new IPsec opcodes, VIRTIO_CRYPTO_IPSEC_OUTBOUND and
VIRTIO_CRYPTO_IPSEC_INBOUND and defines opcode specific
data structures for IPsec data processing.
Reviewed-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
Signed-off-by: Srujana Challa <schalla@marvell.com>
---
device-types/crypto/description.tex | 80 +++++++++++++++++++++++++++++
1 file changed, 80 insertions(+)
diff --git a/device-types/crypto/description.tex b/device-types/crypto/description.tex
index 0ba09df..cf5de23 100644
--- a/device-types/crypto/description.tex
+++ b/device-types/crypto/description.tex
@@ -992,6 +992,10 @@ \subsubsection{Data Virtqueue}\label{sec:Device Types / Crypto Device / Device O
VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x02)
#define VIRTIO_CRYPTO_AKCIPHER_VERIFY \
VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x03)
+#define VIRTIO_CRYPTO_IPSEC_OUTBOUND \
+ VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_IPSEC, 0x00)
+#define VIRTIO_CRYPTO_IPSEC_INBOUND \
+ VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_IPSEC, 0x01)
le32 opcode;
/* algo should be service-specific algorithms */
le32 algo;
@@ -1009,6 +1013,17 @@ \subsubsection{Data Virtqueue}\label{sec:Device Types / Crypto Device / Device O
If VIRTIO_CRYPTO_F_REVISION_1 is negotiated but VIRTIO_CRYPTO_F_<SERVICE>_STATELESS_MODE
is not negotiated, then the device SHOULD reject <SERVICE> requests if
VIRTIO_CRYPTO_FLAG_SESSION_MODE is not set (in \field{flag}).
+
+For VIRTIO_CRYPTO_IPSEC_OUTBOUND and VIRTIO_CRYPTO_IPSEC_INBOUND opcodes,
+\field{algo} is ignored.
+
+For VIRTIO_CRYPTO_IPSEC_OUTBOUND opcode, \field{session_id} MUST be set to
+one of the resource objects \field{id} created using
+VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_OUTBOUND_SA resource type.
+
+For VIRTIO_CRYPTO_IPSEC_INBOUND opcode, \field{session_id} MUST be set to
+one of the resource objects \field{id} created using
+VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_INBOUND_SA resource type.
\end{note}
The dataq request is composed of four parts:
@@ -1096,6 +1111,13 @@ \subsubsection{Data Virtqueue}\label{sec:Device Types / Crypto Device / Device O
and struct virtio_crypto_akcipher_data_flf is padded to 48 bytes if NOT negotiated,
and \field{op_vlf} is struct virtio_crypto_akcipher_data_vlf.
\end{itemize*}
+\item If the the opcode (in \field{header}) is VIRTIO_CRYPTO_IPSEC_OUTBOUND
+ or VIRTIO_CRYPTO_IPSEC_INBOUND then:
+ \begin{itemize*}
+ \item \field{op_flf} is struct virtio_crypto_ipsec_data_flf and
+ \field{op_vlf} is struct virtio_crypto_ipsec_data_vlf.
+ Works only for session mode.
+ \end{itemize*}
\end{itemize*}
\field{inhdr} is a unified input header that used to return the status of
@@ -1916,11 +1938,27 @@ \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device /
in tunnel mode, as well as the ESP/AH header from the packet(See \hyperref[intro:IPSEC]{IPSEC} RFC).
The resulting packet contains only the plain data.
+The driver can request IPsec Inbound processing by
+\begin{itemize*}
+\item Creating inbound SAs using the VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_INBOUND_SA command.
+\item Setting the \field{opcode} in struct virtio_crypto_op_data_req to
+VIRTIO_CRYPTO_IPSEC_INBOUND.
+\end{itemize*}
+
IPsec Outbound processing: The device will perform encryption, attach ICV,
update/add IP header, add ESP/AH header/trailer.
+The driver can request IPsec outbound processing by
+\begin{itemize*}
+\item Creating outbound SAs using the VIRTIO_CRYPTO_RESOURCE_OBJ_IPSEC_OUTBOUND_SA command.
+\item Setting the \field{opcode} in struct virtio_crypto_op_data_req to
+VIRTIO_CRYPTO_IPSEC_OUTBOUND.
+\end{itemize*}
+
A crypto device can support number of IPsec SAs, allowing it to manage multiple secure
connections simultaneously.
+See \ref{sec:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Resource objects}
+for IPsec SA information.
The device and the driver indicate IPsec SA resource limits using the
VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP capability specifying the limits on the number of
@@ -2173,3 +2211,45 @@ \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device /
capability VIRTIO_CRYPTO_IPSEC_RESOURCE_CAP. For the IPsec inbound SA resource object
\field{resource_obj_specific_data} is in the format
\field{struct virtio_crypto_resource_obj_ipsec_sa}.
+
+\paragraph{Data processing}
+\label{par:Device Types / Crypto Device / Device Operation / IPsec Service Operation / Data processing}
+
+Data requests for IPsec processing are as follows:
+
+\begin{lstlisting}
+struct virtio_crypto_ipsec_data_flf {
+ /* length of source data, full IP/IPsec packet */
+ le32 src_data_len;
+ /* length of dst data */
+ le32 dst_data_len;
+};
+
+struct virtio_crypto_ipsec_data_vlf {
+ /* Device read only portion */
+ /* Source data */
+ u8 src_data[src_data_len];
+
+ /* Device write only portion */
+ /* Pointer to output data */
+ u8 dst_data[dst_data_len];
+};
+\end{lstlisting}
+
+Each data request uses the virtio_crypto_ipsec_data_flf structure and
+the virtio_crypto_ipsec_data_vlf structure to store information used to
+run the IPSEC operations.
+
+For IPsec encryption:
+\field{src_data} is the full IP packet that will be processed.
+\field{src_data_len} is the length of source data.
+\field{dst_result} is the result ESP encrypted packet and
+\field{dst_data_len} is the length of it. Please note,
+dst_data_len MUST include additional header and trailer
+lengths.
+
+For IPsec decryption:
+\field{src_data} is the IPsec packet that will be processed.
+\field{src_data_len} is the length of source data.
+\field{dst_result} is the result plain IP packet and
+\field{dst_data_len} is the length of it.
--
2.25.1
next prev parent reply other threads:[~2025-01-22 6:17 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-22 6:16 [PATCH RFC v3 0/4] introduce IPsec Service in virtio-crypto Srujana Challa
2025-01-22 6:16 ` [PATCH RFC v3 1/4] virtio-crypto: Add IPsec service operation and Capabilities Srujana Challa
2025-02-10 19:46 ` Parav Pandit
2025-02-13 12:55 ` Sebastian Mauritsson
2025-02-13 17:34 ` Srujana Challa
2025-01-22 6:16 ` [PATCH RFC v3 2/4] virtio-crypto: Add resource objects for IPsec outbound and inbound SAs Srujana Challa
2025-02-10 19:46 ` Parav Pandit
2025-02-13 13:09 ` Sebastian Mauritsson
2025-02-13 14:35 ` Srujana Challa
2025-02-15 18:35 ` Parav Pandit
2025-02-17 5:40 ` Srujana Challa
2025-01-22 6:16 ` Srujana Challa [this message]
2025-02-10 19:46 ` [PATCH RFC v3 3/4] virtio-crypto: Add new IPsec opcodes to data request Parav Pandit
2025-01-22 6:16 ` [PATCH RFC v3 4/4] virtio-crypto: Add device and driver requirements for IPsec operation Srujana Challa
2025-02-10 19:47 ` Parav Pandit
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=20250122061644.266560-4-schalla@marvell.com \
--to=schalla@marvell.com \
--cc=anoobj@marvell.com \
--cc=cohuck@redhat.com \
--cc=jerinj@marvell.com \
--cc=mst@redhat.com \
--cc=mvaralar@redhat.com \
--cc=ndabilpuram@marvell.com \
--cc=parav@nvidia.com \
--cc=sburla@marvell.com \
--cc=virtio-comment@lists.linux.dev \
/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