Method for realizing multi-process concurrency based on PCIe XDMA

By designing a multi-parallel running cipher algorithm module and DPDK driver based on PCIe XDMA, the problem of the inability to meet the concurrency of multiple processes is solved, and the system password computing speed is improved.

CN117149276BActive Publication Date: 2024-11-01SHANDONG YISHENG INFORMATION TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311089847.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-28
Publication Date
2024-11-01
Estimated Expiration
2043-08-28

AI Technical Summary

Technical Problem

The existing PCIe 2.0 XDMA IP core can only support two DMA channels at most, and cannot meet the needs of multiple application processes to access different password algorithm modules of password cards at the same time, and cannot achieve multi-process concurrency.

Method used

Design a method based on PCIe XDMA, through the cooperation of FPGA hardware logic programs, drivers and host computer applications, define the data packet format, use multiple parallel running cipher algorithm modules, and adopt data packet analysis, scheduling and integration modules. Implement multi-process concurrency and provide multiple write channel support through the DPDK driver.

Benefits of technology

Based on the existing PCIe 2.0 XDMA, it meets the concurrency requirements of multiple processes, improves the system's password computing speed, and realizes that multiple application processes can access different password algorithm modules at the same time, improving data throughput and response time .

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117149276B_ABST
    Figure CN117149276B_ABST
Patent Text Reader

Abstract

The invention discloses a method for realizing multi-process concurrency based on PCIe XDMA, and belongs to the technical field of password card and data encryption. The method is designed from three parts: bottom FPGA hardware logic, driver and upper computer application program. A plurality of different password algorithm modules are designed through FPGA hardware programming. The plurality of password algorithm modules run in parallel, and data distribution and password operation in data packets are realized. The driver realizes XDMA IP core DPDK based on FPGA logic program, and provides support for multiple write channels in logic. The application realizes multi-channel support in the whole read-write logic based on the driver implementation, and ensures that multiple application programs can concurrently access PCIe password card. The invention not only meets the demand for multi-process concurrency, but also makes full use of the speed advantage of FPGA hardware in realizing password operation, and improves the password operation speed of the system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of password cards and data encryption, and in particular to a method for realizing multi-process concurrency based on PCIe XDMA. Background Art

[0002] Information security is receiving more and more attention, and the password card system is an effective means to solve information security problems.

[0003] The password card system mainly consists of three parts: password card hardware and control program, driver and application program. The password card hardware is mainly controlled by FPGA (Field Programmable Gate Array) chip, the control program adopts FPGA hardware logic programming, the application program is the host computer program, and the driver program is located between the logic program and the application program, playing the role of up and down data transmission. The password card adopts PCIe (Peripheral Component Interconnect Express, a high-speed serial computer expansion bus standard) 2.0 interface to the outside. The FPGA chip realizes PCIe 2.0 protocol and DMA (Direct Memory Access) transmission function through XDMA (official PCIE advanced IP in Xilinx series FPGA) IP core. For the password card system structure diagram, see Figure 1 .

[0004] XDMA is the PCIe IP core that comes with FPGA. The IP core encapsulates the transaction layer, data link layer and physical layer of the PCIe protocol, and reserves a data port in the transaction layer for development. XDMA uses memory space as the basis for data interaction and realizes data transmission by operating DMA descriptors; DMA descriptors include information such as source address, destination address and DMA length. XDMA data transmission directions are divided into host to card H2C (Host to Card) and card to host C2H (Card to Host). The IP core also provides multiple user interrupt lines for generating interrupts to the host. The XDMA IP core has the following features: support for polling mode; support for multiple data bit widths; support for 64-bit source address, destination address and descriptor address; support for user configurable interface; support for multiple interrupt mechanisms including MSI (Message Signaled Interrupt) and MSI-X (Message Signaled Interrupt eXtended); support for 256MB data transmission for each descriptor; support for continuous acquisition of descriptors; support for PCIe transaction DMA engine.

[0005] In actual use, PCIe cryptographic cards face the need for multi-process concurrency of host computer applications, that is, multiple application processes simultaneously access different cryptographic algorithm modules of the PCIe cryptographic card to perform cryptographic operations. To meet the need for multi-process concurrency, a combination of multiple cryptographic algorithm modules and multiple DMA channels is generally used, with one channel corresponding to one application process. Since the current PCIe 2.0 XDMA IP core can support up to two DMA channels, when there are more than two processes, it is impossible to have one channel corresponding to one process. Therefore, how to meet the need for multi-process concurrency based on the existing PCIe 2.0 XDMA has become a problem that needs to be solved. Summary of the invention

