xref: /dpdk/doc/guides/contributing/new_driver.rst (revision ad6833e5accbf67b4e1e8c9ca4911ba1163d3cb5)
1*ad6833e5SNandini Persad.. SPDX-License-Identifier: BSD-3-Clause
2*ad6833e5SNandini Persad   Copyright 2024 The DPDK contributors
3*ad6833e5SNandini Persad
4*ad6833e5SNandini Persad
5*ad6833e5SNandini PersadAdding a New Driver
6*ad6833e5SNandini Persad===================
7*ad6833e5SNandini Persad
8*ad6833e5SNandini PersadThe DPDK project continuously grows its ecosystem by adding support for new devices.
9*ad6833e5SNandini PersadThis document is designed to assist contributors in creating DPDK drivers,
10*ad6833e5SNandini Persadalso known as Poll Mode Drivers (PMD).
11*ad6833e5SNandini Persad
12*ad6833e5SNandini PersadBy having public support for a device, we can ensure accessibility across various
13*ad6833e5SNandini Persadoperating systems and guarantee community maintenance in future releases.
14*ad6833e5SNandini PersadIf a new device is similar to a device already supported by an existing driver,
15*ad6833e5SNandini Persadit is more efficient to update the existing driver.
16*ad6833e5SNandini Persad
17*ad6833e5SNandini PersadHere are our best practice recommendations for creating a new driver.
18*ad6833e5SNandini Persad
19*ad6833e5SNandini Persad
20*ad6833e5SNandini PersadEarly Engagement with the Community
21*ad6833e5SNandini Persad-----------------------------------
22*ad6833e5SNandini Persad
23*ad6833e5SNandini PersadWhen creating a new driver, we highly recommend engaging with the DPDK
24*ad6833e5SNandini Persadcommunity early instead of waiting the work to mature.
25*ad6833e5SNandini Persad
26*ad6833e5SNandini PersadThese public discussions help align development of your driver with DPDK expectations.
27*ad6833e5SNandini PersadYou may submit a roadmap before the release to inform the community of your plans.
28*ad6833e5SNandini PersadAdditionally, sending a Request For Comments (RFC) early in the release cycle,
29*ad6833e5SNandini Persador even during the prior release, is advisable.
30*ad6833e5SNandini Persad
31*ad6833e5SNandini PersadDPDK is mainly consumed via Long Term Support (LTS) releases.
32*ad6833e5SNandini PersadIt is common to target a new PMD to a LTS release. For this,
33*ad6833e5SNandini Persadit is suggested to start upstreaming at least one release before a LTS release.
34*ad6833e5SNandini Persad
35*ad6833e5SNandini Persad
36*ad6833e5SNandini PersadProgressive Work
37*ad6833e5SNandini Persad----------------
38*ad6833e5SNandini Persad
39*ad6833e5SNandini PersadTo continually progress your work, we recommend planning
40*ad6833e5SNandini Persadfor incremental upstreaming across multiple patch series or releases.
41*ad6833e5SNandini Persad
42*ad6833e5SNandini PersadIt's important to prioritize quality of the driver over upstreaming
43*ad6833e5SNandini Persadin a single release or single patch series.
44*ad6833e5SNandini Persad
45*ad6833e5SNandini Persad
46*ad6833e5SNandini PersadFinalizing
47*ad6833e5SNandini Persad----------
48*ad6833e5SNandini Persad
49*ad6833e5SNandini PersadOnce the driver has been upstreamed,
50*ad6833e5SNandini Persadthe author has a responsibility to the community to maintain it.
51*ad6833e5SNandini Persad
52*ad6833e5SNandini PersadThis includes the public test report.
53*ad6833e5SNandini PersadAuthors must send a public test report after the first upstreaming of the PMD.
54*ad6833e5SNandini PersadThe same public test procedure may be reproduced regularly per release.
55*ad6833e5SNandini Persad
56*ad6833e5SNandini PersadAfter the PMD is upstreamed, the author should send a patch to update
57*ad6833e5SNandini Persad`the website <https://core.dpdk.org/supported/>`_
58*ad6833e5SNandini Persadwith the name of the new PMD and supported devices via the
59*ad6833e5SNandini Persad`DPDK web mailing list <https://mails.dpdk.org/listinfo/web>`_.
60*ad6833e5SNandini Persad
61*ad6833e5SNandini PersadFor more information about the role of maintainers, see :doc:`patches`.
62*ad6833e5SNandini Persad
63*ad6833e5SNandini Persad
64*ad6833e5SNandini PersadSplitting into Patches
65*ad6833e5SNandini Persad----------------------
66*ad6833e5SNandini Persad
67*ad6833e5SNandini PersadWe recommend that drivers are split into patches,
68*ad6833e5SNandini Persadso that each patch represents a single feature.
69*ad6833e5SNandini PersadIf the driver code is already developed, it may be challenging to split.
70*ad6833e5SNandini PersadHowever, there are many benefits to doing so.
71*ad6833e5SNandini Persad
72*ad6833e5SNandini PersadSplitting patches makes it easier to understand a feature
73*ad6833e5SNandini Persadand clarifies the list of components/files that compose that specific feature.
74*ad6833e5SNandini Persad
75*ad6833e5SNandini PersadIt also enables the ability to track
76*ad6833e5SNandini Persadfrom the source code to the feature it is enabled for,
77*ad6833e5SNandini Persadand helps users to understand the reasoning and intention of implementation.
78*ad6833e5SNandini PersadThis kind of tracing is regularly required for defect resolution and refactoring.
79*ad6833e5SNandini Persad
80*ad6833e5SNandini PersadAnother benefit of splitting the codebase per feature is that
81*ad6833e5SNandini Persadit highlights unnecessary or irrelevant code,
82*ad6833e5SNandini Persadas any code not belonging to any specific feature becomes obvious.
83*ad6833e5SNandini Persad
84*ad6833e5SNandini PersadGit bisect is also more useful if patches are split per patch.
85*ad6833e5SNandini Persad
86*ad6833e5SNandini PersadThe split should focus on logical features rather than file-based divisions.
87*ad6833e5SNandini Persad
88*ad6833e5SNandini PersadEach patch in the series must compile without errors
89*ad6833e5SNandini Persadand should maintain functionality.
90*ad6833e5SNandini Persad
91*ad6833e5SNandini PersadEnable the build as early as possible within the series
92*ad6833e5SNandini Persadto facilitate continuous integration and testing.
93*ad6833e5SNandini PersadThis approach ensures a clear and manageable development process.
94*ad6833e5SNandini Persad
95*ad6833e5SNandini PersadWe suggest splitting patches following this approach:
96*ad6833e5SNandini Persad
97*ad6833e5SNandini Persad* Each patch should be organized logically as a new feature.
98*ad6833e5SNandini Persad* Run test tools per patch (See :ref:`tool_list`).
99*ad6833e5SNandini Persad* Update relevant documentation and `<driver>.ini` file with each patch.
100*ad6833e5SNandini Persad
101*ad6833e5SNandini PersadThe following order in the patch series is as suggested below.
102*ad6833e5SNandini Persad
103*ad6833e5SNandini PersadThe first patch should have the driver's skeleton which should include:
104*ad6833e5SNandini Persad
105*ad6833e5SNandini Persad* Maintainers file update
106*ad6833e5SNandini Persad* Driver documentation
107*ad6833e5SNandini Persad* Document must have links to official product documentation web page
108*ad6833e5SNandini Persad* The new document should be added into the index (`index.rst`)
109*ad6833e5SNandini Persad* Initial `<driver>.ini` file
110*ad6833e5SNandini Persad* Release notes announcement for the new driver
111*ad6833e5SNandini Persad
112*ad6833e5SNandini PersadThe next patches should include basic device features.
113*ad6833e5SNandini PersadThe following is a suggested sample list of such patches:
114*ad6833e5SNandini Persad
115*ad6833e5SNandini Persad================================  ================================
116*ad6833e5SNandini PersadNet                               Crypto
117*ad6833e5SNandini Persad================================  ================================
118*ad6833e5SNandini PersadInitialization                    Initialization
119*ad6833e5SNandini PersadConfigure queues                  Configure queues
120*ad6833e5SNandini PersadStart queues                      Configure sessions
121*ad6833e5SNandini PersadSimple Rx / Tx                    Add capabilities
122*ad6833e5SNandini PersadStatistics                        Statistics and device info
123*ad6833e5SNandini PersadDevice info                       Simple data processing
124*ad6833e5SNandini PersadLink interrupt
125*ad6833e5SNandini PersadBurst mode info
126*ad6833e5SNandini PersadPromisc all-multicast
127*ad6833e5SNandini PersadRSS
128*ad6833e5SNandini Persad================================  ================================
129*ad6833e5SNandini Persad
130*ad6833e5SNandini PersadAdvanced features should be in the next group of patches.
131*ad6833e5SNandini PersadThe suggestions for these, listed below, are in no specific order:
132*ad6833e5SNandini Persad
133*ad6833e5SNandini Persad================================  ================================
134*ad6833e5SNandini PersadNet                               Crypto
135*ad6833e5SNandini Persad================================  ================================
136*ad6833e5SNandini PersadAdvanced Rx / Tx                  Chained operations
137*ad6833e5SNandini PersadVector Rx / Tx                    Scatter Gather
138*ad6833e5SNandini PersadScatter support                   Security protocols (IPsec, etc.)
139*ad6833e5SNandini PersadTSO / LRO                         Asymmetric crypto
140*ad6833e5SNandini PersadRx / Tx descriptor status
141*ad6833e5SNandini PersadRx / Tx queue info
142*ad6833e5SNandini PersadFlow offload
143*ad6833e5SNandini PersadTraffic management / metering
144*ad6833e5SNandini PersadExtended statistics
145*ad6833e5SNandini PersadSecondary process support
146*ad6833e5SNandini PersadFreeBSD / Windows support
147*ad6833e5SNandini PersadFlow control
148*ad6833e5SNandini PersadFEC
149*ad6833e5SNandini PersadEEPROM access
150*ad6833e5SNandini PersadRegister dump
151*ad6833e5SNandini PersadTime synchronization, PTP
152*ad6833e5SNandini PersadPerformance documentation
153*ad6833e5SNandini Persad================================  ================================
154*ad6833e5SNandini Persad
155*ad6833e5SNandini PersadAfter all features are enabled,
156*ad6833e5SNandini Persadif there is remaining base code that is not upstreamed,
157*ad6833e5SNandini Persadthey can be upstreamed at the end of the patch series.
158*ad6833e5SNandini PersadHowever, we recommend these patches are still split into logical groups.
159*ad6833e5SNandini Persad
160*ad6833e5SNandini Persad
161*ad6833e5SNandini PersadAdditional Suggestions
162*ad6833e5SNandini Persad----------------------
163*ad6833e5SNandini Persad
164*ad6833e5SNandini PersadAvoid doing the following:
165*ad6833e5SNandini Persad
166*ad6833e5SNandini Persad* Using PMD specific macros when DPDK macros exist
167*ad6833e5SNandini Persad* Including unused headers (see `process-iwyu.py`)
168*ad6833e5SNandini Persad* Disabling compiler warnings for a driver
169*ad6833e5SNandini Persad* #ifdef with driver-defined macros
170*ad6833e5SNandini Persad* DPDK version checks (via ``RTE_VERSION_NUM``) in the upstream code
171*ad6833e5SNandini Persad* Introducing public API directly from the driver
172*ad6833e5SNandini Persad
173*ad6833e5SNandini PersadRemember to do the following:
174*ad6833e5SNandini Persad
175*ad6833e5SNandini Persad* Runtime configuration when applicable
176*ad6833e5SNandini Persad* Document device parameters in the driver guide
177*ad6833e5SNandini Persad* Make device operations struct 'const'
178*ad6833e5SNandini Persad* Dynamic logging
179*ad6833e5SNandini Persad* SPDX license tags and copyright notice on each file
180*ad6833e5SNandini Persad* Run the Coccinelle scripts `devtools/cocci.sh`
181*ad6833e5SNandini Persad  which check for common cleanups
182*ad6833e5SNandini Persad  such as useless null checks before calling free routines
183*ad6833e5SNandini Persad
184*ad6833e5SNandini Persad
185*ad6833e5SNandini PersadDependencies
186*ad6833e5SNandini Persad------------
187*ad6833e5SNandini Persad
188*ad6833e5SNandini PersadAt times, drivers may have dependencies to external software.
189*ad6833e5SNandini PersadFor driver dependencies, same DPDK rules for dependencies applies.
190*ad6833e5SNandini PersadDependencies should be publicly and freely available,
191*ad6833e5SNandini Persaddrivers which depend on non-available components will not be accepted.
192*ad6833e5SNandini PersadIf the required dependency is not yet publicly available,
193*ad6833e5SNandini Persadthen wait to submit the driver until the dependent library is available.
194*ad6833e5SNandini Persad
195*ad6833e5SNandini Persad
196*ad6833e5SNandini Persad.. _tool_list:
197*ad6833e5SNandini Persad
198*ad6833e5SNandini PersadTest Tools
199*ad6833e5SNandini Persad----------
200*ad6833e5SNandini Persad
201*ad6833e5SNandini PersadBuild and check the driver's documentation.
202*ad6833e5SNandini PersadMake sure there are no warnings,
203*ad6833e5SNandini Persadand driver shows up in the relevant index page.
204*ad6833e5SNandini Persad
205*ad6833e5SNandini PersadBe sure to run the following test tools per patch in a patch series:
206*ad6833e5SNandini Persad
207*ad6833e5SNandini Persad* `checkpatches.sh`
208*ad6833e5SNandini Persad* `check-git-log.sh`
209*ad6833e5SNandini Persad* `check-meson.py`
210*ad6833e5SNandini Persad* `check-doc-vs-code.sh`
211*ad6833e5SNandini Persad* `check-spdx-tag.sh`
212*ad6833e5SNandini Persad* Build documentation and validate how output looks
213