Skip to content

Commit eecde6f

Browse files
Merge pull request #74 from dsharma-dc/cry-pkg
This gets basic crypto build to be working with software accel module. The ipsecMB package isn't enabled as part of this, which will be required for dpdk_cryptodev module. Will do that in subsequent change once issues with that are sorted.
2 parents 520ab75 + 5be07f1 commit eecde6f

File tree

5 files changed

+26
-4
lines changed

5 files changed

+26
-4
lines changed

build.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ fn configure_spdk() -> Result<LibraryConfig, Error> {
150150
spdk_lib.mark_system("uuid");
151151
spdk_lib.mark_system("rdmacm");
152152
spdk_lib.mark_system("ibverbs");
153+
spdk_lib.mark_system("mlx5");
154+
spdk_lib.mark_system("keyutils");
153155

154156
spdk_lib.set_static_search(true);
155157

@@ -294,7 +296,9 @@ fn main() {
294296
.header("wrapper.h")
295297
.formatter(bindgen::Formatter::Rustfmt)
296298
.allowlist_function(".*.aio.*")
299+
.allowlist_function("^accel.*")
297300
.allowlist_function(".*.crypto_disk.*")
301+
.allowlist_function(".*.crypto_opts.*")
298302
.allowlist_function(".*.iscsi.*")
299303
.allowlist_function(".*.lock_lba_range")
300304
.allowlist_function(".*.lvol.*")

build_scripts/build_spdk.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ function cmd_configure() {
262262
msg_info "Target platform: $TARGET_PLATFORM"
263263
case $TARGET_PLATFORM in
264264
"x86_64-unknown-linux-gnu")
265-
CONFIGURE_ARGS+=("--target-arch=nehalem" "--without-crypto")
265+
CONFIGURE_ARGS+=("--target-arch=nehalem" "--with-crypto")
266266
;;
267267
"aarch64-unknown-linux-gnu")
268268
CONFIGURE_ARGS+=(" --target-arch=armv8-a+crypto")

nix/pkgs/libspdk/default.nix

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
, utillinux
4545
, zlib
4646
, rdma-core
47+
, keyutils
4748
}:
4849
let
4950
# Suffix for debug build name.
@@ -85,8 +86,8 @@ let
8586
# Derivation attributes
8687
#
8788
spdk = rec {
88-
rev = "50b064f553970b0f352691530e80f19b8432f034";
89-
sha256 = "sha256-fim71qqNjGtITeXfR7kWIRpBbI2iF47D0suny3mjcCQ=";
89+
rev = "5ad4b3f7da32eb96543bf15df88cfd790dbd5307";
90+
sha256 = "sha256-P3/rhhxNuNC3LJK7em+v5ES4aZsx0LSTHf8HcCaWk5Y=";
9091
pname = "libspdk${nameSuffix}";
9192
version = "24.05-${lib.substring 0 7 rev}";
9293
name = "${pname}-${version}";
@@ -143,6 +144,7 @@ let
143144
numactl
144145
openssl
145146
rdma-core
147+
keyutils
146148
zlib
147149
] ++ extraBuildInputs;
148150

src/bdev.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::{
1717
spdk_bdev_get_aliases, spdk_bdev_get_buf_align, spdk_bdev_get_by_name,
1818
spdk_bdev_has_write_cache, spdk_bdev_io_type_supported, spdk_bdev_module,
1919
spdk_bdev_module_release_bdev, spdk_bdev_register, spdk_bdev_unregister,
20-
SPDK_BDEV_CLAIM_EXCL_WRITE, SPDK_BDEV_CLAIM_NONE,
20+
vbdev_crypto_disk_get_base_bdev, SPDK_BDEV_CLAIM_EXCL_WRITE, SPDK_BDEV_CLAIM_NONE,
2121
},
2222
BdevIo, BdevModule, BdevOps, IoChannel, IoDevice, IoType, Thread, Uuid,
2323
};
@@ -71,6 +71,20 @@ where
7171
unsafe { (*self.as_inner_ref().module).name.as_str() }
7272
}
7373

74+
/// Returns the bdev handle which is the base of `self` bdev here.
75+
/// e.g self could be a crypto vbdev and base an aio bdev.
76+
/// XXX: This must be called only by crypto vbdev today.
77+
pub fn crypto_base_bdev(&self) -> Option<Self> {
78+
let p = unsafe {
79+
vbdev_crypto_disk_get_base_bdev(self.name().as_ptr() as *mut std::os::raw::c_char)
80+
};
81+
if p.is_null() {
82+
None
83+
} else {
84+
Some(Self::from_inner_ptr(p))
85+
}
86+
}
87+
7488
/// TODO
7589
/// ... lookup a bdev by its name
7690
pub fn lookup_by_name(name: &str) -> Option<Self> {

wrapper.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
#include <thread/thread_internal.h>
4646
#include <bdev/bdev_internal.h>
4747
#include <blob/blobstore.h>
48+
#include <spdk/accel_module.h>
49+
#include <accel/dpdk_cryptodev/accel_dpdk_cryptodev.h>
4850

4951
#include "helpers/logwrapper.h"
5052
#include "helpers/nvme_helper.h"

0 commit comments

Comments
 (0)