[0006] The technical problem to be solved by the present invention is to provide a method for realizing multi-process concurrency based on PCIe XDMA to meet the requirements of multi-process concurrency of application programs and improve the system cryptographic operation speed.

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

[0008] A method for realizing multi-process concurrency based on PCIe XDMA, which is used in a password card system, wherein the password card system includes a host and a password card connected to the host, the host is installed with a DPDK, and the password card is provided with an FPGA using XDMA, wherein the FPGA includes an H2C DMA transmission channel, a data packet parsing module, a cryptographic algorithm scheduling module, a cryptographic algorithm module, a data packet integration module and a C2H DMA transmission channel connected in sequence, and the cryptographic algorithm modules are multiple and run in parallel;

[0009] The method for executing the logic program on the FPGA includes:

[0010] Step 10: After the H2C DMA transmission channel receives the data packet sent by the application on the host through the DPDK driver, the data packet parsing module parses and filters the data packet; wherein, the data packet is divided into two parts: a packet header and data. The two fields proc_seq and enc_seq are defined in the packet header, which represent the serial number of the application process and the serial number of the cryptographic algorithm module to be called, respectively;

[0011] Step 11: The data packets that meet the format requirements are sent to the cryptographic algorithm scheduling module, which distributes the data in the data packets to the corresponding cryptographic algorithm modules according to the sequence number of the enc_seq field in the data packet. Each cryptographic algorithm module is pre-assigned a unique sequence number, corresponding to the enc_seq field in the data packet message.

[0012] Step 12: The cryptographic algorithm module operates on the data packet;

[0013] Step 13: After the data packet is processed by the cryptographic algorithm module, the proc_seq field and enc_seq field in the message remain unchanged. After being processed by the data packet integration module, it is sent to the host computer software through the C2H DMA transmission channel and the DPDK driver.

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

[0015] The method for realizing multi-process concurrency based on PCIe XDMA provided by the present invention is designed from three parts, namely, the bottom FPGA hardware logic program, the driver and the host computer application program, on the basis of the existing PCIe 2.0 XDMA, and cooperates with each other to meet the requirements of multi-process concurrency of the application program and improve the system cryptographic operation speed. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 It is a schematic diagram of the architecture of the password card system in the present invention;

[0017] Figure 2 It is a flowchart of the FPGA hardware logic program execution method of the present invention;

[0018] Figure 3 It is a flowchart of the DPDK driver execution method in the present invention;

[0019] Figure 4 It is a flowchart of the application side execution method in the present invention. DETAILED DESCRIPTION

[0020] 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.

[0021] The present invention proposes a method for realizing multi-process concurrency based on PCIe XDMA. On the basis of the existing PCIe 2.0 XDMA, the method is designed from the bottom FPGA hardware logic program, the driver and the host computer application program, which cooperate with each other to meet the requirements of multi-process concurrency of the application program and improve the system cryptographic operation speed.

[0022] The method for realizing multi-process concurrency based on PCIe XDMA provided by the present invention is used in a password card system, such as Figure 1As shown, the password card system includes a host (where the application and driver are located) and a (PCIe) password card connected to the host (i.e., a board, where the FPGA hardware logic program is located), the host is installed with DPDK (Data Plane Development Kit, data plane development kit), and the password card is provided with an FPGA (chip) using XDMA, wherein the FPGA includes an H2C DMA transmission channel, a data packet parsing module, a cryptographic algorithm scheduling module, a cryptographic algorithm module, a data packet integration module and a C2H DMA transmission channel connected in sequence, and the cryptographic algorithm modules are multiple (more than two, and can be 3, 4, 5, etc.) and run in parallel; each part of the present invention and its working method are described one by one as follows:

[0023] FPGA hardware logic program side

[0024] In terms of FPGA logic program, the format of the password card data packet is first defined. The data packet is divided into two parts: the header and the data. The two fields proc_seq and enc_seq are defined in the header, representing the serial number of the application process and the serial number of the cryptographic algorithm module to be called, respectively. Both fields can be 1 byte wide. Then, in FPGA, the PCIe 2.0 interface, H2C DMA transmission channel and C2H DMA transmission channel are implemented through the XDMA IP core; finally, multiple enc_mod cryptographic algorithm modules are designed through FPGA hardware programming to implement multiple different cryptographic operation functions; each cryptographic algorithm module is assigned a unique serial number corresponding to the enc_seq field in the message; at the same time, the data packet parsing module, the cryptographic algorithm scheduling module and the data packet integration module are designed to be responsible for the parsing, distribution, integration and scheduling of the cryptographic algorithm module of the data packet; the cryptographic algorithm scheduling can adopt a pipeline design, and multiple different cryptographic algorithm modules run in parallel.

