A method and device for dynamically constructing DMA descriptors and transmitting data, and a medium

By dynamically constructing DMA descriptors using giant pages during DMA data transfer and adjusting the granularity of data fragments in conjunction with the DMA circular queue state, the problem of insufficient descriptor resources is solved, and efficient DMA data transfer is achieved.

CN123145263APending Publication Date: 2026-11-20QUEENTEST
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611490538.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-23
Publication Date
2026-11-20

AI Technical Summary

Technical Problem

Existing DMA data transfer schemes often result in a number of descriptors exceeding the remaining available number in the DMA circular queue when dealing with multiple address regions or limited descriptor resources, making it difficult to balance descriptor resource utilization and transmission performance.

Method used

A giant page is used to dynamically construct DMA descriptors. Combined with the number of remaining available descriptors in the DMA circular queue, the granularity of data segments is dynamically adjusted to generate DMA descriptors and form a circular connection. Continuous data transfer is achieved through the FPGA-side cyclic transfer control state machine.

Benefits of technology

It improves the continuity and resource utilization efficiency of the DMA transfer process, reduces the queue resource shortage caused by an excessive number of descriptors, and balances the requirements of descriptor resource occupation, data transfer bandwidth and time latency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123145263A_ABST
    Figure CN123145263A_ABST
Patent Text Reader

Abstract

The application discloses a DMA descriptor dynamic construction and data transmission method, device and medium, comprising the following steps: constructing a DMA target buffer, establishing a mapping relationship, and initializing a DMA ring queue; acquiring transmission parameters of to-be-transmitted data and a queue state of the DMA ring queue; determining a target address range, dividing to generate address division information; determining an initial descriptor granularity, dividing a continuous address area in a page to generate an initial data segment; performing in-page splitting in combination with a bandwidth target and a time delay target to generate a target data segment; generating a DMA descriptor and writing the DMA descriptor into a queue, setting a next descriptor pointer and forming a ring connection; and updating the queue state by a FPGA side cyclic transmission control state machine, carrying data and cyclically reading DMA descriptors to execute cyclic transmission. The application utilizes a giant page to dynamically construct a DMA descriptor, realizes efficient cyclic transmission, and has the advantages of low occupation, high bandwidth and low time delay.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of dynamic descriptor construction and data transmission technology, and in particular to a method, apparatus and medium for dynamic construction and data transmission of DMA descriptors. Background Technology

[0002] Existing DMA data transfer typically involves establishing a target buffer in the host memory, dividing the data to be transferred into multiple data segments according to fixed page boundaries or fixed transfer granularity, generating DMA descriptors for each data segment and writing them into a descriptor queue, and then having the DMA engine read the descriptors sequentially to complete the data transfer. In some high-performance scenarios, a circular descriptor queue and FPGA control logic are also used to achieve continuous transfer.

[0003] However, existing solutions mostly use fixed descriptor granularity, which is easily affected by the 4KB page boundary and generates a large number of descriptors. When the data to be transmitted spans multiple address regions or descriptor resources are limited, the number of descriptors can easily exceed the remaining available number of DMA ring queues. At the same time, existing technologies usually only reduce descriptor occupation by expanding data segments, which makes it difficult to dynamically adjust the data segment granularity in combination with the current queue state, the physical continuity within the giant page, and bandwidth and latency targets. This makes it difficult to balance descriptor resource utilization and transmission performance. Summary of the Invention

[0004] One objective of this invention is to provide a method, apparatus, and medium for dynamic construction of DMA descriptors and data transmission. This invention utilizes giant pages to dynamically construct DMA descriptors, achieving efficient cyclic transmission and possessing the advantages of low resource consumption, high bandwidth, and low latency.

[0005] A method for dynamically constructing a DMA descriptor and transmitting data according to an embodiment of the present invention includes the following steps:

[0006] Allocate massive pages in host memory, construct DMA target buffers, establish a mapping relationship between virtual addresses and physical addresses, and initialize a DMA circular queue, with contiguous physical addresses within each massive page;

[0007] Obtain the transmission parameters of the data to be transmitted and the queue status of the DMA ring queue, wherein the queue status includes the number of remaining available descriptors and the queue's empty / full status;

[0008] The target address range is determined based on the transmission parameters, and then divided according to the giant page boundary to generate address division information including alignment relationships and continuous address regions within the page.

[0009] The initial descriptor granularity is determined based on address partitioning information, and continuous address regions within a page are divided to generate initial data fragments.

[0010] Compare the number of initial data fragments with the number of remaining available descriptors. If the number is within the limit, the initial data fragment is identified as the target data fragment. If the number exceeds the limit, merge the initial data fragments that are consecutive within the same giant page and perform intra-page splitting based on the bandwidth target and the time delay target to generate the target data fragment.

[0011] DMA descriptors are generated based on the mapping relationship and the target data fragments, written to the DMA circular queue in the transfer order, and the next descriptor pointer is set to form a circular connection.

[0012] The FPGA-side cyclic transfer control state machine updates the queue state, controls the DMA engine to move data to the DMA target buffer according to the DMA descriptor, and reads the DMA descriptor cyclically along the next descriptor pointer, wrapping around to the head of the queue to perform cyclic transfer.

[0013] Optionally, constructing the DMA target buffer includes:

[0014] Multiple massive pages are allocated in the host memory, making the physical addresses within each massive page contiguous, and the memory spaces corresponding to each massive page are combined to form a DMA target buffer.

[0015] Obtain the virtual address range and physical address range corresponding to each giant page in the DMA target buffer, and establish the mapping relationship between the virtual address and physical address of the DMA target buffer according to the correspondence between the two.

[0016] Create a DMA circular queue, determine the total number of descriptors in the DMA circular queue, and initialize the head position, tail position, and the number of currently occupied descriptors.

[0017] Optionally, obtaining the queue status includes:

[0018] Obtain the transmission request corresponding to the data to be transmitted, determine the target start address, transmission length, jumbo page size, bandwidth target, and time delay target from the transmission request, and generate transmission parameters;

[0019] Read the total number of descriptors in the DMA circular queue and the number of currently occupied descriptors, and determine the number of remaining available descriptors based on the difference between the total number of descriptors and the number of currently occupied descriptors;

[0020] The queue status is determined based on the number of currently occupied descriptors and the total number of descriptors. The remaining available descriptors and the queue status are combined to form the queue status.

[0021] Optionally, the generation of the address partitioning information includes:

[0022] Obtain the target start address, transmission length, and jumbo page size from the transmission parameters. Offset the target start address along the address increment direction by the transmission length to determine the target end address, forming a target address range that includes the target start address but does not include the target end address.

[0023] The starting and ending addresses of the target are obtained by taking the remainder of the giant page size. The offsets within the starting and ending pages are then determined. Addresses with zero offsets within the page are identified as aligned, and addresses with non-zero offsets within the page are identified as unaligned, thus establishing the alignment relationship between the target address range and the giant page boundary.

[0024] Subtract the offset within the starting page from the target starting address and add the jumbo page size to determine the first jumbo page boundary. Gradually increase the jumbo page size along the address increment direction. Divide the target address range with a jumbo page boundary smaller than the target ending address to generate a continuous address region within the page. When no division is needed, the target address range is determined as a continuous address region within the page.

