3 Contributing Code to DPDK
4 =========================
6 This document outlines the guidelines for submitting code to DPDK.
8 The DPDK development process is modelled (loosely) on the Linux Kernel development model so it is worth reading the
9 Linux kernel guide on submitting patches:
10 `How to Get Your Change Into the Linux Kernel <http://www.kernel.org/doc/Documentation/SubmittingPatches>`_.
11 The rationale for many of the DPDK guidelines is explained in greater detail in the kernel guidelines.
14 The DPDK Development Process
15 -----------------------------
17 The DPDK development process has the following features:
19 * The code is hosted in a public git repository.
20 * There is a mailing list where developers submit patches.
21 * There are maintainers for hierarchical components.
22 * Patches are reviewed publicly on the mailing list.
23 * Successfully reviewed patches are merged to the master branch of the repository.
25 The mailing list for DPDK development is `dev@dpkg.org <http://dpdk.org/ml/archives/dev/>`_.
26 Contributors will need to `register for the mailing list <http://dpdk.org/ml/listinfo/dev>`_ in order to submit patches.
27 It is also worth registering for the DPDK `Patchwork <http://dpdk.org/dev/patchwxispork/project/dpdk/list/>`_
29 The development process requires some familiarity with the ``git`` version control system.
30 Refer to the `Pro Git Book <http://www.git-scm.com/book/>`_ for further information.
33 Getting the Source Code
34 -----------------------
36 The source code can be cloned using either of the following::
38 git clone git://dpdk.org/dpdk
40 git clone http://dpdk.org/git/dpdk
46 Make your planned changes in the cloned ``dpdk`` repo. Here are some guidelines and requirements:
48 * Follow the :ref:`coding_style` guidelines.
50 * If you add new files or directories you should add your name to the ``MAINTAINERS`` file.
52 * New external functions should be added to the local ``version.map`` file.
53 See the :doc:`Guidelines for ABI policy and versioning </contributing/versioning>`.
54 New external functions should also be added in alphabetical order.
56 * Important changes will require an addition to the release notes in ``doc/guides/rel_notes/``.
57 See the :ref:`Release Notes section of the Documentation Guidelines <doc_guidelines>` for details.
59 * Test the compilation works with different targets, compilers and options, see :ref:`contrib_check_compilation`.
61 * Don't break compilation between commits with forward dependencies in a patchset.
62 Each commit should compile on its own to allow for ``git bisect`` and continuous integration testing.
64 * Add tests to the the ``app/test`` unit test framework where possible.
66 * Add documentation, if relevant, in the form of Doxygen comments or a User Guide in RST format.
67 See the :ref:`Documentation Guidelines <doc_guidelines>`.
69 Once the changes have been made you should commit them to your local repo.
71 For small changes, that do not require specific explanations, it is better to keep things together in the
73 Larger changes that require different explanations should be separated into logical patches in a patchset.
74 A good way of thinking about whether a patch should be split is to consider whether the change could be
75 applied without dependencies as a backport.
77 As a guide to how patches should be structured run ``git log`` on similar files.
80 Commit Messages: Subject Line
81 -----------------------------
83 The first, summary, line of the git commit message becomes the subject line of the patch email.
84 Here are some guidelines for the summary line:
86 * The summary line must capture the area and the impact of the change.
88 * The summary line should be around 50 characters.
90 * The summary line should be lowercase apart from acronyms.
92 * It should be prefixed with the component name (use git log to check existing components).
95 ixgbe: fix offload config option name
97 config: increase max queues per port
99 * Use the imperative of the verb (like instructions to the code base).
101 * Don't add a period/full stop to the subject line or you will end up two in the patch name: ``dpdk_description..patch``.
103 The actual email subject line should be prefixed by ``[PATCH]`` and the version, if greater than v1,
104 for example: ``PATCH v2``.
105 The is generally added by ``git send-email`` or ``git format-patch``, see below.
107 If you are submitting an RFC draft of a feature you can use ``[RFC]`` instead of ``[PATCH]``.
108 An RFC patch doesn't have to be complete.
109 It is intended as a way of getting early feedback.
112 Commit Messages: Body
113 ---------------------
115 Here are some guidelines for the body of a commit message:
117 * The body of the message should describe the issue being fixed or the feature being added.
118 It is important to provide enough information to allow a reviewer to understand the purpose of the patch.
120 * When the change is obvious the body can be blank, apart from the signoff.
122 * The commit message must end with a ``Signed-off-by:`` line which is added using::
124 git commit --signoff # or -s
126 The purpose of the signoff is explained in the
127 `Developer's Certificate of Origin <http://www.kernel.org/doc/Documentation/SubmittingPatches>`_
128 section of the Linux kernel guidelines.
132 All developers must ensure that they have read and understood the
133 Developer's Certificate of Origin section of the documentation prior
134 to applying the signoff and submitting a patch.
136 * The signoff must be a real name and not an alias or nickname.
137 More than one signoff is allowed.
139 * The text of the commit message should be wrapped at 72 characters.
141 * When fixing a regression, it is a good idea to reference the id of the commit which introduced the bug.
142 You can generate the required text using the following git alias::
144 git config alias.fixline "log -1 --abbrev=12 --format='Fixes: %h (\"%s\")'"
146 The ``Fixes:`` line can then be added to the commit message::
148 doc: fix vhost sample parameter
150 Update the docs to reflect removed dev-index.
152 Fixes: 17b8320a3e11 ("vhost: remove index parameter")
154 Signed-off-by: Alex Smith <alex.smith@example.com>
156 * When fixing an error or warning it is useful to add the error message and instructions on how to reproduce it.
158 * Use correct capitalization, punctuation and spelling.
160 In addition to the ``Signed-off-by:`` name the commit messages can also have one or more of the following:
162 * ``Reported-by:`` The reporter of the issue.
163 * ``Tested-by:`` The tester of the change.
164 * ``Reviewed-by:`` The reviewer of the change.
165 * ``Suggested-by:`` The person who suggested the change.
166 * ``Acked-by:`` When a previous version of the patch was acked and the ack is still relevant.
172 It is possible to send patches directly from git but for new contributors it is recommended to generate the
173 patches with ``git format-patch`` and then when everything looks okay, and the patches have been checked, to
174 send them with ``git send-email``.
176 Here are some examples of using ``git format-patch`` to generate patches:
178 .. code-block:: console
180 # Generate a patch from the last commit.
183 # Generate a patch from the last 3 commits.
186 # Generate the patches in a directory.
187 git format-patch -3 -o ~/patch/
189 # Add a cover letter to explain a patchset.
190 git format-patch -3 -o ~/patch/ --cover-letter
192 # Add a prefix with a version number.
193 git format-patch -3 -o ~/patch/ -v 2
196 Cover letters are useful for explaining a patchset and help to generate a logical threading to the patches.
197 Smaller notes can be put inline in the patch after the ``---`` separator, for example::
199 Subject: [PATCH] fm10k/base: add FM10420 device ids
201 Add the device ID for Boulder Rapids and Atwood Channel to enable
202 drivers to support those devices.
204 Signed-off-by: Alex Smith <alex.smith@example.com>
209 drivers/net/fm10k/base/fm10k_api.c | 6 ++++++
210 drivers/net/fm10k/base/fm10k_type.h | 6 ++++++
211 2 files changed, 12 insertions(+)
214 Version 2 and later of a patchset should also include a short log of the changes so the reviewer knows what has changed.
215 This can be added to the cover letter or the annotations.
220 * Fixed issued with version.map.
223 * Added i40e support.
224 * Renamed ethdev functions from rte_eth_ieee15888_*() to rte_eth_timesync_*()
225 since 802.1AS can be supported through the same interfaces.
228 .. _contrib_checkpatch:
233 Patches should be checked for formatting and syntax issues using the ``checkpatches.sh`` script in the ``scripts``
234 directory of the DPDK repo.
235 This uses the Linux kernel development tool ``checkpatch.pl`` which can be obtained by cloning, and periodically,
236 updating the Linux kernel sources.
238 The path to the original Linux script must be set in the environment variable ``DPDK_CHECKPATCH_PATH``.
239 This, and any other configuration variables required by the development tools, are loaded from the following
240 files, in order of preference::
243 ~/.config/dpdk/devel.config
244 /etc/dpdk/devel.config.
246 Once the environment variable the script can be run as follows::
248 scripts/checkpatches.sh ~/patch/
250 The script usage is::
252 checkpatches.sh [-h] [-q] [-v] [patch1 [patch2] ...]]"
256 * ``-h``: help, usage.
257 * ``-q``: quiet. Don't output anything for files without issues.
259 * ``patchX``: path to one or more patches.
262 .. _contrib_check_compilation:
267 Compilation of patches and changes should be tested using the the ``test-build.sh`` script in the ``scripts``
268 directory of the DPDK repo::
270 scripts/test-build.sh x86_64-native-linuxapp-gcc+next+shared
272 The script usage is::
274 test-build.sh [-h] [-jX] [-s] [config1 [config2] ...]]
278 * ``-h``: help, usage.
279 * ``-jX``: use X parallel jobs in "make".
280 * ``-s``: short test with only first config and without examples/doc.
281 * ``config``: default config name plus config switches delimited with a ``+`` sign.
283 Examples of configs are::
285 x86_64-native-linuxapp-gcc
286 x86_64-native-linuxapp-gcc+next+shared
287 x86_64-native-linuxapp-clang+shared
289 The builds can be modifies via the following environmental variables:
291 * ``DPDK_BUILD_TEST_CONFIGS`` (target1+option1+option2 target2)
292 * ``DPDK_DEP_CFLAGS``
293 * ``DPDK_DEP_LDFLAGS``
294 * ``DPDK_DEP_MOFED`` (y/[n])
295 * ``DPDK_DEP_PCAP`` (y/[n])
296 * ``DPDK_NOTIFY`` (notify-send)
298 These can be set from the command line or in the config files shown above in the :ref:`contrib_checkpatch`.
300 The recommended configurations and options to test compilation prior to submitting patches are::
302 x86_64-native-linuxapp-gcc+shared+next
303 x86_64-native-linuxapp-clang+shared
304 i686-native-linuxapp-gcc
306 export DPDK_DEP_ZLIB=y
307 export DPDK_DEP_PCAP=y
308 export DPDK_DEP_SSL=y
314 Patches should be sent to the mailing list using ``git send-email``.
315 You can configure an external SMTP with something like the following::
318 smtpuser = name@domain.com
319 smtpserver = smtp.domain.com
323 See the `Git send-email <https://git-scm.com/docs/git-send-email>`_ documentation for more details.
325 The patches should be sent to ``dev@dpdk.org``.
326 If the patches are a change to existing files then you should send them TO the maintainer(s) and CC ``dev@dpdk.org``.
327 The appropriate maintainer can be found in the ``MAINTAINERS`` file::
329 git send-email --to maintainer@some.org --cc dev@dpdk.org 000*.patch
331 New additions can be sent without a maintainer::
333 git send-email --to dev@dpdk.org 000*.patch
335 You can test the emails by sending it to yourself or with the ``--dry-run`` option.
337 If the patch is in relation to a previous email thread you can add it to the same thread using the Message ID::
339 git send-email --to dev@dpdk.org --in-reply-to <1234-foo@bar.com> 000*.patch
341 The Message ID can be found in the raw text of emails or at the top of each Patchwork patch,
342 `for example <http://dpdk.org/dev/patchwork/patch/7646/>`_.
343 Shallow threading (``--thread --no-chain-reply-to``) is preferred for a patch series.
345 Once submitted your patches will appear on the mailing list and in Patchwork.
347 Experienced committers may send patches directly with ``git send-email`` without the ``git format-patch`` step.
348 The options ``--annotate`` and ``confirm = always`` are recommended for checking patches before sending.
354 The more work you put into the previous steps the easier it will be to get a patch accepted.
356 The general cycle for patch review and acceptance is:
360 #. Check the automatic test reports in the coming hours.
362 #. Wait for review comments. While you are waiting review some other patches.
364 #. Fix the review comments and submit a ``v n+1`` patchset::
366 git format-patch -3 -v 2
368 #. Update Patchwork to mark your previous patches as "Superseded".
370 #. If the patch is deemed suitable for merging by the relevant maintainer(s) or other developers they will ``ack``
371 the patch with an email that includes something like::
373 Acked-by: Alex Smith <alex.smith@example.com>
375 **Note**: When acking patches please remove as much of the text of the patch email as possible.
376 It is generally best to delete everything after the ``Signed-off-by:`` line.
378 #. Having the patch ``Reviewed-by:`` and/or ``Tested-by:`` will also help the patch to be accepted.
380 #. If the patch isn't deemed suitable based on being out of scope or conflicting with existing functionality
381 it may receive a ``nack``.
382 In this case you will need to make a more convincing technical argument in favor of your patches.
384 #. In addition a patch will not be accepted if it doesn't address comments from a previous version with fixes or
387 #. Acked patches will be merged in the current or next merge window.