[0025] Specifically, if Figure 2 As shown, the method for executing the logic program on the FPGA may include:

[0026] Step 10: After the H2C DMA transmission channel receives the data packet sent by the application on the host (host computer) through the DPDK driver, the data packet parsing module parses and filters the data packet; wherein, the data packet is divided into two parts: a packet header and data. The two fields proc_seq and enc_seq are defined in the packet header, which represent the serial number of the application process and the serial number of the cryptographic algorithm module to be called respectively;

[0027] In this step, data packets that do not meet the message format requirements can be discarded.

[0028] Step 11: The data packets that meet the format requirements are sent to the cryptographic algorithm scheduling module, which distributes the data in the data packets to the corresponding cryptographic algorithm modules according to the sequence number of the enc_seq field in the data packet. Each cryptographic algorithm module is pre-assigned a unique sequence number, corresponding to the enc_seq field in the data packet message.

[0029] Step 12: The cryptographic algorithm module operates on the data packet;

[0030] In this step, the cryptographic algorithm module can use the cryptographic algorithm implemented by hardware programming to perform operations such as encryption, decryption, signing and verification on the data; since multiple different cryptographic algorithm modules are in parallel and do not affect each other, multiple cryptographic algorithm modules can run in parallel at the same time, which improves the overall data throughput of cryptographic operation processing and shortens the response time of the application process.

[0031] Step 13: After the data packet is processed by the cryptographic algorithm module, the proc_seq field and enc_seq field in the message remain unchanged. After being processed by the data packet integration module, it is sent to the host computer software through the C2H DMA transmission channel and the DPDK driver.

[0032] In this step, the host computer software may further transfer the data packet to the corresponding application (process) according to the proc_seq field.

[0033] DPDK Driver Side

[0034] The DPDK driver implements the XDMA IP core DPDK based on the FPGA logic program, and on this basis provides support for multiple logical write channels.

[0035] Specifically, refer to Figure 1 , the method performed by the DPDK driver may include:

[0036] Step 20: The DPDK driver on the sending end adds a lock at the beginning of the sending function. When the sending of one channel enters the critical section, the other channels will wait at the entrance until the previous sending ends and exits the critical section and releases the lock, and then the data of the next channel will continue to be sent.

[0037] In the present invention, the DPDK driver receives and sends data through the DMA channel, so the DPDK driver needs to have a corresponding DMA descriptor, and the data storage unit is mbuf (cache area), so each mbuf needs to be associated with a DMA descriptor. All DMA descriptors form a ring, and each member on the ring corresponds to an mbuf. The DPDK driver will record the last position, and start from this position when sending and receiving again; the mbuf of the sending driver is provided by the application each time, and the receiving driver returns the mbuf filled with data to the application. Each descriptor is a structure of a specific type, and the number of descriptors is determined when the program is initialized. The sending process and the receiving process are described below.

[0038] As an optional embodiment, Figure 3 As shown on the left side, step 20 may include:

[0039] Step 201: When the host wants to send data to the cryptographic card, the DPDK driver receives the address of the mbuf passed by the application, where the mbuf is filled with the data to be sent by the application;

[0040] In this step, when data is to be sent, after the application fills the mbuf, it passes the address of the mbuf to the corresponding DPDK driver.

[0041] Step 202: The DPDK driver obtains the DMA descriptor ring and determines the current starting position, obtains the physical address of the current mbuf, fills it into the src (source address) field of the current DMA descriptor, obtains the address of the next DMA descriptor and fills it into the next (next descriptor address) field of the current DMA descriptor, and completes the association between the mbuf and the DMA descriptor in sequence;

[0042] Step 203: After all mbufs are associated with DMA descriptors, set the next field of the last DMA descriptor to be empty;

[0043] Step 204: Start DMA transfer.

[0044] As another optional embodiment, Figure 3 As shown on the right side of the figure, the method executed by the DPDK driver may also include:

