Re: [PATCH v2 04/17] bsd-user: Add FreeBSD cryptodev ioctl definitions

2026-04-29 Thread Pierrick Bouvier
On 4/29/2026 7:45 AM, Warner Losh wrote:
> From: "Stacey D. Son" 
> 
> Add os-ioctl-cryptodev.h with /dev/crypto ioctl definitions including
> CIOCGSESSION, CIOCCRYPT, and related cryptographic device control
> ioctls.
> 
> Signed-off-by: Stacey D. Son 
> Signed-off-by: Warner Losh 
> ---
>  bsd-user/freebsd/os-ioctl-cryptodev.h | 74 
> +++
>  1 file changed, 74 insertions(+)
> 

Reviewed-by: Pierrick Bouvier 



[PATCH v2 04/17] bsd-user: Add FreeBSD cryptodev ioctl definitions

2026-04-29 Thread Warner Losh
From: "Stacey D. Son" 

Add os-ioctl-cryptodev.h with /dev/crypto ioctl definitions including
CIOCGSESSION, CIOCCRYPT, and related cryptographic device control
ioctls.

Signed-off-by: Stacey D. Son 
Signed-off-by: Warner Losh 
---
 bsd-user/freebsd/os-ioctl-cryptodev.h | 74 +++
 1 file changed, 74 insertions(+)

diff --git a/bsd-user/freebsd/os-ioctl-cryptodev.h 
b/bsd-user/freebsd/os-ioctl-cryptodev.h
new file mode 100644
index 00..dc88521057
--- /dev/null
+++ b/bsd-user/freebsd/os-ioctl-cryptodev.h
@@ -0,0 +1,74 @@
+/*
+ * FreeBSD cryptodev definitions for ioctl(2) emulation
+ *
+ * Copyright (c) 2014 Stacey D. Son
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef BSD_USER_FREEBSD_OS_IOCTL_CRYPTODEV_H
+#define BSD_USER_FREEBSD_OS_IOCTL_CRYPTODEV_H
+
+/* see opencrypto/cryptodev.h */
+
+struct target_session_op {
+u_int32_t   cipher;
+u_int32_t   mac;
+
+u_int32_t   keylen;
+abi_ulong   key;
+int32_t mackeylen;
+abi_ulong   mackey;
+
+u_int32_t   ses;
+};
+
+
+struct target_session2_op {
+u_int32_t   cipher;
+u_int32_t   mac;
+
+u_int32_t   keylen;
+abi_ulong   key;
+int32_t mackeylen;
+abi_ulong   mackey;
+
+u_int32_t   ses;
+int32_t crid;
+int pad[4];
+};
+
+struct target_crypt_find_op {
+int crid;
+charname[32];
+};
+
+struct target_crparam {
+abi_ulong   crp_p;
+u_int   crp_nbits;
+};
+
+#define TARGET_CRK_MAXPARAM 8
+
+struct target_crypt_kop {
+u_int   crk_op;
+u_int   crk_status;
+u_short crk_iparams;
+u_short crk_oparams;
+u_int   crk_crid;
+struct target_crparam   crk_param[TARGET_CRK_MAXPARAM];
+};
+
+#define TARGET_CRIOGET  TARGET_IOWR('c', 100, u_int32_t)
+#define TARGET_CRIOASYMFEAT TARGET_CIOCASYMFEAT
+#define TARGET_CRIOFINDDEV  TARGET_CIOCFINDDEV
+
+#define TARGET_CIOCGSESSION TARGET_IOWR('c', 101, struct target_session_op)
+#define TARGET_CIOCFSESSION TARGET_IOW('c', 102, u_int32_t)
+#define TARGET_CIOCCRYPTTARGET_IOWR('c', 103, struct target_crypt_op)
+#define TARGET_CIOCKEY  TARGET_IOWR('c', 104, struct target_crypt_kop)
+#define TARGET_CIOCASYMFEAT TARGET_IOR('c', 105, u_int32_t)
+#define TARGET_CIOCGSESSION2TARGET_IOWR('c', 106, struct 
target_session2_op)
+#define TARGET_CIOCKEY2 TARGET_IOWR('c', 107, struct target_crypt_kop)
+#define TARGET_CIOCFINDDEV TARGET_IOWR('c', 108, struct target_crypt_find_op)
+
+#endif /* BSD_USER_FREEBSD_OS_IOCTL_CRYPTODEV_H */

-- 
2.52.0