2017-08-29 17:40:05 +00:00
|
|
|
# Getting Started {#getting_started}
|
|
|
|
|
2021-08-02 12:27:54 +00:00
|
|
|
## Getting the Source Code {#getting_started_source}
|
2017-08-29 17:40:05 +00:00
|
|
|
|
|
|
|
~~~{.sh}
|
|
|
|
git clone https://github.com/spdk/spdk
|
|
|
|
cd spdk
|
|
|
|
git submodule update --init
|
|
|
|
~~~
|
|
|
|
|
2021-08-02 12:27:54 +00:00
|
|
|
## Installing Prerequisites {#getting_started_prerequisites}
|
2017-11-03 20:27:17 +00:00
|
|
|
|
2020-01-14 09:59:31 +00:00
|
|
|
The `scripts/pkgdep.sh` script will automatically install the bare minimum
|
|
|
|
dependencies required to build SPDK.
|
|
|
|
Use `--help` to see information on installing dependencies for optional components.
|
2017-11-30 23:25:15 +00:00
|
|
|
|
2017-11-03 20:27:17 +00:00
|
|
|
~~~{.sh}
|
2017-11-30 23:25:15 +00:00
|
|
|
sudo scripts/pkgdep.sh
|
2017-11-03 20:27:17 +00:00
|
|
|
~~~
|
|
|
|
|
2020-01-14 09:59:31 +00:00
|
|
|
Option --all will install all dependencies needed by SPDK features.
|
|
|
|
|
|
|
|
~~~{.sh}
|
|
|
|
sudo scripts/pkgdep.sh --all
|
|
|
|
~~~
|
|
|
|
|
2021-08-02 12:27:54 +00:00
|
|
|
## Building {#getting_started_building}
|
2017-08-29 17:40:05 +00:00
|
|
|
|
|
|
|
Linux:
|
|
|
|
|
|
|
|
~~~{.sh}
|
|
|
|
./configure
|
|
|
|
make
|
|
|
|
~~~
|
|
|
|
|
|
|
|
FreeBSD:
|
|
|
|
Note: Make sure you have the matching kernel source in /usr/src/
|
|
|
|
|
|
|
|
~~~{.sh}
|
|
|
|
./configure
|
|
|
|
gmake
|
|
|
|
~~~
|
|
|
|
|
|
|
|
There are a number of options available for the configure script, which can
|
|
|
|
be viewed by running
|
|
|
|
|
|
|
|
~~~{.sh}
|
|
|
|
./configure --help
|
|
|
|
~~~
|
|
|
|
|
|
|
|
Note that not all features are enabled by default. For example, RDMA
|
|
|
|
support (and hence NVMe over Fabrics) is not enabled by default. You
|
|
|
|
can enable it by doing the following:
|
|
|
|
|
|
|
|
~~~{.sh}
|
|
|
|
./configure --with-rdma
|
|
|
|
make
|
|
|
|
~~~
|
|
|
|
|
2021-08-02 12:27:54 +00:00
|
|
|
## Running the Unit Tests {#getting_started_unittests}
|
2017-08-29 17:40:05 +00:00
|
|
|
|
|
|
|
It's always a good idea to confirm your build worked by running the
|
|
|
|
unit tests.
|
|
|
|
|
|
|
|
~~~{.sh}
|
2018-02-27 23:07:35 +00:00
|
|
|
./test/unit/unittest.sh
|
2017-08-29 17:40:05 +00:00
|
|
|
~~~
|
|
|
|
|
|
|
|
You will see several error messages when running the unit tests, but they are
|
|
|
|
part of the test suite. The final message at the end of the script indicates
|
|
|
|
success or failure.
|
|
|
|
|
2021-08-02 12:27:54 +00:00
|
|
|
## Running the Example Applications {#getting_started_examples}
|
2017-08-29 17:40:05 +00:00
|
|
|
|
|
|
|
Before running an SPDK application, some hugepages must be allocated and
|
|
|
|
any NVMe and I/OAT devices must be unbound from the native kernel drivers.
|
|
|
|
SPDK includes a script to automate this process on both Linux and FreeBSD.
|
|
|
|
This script should be run as root. It only needs to be run once on the
|
2018-01-26 15:40:12 +00:00
|
|
|
system.
|
2017-08-29 17:40:05 +00:00
|
|
|
|
|
|
|
~~~{.sh}
|
|
|
|
sudo scripts/setup.sh
|
|
|
|
~~~
|
|
|
|
|
|
|
|
To rebind devices back to the kernel, you can run
|
|
|
|
|
|
|
|
~~~{.sh}
|
|
|
|
sudo scripts/setup.sh reset
|
|
|
|
~~~
|
|
|
|
|
2017-08-30 18:20:22 +00:00
|
|
|
By default, the script allocates 2048MB of hugepages. To change this number,
|
|
|
|
specify HUGEMEM (in MB) as follows:
|
2017-08-29 17:40:05 +00:00
|
|
|
|
|
|
|
~~~{.sh}
|
2017-08-30 18:20:22 +00:00
|
|
|
sudo HUGEMEM=4096 scripts/setup.sh
|
2017-08-29 17:40:05 +00:00
|
|
|
~~~
|
|
|
|
|
2017-08-30 18:20:22 +00:00
|
|
|
On Linux machines HUGEMEM will be rounded up to system-default huge page
|
|
|
|
size boundary.
|
|
|
|
|
2018-01-26 15:40:12 +00:00
|
|
|
All available params can be viewed by running
|
|
|
|
|
|
|
|
~~~{.sh}
|
|
|
|
scripts/setup.sh help
|
|
|
|
~~~
|
|
|
|
|
2017-08-29 17:40:05 +00:00
|
|
|
Example code is located in the examples directory. The examples are compiled
|
|
|
|
automatically as part of the build process. Simply call any of the examples
|
|
|
|
with no arguments to see the help output. If your system has its IOMMU
|
|
|
|
enabled you can run the examples as your regular user. If it doesn't, you'll
|
|
|
|
need to run as a privileged user (root).
|
|
|
|
|
2020-05-11 22:02:01 +00:00
|
|
|
A good example to start with is `build/examples/identify`, which prints
|
2017-08-29 17:40:05 +00:00
|
|
|
out information about all of the NVMe devices on your system.
|
|
|
|
|
|
|
|
Larger, more fully functional applications are available in the `app`
|
|
|
|
directory. This includes the iSCSI and NVMe-oF target.
|