[0025] Collect consecutive address regions within a page in ascending order of address, associate these consecutive address regions with alignment relationships, and generate address partitioning information.

[0026] Optionally, the generation of the initial data fragment includes:

[0027] Read the alignment relationship and continuous address regions within a page from the address partitioning information, and determine the start address, end address, and address length of each continuous address region within a page.

[0028] Based on the alignment relationship, the initial descriptor granularity is determined for consecutive address regions within the page that are aligned at the beginning and end and those that are not aligned at the beginning and end. The granularity of each initial descriptor does not exceed the address length of the corresponding consecutive address region within the page, and the corresponding starting address is determined as the partitioning starting point.

[0029] Offset the partition starting point along the address increment direction to the initial descriptor granularity, take the smaller value between the offset address and the corresponding end address as the partition endpoint, and determine the address range that includes the partition starting point but does not include the partition endpoint as the initial data segment, without adding partition positions based on the 4KB boundary inside the giant page.

[0030] If the partition endpoint does not reach the corresponding end address, the partition endpoint is used as the new partition starting point, and initial data fragments are generated at the initial descriptor granularity until the partition endpoint reaches the corresponding end address. The initial data fragments are then collected in ascending order of address.

[0031] Optionally, the generation of the target data fragment includes:

[0032] Based on the queue status, the number of initial data fragments is compared with the number of remaining available descriptors. If the number of initial data fragments does not exceed the number of remaining available descriptors, the initial data fragments are determined as the target data fragments. If the number of initial data fragments exceeds the number of remaining available descriptors, the initial data fragments are arranged according to the jumbo page ownership and address order.

[0033] The address continuity of adjacent initial data segments within the same giant page is determined sequentially. Initial data segments with continuous addresses are merged, and the merged data segments are arranged in address order with the initial data segments that were not merged to generate merged data segments.

[0034] The difference between the number of remaining available descriptors and the number of merged data fragments is determined as the number of remaining available descriptors after merging.

[0035] The lower limit of the segment length corresponding to the intra-page split is determined based on the bandwidth target, the upper limit of the segment length corresponding to the intra-page split is determined based on the latency target, and the target split length is determined by combining the lower limit and the upper limit of the segment length.

[0036] The merged data fragment is split within a page according to the target split length, and the number of descriptors added by the split within the page is accumulated. The splitting stops when continuing to split within the page would cause the number of descriptors added by the split within the page to exceed the number of remaining available descriptors after merging. The split merged data fragment is then combined with the unsplit merged data fragment to generate the target data fragment.

[0037] Optionally, the generation of the DMA descriptor includes:

[0038] According to the transmission order of the target data segments, the target physical starting address corresponding to each target data segment is determined based on the mapping relationship, and the transmission length is determined according to the data length covered by each target data segment;

[0039] For each target data segment, a corresponding DMA descriptor is established. The target physical start address and transmission length corresponding to each target data segment are written into the corresponding DMA descriptor, and the DMA descriptors are arranged according to the transmission order of the target data segments.

[0040] Write each DMA descriptor into the DMA circular queue in the order of their arrangement, and record the descriptor write address corresponding to each DMA descriptor.

[0041] According to the order of the DMA descriptors, the next descriptor pointer of each DMA descriptor is set to the descriptor write address of the next DMA descriptor, and the next descriptor pointer of the last DMA descriptor is set to the descriptor write address of the first DMA descriptor, thus completing the circular connection of the DMA descriptors.

[0042] Optionally, the cyclic transmission includes:

[0043] The FPGA-side cyclic transfer control state machine determines the position corresponding to the DMA descriptor at the head of the DMA circular queue as the current execution position and obtains the queue status.

[0044] Based on queue state control, the DMA engine reads the DMA descriptor corresponding to the current execution position, obtains the target physical start address, transfer length and the next descriptor pointer, and moves data to the DMA target buffer according to the target physical start address and transfer length.

[0045] After the data transfer corresponding to the current DMA descriptor is completed, the FPGA-side cyclic transfer control state machine updates the queue state and determines the position of the next DMA descriptor by following the next descriptor pointer;

[0046] Update the position corresponding to the next DMA descriptor to the current execution position; when the DMA descriptor that has completed data transfer is the tail DMA descriptor, update the position corresponding to the head DMA descriptor pointed to by the next descriptor pointer to the current execution position, and continue to control the DMA engine to read DMA descriptors and perform data transfer based on the updated queue state and the current execution position.

[0047] A DMA descriptor dynamic construction and data transmission apparatus according to an embodiment of the present invention includes:

[0048] The buffer construction module is used to allocate jumbo pages in host memory, construct DMA target buffers, establish mapping relationships, and initialize DMA circular queues.

[0049] The parameter acquisition module is used to acquire the transmission parameters of the data to be transmitted and the queue status of the DMA ring queue.

[0050] The address partitioning module is used to generate address partitioning information based on transmission parameters and giant page boundaries;

[0051] The initial fragmentation module is used to determine the initial descriptor granularity based on address partitioning information and generate initial data fragments;

[0052] The target data fragmentation module is used to merge and split the initial data fragments within a page based on the queue status, bandwidth target, and time delay target to generate target data fragments.

[0053] The descriptor construction module is used to generate DMA descriptors based on mapping relationships and target data fragments, and write the DMA descriptors into the DMA circular queue to form a circular connection;

[0054] The loop transfer module is used to control the DMA engine to read DMA descriptors and move data to the DMA target buffer based on the queue state, and to perform loop transfers along the next descriptor pointer.

[0055] According to an embodiment of the present invention, a computer-readable storage medium stores a computer program that, when executed by a processor, enables the processor to perform a DMA descriptor dynamic construction and data transfer method.

[0056] The beneficial effects of this invention are:

[0057] This invention allocates massive pages in host memory and constructs a DMA target buffer. It utilizes the contiguous physical address characteristics within massive pages to establish a mapping relationship between virtual and physical addresses. This allows the data to be transmitted to form a contiguous address region within the page according to the massive page boundary. Furthermore, when generating initial data fragments, the 4KB boundary within the massive page is no longer used as an additional partitioning position. This reduces excessive data fragment dispersion caused by the basic page boundary, lowers the number of initial DMA descriptors, and provides a continuous address basis for the dynamic construction of subsequent DMA descriptors.

[0058] This invention further combines the remaining available descriptors of the DMA circular queue to dynamically process the initial data fragments. When descriptor resources are sufficient, the initial data fragments remain unchanged. When descriptor resources are insufficient, initial data fragments with consecutive addresses within the same giant page are merged to reduce the corresponding descriptor requirement. The descriptor resources released after merging are then used to continue page splitting, so that the number of descriptors can be adapted to the current available resources of the DMA circular queue, avoiding the queue resource shortage caused by too many descriptors when using a fixed descriptor granularity.

[0059] Meanwhile, this invention introduces bandwidth and latency targets into the intra-page splitting process. The lower limit of the fragment length is determined by the bandwidth target, and the upper limit of the fragment length is determined by the latency target. The actual intra-page splitting result is determined within the range of the number of remaining available descriptors after merging. This allows the transmission granularity of the target data fragment to take into account descriptor resource occupation, data transport bandwidth and latency requirements, thereby reducing the latency increase caused by simply expanding the data fragment and the descriptor overhead caused by excessive subdivision.

