An introduction to PMDs (Poll Mode Drivers) in DPDK
Introduction
In this article, I have explained about a basic DPDK application which reads the packets from NIC interface. In this article we will learn in detail about the concept of PMDs (Poll Mode Drivers) in DPDK. If you are passionate about fast packet processing using DPDK then this article is for you.
PMDs (Poll Mode Drivers)
In one of the previous article, we have discussed how DPDK works and its difference with kernel based packet processing approach. In a DPDK program, we continuously poll the NIC interface queues for any received packets. For polling, the DPDK program continuously calls a DPDK API in a loop. The DPDK API to receive the packets is rte_eth_rx_burst().
When this API is called by the DPDK program, an underlying function is invoked to received the packets from the NIC. The underlying function is specific to the NIC and part of the DPDK driver implementation of that NIC. DPDK library implements multiple drivers for different NICs. Some of the examples of different NICs vendors are Intel, Nvidia, Marvell, Broadcom, Amazon etc. Below are some of the names of different drivers which are provided by DPDK library against each NIC vendor.
Intel (e1000, i40e)
Amazon (ena)
Broadcom (bnxt)
Marvell (bnx2x)
List of all supported devices and their drivers are listed at: https://core.dpdk.org/supported/
These drivers are known as PMDs (Poll Mode Drivers).
How DPDK application load PMDs
Now we will discuss how a PMD (Poll Mode Driver) is loaded by the DPDK application against the specific NIC. When the DPDK application starts, it first calls a DPDK API to initialize the environment. The DPDK API is rte_eal_init() and must be called by the application right after the application starts. The API performs the following steps to detect the attached NIC and load the PMD (poll mode driver) specific to it.
Detects the different kind of buses present in the system. One of the example of a bus which can be present in the system is PCI (Peripheral Component Interconnect) bus. There can be other buses as well which are outside the scope of this article.
Scan the PCI bus and detect the NICs (if any) which are attached to PCI bus. The NIC is attached to the PCI bus and has a specific PCI bus address.
When the DPDK program loads, it loads the information of all the available DPDK PMDs (Poll Mode Driver) in its cache as well. As discussed earlier, different PMD implementations are the part of DPDK library. Each PMD has the following unique values:
a. Vendor id
b. Device idc. Sub system vendor id
d. Sub system device id
e. Class id
All the above mentioned information is also stored in the NIC and we can access it via Linux API ioctl.Now DPDK API compares the unique values of PMDs and NIC one by one and if all the values match, it loads the particular PMD (Poll Mode Driver) for the NIC attached to the system.
In this way a particular PMD is selected for a particular NIC attached to the system.
Summary
In this article, we discussed in detail about the concept of PMD (Poll Mode Drivers) in DPDK. We also discussed about how DPDK application detects the NIC on PCI bus and loads the respective PMD for the NIC.
Feel free to write me in the comments if you questions regarding the concept of PMDs in DPDK.
Subscribe to my newsletter
Read articles from Muhammad Awais Khalid directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Muhammad Awais Khalid
Muhammad Awais Khalid
I am a software engineer. During my career, I have developed high performance software solutions in multiple domains. I have expertise in: C/C++, Linux, Data Plane Development Kit (DPDK), VoIP (Voice Over IP) Lawful Interception Systems, Parallel Computing, GPU Computing