docs: fix spelling errors
[vpp.git] / src / examples / sample-plugin / sample_plugin_doc.rst
1 .. _sample_plugin_doc:
2
3 Sample plugin for VPP
4 =====================
5
6 Overview
7 --------
8
9 This is the VPP sample plugin demonstrates how to create a new plugin
10 that integrates with VPP. The sample code implements a trivial macswap
11 algorithm that demonstrates plugin runtime integration with the VPP
12 graph hierarchy, api and cli.
13
14 For deeper dive information see the annotations in the sample code
15 itself. See `sample.c <@ref%20sample.c>`__
16
17 How to build and run the sample plugin.
18 ---------------------------------------
19
20 Now (re)build VPP.
21
22 ::
23
24    $ make wipe
25
26 Define environmental variable ‘SAMPLE_PLUGIN=yes’ with a process scope
27
28 ::
29
30    $ SAMPLE_PLUGIN=yes make build
31
32 or a session scope, and build VPP.
33
34 ::
35
36    $ export SAMPLE_PLUGIN=yes
37    $ make build
38
39 Now run VPP and make sure the plugin is loaded.
40
41 ::
42
43    $ make run
44    ...
45    load_one_plugin:184: Loaded plugin: memif_plugin.so (Packet Memory Interface (experimetal))
46    load_one_plugin:184: Loaded plugin: sample_plugin.so (Sample of VPP Plugin)
47    load_one_plugin:184: Loaded plugin: nat_plugin.so (Network Address Translation)
48    ...
49    DBGvpp#
50
51 How to create a new plugin
52 --------------------------
53
54 To create a new plugin based on the sample plugin, copy and rename the
55 sample plugin directory and automake config.
56
57 ::
58
59    cp -r src/examples/sample-plugin/sample src/plugins/newplugin
60    cp src/examples/sample-plugin/sample.am src/plugins/newplugin.am
61
62 Add the following entry to the plugins section of ``src/configure.ac``.
63
64 ::
65
66    PLUGIN_ENABLED(newplugin)
67
68 Add the following entry to the plugins section of
69 ``src/plugins/Makefile.am``
70
71 ::
72
73    if ENABLE_NEWPLUGIN
74    include newplugin.am
75    endif
76
77 Now (re)build VPP.
78
79 ::
80
81    $ make wipe
82    $ make build
83
84 Configuration
85 -------------
86
87 To enable the sample plugin
88
89 ::
90
91    sample macswap <interface name>
92
93 To disable the sample plugin
94
95 ::
96
97    sample macswap <interface name> disable