[0060] Furthermore, this invention dynamically generates DMA descriptors according to the transmission order of the target data segments, and constructs a closed-loop DMA circular queue through the next descriptor pointer. The FPGA-side cyclic transmission control state machine controls the DMA engine to continuously read DMA descriptors according to the queue state. After completing the data transfer corresponding to the current DMA descriptor, it automatically switches to the next DMA descriptor along the next descriptor pointer and automatically wraps back to the head of the queue at the tail, thereby realizing continuous cyclic transfer of DMA data, reducing the overhead of repeated descriptor construction and control during the cyclic transmission process, and improving the continuity and resource utilization efficiency of the DMA transmission process. Attached Figure Description

[0061] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings:

[0062] Figure 1 This is an overall flowchart of a DMA descriptor dynamic construction and data transfer method proposed in this invention;

[0063] Figure 2 This diagram illustrates the dynamic adjustment process of the DMA descriptor in the dynamic construction and data transfer method for DMA descriptors proposed in this invention. Detailed Implementation

[0064] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, illustrating only the basic structure of the invention, and therefore only show the components relevant to the invention.

[0065] refer to Figures 1-2 A method for dynamically constructing DMA descriptors and transferring data includes the following steps:

[0066] Allocate massive pages in host memory, construct DMA target buffers, establish the mapping relationship between the virtual address and physical address of the DMA target buffers, and initialize the DMA circular queue, with the physical addresses within each massive page being contiguous.

[0067] Obtain the transmission parameters of the data to be transmitted and the queue status of the DMA ring queue. The transmission parameters include the target start address, transmission length, jumbo page size, bandwidth target, and time delay target. The queue status includes the number of remaining available descriptors and the queue's empty / full status.

[0068] Based on the transmission parameters, the target address range corresponding to the data to be transmitted is determined. The target address range is then divided in conjunction with the giant page boundary to generate address division information. The address division information includes the alignment relationship between the target address range and the giant page boundary, as well as the continuous address regions within the page obtained from the division.

[0069] The initial descriptor granularity is determined based on the address partitioning information. The continuous address regions within the page are divided according to the initial descriptor granularity to generate initial data fragments. Each initial data fragment does not cross the giant page boundary, but is allowed to cross the 4KB boundary inside the giant page.

[0070] Based on the queue status, the number of initial data segments is compared with the number of remaining available descriptors. If the number of initial data segments does not exceed the number of remaining available descriptors, the initial data segment is determined as the target data segment. If the number of initial data segments exceeds the number of remaining available descriptors, the initial data segments with consecutive addresses within the same giant page are merged, and the bandwidth target and delay target in the transmission parameters are combined to perform intra-page splitting. The number of descriptors added by intra-page splitting does not exceed the number of remaining available descriptors after merging, and the target data segment is generated.

[0071] DMA descriptors are generated based on the mapping relationship and target data segments. The DMA descriptors are written into the DMA circular queue according to the transmission order of the target data segments. The next descriptor pointer between adjacent DMA descriptors is set, and the next descriptor pointer of the tail DMA descriptor is pointed to the head DMA descriptor. The DMA descriptor includes the target physical start address, transmission length and next descriptor pointer.

[0072] The FPGA-side cyclic transfer control state machine updates the queue state, and the DMA engine reads the DMA descriptor based on the queue state. Data is moved to the DMA target buffer according to the target physical start address and transfer length in the DMA descriptor. After each DMA descriptor data transfer is completed, the next DMA descriptor is read along the next descriptor pointer, and the cyclic transfer is automatically wrapped around to the head of the queue at the tail of the queue.

[0073] In this embodiment, constructing the DMA target buffer includes:

[0074] Multiple massive pages are allocated in the host memory, making the physical addresses within each massive page contiguous, and the memory spaces corresponding to each massive page are combined to form a DMA target buffer.

[0075] Obtain the virtual address range and physical address range corresponding to each giant page in the DMA target buffer, and establish the mapping relationship between the virtual address and physical address of the DMA target buffer according to the correspondence between the two.

[0076] Create a DMA circular queue, determine the total number of descriptors in the DMA circular queue, and initialize the head position, tail position, and the number of currently occupied descriptors.

[0077] In this embodiment, obtaining the queue status includes:

[0078] Obtain the transmission request corresponding to the data to be transmitted, determine the target start address, transmission length, jumbo page size, bandwidth target, and time delay target from the transmission request, and generate transmission parameters;

[0079] Read the total number of descriptors in the DMA circular queue and the number of currently occupied descriptors, and determine the number of remaining available descriptors based on the difference between the total number of descriptors and the number of currently occupied descriptors;

[0080] The queue status is determined based on the number of currently occupied descriptors and the total number of descriptors. The remaining available descriptors and the queue status are combined to form the queue status.

[0081] In this embodiment, the generation of address partitioning information includes:

[0082] Obtain the target start address, transmission length, and jumbo page size from the transmission parameters. Offset the target start address along the address increment direction by the transmission length to determine the target end address, forming a target address range that includes the target start address but does not include the target end address.

[0083] Specifically, the target start address corresponds to the starting position of the data to be written in the virtual address space of the DMA target buffer. The target start address is added to the continuous address offset corresponding to the transmission length to obtain the target end address. The target address range is formed by using a left-closed and right-open address representation method, so that the address length covered by the target address range is consistent with the transmission length.

[0084] The starting and ending addresses of the target are obtained by taking the remainder of the giant page size. The offsets within the starting and ending pages are then determined. Addresses with zero offsets within the page are identified as aligned, and addresses with non-zero offsets within the page are identified as unaligned, thus establishing the alignment relationship between the target address range and the giant page boundary.

[0085] Specifically, the starting address and ending address of the target are moduloed by the size of the giant page to obtain the offset within the starting page and the offset within the ending page. The two offsets within the page represent the positions of the two ends of the target address range relative to the boundary of the giant page. A zero offset within the page corresponds to the position of the giant page boundary, and a non-zero offset within the page corresponds to the position inside the giant page. Based on this, the alignment relationship between the target address range and the boundary of the giant page is formed.

[0086] Subtract the offset within the starting page from the target starting address and add the jumbo page size to determine the first jumbo page boundary. Gradually increase the jumbo page size along the address increment direction. Divide the target address range with a jumbo page boundary smaller than the target ending address to generate a continuous address region within the page. When no division is needed, the target address range is determined as a continuous address region within the page.

[0087] Specifically, the starting address is subtracted from the offset within the starting page to obtain the starting boundary of the giant page to which the target starting address belongs. The giant page size is then added sequentially on this starting boundary to obtain the giant page boundary located within the target address range. The target address range is then divided along the address increment direction using the obtained giant page boundary, so that the address range obtained by each division is limited to the inside of a single giant page, forming a continuous address region within the page.

[0088] Collect consecutive address regions within a page in ascending order of address, associate these consecutive address regions with alignment relationships, and generate address partitioning information.

[0089] In this embodiment, the generation of the initial data fragment includes:

[0090] Read the alignment relationship and continuous address regions within a page from the address partitioning information, and determine the start address, end address, and address length of each continuous address region within a page.

