1# Storage Performance Development Kit 2 3[](https://travis-ci.org/spdk/spdk) 4 5The Storage Performance Development Kit ([SPDK](http://www.spdk.io)) provides a set of tools 6and libraries for writing high performance, scalable, user-mode storage 7applications. It achieves high performance by moving all of the necessary 8drivers into userspace and operating in a polled mode instead of relying on 9interrupts, which avoids kernel context switches and eliminates interrupt 10handling overhead. 11 12The development kit currently includes: 13 14* [NVMe driver](http://www.spdk.io/doc/nvme.html) 15* [I/OAT (DMA engine) driver](http://www.spdk.io/doc/ioat.html) 16* [NVMe over Fabrics target](http://www.spdk.io/doc/nvmf.html) 17* [iSCSI target](http://www.spdk.io/doc/iscsi.html) 18* [vhost target](http://www.spdk.io/doc/vhost.html) 19* [Virtio-SCSI driver](http://www.spdk.io/doc/virtio.html) 20 21# In this readme 22 23* [Documentation](#documentation) 24* [Prerequisites](#prerequisites) 25* [Source Code](#source) 26* [Build](#libraries) 27* [Unit Tests](#tests) 28* [Vagrant](#vagrant) 29* [AWS](#aws) 30* [Advanced Build Options](#advanced) 31* [Shared libraries](#shared) 32* [Hugepages and Device Binding](#huge) 33* [Example Code](#examples) 34* [Contributing](#contributing) 35 36<a id="documentation"></a> 37## Documentation 38 39[Doxygen API documentation](http://www.spdk.io/doc/) is available, as 40well as a [Porting Guide](http://www.spdk.io/doc/porting.html) for porting SPDK to different frameworks 41and operating systems. 42 43<a id="source"></a> 44## Source Code 45 46~~~{.sh} 47git clone https://github.com/spdk/spdk 48cd spdk 49git submodule update --init 50~~~ 51 52<a id="prerequisites"></a> 53## Prerequisites 54 55The dependencies can be installed automatically by `scripts/pkgdep.sh`. 56The `scripts/pkgdep.sh` script will automatically install the bare minimum 57dependencies required to build SPDK. 58Use `--help` to see information on installing dependencies for optional components 59 60~~~{.sh} 61./scripts/pkgdep.sh 62~~~ 63 64<a id="libraries"></a> 65## Build 66 67Linux: 68 69~~~{.sh} 70./configure 71make 72~~~ 73 74FreeBSD: 75Note: Make sure you have the matching kernel source in /usr/src/ and 76also note that CONFIG_COVERAGE option is not available right now 77for FreeBSD builds. 78 79~~~{.sh} 80./configure 81gmake 82~~~ 83 84<a id="tests"></a> 85## Unit Tests 86 87~~~{.sh} 88./test/unit/unittest.sh 89~~~ 90 91You will see several error messages when running the unit tests, but they are 92part of the test suite. The final message at the end of the script indicates 93success or failure. 94 95<a id="vagrant"></a> 96## Vagrant 97 98A [Vagrant](https://www.vagrantup.com/downloads.html) setup is also provided 99to create a Linux VM with a virtual NVMe controller to get up and running 100quickly. Currently this has been tested on MacOS, Ubuntu 16.04.2 LTS and 101Ubuntu 18.04.3 LTS with the VirtualBox and Libvirt provider. 102The [VirtualBox Extension Pack](https://www.virtualbox.org/wiki/Downloads) 103or [Vagrant Libvirt] (https://github.com/vagrant-libvirt/vagrant-libvirt) must 104also be installed in order to get the required NVMe support. 105 106Details on the Vagrant setup can be found in the 107[SPDK Vagrant documentation](http://spdk.io/doc/vagrant.html). 108 109<a id="aws"></a> 110## AWS 111 112The following setup is known to work on AWS: 113Image: Ubuntu 18.04 114Before running `setup.sh`, run `modprobe vfio-pci` 115then: `DRIVER_OVERRIDE=vfio-pci ./setup.sh` 116 117<a id="advanced"></a> 118## Advanced Build Options 119 120Optional components and other build-time configuration are controlled by 121settings in the Makefile configuration file in the root of the repository. `CONFIG` 122contains the base settings for the `configure` script. This script generates a new 123file, `mk/config.mk`, that contains final build settings. For advanced configuration, 124there are a number of additional options to `configure` that may be used, or 125`mk/config.mk` can simply be created and edited by hand. A description of all 126possible options is located in `CONFIG`. 127 128Boolean (on/off) options are configured with a 'y' (yes) or 'n' (no). For 129example, this line of `CONFIG` controls whether the optional RDMA (libibverbs) 130support is enabled: 131 132 CONFIG_RDMA?=n 133 134To enable RDMA, this line may be added to `mk/config.mk` with a 'y' instead of 135'n'. For the majority of options this can be done using the `configure` script. 136For example: 137 138~~~{.sh} 139./configure --with-rdma 140~~~ 141 142Additionally, `CONFIG` options may also be overridden on the `make` command 143line: 144 145~~~{.sh} 146make CONFIG_RDMA=y 147~~~ 148 149Users may wish to use a version of DPDK different from the submodule included 150in the SPDK repository. Note, this includes the ability to build not only 151from DPDK sources, but also just with the includes and libraries 152installed via the dpdk and dpdk-devel packages. To specify an alternate DPDK 153installation, run configure with the --with-dpdk option. For example: 154 155Linux: 156 157~~~{.sh} 158./configure --with-dpdk=/path/to/dpdk/x86_64-native-linuxapp-gcc 159make 160~~~ 161 162FreeBSD: 163 164~~~{.sh} 165./configure --with-dpdk=/path/to/dpdk/x86_64-native-bsdapp-clang 166gmake 167~~~ 168 169The options specified on the `make` command line take precedence over the 170values in `mk/config.mk`. This can be useful if you, for example, generate 171a `mk/config.mk` using the `configure` script and then have one or two 172options (i.e. debug builds) that you wish to turn on and off frequently. 173 174<a id="shared"></a> 175## Shared libraries 176 177By default, the build of the SPDK yields static libraries against which 178the SPDK applications and examples are linked. 179Configure option `--with-shared` provides the ability to produce SPDK shared 180libraries, in addition to the default static ones. Use of this flag also 181results in the SPDK executables linked to the shared versions of libraries. 182SPDK shared libraries by default, are located in `./build/lib`. This includes 183the single SPDK shared lib encompassing all of the SPDK static libs 184(`libspdk.so`) as well as individual SPDK shared libs corresponding to each 185of the SPDK static ones. 186 187In order to start a SPDK app linked with SPDK shared libraries, make sure 188to do the following steps: 189 190- run ldconfig specifying the directory containing SPDK shared libraries 191- provide proper `LD_LIBRARY_PATH` 192 193If DPDK shared libraries are used, you may also need to add DPDK shared 194libraries to `LD_LIBRARY_PATH` 195 196Linux: 197 198~~~{.sh} 199./configure --with-shared 200make 201ldconfig -v -n ./build/lib 202LD_LIBRARY_PATH=./build/lib/:./dpdk/build/lib/ ./build/bin/spdk_tgt 203~~~ 204 205<a id="huge"></a> 206## Hugepages and Device Binding 207 208Before running an SPDK application, some hugepages must be allocated and 209any NVMe and I/OAT devices must be unbound from the native kernel drivers. 210SPDK includes a script to automate this process on both Linux and FreeBSD. 211This script should be run as root. 212 213~~~{.sh} 214sudo scripts/setup.sh 215~~~ 216 217Users may wish to configure a specific memory size. Below is an example of 218configuring 8192MB memory. 219 220~~~{.sh} 221sudo HUGEMEM=8192 scripts/setup.sh 222~~~ 223 224<a id="examples"></a> 225## Example Code 226 227Example code is located in the examples directory. The examples are compiled 228automatically as part of the build process. Simply call any of the examples 229with no arguments to see the help output. You'll likely need to run the examples 230as a privileged user (root) unless you've done additional configuration 231to grant your user permission to allocate huge pages and map devices through 232vfio. 233 234<a id="contributing"></a> 235## Contributing 236 237For additional details on how to get more involved in the community, including 238[contributing code](http://www.spdk.io/development) and participating in discussions and other activities, please 239refer to [spdk.io](http://www.spdk.io/community) 240