xref: /spdk/doc/overview.md (revision 1e1fd9ac219da3e52bc166c9d2bb2376c62c113d)
168f9bbc7SBen Walker# SPDK Structural Overview {#overview}
268f9bbc7SBen Walker
3*1e1fd9acSwawryk## Overview {#dir_overview}
468f9bbc7SBen Walker
530af9d37SBen WalkerSPDK is composed of a set of C libraries residing in `lib` with public interface
630af9d37SBen Walkerheader files in `include/spdk`, plus a set of applications built out of those
730af9d37SBen Walkerlibraries in `app`. Users can use the C libraries in their software or deploy
830af9d37SBen Walkerthe full SPDK applications.
930af9d37SBen Walker
1030af9d37SBen WalkerSPDK is designed around message passing instead of locking, and most of the SPDK
1130af9d37SBen Walkerlibraries make several assumptions about the underlying threading model of the
1230af9d37SBen Walkerapplication they are embedded into. However, SPDK goes to great lengths to remain
1330af9d37SBen Walkeragnostic to the specific message passing, event, co-routine, or light-weight
1430af9d37SBen Walkerthreading framework actually in use. To accomplish this, all SPDK libraries
1530af9d37SBen Walkerinteract with an abstraction library in `lib/thread` (public interface at
1630af9d37SBen Walker`include/spdk/thread.h`). Any framework can initialize the threading abstraction
1730af9d37SBen Walkerand provide callbacks to implement the functionality that the SPDK libraries
1830af9d37SBen Walkerneed. For more information on this abstraction, see @ref concurrency.
1930af9d37SBen Walker
2030af9d37SBen WalkerSPDK is built on top of POSIX for most operations. To make porting to non-POSIX
2130af9d37SBen Walkerenvironments easier, all POSIX headers are isolated into
2230af9d37SBen Walker`include/spdk/stdinc.h`. However, SPDK requires a number of operations that
2330af9d37SBen WalkerPOSIX does not provide, such as enumerating the PCI devices on the system or
2430af9d37SBen Walkerallocating memory that is safe for DMA. These additional operations are all
2530af9d37SBen Walkerabstracted in a library called `env` whose public header is at
2630af9d37SBen Walker`include/spdk/env.h`. By default, SPDK implements the `env` interface using a
2730af9d37SBen Walkerlibrary based on DPDK. However, that implementation can be swapped out. See @ref
2830af9d37SBen Walkerporting for additional information.
2968f9bbc7SBen Walker
3068f9bbc7SBen Walker## Applications {#dir_app}
3168f9bbc7SBen Walker
3230af9d37SBen WalkerThe `app` top-level directory contains full-fledged applications, built out of the SPDK
3330af9d37SBen Walkercomponents. For a full overview, see @ref app_overview.
3468f9bbc7SBen Walker
3530af9d37SBen WalkerSPDK applications can typically be started with a small number of configuration
3630af9d37SBen Walkeroptions. Full configuration of the applications is then performed using
3730af9d37SBen WalkerJSON-RPC. See @ref jsonrpc for additional information.
3868f9bbc7SBen Walker
3930af9d37SBen Walker## Libraries {#dir_lib}
4068f9bbc7SBen Walker
4130af9d37SBen WalkerThe `lib` directory contains the real heart of SPDK. Each component is a C library with
4230af9d37SBen Walkerits own directory under `lib`. Some of the key libraries are:
4330af9d37SBen Walker
4430af9d37SBen Walker- @ref bdev
4530af9d37SBen Walker- @ref nvme
4668f9bbc7SBen Walker
4768f9bbc7SBen Walker## Documentation {#dir_doc}
4868f9bbc7SBen Walker
4968f9bbc7SBen WalkerThe `doc` top-level directory contains all of SPDK's documentation. API Documentation
5068f9bbc7SBen Walkeris created using Doxygen directly from the code, but more general articles and longer
5168f9bbc7SBen Walkerexplanations reside in this directory, as well as the Doxygen config file.
5268f9bbc7SBen Walker
5368f9bbc7SBen WalkerTo build the documentation, just type `make` within the doc directory.
5468f9bbc7SBen Walker
5568f9bbc7SBen Walker## Examples {#dir_examples}
5668f9bbc7SBen Walker
5768f9bbc7SBen WalkerThe `examples` top-level directory contains a set of examples intended to be used
5868f9bbc7SBen Walkerfor reference. These are different than the applications, which are doing a "real"
5968f9bbc7SBen Walkertask that could reasonably be deployed. The examples are instead either heavily
6068f9bbc7SBen Walkercontrived to demonstrate some facet of SPDK, or aren't considered complete enough
6168f9bbc7SBen Walkerto warrant tagging them as a full blown SPDK application.
6268f9bbc7SBen Walker
6368f9bbc7SBen WalkerThis is a great place to learn about how SPDK works. In particular, check out
6468f9bbc7SBen Walker`examples/nvme/hello_world`.
6568f9bbc7SBen Walker
6668f9bbc7SBen Walker## Include {#dir_include}
6768f9bbc7SBen Walker
6868f9bbc7SBen WalkerThe `include` directory is where all of the header files are located. The public API
6968f9bbc7SBen Walkeris all placed in the `spdk` subdirectory of `include` and we highly
7068f9bbc7SBen Walkerrecommend that applications set their include path to the top level `include`
7168f9bbc7SBen Walkerdirectory and include the headers by prefixing `spdk/` like this:
7268f9bbc7SBen Walker
7368f9bbc7SBen Walker~~~{.c}
7468f9bbc7SBen Walker#include "spdk/nvme.h"
7568f9bbc7SBen Walker~~~
7668f9bbc7SBen Walker
7730af9d37SBen WalkerMost of the headers here correspond with a library in the `lib` directory. There
7830af9d37SBen Walkerare a few headers that stand alone, however. They are:
7968f9bbc7SBen Walker
8068f9bbc7SBen Walker- `assert.h`
8168f9bbc7SBen Walker- `barrier.h`
8268f9bbc7SBen Walker- `endian.h`
8368f9bbc7SBen Walker- `fd.h`
8468f9bbc7SBen Walker- `mmio.h`
8568f9bbc7SBen Walker- `queue.h` and `queue_extras.h`
8668f9bbc7SBen Walker- `string.h`
8768f9bbc7SBen Walker
8868f9bbc7SBen WalkerThere is also an `spdk_internal` directory that contains header files widely included
8968f9bbc7SBen Walkerby libraries within SPDK, but that are not part of the public API and would not be
9068f9bbc7SBen Walkerinstalled on a user's system.
9168f9bbc7SBen Walker
9268f9bbc7SBen Walker## Scripts {#dir_scripts}
9368f9bbc7SBen Walker
9468f9bbc7SBen WalkerThe `scripts` directory contains convenient scripts for a number of operations. The two most
9568f9bbc7SBen Walkerimportant are `check_format.sh`, which will use astyle and pep8 to check C, C++, and Python
9668f9bbc7SBen Walkercoding style against our defined conventions, and `setup.sh` which binds and unbinds devices
9768f9bbc7SBen Walkerfrom kernel drivers.
9868f9bbc7SBen Walker
9968f9bbc7SBen Walker## Tests {#dir_tests}
10068f9bbc7SBen Walker
10168f9bbc7SBen WalkerThe `test` directory contains all of the tests for SPDK's components and the subdirectories mirror
10268f9bbc7SBen Walkerthe structure of the entire repository. The tests are a mixture of unit tests and functional tests.
103