[0091] Based on the alignment relationship, the initial descriptor granularity is determined for consecutive address regions within the page that are aligned at the beginning and end and those that are not aligned at the beginning and end. The granularity of each initial descriptor does not exceed the address length of the corresponding consecutive address region within the page, and the corresponding starting address is determined as the partitioning starting point.

[0092] Specifically, the maximum transfer length allowed to be carried by a single DMA descriptor of the DMA engine is obtained, and the address length of each contiguous address region within a page is read. For contiguous address regions within a page whose beginning and end are aligned with the giant page boundary, the smaller value between the maximum transfer length and the corresponding address length is determined as the initial descriptor granularity. For contiguous address regions within a page whose starting or ending address is not aligned with the giant page boundary, the smaller value between the actual address length of the contiguous address region within the page and the maximum transfer length is determined as the initial descriptor granularity, so that the initial descriptor granularity does not exceed the address length of the corresponding contiguous address region within the page.

[0093] Offset the partition starting point along the address increment direction to the initial descriptor granularity, take the smaller value between the offset address and the corresponding end address as the partition endpoint, and determine the address range that includes the partition starting point but does not include the partition endpoint as the initial data segment, without adding partition positions based on the 4KB boundary inside the giant page.

[0094] Specifically, the starting address of the contiguous address region within the page is used as the partitioning starting point. An initial descriptor granularity is added to the partitioning starting point to obtain the offset address. The smaller address between the offset address and the ending address of the contiguous address region within the page is determined as the partitioning ending point. The contiguous address range between the partitioning starting point and the partitioning ending point is determined as the initial data segment. During the partitioning process, only the initial descriptor granularity and the ending address of the contiguous address region within the page are used to determine the partitioning position. The 4KB boundary inside the giant page is not used as an additional partitioning position.

[0095] If the partition endpoint does not reach the corresponding end address, the partition endpoint is used as the new partition starting point, and the initial data fragments are generated according to the initial descriptor granularity until the partition endpoint reaches the corresponding end address. The initial data fragments are then collected in ascending order of address.

[0096] Specifically, the endpoint of the initial data segment that has already been formed is used as the starting point of the next segmentation. The granularity of the initial descriptor continues to increase along the address increment direction, and the end segmentation position is restricted by the end address of the continuous address region within the page. Adjacent and address-continuous initial data segments are continuously formed until the corresponding continuous address region within the page is completely covered. Then, they are aggregated according to the incrementing order of the starting address of each initial data segment.

[0097] In this embodiment, the generation of the target data fragment includes:

[0098] Based on the queue status, the number of initial data fragments is compared with the number of remaining available descriptors. If the number of initial data fragments does not exceed the number of remaining available descriptors, the initial data fragments are determined as the target data fragments. If the number of initial data fragments exceeds the number of remaining available descriptors, the initial data fragments are arranged according to the jumbo page ownership and address order.

[0099] Specifically, the initial data fragments whose number does not exceed the number of remaining available descriptors maintain their original address range and transmission order and are directly used as target data fragments. The initial data fragments whose number exceeds the number of remaining available descriptors are grouped according to the jumbo page affiliation and arranged in ascending order of starting address within each jumbo page for subsequent address continuity identification and merging processing.

[0100] The address continuity of adjacent initial data segments within the same giant page is determined sequentially. Initial data segments with continuous addresses are merged, and the merged data segments are arranged in address order with the initial data segments that were not merged to generate merged data segments.

[0101] Specifically, the preceding end address and the following start address of adjacent initial data segments within the same giant page are read sequentially, and the address interval between them is calculated. Consecutive initial data segments with an address interval of zero are grouped into the same merging range. The start address of the first initial data segment in the merging range is used as the merging start address, and the end address of the last initial data segment is used as the merging end address to form a merged data segment. Initial data segments that do not participate in the continuous merging are included in the merged data segment while maintaining their original address range.

[0102] The difference between the number of remaining available descriptors and the number of merged data fragments is determined as the number of remaining available descriptors after merging.

[0103] Specifically, during the DMA ring queue initialization phase, the total number of descriptors is determined according to the system's maximum allowed number of currently occupied descriptors and the maximum number of data to be transferred in a single batch that spans a massive page. This ensures that the number of currently available descriptors can accommodate the merged data segments formed after merging the initial data segments with consecutive addresses within the same massive page. The number of merged data segments is counted, and the number of descriptors required is determined according to the rule that one merged data segment corresponds to one DMA descriptor. The non-negative value obtained by subtracting the number of descriptors required from the number of available descriptors is determined as the number of available descriptors after merging.

[0104] The lower limit of the segment length corresponding to the intra-page split is determined based on the bandwidth target, the upper limit of the segment length corresponding to the intra-page split is determined based on the latency target, and the target split length is determined by combining the lower limit and the upper limit of the segment length.

[0105] Specifically, DMA data transfer is performed using multiple different transmission lengths, and the corresponding total transfer time is recorded. The data length difference between any two transmission lengths is divided by the corresponding total transfer time difference to obtain the transfer bandwidth. The average of multiple calculation results is used to obtain the stable transfer bandwidth. Each transmission length is then divided by the stable transfer bandwidth to obtain the corresponding data transfer time. The total transfer time is subtracted from the data transfer time, and the difference is averaged to obtain the fixed processing time. The product of the bandwidth target and the fixed processing time is divided by one minus the ratio of the bandwidth target to the stable transfer bandwidth and aligned upwards to obtain the lower limit of the segment length. The time obtained by subtracting the fixed processing time from the latency target is multiplied by the stable transfer bandwidth and aligned downwards to obtain the upper limit of the segment length. The upper limit of the segment length is determined as the target split length. The bandwidth target is less than the stable transfer bandwidth, and the upper limit of the resulting segment length is not less than the lower limit of the segment length.

[0106] The merged data fragment is split within a page according to the target split length, and the number of descriptors added by the split within the page is accumulated. The splitting stops when continuing to split within the page would cause the number of descriptors added by the split within the page to exceed the number of remaining available descriptors after the merge. The split merged data fragment is combined with the unsplit merged data fragment to generate the target data fragment.

[0107] Specifically, the address length of each merged data segment is divided by the target split length and rounded up to obtain the number of data segments corresponding to the complete split of each merged data segment. Then, the number of corresponding data segments is reduced by one to obtain the number of descriptors added. The number of descriptors added is accumulated sequentially according to the address order of the merged data segments. It is determined that the cumulative number of descriptors added does not exceed the maximum range of the largest consecutive merged data segments covered by the number of remaining available descriptors after merging. The merged data segments within this range are split into pages according to the target split length. The remaining merged data segments keep their original address range unchanged. The two are then combined according to the address order to form the target data segment.

[0108] In this embodiment, the generation of the DMA descriptor includes:

[0109] According to the transmission order of the target data segments, the target physical starting address corresponding to each target data segment is determined based on the mapping relationship, and the transmission length is determined according to the data length covered by each target data segment;

[0110] Specifically, the virtual address start point and physical address start point corresponding to the giant page to which the starting address of the target data segment belongs are read from the mapping relationship. The virtual address start point is subtracted from the starting address of the target data segment to obtain the page address offset. The page address offset is then added to the physical address start point to obtain the target physical starting address. At the same time, the corresponding transmission length is determined by the address difference between the ending address and the starting address of the target data segment.

