1735f7a5cSBen Walker# Getting Started {#getting_started} 2735f7a5cSBen Walker 31e1fd9acSwawryk## Getting the Source Code {#getting_started_source} 4735f7a5cSBen Walker 5735f7a5cSBen Walker~~~{.sh} 601a88849Spaul lusegit clone https://github.com/spdk/spdk --recursive 7735f7a5cSBen Walker~~~ 8735f7a5cSBen Walker 91e1fd9acSwawryk## Installing Prerequisites {#getting_started_prerequisites} 109b3ae064SJim Harris 119ebbf3acSMaciej WawrykThe `scripts/pkgdep.sh` script will automatically install the bare minimum 129ebbf3acSMaciej Wawrykdependencies required to build SPDK. 139ebbf3acSMaciej WawrykUse `--help` to see information on installing dependencies for optional components. 145c40019fSDaniel Verkamp 159b3ae064SJim Harris~~~{.sh} 165c40019fSDaniel Verkampsudo scripts/pkgdep.sh 179b3ae064SJim Harris~~~ 189b3ae064SJim Harris 199ebbf3acSMaciej WawrykOption --all will install all dependencies needed by SPDK features. 209ebbf3acSMaciej Wawryk 219ebbf3acSMaciej Wawryk~~~{.sh} 229ebbf3acSMaciej Wawryksudo scripts/pkgdep.sh --all 239ebbf3acSMaciej Wawryk~~~ 249ebbf3acSMaciej Wawryk 251e1fd9acSwawryk## Building {#getting_started_building} 26735f7a5cSBen Walker 27735f7a5cSBen WalkerLinux: 28735f7a5cSBen Walker 29735f7a5cSBen Walker~~~{.sh} 30735f7a5cSBen Walker./configure 31735f7a5cSBen Walkermake 32735f7a5cSBen Walker~~~ 33735f7a5cSBen Walker 34735f7a5cSBen WalkerFreeBSD: 35735f7a5cSBen WalkerNote: Make sure you have the matching kernel source in /usr/src/ 36735f7a5cSBen Walker 37735f7a5cSBen Walker~~~{.sh} 38735f7a5cSBen Walker./configure 39735f7a5cSBen Walkergmake 40735f7a5cSBen Walker~~~ 41735f7a5cSBen Walker 42735f7a5cSBen WalkerThere are a number of options available for the configure script, which can 43735f7a5cSBen Walkerbe viewed by running 44735f7a5cSBen Walker 45735f7a5cSBen Walker~~~{.sh} 46735f7a5cSBen Walker./configure --help 47735f7a5cSBen Walker~~~ 48735f7a5cSBen Walker 49735f7a5cSBen WalkerNote that not all features are enabled by default. For example, RDMA 50735f7a5cSBen Walkersupport (and hence NVMe over Fabrics) is not enabled by default. You 51735f7a5cSBen Walkercan enable it by doing the following: 52735f7a5cSBen Walker 53735f7a5cSBen Walker~~~{.sh} 54735f7a5cSBen Walker./configure --with-rdma 55735f7a5cSBen Walkermake 56735f7a5cSBen Walker~~~ 57735f7a5cSBen Walker 581e1fd9acSwawryk## Running the Unit Tests {#getting_started_unittests} 59735f7a5cSBen Walker 60735f7a5cSBen WalkerIt's always a good idea to confirm your build worked by running the 61735f7a5cSBen Walkerunit tests. 62735f7a5cSBen Walker 63735f7a5cSBen Walker~~~{.sh} 6412e840b9SSeth Howell./test/unit/unittest.sh 65735f7a5cSBen Walker~~~ 66735f7a5cSBen Walker 67735f7a5cSBen WalkerYou will see several error messages when running the unit tests, but they are 68735f7a5cSBen Walkerpart of the test suite. The final message at the end of the script indicates 69735f7a5cSBen Walkersuccess or failure. 70735f7a5cSBen Walker 711e1fd9acSwawryk## Running the Example Applications {#getting_started_examples} 72735f7a5cSBen Walker 73735f7a5cSBen WalkerBefore running an SPDK application, some hugepages must be allocated and 74735f7a5cSBen Walkerany NVMe and I/OAT devices must be unbound from the native kernel drivers. 75735f7a5cSBen WalkerSPDK includes a script to automate this process on both Linux and FreeBSD. 76735f7a5cSBen WalkerThis script should be run as root. It only needs to be run once on the 770eff26b3SDariusz Stojaczyksystem. 78735f7a5cSBen Walker 79735f7a5cSBen Walker~~~{.sh} 80735f7a5cSBen Walkersudo scripts/setup.sh 81735f7a5cSBen Walker~~~ 82735f7a5cSBen Walker 83735f7a5cSBen WalkerTo rebind devices back to the kernel, you can run 84735f7a5cSBen Walker 85735f7a5cSBen Walker~~~{.sh} 86735f7a5cSBen Walkersudo scripts/setup.sh reset 87735f7a5cSBen Walker~~~ 88735f7a5cSBen Walker 89f062f797SHailiang WangBy default, the script allocates 2048MB of hugepages. To change this number, 90f062f797SHailiang Wangspecify HUGEMEM (in MB) as follows: 91735f7a5cSBen Walker 92735f7a5cSBen Walker~~~{.sh} 93f062f797SHailiang Wangsudo HUGEMEM=4096 scripts/setup.sh 94735f7a5cSBen Walker~~~ 95735f7a5cSBen Walker 96f062f797SHailiang WangOn Linux machines HUGEMEM will be rounded up to system-default huge page 97f062f797SHailiang Wangsize boundary. 98f062f797SHailiang Wang 990eff26b3SDariusz StojaczykAll available params can be viewed by running 1000eff26b3SDariusz Stojaczyk 1010eff26b3SDariusz Stojaczyk~~~{.sh} 1020eff26b3SDariusz Stojaczykscripts/setup.sh help 1030eff26b3SDariusz Stojaczyk~~~ 1040eff26b3SDariusz Stojaczyk 105735f7a5cSBen WalkerExample code is located in the examples directory. The examples are compiled 106735f7a5cSBen Walkerautomatically as part of the build process. Simply call any of the examples 107735f7a5cSBen Walkerwith no arguments to see the help output. If your system has its IOMMU 108735f7a5cSBen Walkerenabled you can run the examples as your regular user. If it doesn't, you'll 109735f7a5cSBen Walkerneed to run as a privileged user (root). 110735f7a5cSBen Walker 111*017f65b5SBen WalkerA good example to start with is `build/bin/spdk_nvme_identify`, which prints 112735f7a5cSBen Walkerout information about all of the NVMe devices on your system. 113735f7a5cSBen Walker 114735f7a5cSBen WalkerLarger, more fully functional applications are available in the `app` 115d5da6912SKrzysztof Karasdirectory. This includes the [iSCSI target](https://spdk.io/doc/iscsi.html) 116d5da6912SKrzysztof Karasand [NVMe-oF target](https://spdk.io/doc/nvmf.html) and tools like 117d5da6912SKrzysztof Karas[spdk_top](https://spdk.io/doc/spdk_top.html). This neat program simulates 118d5da6912SKrzysztof Karasregular `top` application and shows SPDK threads, pollers and SPDK assigned 119d5da6912SKrzysztof KarasCPU cores statistics in a form of interactive list. 120