[0045] Step 30: When the host wants to receive data from the cryptographic card, the DPDK driver obtains the receive DMA descriptor ring and determines the starting position of this time;

[0046] Step 31: Check whether the count in the descriptor register is updated. When a count change is detected, calculate the difference between the current count and the previous count to determine the number of packets (data packets) to be received.

[0047] In this step, when it is detected that the count has not changed, it can directly return to 0 without performing any operation.

[0048] Step 32: Receive a corresponding number of mbufs starting from the last end position of the DMA descriptor ring according to the number of packets;

[0049] Step 33: Return the address of the corresponding mbuf to the receiving pointer of the application.

[0050] In this step, the application releases the mbuf after processing the data of the mbuf. It is understandable that at this time, the receiving end application obtains the mbuf filled with data.

[0051] Application side

[0052] The application is based on the DPDK driver and implements multi-channel support for the entire read and write logic. Figure 1 The application as a whole is composed of a background service module and SDK (Software Development Kit). The background service process / program starts with the system. One end connects to the PCIe cryptographic card through the DPDK driver, and the other end accepts connections from multiple client application processes to create a transmission channel between the host application and the PCIe cryptographic card, send data to be encrypted and decrypted, and receive the encryption and decryption results. The SDK library is provided to each client application to ensure that multiple user application processes can access the PCIe cryptographic card concurrently, providing high-speed data transmission for the application process.

[0053] Specifically, the application side has SDK and background service programs, such as Figure 4 As shown on the left side, the methods executed by the application side may include:

[0054] Step 40: The application calls the SDK and connects to the background service program;

[0055] In this step, the background service program can be started along with the system.

[0056] Step 41: The sending-end interface program of the background service program allocates a unique ID as the process sequence number according to the request of the application program, and writes it into the proc_seq field of the message. The sequence number of the cryptographic algorithm module to be called is written into the enc_seq field of the message, and the remaining fields are filled in according to the message format;

[0057] Step 42: After the data to be sent is converted into a data packet in the format agreed upon by the password card, it is transferred to the mbuf corresponding to the DPDK driver and sent to the password card through the DPDK driver write data channel.

[0058] Further, such as Figure 4 As shown on the right side of the figure, the method executed by the application side may also include:

[0059] Step 50: The receiving interface program of the background service program keeps polling and receiving. When there is data, the data packet processed by the password card password algorithm is obtained from the mbuf corresponding to the DPDK driver;

[0060] In this step, the data packet is obtained from the DPDK driver read data channel and stored in the mbuf corresponding to the DPDK driver.

[0061] Step 51: Parse the data packet according to the message format, and forward the data packet to the corresponding application (process) through the inter-process message queue according to the sequence number of the proc_seq field of the data packet.

[0062] In this way, bidirectional data transmission from the host computer application to the PCIe cryptographic card FPGA logic program is completed via the DPDK driver, allowing multiple application processes to simultaneously access different cryptographic algorithm modules of the PCIe cryptographic card to complete functional requirements such as data encryption, decryption, signing and verification.

[0063] In summary, the method for realizing multi-process concurrency based on PCIe XDMA of the present invention is designed from three parts: bottom FPGA hardware logic, driver and host computer application program on the basis of existing PCIe 2.0 XDMA, and multiple different cryptographic algorithm modules are designed through FPGA hardware programming, and the cryptographic algorithm scheduling module adopts pipeline design, and multiple cryptographic algorithm modules run in parallel, so as to realize data distribution and cryptographic operation in data packets; the driver realizes XDMA IP core DPDK on the basis of FPGA logic program, and provides support for multiple write channels in logic; the application realizes multi-channel support in the entire read-write logic based on the driver implementation, and ensures that multiple application processes can concurrently access the PCIe cryptographic card; the three parts cooperate with each other, and in the absence of multiple DMA channels, not only meet the demand of multi-process concurrency, but also make full use of the speed advantage of FPGA hardware in realizing cryptographic operation, and improve the cryptographic operation speed of the system.

