xref: /dpdk/doc/guides/contributing/patches.rst (revision 144beafcc8b1b83c35ce2be6e62b9d160c552c8c)
177c79de0SHemant Agrawal..  SPDX-License-Identifier: BSD-3-Clause
277c79de0SHemant Agrawal    Copyright 2018 The DPDK contributors
377c79de0SHemant Agrawal
458abf6e7SJohn McNamara.. submitting_patches:
558abf6e7SJohn McNamara
658abf6e7SJohn McNamaraContributing Code to DPDK
758abf6e7SJohn McNamara=========================
858abf6e7SJohn McNamara
958abf6e7SJohn McNamaraThis document outlines the guidelines for submitting code to DPDK.
1058abf6e7SJohn McNamara
11d629b7b5SJohn McNamaraThe DPDK development process is modeled (loosely) on the Linux Kernel development model so it is worth reading the
1258abf6e7SJohn McNamaraLinux kernel guide on submitting patches:
13f2b99889SYongseok Koh`How to Get Your Change Into the Linux Kernel <https://www.kernel.org/doc/html/latest/process/submitting-patches.html>`_.
1458abf6e7SJohn McNamaraThe rationale for many of the DPDK guidelines is explained in greater detail in the kernel guidelines.
1558abf6e7SJohn McNamara
1658abf6e7SJohn McNamara
1758abf6e7SJohn McNamaraThe DPDK Development Process
18f9de0667SJohn McNamara----------------------------
1958abf6e7SJohn McNamara
2058abf6e7SJohn McNamaraThe DPDK development process has the following features:
2158abf6e7SJohn McNamara
2258abf6e7SJohn McNamara* The code is hosted in a public git repository.
2358abf6e7SJohn McNamara* There is a mailing list where developers submit patches.
2458abf6e7SJohn McNamara* There are maintainers for hierarchical components.
2558abf6e7SJohn McNamara* Patches are reviewed publicly on the mailing list.
26579a5c98SFerruh Yigit* Successfully reviewed patches are merged to the repository.
27f9de0667SJohn McNamara* Patches should be sent to the target repository or sub-tree, see below.
28f9de0667SJohn McNamara* All sub-repositories are merged into main repository for ``-rc1`` and ``-rc2`` versions of the release.
29f9de0667SJohn McNamara* After the ``-rc2`` release all patches should target the main repository.
3058abf6e7SJohn McNamara
3143d162bcSThomas MonjalonThe mailing list for DPDK development is `dev@dpdk.org <http://mails.dpdk.org/archives/dev/>`_.
3243d162bcSThomas MonjalonContributors will need to `register for the mailing list <http://mails.dpdk.org/listinfo/dev>`_ in order to submit patches.
3343d162bcSThomas MonjalonIt is also worth registering for the DPDK `Patchwork <http://patches.dpdk.org/project/dpdk/list/>`_
3458abf6e7SJohn McNamara
3599889bd8SMichael SantanaIf you are using the GitHub service, you can link your repository to
3699889bd8SMichael Santanathe ``travis-ci.org`` build service.  When you push patches to your GitHub
3799889bd8SMichael Santanarepository, the travis service will automatically build your changes.
3899889bd8SMichael Santana
3958abf6e7SJohn McNamaraThe development process requires some familiarity with the ``git`` version control system.
4058abf6e7SJohn McNamaraRefer to the `Pro Git Book <http://www.git-scm.com/book/>`_ for further information.
4158abf6e7SJohn McNamara
42a4862c9eSHemant AgrawalSource License
43a4862c9eSHemant Agrawal--------------
44a4862c9eSHemant Agrawal
45a4862c9eSHemant AgrawalThe DPDK uses the Open Source BSD-3-Clause license for the core libraries and
46a4862c9eSHemant Agrawaldrivers. The kernel components are GPL-2.0 licensed. DPDK uses single line
47a4862c9eSHemant Agrawalreference to Unique License Identifiers in source files as defined by the Linux
48a4862c9eSHemant AgrawalFoundation's `SPDX project <http://spdx.org/>`_.
49a4862c9eSHemant Agrawal
50a4862c9eSHemant AgrawalDPDK uses first line of the file to be SPDX tag. In case of *#!* scripts, SPDX
51a4862c9eSHemant Agrawaltag can be placed in 2nd line of the file.
52a4862c9eSHemant Agrawal
53a4862c9eSHemant AgrawalFor example, to label a file as subject to the BSD-3-Clause license,
54a4862c9eSHemant Agrawalthe following text would be used:
55a4862c9eSHemant Agrawal
56a4862c9eSHemant Agrawal``SPDX-License-Identifier: BSD-3-Clause``
57a4862c9eSHemant Agrawal
58a4862c9eSHemant AgrawalTo label a file as dual-licensed with BSD-3-Clause and GPL-2.0 (e.g., for code
59a4862c9eSHemant Agrawalthat is shared between the kernel and userspace), the following text would be
60a4862c9eSHemant Agrawalused:
61a4862c9eSHemant Agrawal
62a4862c9eSHemant Agrawal``SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)``
63a4862c9eSHemant Agrawal
64a4862c9eSHemant AgrawalRefer to ``licenses/README`` for more details.
6558abf6e7SJohn McNamara
66f9de0667SJohn McNamaraMaintainers and Sub-trees
67f9de0667SJohn McNamara-------------------------
68f9de0667SJohn McNamara
69f9de0667SJohn McNamaraThe DPDK maintenance hierarchy is divided into a main repository ``dpdk`` and sub-repositories ``dpdk-next-*``.
70f9de0667SJohn McNamara
71f9de0667SJohn McNamaraThere are maintainers for the trees and for components within the tree.
72f9de0667SJohn McNamara
73f9de0667SJohn McNamaraTrees and maintainers are listed in the ``MAINTAINERS`` file. For example::
74f9de0667SJohn McNamara
75f9de0667SJohn McNamara    Crypto Drivers
76f9de0667SJohn McNamara    --------------
77f9de0667SJohn McNamara    M: Some Name <some.name@email.com>
78f9de0667SJohn McNamara    T: git://dpdk.org/next/dpdk-next-crypto
79f9de0667SJohn McNamara
80f9de0667SJohn McNamara    Intel AES-NI GCM PMD
81f9de0667SJohn McNamara    M: Some One <some.one@email.com>
82f9de0667SJohn McNamara    F: drivers/crypto/aesni_gcm/
83f9de0667SJohn McNamara    F: doc/guides/cryptodevs/aesni_gcm.rst
84f9de0667SJohn McNamara
85f9de0667SJohn McNamaraWhere:
86f9de0667SJohn McNamara
87f9de0667SJohn McNamara* ``M`` is a tree or component maintainer.
88f9de0667SJohn McNamara* ``T`` is a repository tree.
89f9de0667SJohn McNamara* ``F`` is a maintained file or directory.
90f9de0667SJohn McNamara
91f9de0667SJohn McNamaraAdditional details are given in the ``MAINTAINERS`` file.
92f9de0667SJohn McNamara
93f9de0667SJohn McNamaraThe role of the component maintainers is to:
94f9de0667SJohn McNamara
95f9de0667SJohn McNamara* Review patches for the component or delegate the review.
96f9de0667SJohn McNamara  The review should be done, ideally, within 1 week of submission to the mailing list.
97f9de0667SJohn McNamara* Add an ``acked-by`` to patches, or patchsets, that are ready for committing to a tree.
98acd6dc98SThomas Monjalon* Reply to questions asked about the component.
99f9de0667SJohn McNamara
100f9de0667SJohn McNamaraComponent maintainers can be added or removed by submitting a patch to the ``MAINTAINERS`` file.
101f9de0667SJohn McNamaraMaintainers should have demonstrated a reasonable level of contributions or reviews to the component area.
102f9de0667SJohn McNamaraThe maintainer should be confirmed by an ``ack`` from an established contributor.
103f9de0667SJohn McNamaraThere can be more than one component maintainer if desired.
104f9de0667SJohn McNamara
105f9de0667SJohn McNamaraThe role of the tree maintainers is to:
106f9de0667SJohn McNamara
107f9de0667SJohn McNamara* Maintain the overall quality of their tree.
108f9de0667SJohn McNamara  This can entail additional review, compilation checks or other tests deemed necessary by the maintainer.
109f9de0667SJohn McNamara* Commit patches that have been reviewed by component maintainers and/or other contributors.
110f9de0667SJohn McNamara  The tree maintainer should determine if patches have been reviewed sufficiently.
111f9de0667SJohn McNamara* Ensure that patches are reviewed in a timely manner.
112f9de0667SJohn McNamara* Prepare the tree for integration.
113f9de0667SJohn McNamara* Ensure that there is a designated back-up maintainer and coordinate a handover for periods where the
114f9de0667SJohn McNamara  tree maintainer can't perform their role.
115f9de0667SJohn McNamara
116f9de0667SJohn McNamaraTree maintainers can be added or removed by submitting a patch to the ``MAINTAINERS`` file.
117f9de0667SJohn McNamaraThe proposer should justify the need for a new sub-tree and should have demonstrated a sufficient level of contributions in the area or to a similar area.
118f9de0667SJohn McNamaraThe maintainer should be confirmed by an ``ack`` from an existing tree maintainer.
119f9de0667SJohn McNamaraDisagreements on trees or maintainers can be brought to the Technical Board.
120f9de0667SJohn McNamara
121f9de0667SJohn McNamaraThe backup maintainer for the master tree should be selected from the existing sub-tree maintainers from the project.
122f9de0667SJohn McNamaraThe backup maintainer for a sub-tree should be selected from among the component maintainers within that sub-tree.
123f9de0667SJohn McNamara
124f9de0667SJohn McNamara
12558abf6e7SJohn McNamaraGetting the Source Code
12658abf6e7SJohn McNamara-----------------------
12758abf6e7SJohn McNamara
128579a5c98SFerruh YigitThe source code can be cloned using either of the following:
129579a5c98SFerruh Yigit
130579a5c98SFerruh Yigitmain repository::
13158abf6e7SJohn McNamara
13258abf6e7SJohn McNamara    git clone git://dpdk.org/dpdk
13358abf6e7SJohn McNamara    git clone http://dpdk.org/git/dpdk
13458abf6e7SJohn McNamara
13543d162bcSThomas Monjalonsub-repositories (`list <http://git.dpdk.org/next>`_)::
136579a5c98SFerruh Yigit
137579a5c98SFerruh Yigit    git clone git://dpdk.org/next/dpdk-next-*
138579a5c98SFerruh Yigit    git clone http://dpdk.org/git/next/dpdk-next-*
13958abf6e7SJohn McNamara
14058abf6e7SJohn McNamaraMake your Changes
14158abf6e7SJohn McNamara-----------------
14258abf6e7SJohn McNamara
14358abf6e7SJohn McNamaraMake your planned changes in the cloned ``dpdk`` repo. Here are some guidelines and requirements:
14458abf6e7SJohn McNamara
14558abf6e7SJohn McNamara* Follow the :ref:`coding_style` guidelines.
14658abf6e7SJohn McNamara
14758abf6e7SJohn McNamara* If you add new files or directories you should add your name to the ``MAINTAINERS`` file.
14858abf6e7SJohn McNamara
14978b04aafSRami Rosen* Initial submission of new PMDs should be prepared against a corresponding repo.
15078b04aafSRami Rosen
15178b04aafSRami Rosen  * Thus, for example, initial submission of a new network PMD should be
15278b04aafSRami Rosen    prepared against dpdk-next-net repo.
15378b04aafSRami Rosen
15478b04aafSRami Rosen  * Likewise, initial submission of a new crypto or compression PMD should be
15578b04aafSRami Rosen    prepared against dpdk-next-crypto repo.
15678b04aafSRami Rosen
15778b04aafSRami Rosen  * For other PMDs and more info, refer to the ``MAINTAINERS`` file.
15878b04aafSRami Rosen
159*144beafcSRay Kinsella* New external functions should be added to the local ``version.map`` file. See
160*144beafcSRay Kinsella  the :doc:`ABI policy <abi_policy>` and :ref:`ABI versioning <abi_versioning>`
161*144beafcSRay Kinsella  guides. New external functions should also be added in alphabetical order.
16258abf6e7SJohn McNamara
16358abf6e7SJohn McNamara* Important changes will require an addition to the release notes in ``doc/guides/rel_notes/``.
16458abf6e7SJohn McNamara  See the :ref:`Release Notes section of the Documentation Guidelines <doc_guidelines>` for details.
16558abf6e7SJohn McNamara
16658abf6e7SJohn McNamara* Test the compilation works with different targets, compilers and options, see :ref:`contrib_check_compilation`.
16758abf6e7SJohn McNamara
16858abf6e7SJohn McNamara* Don't break compilation between commits with forward dependencies in a patchset.
16958abf6e7SJohn McNamara  Each commit should compile on its own to allow for ``git bisect`` and continuous integration testing.
17058abf6e7SJohn McNamara
1718f87ba70SThierry Herbelot* Add tests to the ``app/test`` unit test framework where possible.
17258abf6e7SJohn McNamara
17358abf6e7SJohn McNamara* Add documentation, if relevant, in the form of Doxygen comments or a User Guide in RST format.
17458abf6e7SJohn McNamara  See the :ref:`Documentation Guidelines <doc_guidelines>`.
17558abf6e7SJohn McNamara
17658abf6e7SJohn McNamaraOnce the changes have been made you should commit them to your local repo.
17758abf6e7SJohn McNamara
17858abf6e7SJohn McNamaraFor small changes, that do not require specific explanations, it is better to keep things together in the
17958abf6e7SJohn McNamarasame patch.
18058abf6e7SJohn McNamaraLarger changes that require different explanations should be separated into logical patches in a patchset.
18158abf6e7SJohn McNamaraA good way of thinking about whether a patch should be split is to consider whether the change could be
18258abf6e7SJohn McNamaraapplied without dependencies as a backport.
18358abf6e7SJohn McNamara
1849e0e4a00SDavid HuntIt is better to keep the related documentation changes in the same patch
1859e0e4a00SDavid Huntfile as the code, rather than one big documentation patch at then end of a
1869e0e4a00SDavid Huntpatchset. This makes it easier for future maintenance and development of the
1879e0e4a00SDavid Huntcode.
1889e0e4a00SDavid Hunt
18958abf6e7SJohn McNamaraAs a guide to how patches should be structured run ``git log`` on similar files.
19058abf6e7SJohn McNamara
19158abf6e7SJohn McNamara
19258abf6e7SJohn McNamaraCommit Messages: Subject Line
19358abf6e7SJohn McNamara-----------------------------
19458abf6e7SJohn McNamara
19558abf6e7SJohn McNamaraThe first, summary, line of the git commit message becomes the subject line of the patch email.
19658abf6e7SJohn McNamaraHere are some guidelines for the summary line:
19758abf6e7SJohn McNamara
19858abf6e7SJohn McNamara* The summary line must capture the area and the impact of the change.
19958abf6e7SJohn McNamara
20058abf6e7SJohn McNamara* The summary line should be around 50 characters.
20158abf6e7SJohn McNamara
20258abf6e7SJohn McNamara* The summary line should be lowercase apart from acronyms.
20358abf6e7SJohn McNamara
20458abf6e7SJohn McNamara* It should be prefixed with the component name (use git log to check existing components).
20558abf6e7SJohn McNamara  For example::
20658abf6e7SJohn McNamara
20758abf6e7SJohn McNamara     ixgbe: fix offload config option name
20858abf6e7SJohn McNamara
20958abf6e7SJohn McNamara     config: increase max queues per port
21058abf6e7SJohn McNamara
21158abf6e7SJohn McNamara* Use the imperative of the verb (like instructions to the code base).
21258abf6e7SJohn McNamara
21358abf6e7SJohn McNamara* Don't add a period/full stop to the subject line or you will end up two in the patch name: ``dpdk_description..patch``.
21458abf6e7SJohn McNamara
21558abf6e7SJohn McNamaraThe actual email subject line should be prefixed by ``[PATCH]`` and the version, if greater than v1,
21658abf6e7SJohn McNamarafor example: ``PATCH v2``.
21758abf6e7SJohn McNamaraThe is generally added by ``git send-email`` or ``git format-patch``, see below.
21858abf6e7SJohn McNamara
21958abf6e7SJohn McNamaraIf you are submitting an RFC draft of a feature you can use ``[RFC]`` instead of ``[PATCH]``.
22058abf6e7SJohn McNamaraAn RFC patch doesn't have to be complete.
22158abf6e7SJohn McNamaraIt is intended as a way of getting early feedback.
22258abf6e7SJohn McNamara
22358abf6e7SJohn McNamara
22458abf6e7SJohn McNamaraCommit Messages: Body
22558abf6e7SJohn McNamara---------------------
22658abf6e7SJohn McNamara
22758abf6e7SJohn McNamaraHere are some guidelines for the body of a commit message:
22858abf6e7SJohn McNamara
22958abf6e7SJohn McNamara* The body of the message should describe the issue being fixed or the feature being added.
23058abf6e7SJohn McNamara  It is important to provide enough information to allow a reviewer to understand the purpose of the patch.
23158abf6e7SJohn McNamara
23258abf6e7SJohn McNamara* When the change is obvious the body can be blank, apart from the signoff.
23358abf6e7SJohn McNamara
23458abf6e7SJohn McNamara* The commit message must end with a ``Signed-off-by:`` line which is added using::
23558abf6e7SJohn McNamara
23658abf6e7SJohn McNamara      git commit --signoff # or -s
23758abf6e7SJohn McNamara
23858abf6e7SJohn McNamara  The purpose of the signoff is explained in the
239f2b99889SYongseok Koh  `Developer's Certificate of Origin <https://www.kernel.org/doc/html/latest/process/submitting-patches.html#developer-s-certificate-of-origin-1-1>`_
24058abf6e7SJohn McNamara  section of the Linux kernel guidelines.
24158abf6e7SJohn McNamara
24258abf6e7SJohn McNamara  .. Note::
24358abf6e7SJohn McNamara
24458abf6e7SJohn McNamara     All developers must ensure that they have read and understood the
24558abf6e7SJohn McNamara     Developer's Certificate of Origin section of the documentation prior
24658abf6e7SJohn McNamara     to applying the signoff and submitting a patch.
24758abf6e7SJohn McNamara
24858abf6e7SJohn McNamara* The signoff must be a real name and not an alias or nickname.
24958abf6e7SJohn McNamara  More than one signoff is allowed.
25058abf6e7SJohn McNamara
25158abf6e7SJohn McNamara* The text of the commit message should be wrapped at 72 characters.
25258abf6e7SJohn McNamara
253f9ef083cSHarry van Haaren* When fixing a regression, it is required to reference the id of the commit
254f9ef083cSHarry van Haaren  which introduced the bug, and put the original author of that commit on CC.
255f9ef083cSHarry van Haaren  You can generate the required lines using the following git alias, which prints
256f9ef083cSHarry van Haaren  the commit SHA and the author of the original code::
25758abf6e7SJohn McNamara
258f9ef083cSHarry van Haaren     git config alias.fixline "log -1 --abbrev=12 --format='Fixes: %h (\"%s\")%nCc: %ae'"
25958abf6e7SJohn McNamara
260f9ef083cSHarry van Haaren  The output of ``git fixline <SHA>`` must then be added to the commit message::
26158abf6e7SJohn McNamara
262f9ef083cSHarry van Haaren     doc: fix some parameter description
26358abf6e7SJohn McNamara
264f9ef083cSHarry van Haaren     Update the docs, fixing description of some parameter.
26558abf6e7SJohn McNamara
266f9ef083cSHarry van Haaren     Fixes: abcdefgh1234 ("doc: add some parameter")
267f9ef083cSHarry van Haaren     Cc: author@example.com
26858abf6e7SJohn McNamara
26958abf6e7SJohn McNamara     Signed-off-by: Alex Smith <alex.smith@example.com>
27058abf6e7SJohn McNamara
27158abf6e7SJohn McNamara* When fixing an error or warning it is useful to add the error message and instructions on how to reproduce it.
27258abf6e7SJohn McNamara
27358abf6e7SJohn McNamara* Use correct capitalization, punctuation and spelling.
27458abf6e7SJohn McNamara
2754aeedc25SHarry van HaarenIn addition to the ``Signed-off-by:`` name the commit messages can also have
2764aeedc25SHarry van Haarentags for who reported, suggested, tested and reviewed the patch being
2774aeedc25SHarry van Haarenposted. Please refer to the `Tested, Acked and Reviewed by`_ section.
27858abf6e7SJohn McNamara
2796561392cSMarko KovacevicPatch Fix Related Issues
2806561392cSMarko Kovacevic~~~~~~~~~~~~~~~~~~~~~~~~
281d687e0d0SMarko Kovacevic
282d687e0d0SMarko Kovacevic`Coverity <https://scan.coverity.com/projects/dpdk-data-plane-development-kit>`_
283d687e0d0SMarko Kovacevicis a tool for static code analysis.
284d687e0d0SMarko KovacevicIt is used as a cloud-based service used to scan the DPDK source code,
285d687e0d0SMarko Kovacevicand alert developers of any potential defects in the source code.
286d687e0d0SMarko KovacevicWhen fixing an issue found by Coverity, the patch must contain a Coverity issue ID
287d687e0d0SMarko Kovacevicin the body of the commit message. For example::
288d687e0d0SMarko Kovacevic
289d687e0d0SMarko Kovacevic
290d687e0d0SMarko Kovacevic     doc: fix some parameter description
291d687e0d0SMarko Kovacevic
292d687e0d0SMarko Kovacevic     Update the docs, fixing description of some parameter.
293d687e0d0SMarko Kovacevic
294d687e0d0SMarko Kovacevic     Coverity issue: 12345
295d687e0d0SMarko Kovacevic     Fixes: abcdefgh1234 ("doc: add some parameter")
296d687e0d0SMarko Kovacevic     Cc: author@example.com
297d687e0d0SMarko Kovacevic
298d687e0d0SMarko Kovacevic     Signed-off-by: Alex Smith <alex.smith@example.com>
299d687e0d0SMarko Kovacevic
3006561392cSMarko Kovacevic
30143d162bcSThomas Monjalon`Bugzilla <https://bugs.dpdk.org>`_
3026561392cSMarko Kovacevicis a bug- or issue-tracking system.
3036561392cSMarko KovacevicBug-tracking systems allow individual or groups of developers
3046561392cSMarko Kovaceviceffectively to keep track of outstanding problems with their product.
3056561392cSMarko KovacevicWhen fixing an issue raised in Bugzilla, the patch must contain
3066561392cSMarko Kovacevica Bugzilla issue ID in the body of the commit message.
3076561392cSMarko KovacevicFor example::
3086561392cSMarko Kovacevic
3096561392cSMarko Kovacevic    doc: fix some parameter description
3106561392cSMarko Kovacevic
3116561392cSMarko Kovacevic    Update the docs, fixing description of some parameter.
3126561392cSMarko Kovacevic
3136561392cSMarko Kovacevic    Bugzilla ID: 12345
3146561392cSMarko Kovacevic    Fixes: abcdefgh1234 ("doc: add some parameter")
3156561392cSMarko Kovacevic    Cc: author@example.com
3166561392cSMarko Kovacevic
3176561392cSMarko Kovacevic    Signed-off-by: Alex Smith <alex.smith@example.com>
3186561392cSMarko Kovacevic
319f16e13c9SMarko KovacevicPatch for Stable Releases
320f16e13c9SMarko Kovacevic~~~~~~~~~~~~~~~~~~~~~~~~~
321f16e13c9SMarko Kovacevic
322f16e13c9SMarko KovacevicAll fix patches to the master branch that are candidates for backporting
32343d162bcSThomas Monjalonshould also be CCed to the `stable@dpdk.org <http://mails.dpdk.org/listinfo/stable>`_
324f16e13c9SMarko Kovacevicmailing list.
325f16e13c9SMarko KovacevicIn the commit message body the Cc: stable@dpdk.org should be inserted as follows::
326f16e13c9SMarko Kovacevic
327f16e13c9SMarko Kovacevic     doc: fix some parameter description
328f16e13c9SMarko Kovacevic
329f16e13c9SMarko Kovacevic     Update the docs, fixing description of some parameter.
330f16e13c9SMarko Kovacevic
331f16e13c9SMarko Kovacevic     Fixes: abcdefgh1234 ("doc: add some parameter")
332f16e13c9SMarko Kovacevic     Cc: stable@dpdk.org
333f16e13c9SMarko Kovacevic
334f16e13c9SMarko Kovacevic     Signed-off-by: Alex Smith <alex.smith@example.com>
335f16e13c9SMarko Kovacevic
336f16e13c9SMarko KovacevicFor further information on stable contribution you can go to
337f16e13c9SMarko Kovacevic:doc:`Stable Contribution Guide <stable>`.
338f16e13c9SMarko Kovacevic
33958abf6e7SJohn McNamara
34058abf6e7SJohn McNamaraCreating Patches
34158abf6e7SJohn McNamara----------------
34258abf6e7SJohn McNamara
34358abf6e7SJohn McNamaraIt is possible to send patches directly from git but for new contributors it is recommended to generate the
34458abf6e7SJohn McNamarapatches with ``git format-patch`` and then when everything looks okay, and the patches have been checked, to
34558abf6e7SJohn McNamarasend them with ``git send-email``.
34658abf6e7SJohn McNamara
34758abf6e7SJohn McNamaraHere are some examples of using ``git format-patch`` to generate patches:
34858abf6e7SJohn McNamara
34958abf6e7SJohn McNamara.. code-block:: console
35058abf6e7SJohn McNamara
35158abf6e7SJohn McNamara   # Generate a patch from the last commit.
35258abf6e7SJohn McNamara   git format-patch -1
35358abf6e7SJohn McNamara
35458abf6e7SJohn McNamara   # Generate a patch from the last 3 commits.
35558abf6e7SJohn McNamara   git format-patch -3
35658abf6e7SJohn McNamara
35758abf6e7SJohn McNamara   # Generate the patches in a directory.
35858abf6e7SJohn McNamara   git format-patch -3 -o ~/patch/
35958abf6e7SJohn McNamara
36058abf6e7SJohn McNamara   # Add a cover letter to explain a patchset.
36158abf6e7SJohn McNamara   git format-patch -3 -o ~/patch/ --cover-letter
36258abf6e7SJohn McNamara
36358abf6e7SJohn McNamara   # Add a prefix with a version number.
36458abf6e7SJohn McNamara   git format-patch -3 -o ~/patch/ -v 2
36558abf6e7SJohn McNamara
36658abf6e7SJohn McNamara
36758abf6e7SJohn McNamaraCover letters are useful for explaining a patchset and help to generate a logical threading to the patches.
36858abf6e7SJohn McNamaraSmaller notes can be put inline in the patch after the ``---`` separator, for example::
36958abf6e7SJohn McNamara
37058abf6e7SJohn McNamara   Subject: [PATCH] fm10k/base: add FM10420 device ids
37158abf6e7SJohn McNamara
37258abf6e7SJohn McNamara   Add the device ID for Boulder Rapids and Atwood Channel to enable
37358abf6e7SJohn McNamara   drivers to support those devices.
37458abf6e7SJohn McNamara
37558abf6e7SJohn McNamara   Signed-off-by: Alex Smith <alex.smith@example.com>
37658abf6e7SJohn McNamara   ---
37758abf6e7SJohn McNamara
37858abf6e7SJohn McNamara   ADD NOTES HERE.
37958abf6e7SJohn McNamara
38058abf6e7SJohn McNamara    drivers/net/fm10k/base/fm10k_api.c  | 6 ++++++
38158abf6e7SJohn McNamara    drivers/net/fm10k/base/fm10k_type.h | 6 ++++++
38258abf6e7SJohn McNamara    2 files changed, 12 insertions(+)
38358abf6e7SJohn McNamara   ...
38458abf6e7SJohn McNamara
38558abf6e7SJohn McNamaraVersion 2 and later of a patchset should also include a short log of the changes so the reviewer knows what has changed.
38658abf6e7SJohn McNamaraThis can be added to the cover letter or the annotations.
38758abf6e7SJohn McNamaraFor example::
38858abf6e7SJohn McNamara
38958abf6e7SJohn McNamara   ---
39058abf6e7SJohn McNamara   v3:
39158abf6e7SJohn McNamara   * Fixed issued with version.map.
39258abf6e7SJohn McNamara
39358abf6e7SJohn McNamara   v2:
39458abf6e7SJohn McNamara   * Added i40e support.
39558abf6e7SJohn McNamara   * Renamed ethdev functions from rte_eth_ieee15888_*() to rte_eth_timesync_*()
39658abf6e7SJohn McNamara     since 802.1AS can be supported through the same interfaces.
39758abf6e7SJohn McNamara
39858abf6e7SJohn McNamara
39958abf6e7SJohn McNamara.. _contrib_checkpatch:
40058abf6e7SJohn McNamara
40158abf6e7SJohn McNamaraChecking the Patches
40258abf6e7SJohn McNamara--------------------
40358abf6e7SJohn McNamara
4049a98f50eSThomas MonjalonPatches should be checked for formatting and syntax issues using the ``checkpatches.sh`` script in the ``devtools``
40558abf6e7SJohn McNamaradirectory of the DPDK repo.
40658abf6e7SJohn McNamaraThis uses the Linux kernel development tool ``checkpatch.pl`` which  can be obtained by cloning, and periodically,
40758abf6e7SJohn McNamaraupdating the Linux kernel sources.
40858abf6e7SJohn McNamara
40958abf6e7SJohn McNamaraThe path to the original Linux script must be set in the environment variable ``DPDK_CHECKPATCH_PATH``.
41058abf6e7SJohn McNamaraThis, and any other configuration variables required by the development tools, are loaded from the following
41158abf6e7SJohn McNamarafiles, in order of preference::
41258abf6e7SJohn McNamara
41358abf6e7SJohn McNamara   .develconfig
41458abf6e7SJohn McNamara   ~/.config/dpdk/devel.config
41558abf6e7SJohn McNamara   /etc/dpdk/devel.config.
41658abf6e7SJohn McNamara
41758abf6e7SJohn McNamaraOnce the environment variable the script can be run as follows::
41858abf6e7SJohn McNamara
4199a98f50eSThomas Monjalon   devtools/checkpatches.sh ~/patch/
42058abf6e7SJohn McNamara
42158abf6e7SJohn McNamaraThe script usage is::
42258abf6e7SJohn McNamara
42358abf6e7SJohn McNamara   checkpatches.sh [-h] [-q] [-v] [patch1 [patch2] ...]]"
42458abf6e7SJohn McNamara
42558abf6e7SJohn McNamaraWhere:
42658abf6e7SJohn McNamara
42758abf6e7SJohn McNamara* ``-h``: help, usage.
42858abf6e7SJohn McNamara* ``-q``: quiet. Don't output anything for files without issues.
42958abf6e7SJohn McNamara* ``-v``: verbose.
43058abf6e7SJohn McNamara* ``patchX``: path to one or more patches.
43158abf6e7SJohn McNamara
432edbeb7d9SThomas MonjalonThen the git logs should be checked using the ``check-git-log.sh`` script.
433edbeb7d9SThomas Monjalon
434edbeb7d9SThomas MonjalonThe script usage is::
435edbeb7d9SThomas Monjalon
436edbeb7d9SThomas Monjalon   check-git-log.sh [range]
437edbeb7d9SThomas Monjalon
438edbeb7d9SThomas MonjalonWhere the range is a ``git log`` option.
439edbeb7d9SThomas Monjalon
44058abf6e7SJohn McNamara
44158abf6e7SJohn McNamara.. _contrib_check_compilation:
44258abf6e7SJohn McNamara
44358abf6e7SJohn McNamaraChecking Compilation
44458abf6e7SJohn McNamara--------------------
44558abf6e7SJohn McNamara
4463fe9b93cSVipin VargheseMakefile System
4473fe9b93cSVipin Varghese~~~~~~~~~~~~~~~
4483fe9b93cSVipin Varghese
4498f87ba70SThierry HerbelotCompilation of patches and changes should be tested using the ``test-build.sh`` script in the ``devtools``
45058abf6e7SJohn McNamaradirectory of the DPDK repo::
45158abf6e7SJohn McNamara
452218c4e68SBruce Richardson  devtools/test-build.sh x86_64-native-linux-gcc+next+shared
45358abf6e7SJohn McNamara
45458abf6e7SJohn McNamaraThe script usage is::
45558abf6e7SJohn McNamara
45658abf6e7SJohn McNamara   test-build.sh [-h] [-jX] [-s] [config1 [config2] ...]]
45758abf6e7SJohn McNamara
45858abf6e7SJohn McNamaraWhere:
45958abf6e7SJohn McNamara
46058abf6e7SJohn McNamara* ``-h``: help, usage.
46158abf6e7SJohn McNamara* ``-jX``: use X parallel jobs in "make".
46258abf6e7SJohn McNamara* ``-s``: short test with only first config and without examples/doc.
46358abf6e7SJohn McNamara* ``config``: default config name plus config switches delimited with a ``+`` sign.
46458abf6e7SJohn McNamara
46558abf6e7SJohn McNamaraExamples of configs are::
46658abf6e7SJohn McNamara
467218c4e68SBruce Richardson   x86_64-native-linux-gcc
468218c4e68SBruce Richardson   x86_64-native-linux-gcc+next+shared
469218c4e68SBruce Richardson   x86_64-native-linux-clang+shared
47058abf6e7SJohn McNamara
4711e46fadeSCian FerriterThe builds can be modified via the following environmental variables:
47258abf6e7SJohn McNamara
47358abf6e7SJohn McNamara* ``DPDK_BUILD_TEST_CONFIGS`` (target1+option1+option2 target2)
47458abf6e7SJohn McNamara* ``DPDK_DEP_CFLAGS``
47558abf6e7SJohn McNamara* ``DPDK_DEP_LDFLAGS``
47658abf6e7SJohn McNamara* ``DPDK_DEP_PCAP`` (y/[n])
47758abf6e7SJohn McNamara* ``DPDK_NOTIFY`` (notify-send)
47858abf6e7SJohn McNamara
47958abf6e7SJohn McNamaraThese can be set from the command line or in the config files shown above in the :ref:`contrib_checkpatch`.
48058abf6e7SJohn McNamara
48158abf6e7SJohn McNamaraThe recommended configurations and options to test compilation prior to submitting patches are::
48258abf6e7SJohn McNamara
483218c4e68SBruce Richardson   x86_64-native-linux-gcc+shared+next
484218c4e68SBruce Richardson   x86_64-native-linux-clang+shared
485218c4e68SBruce Richardson   i686-native-linux-gcc
48658abf6e7SJohn McNamara
48758abf6e7SJohn McNamara   export DPDK_DEP_ZLIB=y
48858abf6e7SJohn McNamara   export DPDK_DEP_PCAP=y
48958abf6e7SJohn McNamara   export DPDK_DEP_SSL=y
49058abf6e7SJohn McNamara
4913fe9b93cSVipin VargheseMeson System
4923fe9b93cSVipin Varghese~~~~~~~~~~~~
4933fe9b93cSVipin Varghese
4943fe9b93cSVipin VargheseCompilation of patches is to be tested with ``devtools/test-meson-builds.sh`` script.
4953fe9b93cSVipin Varghese
4963fe9b93cSVipin VargheseThe script internally checks for dependencies, then builds for several
4973fe9b93cSVipin Varghesecombinations of compilation configuration.
4983fe9b93cSVipin Varghese
49958abf6e7SJohn McNamara
50058abf6e7SJohn McNamaraSending Patches
50158abf6e7SJohn McNamara---------------
50258abf6e7SJohn McNamara
50358abf6e7SJohn McNamaraPatches should be sent to the mailing list using ``git send-email``.
50458abf6e7SJohn McNamaraYou can configure an external SMTP with something like the following::
50558abf6e7SJohn McNamara
50658abf6e7SJohn McNamara   [sendemail]
50758abf6e7SJohn McNamara       smtpuser = name@domain.com
50858abf6e7SJohn McNamara       smtpserver = smtp.domain.com
50958abf6e7SJohn McNamara       smtpserverport = 465
51058abf6e7SJohn McNamara       smtpencryption = ssl
51158abf6e7SJohn McNamara
51258abf6e7SJohn McNamaraSee the `Git send-email <https://git-scm.com/docs/git-send-email>`_ documentation for more details.
51358abf6e7SJohn McNamara
51458abf6e7SJohn McNamaraThe patches should be sent to ``dev@dpdk.org``.
51558abf6e7SJohn McNamaraIf the patches are a change to existing files then you should send them TO the maintainer(s) and CC ``dev@dpdk.org``.
51658abf6e7SJohn McNamaraThe appropriate maintainer can be found in the ``MAINTAINERS`` file::
51758abf6e7SJohn McNamara
51858abf6e7SJohn McNamara   git send-email --to maintainer@some.org --cc dev@dpdk.org 000*.patch
51958abf6e7SJohn McNamara
5207a629106SFerruh YigitScript ``get-maintainer.sh`` can be used to select maintainers automatically::
5217a629106SFerruh Yigit
5227a629106SFerruh Yigit  git send-email --to-cmd ./devtools/get-maintainer.sh --cc dev@dpdk.org 000*.patch
5237a629106SFerruh Yigit
52458abf6e7SJohn McNamaraNew additions can be sent without a maintainer::
52558abf6e7SJohn McNamara
52658abf6e7SJohn McNamara   git send-email --to dev@dpdk.org 000*.patch
52758abf6e7SJohn McNamara
52858abf6e7SJohn McNamaraYou can test the emails by sending it to yourself or with the ``--dry-run`` option.
52958abf6e7SJohn McNamara
53058abf6e7SJohn McNamaraIf the patch is in relation to a previous email thread you can add it to the same thread using the Message ID::
53158abf6e7SJohn McNamara
53258abf6e7SJohn McNamara   git send-email --to dev@dpdk.org --in-reply-to <1234-foo@bar.com> 000*.patch
53358abf6e7SJohn McNamara
53458abf6e7SJohn McNamaraThe Message ID can be found in the raw text of emails or at the top of each Patchwork patch,
53543d162bcSThomas Monjalon`for example <http://patches.dpdk.org/patch/7646/>`_.
53658abf6e7SJohn McNamaraShallow threading (``--thread --no-chain-reply-to``) is preferred for a patch series.
53758abf6e7SJohn McNamara
53858abf6e7SJohn McNamaraOnce submitted your patches will appear on the mailing list and in Patchwork.
53958abf6e7SJohn McNamara
54058abf6e7SJohn McNamaraExperienced committers may send patches directly with ``git send-email`` without the ``git format-patch`` step.
54158abf6e7SJohn McNamaraThe options ``--annotate`` and ``confirm = always`` are recommended for checking patches before sending.
54258abf6e7SJohn McNamara
54358abf6e7SJohn McNamara
544d53f61b6SLuca BoccassiBackporting patches for Stable Releases
545d53f61b6SLuca Boccassi~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
546d53f61b6SLuca Boccassi
547d53f61b6SLuca BoccassiSometimes a maintainer or contributor wishes, or can be asked, to send a patch
548d53f61b6SLuca Boccassifor a stable release rather than mainline.
549d53f61b6SLuca BoccassiIn this case the patch(es) should be sent to ``stable@dpdk.org``,
550d53f61b6SLuca Boccassinot to ``dev@dpdk.org``.
551d53f61b6SLuca Boccassi
552d53f61b6SLuca BoccassiGiven that there are multiple stable releases being maintained at the same time,
553d53f61b6SLuca Boccassiplease specify exactly which branch(es) the patch is for
554d53f61b6SLuca Boccassiusing ``git send-email --subject-prefix='PATCH 16.11' ...``
555d53f61b6SLuca Boccassiand also optionally in the cover letter or in the annotation.
556d53f61b6SLuca Boccassi
557d53f61b6SLuca Boccassi
55858abf6e7SJohn McNamaraThe Review Process
55958abf6e7SJohn McNamara------------------
56058abf6e7SJohn McNamara
5614aeedc25SHarry van HaarenPatches are reviewed by the community, relying on the experience and
5624aeedc25SHarry van Haarencollaboration of the members to double-check each other's work. There are a
5634aeedc25SHarry van Haarennumber of ways to indicate that you have checked a patch on the mailing list.
56458abf6e7SJohn McNamara
5654aeedc25SHarry van Haaren
5664aeedc25SHarry van HaarenTested, Acked and Reviewed by
5674aeedc25SHarry van Haaren~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5684aeedc25SHarry van Haaren
5694aeedc25SHarry van HaarenTo indicate that you have interacted with a patch on the mailing list you
5704aeedc25SHarry van Haarenshould respond to the patch in an email with one of the following tags:
5714aeedc25SHarry van Haaren
5724aeedc25SHarry van Haaren * Reviewed-by:
5734aeedc25SHarry van Haaren * Acked-by:
5744aeedc25SHarry van Haaren * Tested-by:
5754aeedc25SHarry van Haaren * Reported-by:
5764aeedc25SHarry van Haaren * Suggested-by:
5774aeedc25SHarry van Haaren
5784aeedc25SHarry van HaarenThe tag should be on a separate line as follows::
5794aeedc25SHarry van Haaren
5804aeedc25SHarry van Haaren   tag-here: Name Surname <email@address.com>
5814aeedc25SHarry van Haaren
5824aeedc25SHarry van HaarenEach of these tags has a specific meaning. In general, the DPDK community
5834aeedc25SHarry van Haarenfollows the kernel usage of the tags. A short summary of the meanings of each
5844aeedc25SHarry van Haarentag is given here for reference:
5854aeedc25SHarry van Haaren
5864aeedc25SHarry van Haaren.. _statement: https://www.kernel.org/doc/html/latest/process/submitting-patches.html#reviewer-s-statement-of-oversight
5874aeedc25SHarry van Haaren
5884aeedc25SHarry van Haaren``Reviewed-by:`` is a strong statement_ that the patch is an appropriate state
5894aeedc25SHarry van Haarenfor merging without any remaining serious technical issues. Reviews from
5904aeedc25SHarry van Haarencommunity members who are known to understand the subject area and to perform
5914aeedc25SHarry van Haarenthorough reviews will increase the likelihood of the patch getting merged.
5924aeedc25SHarry van Haaren
5934aeedc25SHarry van Haaren``Acked-by:`` is a record that the person named was not directly involved in
5944aeedc25SHarry van Haarenthe preparation of the patch but wishes to signify and record their acceptance
5954aeedc25SHarry van Haarenand approval of it.
5964aeedc25SHarry van Haaren
5974aeedc25SHarry van Haaren``Tested-by:`` indicates that the patch has been successfully tested (in some
5984aeedc25SHarry van Haarenenvironment) by the person named.
5994aeedc25SHarry van Haaren
6004aeedc25SHarry van Haaren``Reported-by:`` is used to acknowledge person who found or reported the bug.
6014aeedc25SHarry van Haaren
6024aeedc25SHarry van Haaren``Suggested-by:`` indicates that the patch idea was suggested by the named
6034aeedc25SHarry van Haarenperson.
6044aeedc25SHarry van Haaren
6054aeedc25SHarry van Haaren
6064aeedc25SHarry van Haaren
6074aeedc25SHarry van HaarenSteps to getting your patch merged
6084aeedc25SHarry van Haaren~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6094aeedc25SHarry van Haaren
6104aeedc25SHarry van HaarenThe more work you put into the previous steps the easier it will be to get a
6114aeedc25SHarry van Haarenpatch accepted. The general cycle for patch review and acceptance is:
61258abf6e7SJohn McNamara
61358abf6e7SJohn McNamara#. Submit the patch.
61458abf6e7SJohn McNamara
61558abf6e7SJohn McNamara#. Check the automatic test reports in the coming hours.
61658abf6e7SJohn McNamara
61758abf6e7SJohn McNamara#. Wait for review comments. While you are waiting review some other patches.
61858abf6e7SJohn McNamara
61958abf6e7SJohn McNamara#. Fix the review comments and submit a ``v n+1`` patchset::
62058abf6e7SJohn McNamara
62158abf6e7SJohn McNamara      git format-patch -3 -v 2
62258abf6e7SJohn McNamara
62358abf6e7SJohn McNamara#. Update Patchwork to mark your previous patches as "Superseded".
62458abf6e7SJohn McNamara
62558abf6e7SJohn McNamara#. If the patch is deemed suitable for merging by the relevant maintainer(s) or other developers they will ``ack``
62658abf6e7SJohn McNamara   the patch with an email that includes something like::
62758abf6e7SJohn McNamara
62858abf6e7SJohn McNamara      Acked-by: Alex Smith <alex.smith@example.com>
62958abf6e7SJohn McNamara
63058abf6e7SJohn McNamara   **Note**: When acking patches please remove as much of the text of the patch email as possible.
63158abf6e7SJohn McNamara   It is generally best to delete everything after the ``Signed-off-by:`` line.
63258abf6e7SJohn McNamara
63358abf6e7SJohn McNamara#. Having the patch ``Reviewed-by:`` and/or ``Tested-by:`` will also help the patch to be accepted.
63458abf6e7SJohn McNamara
63558abf6e7SJohn McNamara#. If the patch isn't deemed suitable based on being out of scope or conflicting with existing functionality
63658abf6e7SJohn McNamara   it may receive a ``nack``.
63758abf6e7SJohn McNamara   In this case you will need to make a more convincing technical argument in favor of your patches.
63858abf6e7SJohn McNamara
63958abf6e7SJohn McNamara#. In addition a patch will not be accepted if it doesn't address comments from a previous version with fixes or
64058abf6e7SJohn McNamara   valid arguments.
64158abf6e7SJohn McNamara
6427968191bSBruce Richardson#. It is the responsibility of a maintainer to ensure that patches are reviewed and to provide an ``ack`` or
6437968191bSBruce Richardson   ``nack`` of those patches as appropriate.
6447968191bSBruce Richardson
6457968191bSBruce Richardson#. Once a patch has been acked by the relevant maintainer, reviewers may still comment on it for a further
6467968191bSBruce Richardson   two weeks. After that time, the patch should be merged into the relevant git tree for the next release.
6477968191bSBruce Richardson   Additional notes and restrictions:
6487968191bSBruce Richardson
6497968191bSBruce Richardson   * Patches should be acked by a maintainer at least two days before the release merge
6507968191bSBruce Richardson     deadline, in order to make that release.
6517968191bSBruce Richardson   * For patches acked with less than two weeks to go to the merge deadline, all additional
6527968191bSBruce Richardson     comments should be made no later than two days before the merge deadline.
6537968191bSBruce Richardson   * After the appropriate time for additional feedback has passed, if the patch has not yet
6547968191bSBruce Richardson     been merged to the relevant tree by the committer, it should be treated as though it had,
6557968191bSBruce Richardson     in that any additional changes needed to it must be addressed by a follow-on patch, rather
6567968191bSBruce Richardson     than rework of the original.
6577968191bSBruce Richardson   * Trivial patches may be merged sooner than described above at the tree committer's
6587968191bSBruce Richardson     discretion.
659