A high-speed driving method for FPGA XDMA

By running the DPDK driver in user space and utilizing the association between DMA descriptors and mbufs and a non-circular linked list design, the slow transmission rate and packet loss problems of FPGA XDMA under the Linux platform were solved, achieving high-speed and reliable data transmission.

CN117149282BActive Publication Date: 2024-09-13SHANDONG YISHENG INFORMATION TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311089770.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-28
Publication Date
2024-09-13
Estimated Expiration
2043-08-28

AI Technical Summary

Technical Problem

In the existing technology, the FPGA XDMA driver on the Linux platform requires a large number of memcpy operations and process context switching when transferring data between user space and kernel space, resulting in slow transmission rate and packet loss, and failing to fully utilize the high-speed transmission advantages of PCIe and FPGA.

Method used

The DPDK driver runs in user space, and zero-copy data and no process context switching are achieved by associating DMA descriptors with mbufs. Combined with a non-circular DMA descriptor linked list design, packet loss is prevented.

Benefits of technology

It greatly improves the transmission rate, avoids the overhead of interrupt handling and process context switching, and ensures the reliability of data transmission without packet loss.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117149282B
    Figure CN117149282B
Patent Text Reader

Abstract

The present invention discloses a high-speed driving method of FPGA XDMA, belonging to the technical field of data transmission. The method is used for electronic equipment, the electronic equipment includes a host, a board card is inserted in the host, a DPDK is installed on the host, and an FPGA using XDMA is arranged on the board card; when the host sends data to the board card, the method includes: a driver of DPDK receives the address of a buffer area mbuf transmitted by an application on the host, wherein mbuf is a certain number of mbufs applied by the application from the memory pool of DPDK, and the application fills the data to be sent therein; the driver starts DMA sending after associating a DMA descriptor with mbuf. The present invention adopts DPDK, the driver runs completely in the user space, the data is zero-copy, there is no interrupt processing and the overhead caused by the process context switching, thereby greatly improving the transmission rate without upgrading the hardware.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data transmission, and in particular to a high-speed driving method of FPGA XDMA. Background Art

