DMA operation queue management method, device, equipment and readable storage medium
The DMA operation queue is managed through the device-to-queue and queue-to-device mapping table, which solves the problem of insufficient flexibility and manageability of DMA operation queue allocation in the prior art, and improves system performance and CPU resource utilization.
Patent Information
- Application Number
- CN202311706139.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-12
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2043-12-12
AI Technical Summary
The prior art has poor flexibility and manageability in DMA operation queue allocation, resulting in high CPU resource utilization and affecting system performance.
The DMA operation queue is managed using device-to-queue mapping table and queue-to-device mapping table, reducing dependence on the CPU and improving the flexibility and manageability of DMA operations.
The DMA operation queue is allocated through hardware configuration mapping tables, reducing CPU dependence, improving system performance, and supporting dynamic allocation and recycling of DMA operation queues to adapt to large or changing DMA operation needs.
Smart Images

Figure CN117806997B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a DMA operation queue management method, apparatus, device and readable storage medium. Background Art
[0002] In computer systems, Direct Memory Access (DMA) is a technology that allows peripheral devices to exchange data directly with memory without going through the central processing unit (CPU). This allows data transfers to be completed more quickly, thereby improving the overall performance of the system.
[0003] Existing technical solutions usually use a single mapping table or a simple one-to-many mapping relationship to allocate DMA operation queues to peripheral devices, require the use of hardware registers to set transfer parameters such as target address and transfer length, and require the CPU to allocate DMA operation queues.
[0004] However, the existing method is a simple mapping allocation method with poor flexibility and manageability, and the allocation of DMA operation queues depends on the CPU. When processing more DMA operations, it occupies more CPU resources and affects system performance. Summary of the invention
[0005] In order to solve the above technical problems or at least partially solve the above technical problems, the present disclosure provides a DMA operation queue management method, apparatus, device and readable storage medium to improve the flexibility and manageability of DMA operation queue allocation and improve system performance.
[0006] In a first aspect, an embodiment of the present disclosure provides a DMA operation queue management method, the method comprising:
[0007] receiving a request sent by a central processing unit, wherein the request includes a virtual machine device address;
[0008] Determine the DMA operation queue corresponding to the virtual machine device address based on the device-to-queue mapping table;
[0009] Processing the request based on the DMA operation queue to obtain request processing data;
[0010] Determine the virtual machine device corresponding to the address of the DMA operation queue based on the queue-to-device mapping table, and add the address of the virtual machine device to the request processing data;
[0011] The request processing data with the address of the virtual machine device added is returned to the central processor, so that the central processor sends the request processing data to the virtual machine device corresponding to the address of the virtual machine device.
[0012] In a second aspect, an embodiment of the present disclosure provides a DMA operation queue management device, the device comprising:
[0013] A receiving module, configured to receive a request sent by a central processing unit, wherein the request includes a virtual machine device address;
[0014] A first determination module, configured to determine a DMA operation queue corresponding to the virtual machine device address based on a device-to-queue mapping table;
[0015] An obtaining module, used for processing the request based on the DMA operation queue to obtain request processing data;
[0016] A second determination module is used to determine the virtual machine device corresponding to the address of the DMA operation queue based on a queue-to-device mapping table, and add the address of the virtual machine device to the request processing data;
[0017] The return module is used to return the request processing data with the address of the virtual machine device added to the central processor, so that the central processor sends the request processing data to the virtual machine device corresponding to the address of the virtual machine device.
[0018] In a third aspect, an embodiment of the present disclosure provides an electronic device, including:
[0019] Memory;
[0020] Processor; and
[0021] Computer programs;
[0022] The computer program is stored in the memory and is configured to be executed by the processor to implement the method as described in the first aspect.
[0023] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to implement the method as described in the first aspect.
[0024] In a fifth aspect, an embodiment of the present disclosure further provides a computer program product, which includes a computer program or instructions, and when the computer program or instructions are executed by a processor, the method described in the first aspect is implemented.
[0025] The DMA operation queue management method, apparatus, device and readable storage medium provided in the embodiment of the present disclosure receive a request sent by a central processor, the request includes a virtual machine device address, determine the DMA operation queue corresponding to the virtual machine device address based on a device-to-queue mapping table, process the request based on the DMA operation queue to obtain request processing data, determine the virtual machine device corresponding to the address of the DMA operation queue based on a queue-to-device mapping table, add the address of the virtual machine device to the request processing data, and return the request processing data with the address of the virtual machine device added to the central processor, so that the central processor sends the request processing data to the virtual machine device corresponding to the address of the virtual machine device. Compared with the prior art, the embodiment of the present disclosure manages the DMA operation queue by using a device-to-queue mapping table and a queue-to-device mapping table, one mapping table is used for mapping from device to DMA operation, and the other mapping table is used for mapping from DMA operation to device, thereby improving the flexibility and manageability of DMA operation, using a hardware configuration mapping table to allocate DMA operation queues, reducing dependence on the CPU, and improving system performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0027] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0028] Figure 1 A flow chart of a DMA operation queue management method provided by an embodiment of the present disclosure;
[0029] Figure 2 A principle block diagram of a DMA operation queue management method provided by an embodiment of the present disclosure;
[0030] Figure 3 A flow chart of a DMA operation queue management method provided by another embodiment of the present disclosure;
[0031] Figure 4 A flow chart of a DMA operation queue management method provided by another embodiment of the present disclosure;
[0032] Figure 5 A schematic diagram of a device-to-queue mapping table circuit provided in an embodiment of the present disclosure;
[0033] Figure 6A schematic diagram of a queue-to-device mapping table circuit provided in an embodiment of the present disclosure;
[0034] Figure 7 A schematic diagram of the structure of a DMA operation queue management device provided by an embodiment of the present disclosure;
[0035] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0036] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0037] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0038] In computer systems, Direct Memory Access (DMA) is a technology that allows peripheral devices to exchange data directly with memory without going through the central processing unit (CPU). This allows data transfers to be completed more quickly, thereby improving the overall performance of the system.
[0039] Existing technical solutions usually use a single mapping table or a simple one-to-many mapping relationship to allocate DMA operation queues to peripheral devices, require the use of hardware registers to set transfer parameters such as target address and transfer length, and require the CPU to allocate DMA operation queues.
[0040] However, the existing method is a simple mapping allocation method with poor flexibility and manageability, and the allocation of DMA operation queues depends on the CPU. When processing a large number of DMA operations, it takes up more CPU resources and affects system performance. To address this problem, the embodiment of the present disclosure provides a DMA operation queue management method, which is introduced in conjunction with a specific embodiment below.
[0041] Figure 1A flow chart of the DMA operation queue management method provided in the embodiment of the present disclosure. The executor of the method is an electronic device. The electronic device can be a portable mobile device such as a smart phone, a tablet computer, a laptop computer, a car navigation device, an intelligent sports equipment, etc.; it can also be a fixed device such as a personal computer, a smart home appliance, a server, etc., wherein the server can be a single server, a server cluster, and the server cluster can be a distributed cluster or a centralized cluster. The method can be applied to the scenario of managing the DMA operation queue, and can also be applied to the scenario of allocating the DMA operation queue. It can be understood that the DMA operation queue management method provided in the embodiment of the present disclosure can also be applied in other scenarios.
[0042] Below Figure 1 The DMA operation queue management method shown in the figure is introduced, and the specific steps of the method are as follows:
[0043] S101. Receive a request sent by a central processing unit, where the request includes a virtual machine device address.
[0044] like Figure 2 As shown, a virtual machine device (VM) sends a request through a central processing unit (CPU), and the electronic device receives the request sent by the central processing unit, wherein the request includes the virtual machine device address.
[0045] S102: Determine a DMA operation queue corresponding to the virtual machine device address based on a device-to-queue mapping table.
[0046] like Figure 2 As shown, the electronic device determines the DMA operation queue corresponding to the virtual machine device address through the device-to-queue mapping table (MAP_FTQ), that is, the electronic device allocates the corresponding DMA operation queue to the virtual machine device through the device-to-queue mapping table.
[0047] Optionally, the device-to-queue mapping table uses the device ID as the key and the DMA operation queue ID as the value. When a device needs to be assigned to a DMA operation queue, just add a corresponding relationship between the device ID and the DMA operation queue ID in the device-to-queue mapping table. Similarly, when a device needs to be removed from a DMA operation queue, just delete the data corresponding to the device in the device-to-queue mapping table.
[0048] S103: Process the request based on the DMA operation queue to obtain request processing data.
[0049] After determining the DMA operation queue corresponding to the virtual machine device address, the electronic device processes the request based on the DMA operation queue to obtain request processing data of the request.
[0050] S104: Determine the virtual machine device corresponding to the address of the DMA operation queue based on a queue-to-device mapping table, and add the address of the virtual machine device to the request processing data.
[0051] like Figure 2 As shown, the electronic device determines the virtual machine device corresponding to the address of the DMA operation queue through a queue-to-device mapping table (MAP_QTF), and adds the address of the virtual machine device to the request processing data.
[0052] Optionally, the queue-to-device mapping table uses the DMA operation queue ID as the key and the device ID as the value. When a DMA operation queue needs to be assigned to a device, just add a corresponding relationship between the DMA operation queue ID and the device ID in the queue-to-device mapping table. Similarly, when a DMA operation queue needs to be removed, just delete the data corresponding to the DMA operation queue in the queue-to-device mapping table.
[0053] S105: Return the request processing data with the address of the virtual machine device added to the central processor, so that the central processor sends the request processing data to the virtual machine device corresponding to the address of the virtual machine device.
[0054] Furthermore, the electronic device returns the request processing data with the address of the virtual machine device added to the central processor. The central processor determines the corresponding virtual machine device according to the address of the virtual machine device in the request processing data, sends the request processing data to the virtual machine device, and completes the request process.
[0055] In some embodiments, before receiving the request sent by the central processor, the method further includes: initializing the mapping table from the device to the queue.
[0056] During the system startup phase, the DMA operation queue is initialized and allocated, and a preset threshold is set. Specifically, the device counter and allocation counter are reset to zero, and then the virtual machine devices are serially pre-allocated according to the threshold until all allocations are completed.
[0057] In some embodiments, initializing the device-to-queue mapping table includes: pre-allocating a DMA operation queue according to a virtual machine device to obtain a pre-allocated device-to-queue mapping table.
[0058] Optionally, pre-allocating the DMA operation queue according to the virtual machine device to obtain a mapping table of the pre-allocated device to the queue includes the following steps:
[0059] S1. Reset the device counter and the allocation counter to zero, and clear the mapping table from the device to the queue;
[0060] S2, determine whether the device counter is greater than or equal to a preset threshold, if so, execute S4, otherwise execute S3;
[0061] S3. If the device counter is less than a preset threshold, the current DMA operation queue is allocated to the virtual machine device, and the device counter is incremented by one;
[0062] S4. If the device counter is greater than or equal to a preset threshold, the DMA operation queue address is written, the write address is incremented by one, and the allocation counter is incremented by one;
[0063] S5, determine whether the DMA operation queue pre-allocation is completed;
[0064] S6. If the DMA operation queue pre-allocation has been completed, a mapping table of pre-allocated devices to queues is obtained.
[0065] The disclosed embodiment receives a request sent by a central processor, the request includes a virtual machine device address, determines a DMA operation queue corresponding to the virtual machine device address based on a device-to-queue mapping table, processes the request based on the DMA operation queue to obtain request processing data, determines a virtual machine device corresponding to the address of the DMA operation queue based on a queue-to-device mapping table, adds the address of the virtual machine device to the request processing data, and returns the request processing data with the address of the virtual machine device added to the central processor, so that the central processor sends the request processing data to the virtual machine device corresponding to the address of the virtual machine device. Compared with the prior art, the disclosed embodiment manages the DMA operation queue by using a device-to-queue mapping table and a queue-to-device mapping table, one mapping table is used for mapping from device to DMA operation, and the other mapping table is used for mapping from DMA operation to device, thereby improving the flexibility and manageability of DMA operation, using a hardware configuration mapping table to allocate DMA operation queues, reducing dependence on the CPU, and improving system performance.
[0066] Figure 3 A flow chart of a DMA operation queue management method provided by another embodiment of the present disclosure is shown in FIG. Figure 3 As shown, the method includes the following steps:
[0067] S201. Receive a request sent by a central processing unit, where the request includes a virtual machine device address.
[0068] Specifically, the implementation process and principle of S201 and S101 are the same, and will not be repeated here.
[0069] S202: Determine whether there is a pointer release operation or pointer allocation operation currently.
[0070] In this step, the electronic device determines whether the current operation is an allocation pointer operation (alloc) or a release pointer operation (free).
[0071] S203: If there is no pointer release operation and no pointer allocation operation currently, the read address is set to the current device relative address, and the DMA operation queue address is read out in real time.
[0072] Figure 5 A schematic diagram of a device-to-queue mapping table circuit provided in an embodiment of the present disclosure, such as Figure 5 As shown in the figure, the device-to-queue mapping table (MAP_FTQ) circuit consists of a DPA-RAM (Dual-Port Asynchronous RAM), a three-way selector (MUX3) and an OR gate. When there is no DMA operation queue allocation pointer operation (alloc) or release pointer operation (free), the read state is maintained, the read address is set to the current device relative address (func_addr), and the DMA operation queue address (que_out) is read in real time.
[0073] S204: If there is currently an allocation pointer operation, the allocated DMA operation queue address is written into the current device relative address.
[0074] like Figure 5 As shown, when the DMA operation queue allocation pointer operation (alloc) is performed, the allocated DMA operation queue address (que_in) is written into the current device relative address (func_addr).
[0075] S205: If there is a release pointer operation currently, write zero into the current device relative address.
[0076] like Figure 5 As shown, when the DMA operation queue release pointer operation is performed, 0 is written into the current device relative address (func_addr).
[0077] S206: Process the request based on the DMA operation queue to obtain request processing data.
[0078] Specifically, the implementation process and principle of S206 and S103 are the same, and will not be repeated here.
[0079] S207 . Determine the virtual machine device corresponding to the address of the DMA operation queue based on a queue-to-device mapping table, and add the address of the virtual machine device to the request processing data.
[0080] Specifically, the implementation process and principle of S207 and S104 are the same, and will not be repeated here.
[0081] S208: Return the request processing data with the address of the virtual machine device added to the central processor, so that the central processor sends the request processing data to the virtual machine device corresponding to the address of the virtual machine device.
[0082] Specifically, the implementation process and principle of S208 and S105 are the same, and will not be repeated here.
[0083] The disclosed embodiment receives a request sent by a central processing unit, wherein the request includes a virtual machine device address, and determines whether there is a release pointer operation or an allocation pointer operation. Further, if there is no release pointer operation and no allocation pointer operation, the read address is set to the current device relative address, and the DMA operation queue address is read in real time; if there is an allocation pointer operation, the allocated DMA operation queue address is written into the current device relative address; if there is a release pointer operation, zero is written into the current device relative address. Then, the request is processed based on the DMA operation queue to obtain request processing data, and the virtual machine device corresponding to the address of the DMA operation queue is determined based on the queue-to-device mapping table, and the address of the virtual machine device is added to the request processing data. Then, the request processing data with the address of the virtual machine device added is returned to the central processing unit, so that the central processing unit sends the request processing data to the virtual machine device corresponding to the address of the virtual machine device. Compared with the prior art, the disclosed embodiment manages the DMA operation queue by using a mapping table from device to queue and a mapping table from queue to device. One mapping table is used for mapping from device to DMA operation, and the other mapping table is used for mapping from DMA operation to device, thereby improving the flexibility and manageability of DMA operation, and using the hardware configuration mapping table to allocate the DMA operation queue, reducing the dependence on the CPU and improving the system performance. In addition, it supports dynamic allocation and recovery of DMA operation queues to adapt to a large number or changing DMA operation requirements.
[0084] Figure 4 A flow chart of a DMA operation queue management method provided by another embodiment of the present disclosure is shown in FIG. Figure 4 As shown, the method includes the following steps:
[0085] S301. Receive a request sent by a central processing unit, where the request includes a virtual machine device address.
[0086] Specifically, the implementation process and principle of S301 and S101 are the same, and will not be repeated here.
[0087] S302: Determine the DMA operation queue corresponding to the virtual machine device address based on a device-to-queue mapping table.
[0088] Specifically, the implementation process and principle of S302 and S102 are the same, and will not be repeated here.
[0089] S303: Process the request based on the DMA operation queue to obtain request processing data.
[0090] Specifically, the implementation process and principle of S303 and S103 are the same, and will not be repeated here.
[0091] S304: Determine whether there is a pointer release operation or pointer allocation operation currently.
[0092] In this step, the electronic device determines whether the current operation is an allocation pointer operation (alloc) or a release pointer operation (free).
[0093] S305: If there is no pointer release operation and no pointer allocation operation currently, the read address is set to the current DMA operation queue address, and the device relative address is read in real time.
[0094] Figure 6 A schematic diagram of a queue-to-device mapping table circuit provided in an embodiment of the present disclosure, such as Figure 6 As shown in the figure, the queue to device mapping table (MAP_QTF) circuit consists of a DPA-RAM (Dual-Port Asynchronous RAM), a two-way selector (MUX2) and an OR gate. When there is no DMA operation queue allocation pointer operation (alloc) or release pointer operation (free), the read state is maintained, the read address is set to the current operation queue address (que_out), and the device relative address (func_addr) is read in real time.
[0095] S306: If there is currently an allocation pointer operation, the allocated device relative address is written into the current DMA operation queue address.
[0096] like Figure 6 As shown, when the DMA operation queue allocation pointer operation (alloc) is performed, the allocated device relative address (func_in) is used as the write address and written into the current DMA operation queue address (que_in).
[0097] S307: If there is a release pointer operation currently, write zero into the current DMA operation queue address.
[0098] like Figure 6 As shown, when the DMA operation queue release operation is performed, 0 is written into the current operation queue address (que_in).
[0099] S308: Add the address of the virtual machine device to the request processing data.
[0100] S309: Return the request processing data with the address of the virtual machine device added to the central processor, so that the central processor sends the request processing data to the virtual machine device corresponding to the address of the virtual machine device.
[0101] Specifically, the implementation process and principle of S308 and S105 are the same, and will not be repeated here.
[0102] The disclosed embodiment receives a request sent by a central processing unit, wherein the request includes a virtual machine device address, determines the DMA operation queue corresponding to the virtual machine device address based on a device-to-queue mapping table, processes the request based on the DMA operation queue, and obtains request processing data. Further, it is determined whether there is a release pointer operation or an allocation pointer operation. If there is no release pointer operation and no allocation pointer operation, the read address is set to the current DMA operation queue address, and the device relative address is read out in real time; if there is an allocation pointer operation, the allocated device relative address is written into the current DMA operation queue address; if there is a release pointer operation, zero is written into the current DMA operation queue address. Then, the address of the virtual machine device is added to the request processing data. Then, the request processing data with the address of the virtual machine device added is returned to the central processing unit, so that the central processing unit sends the request processing data to the virtual machine device corresponding to the address of the virtual machine device. Compared with the prior art, the disclosed embodiment manages the DMA operation queue by using a mapping table from device to queue and a mapping table from queue to device. One mapping table is used for mapping from device to DMA operation, and the other mapping table is used for mapping from DMA operation to device, thereby improving the flexibility and manageability of DMA operation, and using the hardware configuration mapping table to allocate the DMA operation queue, reducing the dependence on the CPU and improving the system performance. In addition, it supports dynamic allocation and recovery of DMA operation queues to adapt to a large number or changing DMA operation requirements.
[0103] Figure 7 The schematic diagram of the structure of the DMA operation queue management device provided in the embodiment of the present disclosure. The DMA operation queue management device may be the electronic device as described in the above embodiment, or the DMA operation queue management device may be a component or assembly in the electronic device. The DMA operation queue management device provided in the embodiment of the present disclosure may execute the processing flow provided in the embodiment of the DMA operation queue management method, such as Figure 7As shown, the DMA operation queue management device 40 includes: a receiving module 41, a first determining module 42, an obtaining module 43, a second determining module 44, and a returning module 45; wherein the receiving module 41 is used to receive a request sent by a central processing unit, and the request includes a virtual machine device address; the first determining module 42 is used to determine the DMA operation queue corresponding to the virtual machine device address based on a device-to-queue mapping table; the obtaining module 43 is used to process the request based on the DMA operation queue to obtain request processing data; the second determining module 44 is used to determine the virtual machine device corresponding to the address of the DMA operation queue based on a queue-to-device mapping table, and add the address of the virtual machine device to the request processing data; the returning module 45 is used to return the request processing data with the address of the virtual machine device added to the central processing unit, so that the central processing unit sends the request processing data to the virtual machine device corresponding to the address of the virtual machine device.
[0104] Optionally, the DMA operation queue management device 40 further includes an initialization module 46; the initialization module 46 is used to initialize the device-to-queue mapping table.
[0105] Optionally, when the initialization module 46 initializes the device-to-queue mapping table, it is specifically used to: pre-allocate the DMA operation queue according to the virtual machine device to obtain the pre-allocated device-to-queue mapping table.
[0106] Optionally, when the initialization module 46 pre-allocates the DMA operation queue according to the virtual machine device and obtains the mapping table from the pre-allocated device to the queue, it is specifically used to: reset the device counter and the allocation counter to zero, and clear the mapping table from the device to the queue; determine whether the device counter is greater than or equal to a preset threshold; if the device counter is less than the preset threshold, the current DMA operation queue is allocated to the virtual machine device, and the device counter is incremented by one; if the device counter is greater than or equal to the preset threshold, the DMA operation queue address is written, the write address is incremented by one, and the allocation counter is incremented by one; determine whether the pre-allocation of the DMA operation queue is completed; if the pre-allocation of the DMA operation queue is completed, obtain the mapping table from the pre-allocated device to the queue.
[0107] Optionally, when the first determination module 42 determines the DMA operation queue corresponding to the virtual machine device address based on the device-to-queue mapping table, it is specifically used to: determine whether there is currently a release pointer operation or an allocation pointer operation; if there is currently no release pointer operation and no allocation pointer operation, set the read address to the current device relative address, and read the DMA operation queue address in real time; if there is currently an allocation pointer operation, write the allocated DMA operation queue address into the current device relative address; if there is currently a release pointer operation, write zero into the current device relative address.
[0108] Optionally, when the second determination module 44 determines the virtual machine device corresponding to the address of the DMA operation queue based on the queue-to-device mapping table, it is specifically used to: determine whether there is currently a release pointer operation or an allocation pointer operation; if there is currently no release pointer operation and no allocation pointer operation, set the read address to the current DMA operation queue address, and read the device relative address in real time; if there is currently an allocation pointer operation, write the allocated device relative address into the current DMA operation queue address; if there is currently a release pointer operation, write zero into the current DMA operation queue address.
[0109] Figure 7 The DMA operation queue management device of the illustrated embodiment can be used to execute the technical solution of the above-mentioned method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.
[0110] Figure 8 Schematic diagram of the structure of an electronic device in the embodiment of the present disclosure. Figure 8 , which shows a structural schematic diagram of an electronic device 600 suitable for implementing the embodiments of the present disclosure. Figure 8 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0111] like Figure 8 As shown, the electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 to a random access memory (RAM) 603 to implement the DMA operation queue management method of the embodiment described in the present disclosure. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0112] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 8The electronic device 600 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0113] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart, thereby implementing the DMA operation queue management method as described above. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 609, or installed from the storage device 608, or installed from the ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0114] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0115] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0116] The computer-readable medium may be included in the electronic device, or may exist independently without being installed in the electronic device.
[0117] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device:
[0118] receiving a request sent by a central processing unit, wherein the request includes a virtual machine device address;
[0119] Determine the DMA operation queue corresponding to the virtual machine device address based on the device-to-queue mapping table;
[0120] Processing the request based on the DMA operation queue to obtain request processing data;
[0121] Determine the virtual machine device corresponding to the address of the DMA operation queue based on the queue-to-device mapping table, and add the address of the virtual machine device to the request processing data;
[0122] The request processing data with the address of the virtual machine device added is returned to the central processor, so that the central processor sends the request processing data to the virtual machine device corresponding to the address of the virtual machine device.
[0123] Optionally, when the above one or more programs are executed by the electronic device, the electronic device may also execute other steps described in the above embodiments.
[0124] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0125] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0126] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit does not, in some cases, limit the unit itself.
[0127] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0128] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0129] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
[0130] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0131] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.
Claims
1. A DMA operation queue management method, characterized in that: The method comprises: receiving a request sent by a central processing unit, wherein the request includes a virtual machine device address; Determine the DMA operation queue corresponding to the virtual machine device address based on the device-to-queue mapping table; Processing the request based on the DMA operation queue to obtain request processing data; Determine the virtual machine device corresponding to the address of the DMA operation queue based on the queue-to-device mapping table, and add the address of the virtual machine device to the request processing data; Returning the request processing data with the address of the virtual machine device added to the central processor, so that the central processor sends the request processing data to the virtual machine device corresponding to the address of the virtual machine device; The determining, based on a device-to-queue mapping table, a DMA operation queue corresponding to the virtual machine device address includes: Determine whether there is a pointer release operation or pointer allocation operation currently; If there is no pointer release operation and no pointer allocation operation, the read address is set to the current device relative address, and the DMA operation queue address is read in real time; If there is currently an allocation pointer operation, the allocated DMA operation queue address is written into the current device relative address; If there is a release pointer operation currently, zero is written into the current device relative address.
2. The method according to claim 1, characterized in that Before receiving the request sent by the central processor, the method further includes: Initialize the device-to-queue mapping table.
3. The method according to claim 2, characterized in that Initializing the mapping table from the device to the queue includes: The DMA operation queue is pre-allocated according to the virtual machine device, and a mapping table of the pre-allocated device to the queue is obtained.
4. The method according to claim 3, characterized in that The pre-allocation of the DMA operation queue according to the virtual machine device to obtain a mapping table of the pre-allocated device to the queue includes: Reset the device counter and the allocation counter to zero, and clear the mapping table from the device to the queue; Determine whether the device counter is greater than or equal to a preset threshold; If the device counter is less than a preset threshold, the current DMA operation queue is assigned to the virtual machine device, and the device counter is incremented by one; If the device counter is greater than or equal to a preset threshold, the DMA operation queue address is written, the write address is incremented by one, and the allocation counter is incremented by one; Determine whether the DMA operation queue pre-allocation is completed; If the DMA operation queue pre-allocation has been completed, a mapping table of pre-allocated devices to queues is obtained.
5. The method according to claim 1, characterized in that The determining the virtual machine device corresponding to the address of the DMA operation queue based on the queue-to-device mapping table includes: Determine whether there is a pointer release operation or pointer allocation operation currently; If there is no pointer release operation and no pointer allocation operation, the read address is set to the current DMA operation queue address, and the device relative address is read in real time; If there is currently an allocation pointer operation, the allocated device relative address is written into the current DMA operation queue address; If there is a release pointer operation currently, zero is written into the current DMA operation queue address.
6. A DMA operation queue management device, characterized in that: The device comprises: A receiving module, used for receiving a request sent by a central processing unit, wherein the request includes a virtual machine device address; A first determination module, configured to determine a DMA operation queue corresponding to the virtual machine device address based on a device-to-queue mapping table; An obtaining module, used for processing the request based on the DMA operation queue to obtain request processing data; A second determination module is used to determine the virtual machine device corresponding to the address of the DMA operation queue based on a queue-to-device mapping table, and add the address of the virtual machine device to the request processing data; A return module, used for returning the request processing data for adding the address of the virtual machine device to the central processor, so that the central processor sends the request processing data to the virtual machine device corresponding to the address of the virtual machine device; When the first determination module determines the DMA operation queue corresponding to the virtual machine device address based on the device-to-queue mapping table, it is specifically used to: Determine whether there is a pointer release operation or pointer allocation operation currently; If there is no pointer release operation and no pointer allocation operation, the read address is set to the current device relative address, and the DMA operation queue address is read in real time; If there is currently an allocation pointer operation, the allocated DMA operation queue address is written into the current device relative address; If there is a release pointer operation currently, zero is written into the current device relative address.
7. The device according to claim 6, characterized in that The device also includes: The initialization module is used to initialize the mapping table from the device to the queue.
8. An electronic device, characterized in that: include: Memory; processor; as well as Computer programs; The computer program is stored in the memory and is configured to be executed by the processor to implement the method according to any one of claims 1 to 5.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