[0111] For each target data segment, a corresponding DMA descriptor is established. The target physical start address and transmission length corresponding to each target data segment are written into the corresponding DMA descriptor, and the DMA descriptors are arranged according to the transmission order of the target data segments.

[0112] Specifically, a DMA descriptor is created for each target data segment, the corresponding target physical start address is written into the target physical start address field, the corresponding transmission length is written into the transmission length field, and the DMA descriptors are arranged according to the transmission order of the target data segments, so that the arrangement order is consistent for subsequent DMA descriptor writing and the next descriptor pointer setting.

[0113] Write each DMA descriptor into the DMA circular queue in the order of their arrangement, and record the descriptor write address corresponding to each DMA descriptor.

[0114] Specifically, the starting address of the DMA circular queue, the length occupied by a single DMA descriptor, the head position, and the current tail position are read. The first writable position is determined by the current tail position. The DMA descriptors are written to the remaining available positions in sequence according to the length occupied by a single DMA descriptor. The descriptor write address corresponding to each DMA descriptor is recorded. The first DMA descriptor is appended to the tail DMA descriptor before writing. The position corresponding to the last DMA descriptor is updated to the tail position. If there are no occupied DMA descriptors in the DMA circular queue before writing, the position corresponding to the first DMA descriptor is synchronously determined as the head position.

[0115] According to the order of the DMA descriptors, the next descriptor pointer of each DMA descriptor is set to the descriptor write address of the next DMA descriptor, and the next descriptor pointer of the last DMA descriptor is set to the descriptor write address of the first DMA descriptor, thus completing the circular connection of the DMA descriptors.

[0116] Specifically, according to the order of DMA descriptors in the DMA circular queue, the next descriptor pointer of the tail DMA descriptor before writing is set to the descriptor write address of the first DMA descriptor in this operation, and the next descriptor pointer of the preceding DMA descriptor in each adjacent DMA descriptor in this operation is set to the descriptor write address of the following DMA descriptor. Then, the next descriptor pointer of the updated tail DMA descriptor is set to the descriptor write address of the head DMA descriptor, so that all valid DMA descriptors in the DMA circular queue form a single closed-loop connection.

[0117] In this embodiment, cyclic transmission includes:

[0118] The FPGA-side cyclic transfer control state machine determines the position corresponding to the DMA descriptor at the head of the DMA circular queue as the current execution position and obtains the queue status.

[0119] Specifically, the FPGA-side loop transfer control state machine reads the head position of the DMA ring queue, determines the position corresponding to the head DMA descriptor as the current execution position, and reads the number of currently occupied descriptors before the DMA descriptor is written and the number of DMA descriptors written to the DMA ring queue this time. The two are added together to obtain the number of currently occupied descriptors after the DMA descriptor is written. The remaining available descriptors are obtained by subtracting the number of currently occupied descriptors after the DMA descriptor is written from the total number of descriptors. Then, the queue empty / full state is determined based on the number of currently occupied descriptors after the DMA descriptor is written and the total number of descriptors. The remaining available descriptors and the queue empty / full state are combined to form the queue state.

[0120] Based on queue state control, the DMA engine reads the DMA descriptor corresponding to the current execution position, obtains the target physical start address, transfer length and the next descriptor pointer, and moves data to the DMA target buffer according to the target physical start address and transfer length.

[0121] Specifically, the data to be transferred is sent to the data input terminal of the DMA engine according to the transmission order of the target data segments. The DMA engine reads the target physical start address, transmission length and next descriptor pointer in the corresponding DMA descriptor according to the current execution position. The write start position in the DMA target buffer is determined by the target physical start address. The amount of data corresponding to the transmission length is obtained from the data to be transferred and continuously written to the DMA target buffer. After the corresponding amount of data is transferred, the data transfer completion signal corresponding to the current DMA descriptor is output.

[0122] After the data transfer corresponding to the current DMA descriptor is completed, the FPGA-side cyclic transfer control state machine updates the queue state and determines the position of the next DMA descriptor by following the next descriptor pointer;

[0123] Specifically, after the FPGA-side loop transfer control state machine receives the data transfer completion signal corresponding to the current DMA descriptor, it maintains the current occupancy status of the DMA descriptor and the ring connection relationship between the DMA descriptors unchanged, and reads the current total number of descriptors and the number of currently occupied descriptors in the DMA ring queue. Based on this, it re-determines the remaining available descriptors and the queue empty / full status and forms an updated queue status. At the same time, it reads the next descriptor pointer in the current DMA descriptor, and determines the descriptor write address recorded by the next descriptor pointer as the corresponding position of the next DMA descriptor.

[0124] Update the position corresponding to the next DMA descriptor to the current execution position; when the DMA descriptor that has completed data transfer is the tail DMA descriptor, update the position corresponding to the head DMA descriptor pointed to by the next descriptor pointer to the current execution position, and continue to control the DMA engine to read DMA descriptors and perform data transfer based on the updated queue state and the current execution position;

[0125] Specifically, the position corresponding to the next DMA descriptor is written to the current execution position register, and the DMA engine continues to read DMA descriptors based on the updated queue state and the current execution position. The next descriptor pointer of the tail DMA descriptor has already pointed to the head DMA descriptor, so that after the tail DMA descriptor completes the data transfer, the current execution position is directly updated to the position corresponding to the head DMA descriptor, and the DMA engine continues to execute the next round of DMA descriptor reading and data transfer.

[0126] A DMA descriptor dynamic construction and data transfer apparatus, comprising:

[0127] The buffer construction module is used to allocate jumbo pages in host memory, construct DMA target buffers, establish mapping relationships, and initialize DMA circular queues.

[0128] The parameter acquisition module is used to acquire the transmission parameters of the data to be transmitted and the queue status of the DMA ring queue.

[0129] The address partitioning module is used to generate address partitioning information based on transmission parameters and giant page boundaries;

[0130] The initial fragmentation module is used to determine the initial descriptor granularity based on address partitioning information and generate initial data fragments;

[0131] The target data fragmentation module is used to merge and split the initial data fragments within a page based on the queue status, bandwidth target, and time delay target to generate target data fragments.

[0132] The descriptor construction module is used to generate DMA descriptors based on mapping relationships and target data fragments, and write the DMA descriptors into the DMA circular queue to form a circular connection;

[0133] The loop transfer module is used to control the DMA engine to read DMA descriptors and move data to the DMA target buffer based on the queue state, and to perform loop transfers along the next descriptor pointer.

[0134] A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program that, when executed by a processor, enables the processor to perform a DMA descriptor dynamic construction and data transfer method.

[0135] Example 1: To verify the feasibility of this invention in practice, it was applied to a high-speed data acquisition and host memory DMA transfer scenario in a data center. The front-end acquisition device continuously outputs a high-speed data stream, which is written to the DMA target buffer in the host memory via the FPGA-side DMA engine. This scenario requires DMA transfer to run continuously with limited descriptor resources, while simultaneously meeting data transfer bandwidth and latency requirements. When using a fixed 4KB boundary partition, large amounts of data to be transferred will form a large number of DMA descriptors, easily exceeding the number of descriptors that the DMA circular queue can accommodate. Using larger fixed data segments will prolong the data transfer time corresponding to a single DMA descriptor. Therefore, it is necessary to coordinate the number of descriptors occupied, the transmission bandwidth, and the data transfer latency.

