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>, <sma@napatech.com>, <sburla@marvell.com>,
<ndabilpuram@marvell.com>, <jerinj@marvell.com>,
<anoobj@marvell.com>, <schalla@marvell.com>
Subject: [PATCH RFC v5 3/4] virtio-crypto: Add new IPsec opcodes to data request
Date: Tue, 8 Apr 2025 13:05:11 +0530 [thread overview]
Message-ID: <20250408073512.1783641-4-schalla@marvell.com> (raw)
In-Reply-To: <20250408073512.1783641-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>
Reviewed-by: Parav Pandit <parav@nvidia.com>
Signed-off-by: Srujana Challa <schalla@marvell.com>
---
device-types/crypto/description.tex | 84 +++++++++++++++++++++++++++++
1 file changed, 84 insertions(+)
diff --git a/device-types/crypto/description.tex b/device-types/crypto/description.tex
index 15b1d1d..4ccdd33 100644
--- a/device-types/crypto/description.tex
+++ b/device-types/crypto/description.tex
@@ -379,6 +379,7 @@ \subsubsection{Operation Status}\label{sec:Device Types / Crypto Device / Device
VIRTIO_CRYPTO_INVSESS = 4,
VIRTIO_CRYPTO_NOSPC = 5,
VIRTIO_CRYPTO_KEY_REJECTED = 6,
+ VIRTIO_CRYPTO_IPSEC_SA_SOFT_EXPIRY = 7,
VIRTIO_CRYPTO_MAX
};
\end{lstlisting}
@@ -391,6 +392,9 @@ \subsubsection{Operation Status}\label{sec:Device Types / Crypto Device / Device
\item VIRTIO_CRYPTO_NOSPC: no free session ID (only when the VIRTIO_CRYPTO_F_REVISION_1
feature bit is negotiated).
\item VIRTIO_CRYPTO_KEY_REJECTED: signature verification failed (only when AKCIPHER verification).
+\item VIRTIO_CRYPTO_IPSEC_SA_SOFT_EXPIRY: IPsec SA lifetime soft limits are reached.
+ When VIRTIO_CRYPTO_IPSEC_SA_SOFT_EXPIRY occurs, the request is completed successfully,
+ but one or all of the soft limits are reached. This is applicable only for IPsec service operations.
\item VIRTIO_CRYPTO_ERR: any failure not mentioned above occurs.
\end{itemize*}
@@ -992,6 +996,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 +1017,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 +1115,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,12 +1942,28 @@ \subsubsection{IPSEC Service Operation}\label{sec:Device Types / Crypto Device /
in tunnel mode, as well as the ESP/AH header on the given 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 performs encryption, attach ICV,
update/add IP header and add ESP/AH header/trailer. The resulting packet
contains encrypted data along with the IPsec header and 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
@@ -2193,3 +2235,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-04-08 7:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-08 7:35 [PATCH RFC v5 0/4] introduce IPsec Service in virtio-crypto Srujana Challa
2025-04-08 7:35 ` [PATCH RFC v5 1/4] virtio-crypto: Add IPsec service operation and Capabilities Srujana Challa
2025-04-08 7:35 ` [PATCH RFC v5 2/4] virtio-crypto: Add resource objects for IPsec outbound and inbound SAs Srujana Challa
2025-04-22 9:51 ` Sebastian Mauritsson
2025-04-23 9:46 ` Srujana Challa
2025-04-08 7:35 ` Srujana Challa [this message]
2025-04-08 7:35 ` [PATCH RFC v5 4/4] virtio-crypto: Add device and driver requirements for IPsec operation Srujana Challa
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=20250408073512.1783641-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=sma@napatech.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