[0002] FPGA (Field Programmable Gate Array) is widely used in the field of data encryption due to its advantages of fast data processing speed, low latency, and good security. This type of FPGA usually uses PCIE (Peripheral Component Interconnect Express, a high-speed serial computer expansion bus standard) IP core to give full play to its advantage of fast transmission rate. Currently, low-end and mid-range FPGAs mostly use XDMA (official PCIE advanced IP in Xilinx series FPGA) IP core. Under the Linux platform, its driver is usually implemented based on the kernel driver framework and does not support DPDK (Data Plane Development Kit). In this way, data needs to be transferred between user space and kernel space (see Figure 1 In the left part, the kernel space uses XilinxXDMA driver, and there are a large number of memcpy (memory copy) operations. At the same time, the continuous context switching of the process will also increase the system overhead, resulting in slow transmission rate and packet loss, and unable to give full play to the high-speed transmission advantages of PCIE and FPGA. Summary of the invention

[0003] The technical problem to be solved by the present invention is to provide a high-speed driving method of FPGA XDMA with high transmission rate.

[0004] In order to solve the above technical problems, the present invention provides the following technical solutions:

[0005] On the one hand, a high-speed driving method of FPGA XDMA is provided, which is used in an electronic device, wherein the electronic device includes a host, a board is inserted into the host, a DPDK is installed on the host, and an FPGA using XDMA is provided on the board; when the host sends data to the board, the method includes:

[0006] Step 10: The DPDK driver receives the address of the buffer area mbuf transmitted by the application on the host, wherein the mbuf is a certain number of mbufs requested by the application from the memory pool mempool of the DPDK, and the application fills the mbufs with the data to be sent;

[0007] Step 11: The driver associates the DMA descriptor with the mbuf, and starts DMA transmission after the association is completed.

[0008] On the other hand, a high-speed driving method of FPGA XDMA is provided, which is used in an electronic device, wherein the electronic device includes a host, a board card is inserted into the host, a DPDK is installed on the host, and an FPGA using XDMA is provided on the board card; when the host receives data from the board card, the method includes:

[0009] Step 20: During initialization, the DPDK driver applies for a certain number of buffer mbufs from the DPDK memory pool mempool and associates them with the DMA descriptors. After receiving the data, the driver returns the mbuf address associated with the DMA descriptor corresponding to the received data packet to the application on the host, and applies for the same number of mbufs as the received data packets from the DPDK mempool and associates them with the DMA descriptors.

[0010] The present invention has the following beneficial effects:

[0011] The present invention uses DPDK, and the driver runs completely in user space (see Figure 1 In the right part, the user space adopts DPDK PMD (Poll Mode Driver), with zero data copy and no interrupt processing and process context switching overhead, thereby greatly improving the transmission rate without upgrading the hardware. At the same time, the design of the descriptor linked list in the present invention also ensures that there will be no packet loss problem. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] Figure 1 A schematic diagram comparing the traditional driver and the DPDK driver solution of the present invention;

[0013] Figure 2 It is a schematic diagram of the principle of the high-speed driving method of FPGA XDMA of the present invention;

[0014] Figure 3 It is a schematic diagram of the process of the host sending data to the board in the present invention;

[0015] Figure 4 It is a schematic diagram of the process of the host receiving data from the board in the present invention. DETAILED DESCRIPTION

[0016] In order to make the technical problems, technical solutions and advantages to be solved by the present invention more clear, a detailed description will be given below with reference to the accompanying drawings and specific embodiments.

[0017] On the one hand, the present invention provides a high-speed driving method of FPGA XDMA, such as Figure 2 As shown, it is used for electronic equipment, and the electronic equipment includes a host ( Figure 2 The part above the FPGA in the figure can be regarded as a host), the host is provided with a board card, the host is installed with a DPDK, and the board card is provided with an FPGA (chip) using XDMA; when the host sends data to the board card, the method includes:

[0018] Step 10: The DPDK driver receives the address of the mbuf (buffer area) passed by the application on the host, wherein the mbuf is a certain number of mbufs requested by the application from the mempool (memory pool) of the DPDK, and the application fills the mbuf with the data to be sent;

[0019] In this step, when the application on the host ( Figure 2 APP in DPDK) applies for a certain number of mbufs from DPDK's mempool and fills them with the data to be sent, and then passes the address of the mbuf to the DPDK driver.

[0020] Step 11: The driver associates a DMA (Direct Memory Access) descriptor with the mbuf, and starts DMA transmission after the association is completed.

[0021] In this step, the driver will DMA descriptor (ie Figure 2 After the association is completed, DMA transmission can be started to send data to the board.

[0022] As an optional embodiment, see Figure 3 , the step 11 may include:

[0023] Step 111: Obtain a DMA descriptor linked list and determine a current starting position, wherein the DMA descriptor linked list is a non-circular linked list;

[0024] For the host to send data to the board, the application can send data by calling the rte_eth_tx_burst function interface of DPDK. This function will call back the XDMA_xmit_pkts_st function of the driver (program) to complete the data transmission. Therefore, the relevant content of step 11 can be implemented with the help of the XDMA_xmit_pkts_st function.

[0025] Step 112: according to the number of data packets to be sent by the application, loop through each mbuf, fill in the control field of the DMA descriptor corresponding to the current mbuf, obtain the address of the current mbuf and fill it in the src field of the DMA descriptor corresponding to the current mbuf, obtain the address of the next DMA descriptor and fill it in the next field of the DMA descriptor corresponding to the current mbuf, and now the current mbuf is associated with its corresponding DMA descriptor;

[0026] Step 113: After all mbufs are associated with DMA descriptors, a stop flag is set for the last DMA descriptor so that the DMA transfer stops when it reaches this point;

[0027] In this step, when it is specifically implemented, a stop flag, such as XDMA_DESC_STOPPED, may be added to the control field of the last DMA descriptor, and the next field may also be set to empty.

[0028] Step 114: Start DMA transfer.

[0029] In this step, when implemented, the FPGA XDMA register can be set to start DMA transmission, for example, the register control bit is set to XDMA_MM_POLLMODE_WB_EN | XDMA_MM_CTRL_START, where XDMA_MM_POLLMODE_WB_EN indicates enabling the polling mode, and XDMA_MM_CTRL_START indicates starting transmission.

[0030] Furthermore, to facilitate data statistics and management, the step 114 may include:

[0031] Step 115: After waiting for the transmission to be completed, the number of packets sent (ie, the number of data packets) is returned. The sending operation is now completed.

[0032] On the other hand, the present invention provides a high-speed driving method of FPGA XDMA, which is used in an electronic device, wherein the electronic device includes a host, a board card is inserted into the host, a DPDK is installed on the host, and an FPGA using XDMA is provided on the board card; when the host receives data from the board card, the method includes:

[0033] Step 20: During initialization, the DPDK driver applies for a certain number of mbufs from the DPDK mempool and associates them with the DMA descriptors. After receiving the data, the driver returns the mbuf address associated with the DMA descriptor corresponding to the received data packet to the application on the host, and applies for the same number of mbufs as the received data packets from the DPDK mempool and associates them with the DMA descriptors.

[0034] In this step, the DPDK driver applies for a certain number of mbufs from the DPDK mempool during initialization. The "certain number" can be the total number of descriptors contained in the DMA descriptor linked list, and the specific size can be flexibly set as needed. Generally speaking, there is a one-to-one correspondence between data packets and DMA descriptors. When the host receives data from the board, the driver returns the mbuf address associated with the DMA descriptor corresponding to the received data packet to the application on the host, so that the application can read data from the mbuf. After the application reads data from the mbuf, the mbuf will be released. Therefore, at the end of this step, the same number of mbufs as the received data packets are applied from the DPDK mempool and associated with the DMA descriptors to ensure that each DMA descriptor is associated with an mbuf, thereby ensuring that subsequent data reception can proceed smoothly.

[0035] As an optional embodiment, see Figure 4 , the step 20 may include:

[0036] Step 201: Obtain the cumulative number of received descriptors of the driver program, total_recv, and the cumulative number of read descriptors of the application program, total_read;

[0037] During the implementation of the present invention, a data structure can be maintained for each sending and receiving channel to record the status, descriptor information, read and write position, etc. of the channel. Specifically, two variables, total_recv and total_read, can be maintained in the rxq (receive queue) of the driver, which are used to record the cumulative number of descriptors received by the driver (i.e., the number of descriptors corresponding to the data packets received cumulatively by the driver) and the cumulative number of descriptors read by the application (i.e., the number of descriptors corresponding to the data packets read cumulatively by the application) in DMA transmission. For total_recv, it can be maintained by the FPGA XDMA register, and accumulated each time the board sends a data packet to the host; for total_read, it can be maintained by the driver, and accumulated each time the driver passes the mbuf address associated with the DMA descriptor corresponding to the data packet to the application.

[0038] For the host to receive data from the board, the application can receive the data by calling the rte_eth_rx_burst function interface of DPDK. This function will call back the XDMA_recv_pkts_st function of the driver (program) to complete the data reception. Therefore, the relevant content of step 20 can be implemented with the help of the XDMA_recv_pkts_st function.

[0039] Step 202: Calculate the difference between total_recv and total_read, where the difference represents the number of data packets received between two polling intervals;

[0040] In the present invention, DPDK is driven in polling mode (see Figure 2 Therefore, in this step, it is necessary to determine the number of packets received between two polling intervals.

[0041] Step 203: if the difference is not zero, then read the descriptors from the number of total_read records in the DMA descriptor linked list, process the received data packets one by one, that is, fill the value of the src field in each DMA descriptor, which value represents the data length at this time, into the data length data_len member of the corresponding mbuf, and pass the address of the mbuf to the pointer specified by the application, wherein the DMA descriptor linked list is not a circular linked list;

[0042] In this step, if the difference is zero, it means that no new data packets are received during the two pollings, so the application needs to keep polling rte_eth_rx_burst and check the return value; if the difference is not zero, it means that a new data packet is received and needs to be sent to the application, so the actual position of the currently read DMA descriptor can be determined in the DMA descriptor linked list according to total_read, and the received data packets are processed one by one. The specific processing method can refer to the conventional technology in this field. It can be understood that the relevant design of the DMA descriptor linked list in the aforementioned data sending part is also applied to the data receiving part, so it will not be repeated here.

[0043] After receiving the address of mbuf, the application can read data from mbuf. After the application finishes reading the data in mbuf, it releases mbuf.

[0044] Step 204: After processing all received data packets, apply for mbufs with the same number as the difference from the mempool of the DPDK to associate with the DMA descriptors corresponding to the data packets received this time.

[0045] See also Figure 2It is understandable that what the receiving application obtains are mbufs filled with data. These mbufs are not requested by the receiving application, but by the driver during the initialization operation. According to the number of data packets / DMA descriptors (passed to the driver by the application during initialization), the corresponding number of mbufs are requested from the DPDK mempool to associate with the DMA descriptors. Each subsequent data reception, after the data reception processing is completed (the mbuf address associated with the DMA descriptor is passed to the application pointer), the same number of mbufs are requested from the DPDK mempool to associate with the DMA descriptors.

[0046] Further, to facilitate the data receiving loop execution, the step 204 may include:

[0047] Step 205: Determine whether the DMA transmission is in a stopped state, and whether the total_recv and total_read have reached the total number of DMA descriptors recorded in the DMA descriptor linked list;

[0048] Step 206: If no, jump to the next step;

[0049] In specific implementation, this step 206 may also include:

[0050] If both are yes, then clear the total_recv and total_read, stop DMA transmission, set the DMA descriptor start address to the first address of the DMA descriptor linked list, start DMA transmission, and go to step 207.

[0051] That is to say, when it is detected that the DMA transfer is in a stopped state and total_recv and total_read are equal to nb_rx_desc (the total number of DMA descriptors, that is, the end of the DMA descriptor list), it means that the end of the DMA descriptor list has been reached, and the DMA transfer is stopped at this time. In order to facilitate the subsequent data transfer, the total_recv and total_read variables can be cleared, and the starting address of the DMA transfer is set to the head of the DMA descriptor list, and the DMA transfer is started again.

[0052] In the present invention, the circular linked list of DPDK is not used, thereby ensuring that when the receiving end processes slowly, the DMA transmission will stop after all the DMA descriptors of the driver (program) are fully received. Since the board is still receiving data from the external device, the FPGA's receiving FIFO (First Input First Output) will be full. When the FPGA detects that the FIFO is full, it will block the external device sending end. When the driver receiving end starts DMA transmission again, the FPGA will continue to transmit, thereby preventing packet loss.

[0053] Step 207: Return the number of received packets (ie, the number of data packets). The receiving operation is now completed.

[0054] The present invention is based on the currently widely used DPDK, adapts the XDMA driver to the DPDK, solves the problem that DPDK does not support XDMA, and provides a standard DPDK interface to the upper application, which can effectively improve the transmission rate. At the same time, the driver implementation fully utilizes the characteristics of FPGA to ensure that there is no packet loss during the transmission process. Different FPGAs will have multiple transceiver channels, and the present invention also supports this, which can give full play to the advantages of multiple channels.

[0055] The present invention combines the characteristics of XDMA, the DMA descriptor does not adopt a ring, and sets a stop mark for the DMA descriptor at the end of the linked list to prevent the problem of packet loss when the application program receives and processes slowly. When the reception reaches the last descriptor, the DMA transmission stops, and when the FIFO of the FPGA is full, the external device sending end is prevented from further sending, thereby ensuring that no packet loss occurs.

[0056] In summary, the present invention uses DPDK, and the driver runs completely in user space (see Figure 1 Right part), data is zero-copy, there is no interrupt processing and process context switching overhead, thus greatly improving the transmission rate without upgrading the hardware. At the same time, the design of the descriptor linked list in the present invention also ensures that there will be no packet loss problem.

[0057] The above is a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A high-speed driving method of FPGA XDMA, used in electronic equipment, characterized in that: The electronic device comprises a host, a board is inserted into the host, a DPDK is installed on the host, and an FPGA using XDMA is arranged on the board; When the host sends data to the board, the method includes: Step 10: The DPDK driver receives the address of the buffer area mbuf transmitted by the application on the host, wherein the mbuf is a certain number of mbufs requested by the application from the memory pool mempool of the DPDK, and the application fills the mbufs with the data to be sent; Step 11: The driver associates the DMA descriptor with the mbuf, and starts DMA transmission after the association is completed; Wherein, the step 11 comprises: Step 111: Obtain a DMA descriptor linked list and determine the current starting position, wherein the DMA descriptor linked list is a non-circular linked list; for the host to send data to the board, the application sends data by calling the rte_eth_tx_burst function interface of the DPDK, and the function calls back the XDMA_xmit_pkts_st function of the driver to complete the data sending; Step 112: according to the number of data packets to be sent by the application, loop through each mbuf, fill in the control field of the DMA descriptor corresponding to the current mbuf, obtain the address of the current mbuf and fill it in the source address src field of the DMA descriptor corresponding to the current mbuf, obtain the address of the next DMA descriptor and fill it in the next descriptor address next field of the DMA descriptor corresponding to the current mbuf; Step 113: After all mbufs are associated with DMA descriptors, a stop flag is set for the last DMA descriptor so that the DMA transfer stops when it reaches this point; Step 114: Start DMA transfer.

2. The method according to claim 1, characterized in that: The step 114 then includes: Step 115: After waiting for the transmission to be completed, the number of packets sent is returned.

3. A high-speed driving method of FPGA XDMA, used in electronic equipment, characterized in that: The electronic device comprises a host, a board is inserted into the host, a DPDK is installed on the host, and an FPGA using XDMA is arranged on the board; When the host receives data from the board, the method includes: Step 20: The DPDK driver applies for a certain number of buffer mbufs from the DPDK memory pool mempool during initialization and associates them with the DMA descriptors. After receiving the data, the driver returns the mbuf address associated with the DMA descriptor corresponding to the received data packet to the application on the host, and applies for the same number of mbufs as the received data packet from the DPDK mempool and associates them with the DMA descriptors. Wherein, the step 20 comprises: Step 201: Get the total_recv cumulative number of descriptors received by the driver and the total_read cumulative number of descriptors read by the application; for the host to receive data from the board, the application receives the data by calling the rte_eth_rx_burst function interface of the DPDK, which calls back the XDMA_recv_pkts_st function of the driver to complete the data reception; Step 202: Calculate the difference between total_recv and total_read, where the difference represents the number of data packets received between two polling intervals; Step 203: if the difference is not zero, then read the descriptors from the number of total_read records in the DMA descriptor linked list, process the received data packets one by one, that is, fill the value of the src field in each DMA descriptor, which value represents the data length at this time, into the data length data_len member of the corresponding mbuf, and pass the address of the mbuf to the pointer specified by the application, wherein the DMA descriptor linked list is not a circular linked list; Step 204: After processing all received data packets, apply for mbufs with the same number as the difference from the mempool of the DPDK to associate with the DMA descriptors corresponding to the data packets received this time.

4. The method according to claim 3, characterized in that The step 204 then includes: Step 205: Determine whether the DMA transmission is in a stopped state, and whether the total_recv and total_read have reached the total number of DMA descriptors recorded in the DMA descriptor linked list; Step 206: If no, jump to the next step; Step 207: Return the number of received packets.

5. The method according to claim 4, characterized in that The step 206 further includes: If both are yes, then clear the total_recv and total_read, stop DMA transmission, set the DMA descriptor start address to the first address of the DMA descriptor linked list, start DMA transmission, and go to step 207.