[0136] Multiple 2MB giant pages are allocated in the host memory, and these giant pages are used to construct a DMA target buffer. The physical addresses within each giant page are contiguous, and a mapping relationship is established between the virtual address range and the physical address range corresponding to each giant page. The DMA circular queue has 64 descriptor positions. At the start of this data transfer, the DMA circular queue is empty, with 64 remaining available descriptors. The maximum data length that a single DMA descriptor can carry is 2MB. The data length to be transferred in this instance is 64MB. The target starting address is aligned with the giant page boundary, the bandwidth target is 10GB / s, and the latency target is 100μs.

[0137] The system offsets the target starting address by 64MB along the address increment direction to obtain the target ending address. Based on the 2MB giant page boundary, it divides the target address range into 32 contiguous address regions within each page, each 2MB in length. Considering the alignment between each contiguous address region and the giant page boundary, a 512KB initial descriptor granularity is used. Dividing along the address increment direction of each contiguous address region within the page results in four 512KB initial data segments within each 2MB contiguous address region, generating a total of 128 initial data segments. Each 512KB initial data segment can continuously span multiple 4KB boundaries within the giant page without adding new data segments due to 4KB boundaries.

[0138] The initial 128 data segments exceeded the 64 remaining available descriptors in the DMA circular queue. The system grouped the initial data segments according to their ownership within a gigapage and arranged the initial data segments within the same gigapage in ascending order of their starting address. Since the addresses of the four 512KB initial data segments within each gigapage were consecutive, they were merged into a single 2MB merged data segment. After merging all 128 initial data segments, 32 merged data segments were formed. Based on the calculation that one merged data segment corresponds to one DMA descriptor, the remaining 64 available descriptors, after deducting the descriptor requirements corresponding to the 32 merged data segments, yielded 32 merged available descriptors.

[0139] DMA transfer link operation records indicate that the current stable transfer bandwidth of the DMA engine is approximately 12GB / s, and the fixed processing time for a single DMA descriptor is approximately 2μs. The system calculates the lower limit of the fragment length required to meet the bandwidth target (10GB / s) and the upper limit of the fragment length based on the 100μs latency target. After DMA data length alignment, the lower limit of the fragment length is less than 1MB, and the upper limit of the fragment length is 1MB. Therefore, 1MB is determined as the target split length. Since the target split length is less than the 2MB data length limit allowed by a single DMA descriptor of the DMA engine, it can be directly used for subsequent DMA descriptor generation.

[0140] Each 2MB merged data segment, when split into two 1MB target segments, adds one descriptor compared to the original size. When all 32 merged data segments are split intra-page, a total of 32 descriptors are added, matching the remaining 32 available descriptors after merging. Therefore, the number of descriptors added by intra-page splitting does not exceed the currently available number of descriptors. After intra-page splitting, the 64MB of data to be transferred ultimately forms 64 1MB target data segments, requiring 64 DMA descriptors, which matches the 64 remaining available descriptors in the DMA circular queue.

[0141] The system reads the mapping relationship between virtual and physical addresses according to the transmission order of 64 target data segments. Based on the offset of the starting address of each target data segment within its corresponding massive page, it determines the corresponding physical starting address and uses 1MB as the corresponding transmission length, thus forming 64 DMA descriptors. These 64 DMA descriptors are sequentially written into a DMA circular queue, with the first DMA descriptor at the head of the queue and the last DMA descriptor at the tail. Adjacent DMA descriptors are connected sequentially via a next descriptor pointer, with the next descriptor pointer of the tail DMA descriptor pointing to the head DMA descriptor, forming a complete circular connection among the 64 DMA descriptors.

[0142] The FPGA-side loop transfer control state machine determines the current execution position corresponding to the head DMA descriptor. At this time, the DMA circular queue has 64 occupied descriptors and 0 remaining available descriptors, indicating a full queue. The DMA engine reads the target physical start address, 1MB transfer length, and next descriptor pointer from the DMA descriptor according to the current execution position, and writes the data to be transferred corresponding to the current DMA descriptor into the corresponding position in the DMA target buffer. After completing the data transfer for one DMA descriptor, the FPGA-side loop transfer control state machine maintains the occupancy status and circular connection relationship of the DMA descriptors, updates the current execution position along the next descriptor pointer, continuously executes subsequent data transfers, and after completing the tail DMA descriptor, directly loops back to the head DMA descriptor to continue the loop transfer.

[0143] The operation log for 3 hours of continuous operation shows that if the 64MB of data to be transferred is fixedly divided according to 4KB boundaries, 16384 DMA descriptors are needed, which is far more than 64 descriptor positions. Using a fixed granularity of 512KB requires 128 DMA descriptors, which is also insufficient for writing to the DMA circular queue in one go. When the data is directly maintained as 32 2MB data segments, although the number of descriptors meets the queue capacity requirement, the data transfer time for a single 2MB data segment is approximately 177μs based on a stable transfer bandwidth of approximately 12GB / s and a fixed processing time of approximately 2μs, which is higher than the 100μs latency target. After adopting this invention, 64 target 1MB data segments are formed, with 64 descriptors, which can be completely written to the DMA circular queue. The data transfer time for a single 1MB target data segment is approximately 89μs, lower than the 100μs latency target, and the corresponding effective data transfer bandwidth is approximately 11.7GB / s, higher than the 10GB / s bandwidth target.

[0144] The results show that this invention first utilizes the contiguous physical address characteristics within a giant page to reduce excessive data fragmentation caused by the 4KB boundary. After the initial number of data fragments exceeds the number of remaining available descriptors, it reduces descriptor requirements by merging contiguous fragments within the same giant page. Then, it uses the remaining descriptor space formed after merging, combined with bandwidth and latency targets, to redetermine the granularity of page splitting. This allows the 64MB of data to be transmitted to be adjusted from 128 initial data fragments to 64 target data fragments. While meeting the DMA circular queue capacity, it controls the data transfer time of a single data fragment within the latency target and maintains a continuous data transfer capability higher than the bandwidth target. This verifies the feasibility of this invention for dynamic descriptor construction and cyclic data transfer under limited DMA descriptor resources.

[0145] Table 1. Comparison of resource utilization and transmission performance of different DMA descriptor construction methods

[0146] Performance indicators 4KB fixed boundary partitioning 512KB fixed granularity partitioning 2MB fixed granularity division The dynamic construction method of this invention Final data segment length 4KB 512KB 2MB 1MB Number of DMA descriptors 16,384 128 32 64 Is it possible to load a circular queue of 64 items at once? no no yes yes Descriptor fixed total processing time 32.768ms 0.256ms 0.064ms 0.128ms Single descriptor processing and transfer time Approximately 2.34 μs Approximately 45.69 μs Approximately 176.76 μs Approximately 89.38 μs 64MB theoretical link transmission time Approximately 38.36ms Approximately 5.85ms Approximately 5.66ms Approximately 5.72ms Theoretical effective data transport bandwidth Approximately 1.75GB / s Approximately 11.47 GB / s Approximately 11.86 GB / s Approximately 11.73 GB / s