[0064] 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 method for realizing multi-process concurrency based on PCIe XDMA, used in a password card system, characterized in that: The password card system includes a host and a password card connected to the host, the host is installed with a DPDK, and the password card is provided with an FPGA using XDMA, wherein the FPGA includes an H2C DMA transmission channel, a data packet parsing module, a password algorithm scheduling module, a password algorithm module, a data packet integration module and a C2H DMA transmission channel connected in sequence, and the password algorithm modules are multiple and run in parallel; The XDMA indicates the official PCIE advanced IP in the Xilinx series FPGA; the DMA indicates direct memory access; the H2C indicates host to board; the C2H indicates board to host; The method for executing the logic program on the FPGA includes: Step 10: After the H2C DMA transmission channel receives the data packet sent by the application on the host through the DPDK driver, the data packet parsing module parses and filters the data packet; wherein, the data packet is divided into two parts: a packet header and data. The two fields proc_seq and enc_seq are defined in the packet header, which represent the serial number of the application process and the serial number of the cryptographic algorithm module to be called, respectively; The method performed by the DPDK driver includes: Step 20: The DPDK driver on the sending end adds a lock at the beginning of the sending function. When the sending of one channel enters the critical section, the other channels will wait at the entrance until the previous sending ends and exits the critical section and releases the lock, and then the data of the next channel will continue to be sent; at the same time, the DPDK driver has a corresponding DMA descriptor, and the data storage unit is the buffer mbuf, which associates each mbuf with the DMA descriptor; Step 11: The data packets that meet the format requirements are sent to the cryptographic algorithm scheduling module. The cryptographic algorithm scheduling module distributes the data in the data packets to the corresponding cryptographic algorithm modules according to the sequence number of the enc_seq field in the data packet. Each cryptographic algorithm module is pre-assigned a unique sequence number, corresponding to the enc_seq field in the data packet message. Step 12: The cryptographic algorithm module operates on the data packet; Step 13: After the data packet is processed by the cryptographic algorithm module, the proc_seq field and enc_seq field in the message remain unchanged. After being processed by the data packet integration module, it is sent to the host computer software through the C2H DMA transmission channel and the DPDK driver.

2. The method according to claim 1, characterized in that In step 10, data packets that do not meet the message format requirements are discarded.

3. The method according to claim 1, characterized in that: In step 13, the host computer software passes the data packet to the corresponding application according to the proc_seq field.

4. The method according to claim 1, characterized in that The step 20 comprises: Step 201: When the host wants to send data to the cryptographic card, the DPDK driver receives the address of the buffer area mbuf passed by the application, where the mbuf is filled with the data to be sent by the application; Step 202: The DPDK driver obtains the DMA descriptor ring and determines the current starting position, obtains the physical address of the current mbuf, fills it into the source address src field of the current DMA descriptor, obtains the address of the next DMA descriptor and fills it into the next descriptor address next field of the current DMA descriptor, and completes the association between the mbuf and the DMA descriptor in sequence; The DMA descriptor ring refers to a ring composed of all DMA descriptors, and each member on the ring corresponds to an mbuf; Step 203: After all mbufs are associated with DMA descriptors, set the next field of the last DMA descriptor to be empty; Step 204: Start DMA transfer.

5. The method according to claim 1, characterized in that The method executed by the DPDK driver further includes: Step 30: When the host wants to receive data from the cryptographic card, the DPDK driver obtains the receive DMA descriptor ring and determines the starting position of this time; Step 31: Check whether the count in the descriptor register is updated. When a count change is detected, calculate the difference between the current count and the previous count to determine the number of packets to be received; Step 32: Receive a corresponding number of mbufs starting from the last end position of the DMA descriptor ring according to the number of packets; Step 33: Return the address of the corresponding mbuf to the receiving pointer of the application.

6. The method according to any one of claims 1 to 5, characterized in that: The application side is provided with a software development tool library SDK and a background service program, and the method executed by the application side includes: Step 40: The application calls the SDK and connects to the background service program; Step 41: The sending-end interface program of the background service program allocates a unique ID as the process sequence number according to the request of the application program, and writes it into the proc_seq field of the message. The sequence number of the cryptographic algorithm module to be called is written into the enc_seq field of the message, and the remaining fields are filled in according to the message format; Step 42: After the data to be sent is converted into a data packet in the format agreed upon by the password card, it is transferred to the mbuf corresponding to the DPDK driver and sent to the password card through the DPDK driver write data channel.

7. The method according to claim 6, characterized in that The method executed by the application side also includes: Step 50: The receiving interface program of the background service program keeps polling and receiving. When there is data, the data packet processed by the password card password algorithm is obtained from the mbuf corresponding to the DPDK driver; Step 51: Parse the data packet according to the message format, and forward the data packet to the corresponding application through the inter-process message queue according to the sequence number of the proc_seq field of the data packet.