doc: add sub-repositories information
[dpdk.git] / doc / guides / contributing / patches.rst
1 .. submitting_patches:
2
3 Contributing Code to DPDK
4 =========================
5
6 This document outlines the guidelines for submitting code to DPDK.
7
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.
12
13
14 The DPDK Development Process
15 -----------------------------
16
17 The DPDK development process has the following features:
18
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 repository.
24
25 |
26
27 * There are main repository ``dpdk`` and sub-repositories ``dpdk-next-*``.
28 * A patch should be sent for its target repository. Like net drivers should be on top of dpdk-next-net repository.
29 * All sub-repositories are merged into main repository for -rc1 and -rc2 versions of the release.
30 * After -rc2 release all patches should target main repository.
31
32 The mailing list for DPDK development is `dev@dpdk.org <http://dpdk.org/ml/archives/dev/>`_.
33 Contributors will need to `register for the mailing list <http://dpdk.org/ml/listinfo/dev>`_ in order to submit patches.
34 It is also worth registering for the DPDK `Patchwork <http://dpdk.org/dev/patchwork/project/dpdk/list/>`_
35
36 The development process requires some familiarity with the ``git`` version control system.
37 Refer to the `Pro Git Book <http://www.git-scm.com/book/>`_ for further information.
38
39
40 Getting the Source Code
41 -----------------------
42
43 The source code can be cloned using either of the following:
44
45 main repository::
46
47     git clone git://dpdk.org/dpdk
48     git clone http://dpdk.org/git/dpdk
49
50 sub-repositories (`list <http://dpdk.org/browse/next>`_)::
51
52     git clone git://dpdk.org/next/dpdk-next-*
53     git clone http://dpdk.org/git/next/dpdk-next-*
54
55 Make your Changes
56 -----------------
57
58 Make your planned changes in the cloned ``dpdk`` repo. Here are some guidelines and requirements:
59
60 * Follow the :ref:`coding_style` guidelines.
61
62 * If you add new files or directories you should add your name to the ``MAINTAINERS`` file.
63
64 * New external functions should be added to the local ``version.map`` file.
65   See the :doc:`Guidelines for ABI policy and versioning </contributing/versioning>`.
66   New external functions should also be added in alphabetical order.
67
68 * Important changes will require an addition to the release notes in ``doc/guides/rel_notes/``.
69   See the :ref:`Release Notes section of the Documentation Guidelines <doc_guidelines>` for details.
70
71 * Test the compilation works with different targets, compilers and options, see :ref:`contrib_check_compilation`.
72
73 * Don't break compilation between commits with forward dependencies in a patchset.
74   Each commit should compile on its own to allow for ``git bisect`` and continuous integration testing.
75
76 * Add tests to the the ``app/test`` unit test framework where possible.
77
78 * Add documentation, if relevant, in the form of Doxygen comments or a User Guide in RST format.
79   See the :ref:`Documentation Guidelines <doc_guidelines>`.
80
81 Once the changes have been made you should commit them to your local repo.
82
83 For small changes, that do not require specific explanations, it is better to keep things together in the
84 same patch.
85 Larger changes that require different explanations should be separated into logical patches in a patchset.
86 A good way of thinking about whether a patch should be split is to consider whether the change could be
87 applied without dependencies as a backport.
88
89 As a guide to how patches should be structured run ``git log`` on similar files.
90
91
92 Commit Messages: Subject Line
93 -----------------------------
94
95 The first, summary, line of the git commit message becomes the subject line of the patch email.
96 Here are some guidelines for the summary line:
97
98 * The summary line must capture the area and the impact of the change.
99
100 * The summary line should be around 50 characters.
101
102 * The summary line should be lowercase apart from acronyms.
103
104 * It should be prefixed with the component name (use git log to check existing components).
105   For example::
106
107      ixgbe: fix offload config option name
108
109      config: increase max queues per port
110
111 * Use the imperative of the verb (like instructions to the code base).
112
113 * Don't add a period/full stop to the subject line or you will end up two in the patch name: ``dpdk_description..patch``.
114
115 The actual email subject line should be prefixed by ``[PATCH]`` and the version, if greater than v1,
116 for example: ``PATCH v2``.
117 The is generally added by ``git send-email`` or ``git format-patch``, see below.
118
119 If you are submitting an RFC draft of a feature you can use ``[RFC]`` instead of ``[PATCH]``.
120 An RFC patch doesn't have to be complete.
121 It is intended as a way of getting early feedback.
122
123
124 Commit Messages: Body
125 ---------------------
126
127 Here are some guidelines for the body of a commit message:
128
129 * The body of the message should describe the issue being fixed or the feature being added.
130   It is important to provide enough information to allow a reviewer to understand the purpose of the patch.
131
132 * When the change is obvious the body can be blank, apart from the signoff.
133
134 * The commit message must end with a ``Signed-off-by:`` line which is added using::
135
136       git commit --signoff # or -s
137
138   The purpose of the signoff is explained in the
139   `Developer's Certificate of Origin <http://www.kernel.org/doc/Documentation/SubmittingPatches>`_
140   section of the Linux kernel guidelines.
141
142   .. Note::
143
144      All developers must ensure that they have read and understood the
145      Developer's Certificate of Origin section of the documentation prior
146      to applying the signoff and submitting a patch.
147
148 * The signoff must be a real name and not an alias or nickname.
149   More than one signoff is allowed.
150
151 * The text of the commit message should be wrapped at 72 characters.
152
153 * When fixing a regression, it is a good idea to reference the id of the commit which introduced the bug.
154   You can generate the required text using the following git alias::
155
156      git config alias.fixline "log -1 --abbrev=12 --format='Fixes: %h (\"%s\")'"
157
158   The ``Fixes:`` line can then be added to the commit message::
159
160      doc: fix vhost sample parameter
161
162      Update the docs to reflect removed dev-index.
163
164      Fixes: 17b8320a3e11 ("vhost: remove index parameter")
165
166      Signed-off-by: Alex Smith <alex.smith@example.com>
167
168 * When fixing an error or warning it is useful to add the error message and instructions on how to reproduce it.
169
170 * Use correct capitalization, punctuation and spelling.
171
172 In addition to the ``Signed-off-by:`` name the commit messages can also have one or more of the following:
173
174 * ``Reported-by:`` The reporter of the issue.
175 * ``Tested-by:`` The tester of the change.
176 * ``Reviewed-by:`` The reviewer of the change.
177 * ``Suggested-by:`` The person who suggested the change.
178 * ``Acked-by:`` When a previous version of the patch was acked and the ack is still relevant.
179
180
181 Creating Patches
182 ----------------
183
184 It is possible to send patches directly from git but for new contributors it is recommended to generate the
185 patches with ``git format-patch`` and then when everything looks okay, and the patches have been checked, to
186 send them with ``git send-email``.
187
188 Here are some examples of using ``git format-patch`` to generate patches:
189
190 .. code-block:: console
191
192    # Generate a patch from the last commit.
193    git format-patch -1
194
195    # Generate a patch from the last 3 commits.
196    git format-patch -3
197
198    # Generate the patches in a directory.
199    git format-patch -3 -o ~/patch/
200
201    # Add a cover letter to explain a patchset.
202    git format-patch -3 -o ~/patch/ --cover-letter
203
204    # Add a prefix with a version number.
205    git format-patch -3 -o ~/patch/ -v 2
206
207
208 Cover letters are useful for explaining a patchset and help to generate a logical threading to the patches.
209 Smaller notes can be put inline in the patch after the ``---`` separator, for example::
210
211    Subject: [PATCH] fm10k/base: add FM10420 device ids
212
213    Add the device ID for Boulder Rapids and Atwood Channel to enable
214    drivers to support those devices.
215
216    Signed-off-by: Alex Smith <alex.smith@example.com>
217    ---
218
219    ADD NOTES HERE.
220
221     drivers/net/fm10k/base/fm10k_api.c  | 6 ++++++
222     drivers/net/fm10k/base/fm10k_type.h | 6 ++++++
223     2 files changed, 12 insertions(+)
224    ...
225
226 Version 2 and later of a patchset should also include a short log of the changes so the reviewer knows what has changed.
227 This can be added to the cover letter or the annotations.
228 For example::
229
230    ---
231    v3:
232    * Fixed issued with version.map.
233
234    v2:
235    * Added i40e support.
236    * Renamed ethdev functions from rte_eth_ieee15888_*() to rte_eth_timesync_*()
237      since 802.1AS can be supported through the same interfaces.
238
239
240 .. _contrib_checkpatch:
241
242 Checking the Patches
243 --------------------
244
245 Patches should be checked for formatting and syntax issues using the ``checkpatches.sh`` script in the ``scripts``
246 directory of the DPDK repo.
247 This uses the Linux kernel development tool ``checkpatch.pl`` which  can be obtained by cloning, and periodically,
248 updating the Linux kernel sources.
249
250 The path to the original Linux script must be set in the environment variable ``DPDK_CHECKPATCH_PATH``.
251 This, and any other configuration variables required by the development tools, are loaded from the following
252 files, in order of preference::
253
254    .develconfig
255    ~/.config/dpdk/devel.config
256    /etc/dpdk/devel.config.
257
258 Once the environment variable the script can be run as follows::
259
260    scripts/checkpatches.sh ~/patch/
261
262 The script usage is::
263
264    checkpatches.sh [-h] [-q] [-v] [patch1 [patch2] ...]]"
265
266 Where:
267
268 * ``-h``: help, usage.
269 * ``-q``: quiet. Don't output anything for files without issues.
270 * ``-v``: verbose.
271 * ``patchX``: path to one or more patches.
272
273 Then the git logs should be checked using the ``check-git-log.sh`` script.
274
275 The script usage is::
276
277    check-git-log.sh [range]
278
279 Where the range is a ``git log`` option.
280
281
282 .. _contrib_check_compilation:
283
284 Checking Compilation
285 --------------------
286
287 Compilation of patches and changes should be tested using the the ``test-build.sh`` script in the ``scripts``
288 directory of the DPDK repo::
289
290   scripts/test-build.sh x86_64-native-linuxapp-gcc+next+shared
291
292 The script usage is::
293
294    test-build.sh [-h] [-jX] [-s] [config1 [config2] ...]]
295
296 Where:
297
298 * ``-h``: help, usage.
299 * ``-jX``: use X parallel jobs in "make".
300 * ``-s``: short test with only first config and without examples/doc.
301 * ``config``: default config name plus config switches delimited with a ``+`` sign.
302
303 Examples of configs are::
304
305    x86_64-native-linuxapp-gcc
306    x86_64-native-linuxapp-gcc+next+shared
307    x86_64-native-linuxapp-clang+shared
308
309 The builds can be modifies via the following environmental variables:
310
311 * ``DPDK_BUILD_TEST_CONFIGS`` (target1+option1+option2 target2)
312 * ``DPDK_DEP_CFLAGS``
313 * ``DPDK_DEP_LDFLAGS``
314 * ``DPDK_DEP_MOFED`` (y/[n])
315 * ``DPDK_DEP_PCAP`` (y/[n])
316 * ``DPDK_NOTIFY`` (notify-send)
317
318 These can be set from the command line or in the config files shown above in the :ref:`contrib_checkpatch`.
319
320 The recommended configurations and options to test compilation prior to submitting patches are::
321
322    x86_64-native-linuxapp-gcc+shared+next
323    x86_64-native-linuxapp-clang+shared
324    i686-native-linuxapp-gcc
325
326    export DPDK_DEP_ZLIB=y
327    export DPDK_DEP_PCAP=y
328    export DPDK_DEP_SSL=y
329
330
331 Sending Patches
332 ---------------
333
334 Patches should be sent to the mailing list using ``git send-email``.
335 You can configure an external SMTP with something like the following::
336
337    [sendemail]
338        smtpuser = name@domain.com
339        smtpserver = smtp.domain.com
340        smtpserverport = 465
341        smtpencryption = ssl
342
343 See the `Git send-email <https://git-scm.com/docs/git-send-email>`_ documentation for more details.
344
345 The patches should be sent to ``dev@dpdk.org``.
346 If the patches are a change to existing files then you should send them TO the maintainer(s) and CC ``dev@dpdk.org``.
347 The appropriate maintainer can be found in the ``MAINTAINERS`` file::
348
349    git send-email --to maintainer@some.org --cc dev@dpdk.org 000*.patch
350
351 New additions can be sent without a maintainer::
352
353    git send-email --to dev@dpdk.org 000*.patch
354
355 You can test the emails by sending it to yourself or with the ``--dry-run`` option.
356
357 If the patch is in relation to a previous email thread you can add it to the same thread using the Message ID::
358
359    git send-email --to dev@dpdk.org --in-reply-to <1234-foo@bar.com> 000*.patch
360
361 The Message ID can be found in the raw text of emails or at the top of each Patchwork patch,
362 `for example <http://dpdk.org/dev/patchwork/patch/7646/>`_.
363 Shallow threading (``--thread --no-chain-reply-to``) is preferred for a patch series.
364
365 Once submitted your patches will appear on the mailing list and in Patchwork.
366
367 Experienced committers may send patches directly with ``git send-email`` without the ``git format-patch`` step.
368 The options ``--annotate`` and ``confirm = always`` are recommended for checking patches before sending.
369
370
371 The Review Process
372 ------------------
373
374 The more work you put into the previous steps the easier it will be to get a patch accepted.
375
376 The general cycle for patch review and acceptance is:
377
378 #. Submit the patch.
379
380 #. Check the automatic test reports in the coming hours.
381
382 #. Wait for review comments. While you are waiting review some other patches.
383
384 #. Fix the review comments and submit a ``v n+1`` patchset::
385
386       git format-patch -3 -v 2
387
388 #. Update Patchwork to mark your previous patches as "Superseded".
389
390 #. If the patch is deemed suitable for merging by the relevant maintainer(s) or other developers they will ``ack``
391    the patch with an email that includes something like::
392
393       Acked-by: Alex Smith <alex.smith@example.com>
394
395    **Note**: When acking patches please remove as much of the text of the patch email as possible.
396    It is generally best to delete everything after the ``Signed-off-by:`` line.
397
398 #. Having the patch ``Reviewed-by:`` and/or ``Tested-by:`` will also help the patch to be accepted.
399
400 #. If the patch isn't deemed suitable based on being out of scope or conflicting with existing functionality
401    it may receive a ``nack``.
402    In this case you will need to make a more convincing technical argument in favor of your patches.
403
404 #. In addition a patch will not be accepted if it doesn't address comments from a previous version with fixes or
405    valid arguments.
406
407 #. Acked patches will be merged in the current or next merge window.