[0147] As shown in Table 1, although the data volume corresponding to a single DMA descriptor is small with a fixed 4KB boundary, and the processing and transfer time per descriptor is only about 2.34μs, 64MB of data requires the generation of 16384 DMA descriptors, far exceeding the capacity of a 64-item DMA circular queue. Based on a fixed processing overhead of approximately 2μs per descriptor, the total fixed descriptor processing time reaches 32.768ms, while the pure data transfer time for 64MB of data at a stable transfer capacity of 12GB / s is approximately 5.59ms. Therefore, the main time consumption in this method has shifted from data transfer to descriptor processing. The final theoretical link transmission time reaches approximately 38.36ms, and the theoretical effective data transfer bandwidth is only about 1.75GB / s, which cannot meet the bandwidth target of 10GB / s. This demonstrates that forcibly splitting within a giant page according to a 4KB boundary will cause a sharp increase in the number of descriptors, making descriptor management overhead the main performance bottleneck for sustained high-speed DMA transfers.

[0148] After adopting a fixed 512KB granularity partitioning, the number of DMA descriptors corresponding to 64MB of data is reduced to 128, a reduction of 16256 compared to the 4KB fixed boundary partitioning. The total processing time for fixed descriptors decreases to 0.256ms, the theoretical link transmission time is shortened to approximately 5.85ms, and the theoretical effective data transfer bandwidth increases to approximately 11.47GB / s. This method meets the performance targets set in this embodiment in terms of bandwidth and single descriptor latency. However, 128 descriptors still exceed the capacity of the 64-item DMA circular queue, and not all descriptors can be loaded at once. In actual engineering operation, additional descriptors or batch processing are required, thus generating additional queue management, host interaction, and control overhead. This result shows that although the fixed 512KB granularity significantly reduces the descriptor processing burden, it does not solve the adaptation problem between the number of descriptors and the available resources of the current DMA circular queue.

[0149] When using a fixed 2MB granularity partition, 64MB of data requires only 32 DMA descriptors, which can be written to a 64-entry DMA circular queue at once. The total processing time for fixed descriptors is further reduced to 0.064ms, and the theoretical effective data transfer bandwidth reaches approximately 11.86GB / s. This approach performs well when simply pursuing the number of descriptors and transmission bandwidth, but the processing and transfer time for each 2MB data segment is approximately 176.76μs, exceeding the latency target of 100μs. This is because, while larger data segments reduce the number of DMA descriptor switches, they also prolong the time a single DMA descriptor continuously occupies the DMA engine. Therefore, simply increasing the data segment size to reduce the number of descriptors cannot simultaneously meet low latency requirements.

[0150] In this embodiment, the dynamic construction method of the present invention ultimately forms 64 1MB target data segments, corresponding to 64 DMA descriptors, which can be completely loaded into the DMA circular queue in one go. The total fixed processing time for the 64 descriptors is only 0.128ms, the theoretical link transmission time for 64MB is approximately 5.72ms, and the theoretical effective data transfer bandwidth is approximately 11.73GB / s, which is higher than the 10GB / s bandwidth target. At the same time, the processing and transfer time for a single 1MB target data segment is approximately 89.38μs, which is lower than the 100μs latency target. Compared with the 4KB fixed boundary partitioning, the number of DMA descriptors in the present invention is reduced from 16384 to 64, a reduction of approximately 99.61%, and the total fixed processing time for descriptors is also reduced from 32.768ms to 0.128ms, while the theoretical effective data transfer bandwidth is increased from approximately 1.75GB / s to approximately 11.73GB / s.

[0151] Compared to a fixed 512KB granularity partition, this invention reduces the number of DMA descriptors from 128 to 64, a 50% reduction. This transforms the situation from being unable to load 64 items into a single DMA circular queue to being able to load them all at once. Simultaneously, the theoretical effective data transfer bandwidth increases from approximately 11.47 GB / s to approximately 11.73 GB / s. Compared to a fixed 2MB granularity partition, while this invention increases the number of descriptors from 32 to 64, and slightly reduces the theoretical effective data transfer bandwidth from approximately 11.86 GB / s to approximately 11.73 GB / s, the processing and transfer time per descriptor decreases from approximately 176.76 μs to approximately 89.38 μs, a reduction of approximately 49.4%. This shifts the focus from a latency target exceeding 100 μs to meeting the latency target. Therefore, this invention does not simply pursue the minimum number of descriptors or the maximum data segment size, but rather seeks a data segment granularity that simultaneously satisfies bandwidth and latency requirements within the limited queue resources.

[0152] The performance improvement achieved by this invention lies in several key aspects. First, by leveraging the contiguous physical addressing within a giant page, excessive partitioning of data to be transmitted using 4KB boundaries is avoided, reducing unnecessary DMA descriptors at the source. Second, when the number of initial data segments exceeds the number of remaining available descriptors, contiguous initial data segments within the same giant page are merged, rapidly reducing descriptor demand and freeing up descriptor space for subsequent adjustments. Third, the page split length is determined based on current bandwidth and latency targets, limiting the number of descriptors added by the page split to no more than the number of remaining available descriptors after merging. This approach of first merging and releasing descriptor resources, then performing limited splitting based on performance targets, results in data segments that can adapt to the DMA ring queue capacity while avoiding increased single-transfer latency caused by excessively large data segments. This achieves a more reasonable engineering balance between descriptor resource usage, effective data transfer bandwidth, and single-descriptor processing latency.

[0153] The above are merely preferred embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.

Claims

1. A method for dynamically constructing DMA descriptors and transferring data, characterized in that, Includes the following steps: Allocate massive pages in host memory, construct DMA target buffers, establish a mapping relationship between virtual addresses and physical addresses, and initialize a DMA circular queue, with contiguous physical addresses within each massive page; Obtain the transmission parameters of the data to be transmitted and the queue status of the DMA ring queue, wherein the queue status includes the number of remaining available descriptors and the queue's empty / full status; The target address range is determined based on the transmission parameters, and then divided according to the giant page boundary to generate address division information including alignment relationships and continuous address regions within the page. The initial descriptor granularity is determined based on address partitioning information, and continuous address regions within a page are divided to generate initial data fragments. Compare the number of initial data fragments with the number of remaining available descriptors. If the number is within the limit, the initial data fragment is identified as the target data fragment. If the number exceeds the limit, merge the initial data fragments that are consecutive within the same giant page and perform intra-page splitting based on the bandwidth target and the time delay target to generate the target data fragment. DMA descriptors are generated based on the mapping relationship and the target data fragments, written to the DMA circular queue in the transfer order, and the next descriptor pointer is set to form a circular connection. The FPGA-side cyclic transfer control state machine updates the queue state, controls the DMA engine to move data to the DMA target buffer according to the DMA descriptor, and reads the DMA descriptor cyclically along the next descriptor pointer, wrapping around to the head of the queue to perform cyclic transfer.

2. The method for dynamic construction of DMA descriptors and data transfer according to claim 1, characterized in that, The construction of the DMA target buffer includes: Multiple massive pages are allocated in the host memory, making the physical addresses within each massive page contiguous, and the memory spaces corresponding to each massive page are combined to form a DMA target buffer. Obtain the virtual address range and physical address range corresponding to each giant page in the DMA target buffer, and establish the mapping relationship between the virtual address and physical address of the DMA target buffer according to the correspondence between the two. Create a DMA circular queue, determine the total number of descriptors in the DMA circular queue, and initialize the head position, tail position, and the number of currently occupied descriptors.

3. The method for dynamic construction of DMA descriptors and data transfer according to claim 1, characterized in that, The acquisition of the queue status includes: Obtain the transmission request corresponding to the data to be transmitted, determine the target start address, transmission length, jumbo page size, bandwidth target, and time delay target from the transmission request, and generate transmission parameters; Read the total number of descriptors in the DMA circular queue and the number of currently occupied descriptors, and determine the number of remaining available descriptors based on the difference between the total number of descriptors and the number of currently occupied descriptors; The queue status is determined based on the number of currently occupied descriptors and the total number of descriptors. The remaining available descriptors and the queue status are combined to form the queue status.

4. The method for dynamic construction of DMA descriptors and data transfer according to claim 1, characterized in that, The generation of the address partitioning information includes: Obtain the target start address, transmission length, and jumbo page size from the transmission parameters. Offset the target start address along the address increment direction by the transmission length to determine the target end address, forming a target address range that includes the target start address but does not include the target end address. The starting and ending addresses of the target are obtained by taking the remainder of the giant page size. The offsets within the starting and ending pages are then determined. Addresses with zero offsets within the page are identified as aligned, and addresses with non-zero offsets within the page are identified as unaligned, thus establishing the alignment relationship between the target address range and the giant page boundary. Subtract the offset within the starting page from the target starting address and add the jumbo page size to determine the first jumbo page boundary. Gradually increase the jumbo page size along the address increment direction. Divide the target address range with a jumbo page boundary smaller than the target ending address to generate a continuous address region within the page. When no division is needed, the target address range is determined as a continuous address region within the page. Collect consecutive address regions within a page in ascending order of address, associate these consecutive address regions with alignment relationships, and generate address partitioning information.

5. The method for dynamic construction of DMA descriptors and data transfer according to claim 1, characterized in that, The generation of the initial data fragment includes: Read the alignment relationship and continuous address regions within a page from the address partitioning information, and determine the start address, end address, and address length of each continuous address region within a page. Based on the alignment relationship, the initial descriptor granularity is determined for consecutive address regions within the page that are aligned at the beginning and end and those that are not aligned at the beginning and end. The granularity of each initial descriptor does not exceed the address length of the corresponding consecutive address region within the page, and the corresponding starting address is determined as the partitioning starting point. Offset the partition starting point along the address increment direction to the initial descriptor granularity, take the smaller value between the offset address and the corresponding end address as the partition endpoint, and determine the address range that includes the partition starting point but does not include the partition endpoint as the initial data segment, without adding partition positions based on the 4KB boundary inside the giant page. If the partition endpoint does not reach the corresponding end address, the partition endpoint is used as the new partition starting point, and initial data fragments are generated at the initial descriptor granularity until the partition endpoint reaches the corresponding end address. The initial data fragments are then collected in ascending order of address.

6. The method for dynamic construction of DMA descriptors and data transfer according to claim 1, characterized in that, The generation of the target data fragment includes: Based on the queue status, the number of initial data fragments is compared with the number of remaining available descriptors. If the number of initial data fragments does not exceed the number of remaining available descriptors, the initial data fragments are determined as the target data fragments. If the number of initial data fragments exceeds the number of remaining available descriptors, the initial data fragments are arranged according to the jumbo page ownership and address order. The address continuity of adjacent initial data segments within the same giant page is determined sequentially. Initial data segments with continuous addresses are merged, and the merged data segments are arranged in address order with the initial data segments that were not merged to generate merged data segments. The difference between the number of remaining available descriptors and the number of merged data fragments is determined as the number of remaining available descriptors after merging. The lower limit of the segment length corresponding to the intra-page split is determined based on the bandwidth target, the upper limit of the segment length corresponding to the intra-page split is determined based on the latency target, and the target split length is determined by combining the lower limit and the upper limit of the segment length. The merged data fragment is split within a page according to the target split length, and the number of descriptors added by the split within the page is accumulated. The splitting stops when continuing to split within the page would cause the number of descriptors added by the split within the page to exceed the number of remaining available descriptors after merging. The split merged data fragment is then combined with the unsplit merged data fragment to generate the target data fragment.

7. The method for dynamic construction of DMA descriptors and data transfer according to claim 1, characterized in that, The generation of the DMA descriptor includes: According to the transmission order of the target data segments, the target physical starting address corresponding to each target data segment is determined based on the mapping relationship, and the transmission length is determined according to the data length covered by each target data segment; For each target data segment, a corresponding DMA descriptor is established. The target physical start address and transmission length corresponding to each target data segment are written into the corresponding DMA descriptor, and the DMA descriptors are arranged according to the transmission order of the target data segments. Write each DMA descriptor into the DMA circular queue in the order of their arrangement, and record the descriptor write address corresponding to each DMA descriptor. According to the order of the DMA descriptors, the next descriptor pointer of each DMA descriptor is set to the descriptor write address of the next DMA descriptor, and the next descriptor pointer of the last DMA descriptor is set to the descriptor write address of the first DMA descriptor, thus completing the circular connection of the DMA descriptors.

8. The method for dynamic construction of DMA descriptors and data transfer according to claim 1, characterized in that, The cyclic transmission includes: The FPGA-side cyclic transfer control state machine determines the position corresponding to the DMA descriptor at the head of the DMA circular queue as the current execution position and obtains the queue state; Based on queue state control, the DMA engine reads the DMA descriptor corresponding to the current execution position, obtains the target physical start address, transfer length and the next descriptor pointer, and moves data to the DMA target buffer according to the target physical start address and transfer length. After the data transfer corresponding to the current DMA descriptor is completed, the FPGA-side cyclic transfer control state machine updates the queue state and determines the position of the next DMA descriptor by following the next descriptor pointer; Update the position corresponding to the next DMA descriptor to the current execution position; when the DMA descriptor that has completed data transfer is the tail DMA descriptor, update the position corresponding to the head DMA descriptor pointed to by the next descriptor pointer to the current execution position, and continue to control the DMA engine to read DMA descriptors and perform data transfer based on the updated queue state and the current execution position.

9. A DMA descriptor dynamic construction and data transfer apparatus, performing the DMA descriptor dynamic construction and data transfer method according to any one of claims 1 to 8, characterized in that, include: The buffer construction module is used to allocate jumbo pages in host memory, construct DMA target buffers, establish mapping relationships, and initialize DMA circular queues. The parameter acquisition module is used to acquire the transmission parameters of the data to be transmitted and the queue status of the DMA ring queue. The address partitioning module is used to generate address partitioning information based on transmission parameters and giant page boundaries; The initial fragmentation module is used to determine the initial descriptor granularity based on address partitioning information and generate initial data fragments; The target data fragmentation module is used to merge and split the initial data fragments within a page based on the queue status, bandwidth target, and time delay target to generate target data fragments. The descriptor construction module is used to generate DMA descriptors based on mapping relationships and target data fragments, and write the DMA descriptors into the DMA circular queue to form a circular connection; The loop transfer module is used to control the DMA engine to read DMA descriptors and move data to the DMA target buffer based on the queue state, and to perform loop transfers along the next descriptor pointer.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, enables the processor to perform the DMA descriptor dynamic construction and data transfer method according to any one of claims 1 to 8.