A transmission optimization method based on Virtio-net

By optimizing the descriptor generation and notify mechanism of Virtio-net, DMA read operations are reduced, packet forwarding performance of smart network cards is improved and delayed, and the performance bottleneck of smart network cards is solved when processing packet data is solved, and efficient network transmission is achieved.

CN116346737BActive Publication Date: 2025-08-12CHINA TELECOM CLOUD TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310259448.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-10
Publication Date
2025-08-12
Estimated Expiration
2043-03-10

AI Technical Summary

Technical Problem

In the prior art, when processing packet data, the forwarding performance of the smart network card is poor, resulting in insufficient throughput of the network platform, which cannot meet the needs of the enterprise's intranet users to access the Internet, affecting network transmission efficiency.

Method used

The driver module of the Virtio front-end generates descriptors and updates availidx, sends notify information containing queue ID and availidx to the back-end device, reduces DMA read operations, optimizes the flag information of the descriptors to support the merge-desc mechanism, and improves packet forwarding performance.

Benefits of technology

It effectively improves the packet forwarding performance, reduces latency, improves the throughput of the network platform, and meets the needs of enterprise intranet users to access the Internet.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116346737B_ABST
    Figure CN116346737B_ABST
Patent Text Reader

Abstract

The present invention discloses a transmission optimization method based on Virtio‑net, belonging to the field of data communication technology. The method comprises: querying a to-be-sent packet through a driver module in a Virtio front end; generating a descriptor and updating availidx when a to-be-sent packet exists; the to-be-sent packet forms a target message; sending a notify message to a back-end device, the notify message including ID information of a queue where the to-be-sent packet is located and availidx; obtaining a descriptor through the back-end device according to the notify message; obtaining the to-be-sent packet according to the descriptor, and transporting the target message to the back-end device side.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of data communications, and in particular relates to a transmission optimization method based on Virtio-net. Background Art

[0002] Data centers are the most crucial infrastructure in the cloud computing era, providing powerful computing and storage capabilities for the cloud. Data center networks, serving as the "transportation hub" connecting all computing and storage units within a data center, are crucial to cloud service capabilities. However, the industry's growing demand for data center network performance and virtualization capabilities has posed significant challenges to the processing of network protocol stacks in existing end systems. On the one hand, the high-performance network infrastructure currently available in the industry, with its hundreds of gigabits of bandwidth and microsecond latency, requires extremely high processing speeds in end-system protocol stacks. Therefore, offloading protocol stack processing to network interface card (NIC) ASICs is a common approach. On the other hand, to meet the ever-increasing demands of virtualization, the processing functions within the network protocol stack require frequent updates, making offloading protocol stack processing to NIC ASICs extremely difficult. Against this backdrop, SmartNIC technology has emerged and is gaining widespread adoption. Unlike traditional NICs, SmartNICs combine high performance and programmability, enabling them to handle high-speed network data flows while also allowing for programming to implement customized processing logic.

[0003] Furthermore, from a business perspective, with the increasing popularity of the Internet, the demand for internet access among enterprise intranet users is increasing. Enterprises need to provide external services such as www web browsing, FTP (File Transfer Protocol) file transfer, and DNS domain name resolution. These factors lead to a sharp increase in network traffic. If the network platform's throughput is too low, it will become a network bottleneck, negatively impacting the transmission efficiency of the entire network. Therefore, in cloud computing, throughput is a core technical indicator when conducting network performance testing and is an effective indicator of the team's R&D capabilities.

[0004] According to the RFC2544 standard, Ethernet data packets are framed at 64, 128, 256, 512, 1024, 1280, and 1518 bytes. Currently, most X86-based network platforms achieve near-line-speed throughput when processing medium- and large-sized packets such as 256, 512, 1024, and 1518 bytes. However, performance differences are immediately apparent when processing small 64 and 128 bytes packets. However, recently popular applications, including MSN, QQ, video streaming, and online gaming, utilize small packets. Consequently, the industry is increasingly focused on network platforms' ability to handle small packets. Improving small packet forwarding performance and reducing latency are therefore crucial. Summary of the Invention

[0005] The purpose of the embodiments of the present invention is to provide a transmission optimization method and device based on Virtio-net to improve small packet forwarding performance and reduce latency.

[0006] In order to solve the above-mentioned technical problems, the present invention is achieved as follows:

[0007] In a first aspect, an embodiment of the present invention provides a transmission optimization method based on Virtio-net, characterized in that the method includes:

[0008] Query the driver module in the Virtio front-end for packets to be sent, and if there are packets to be sent, generate a descriptor and update availidx, wherein the packets to be sent constitute the target message;

[0009] Send a notify message to the backend device, where the notify message includes the ID information of the queue where the packet to be sent is located and the availidx;

[0010] Obtaining the descriptor according to the notify information by the backend device;

[0011] The packet to be sent is obtained according to the descriptor, so as to transport the target message to the back-end device side.

[0012] Optionally, after querying the to-be-sent packet through the driver module in the Virtio front-end and before generating the descriptor, the method further includes:

[0013] Send the packet to be sent to the buffer corresponding to skb.

[0014] Optionally, obtaining the descriptor according to the notify information by the backend device includes:

[0015] Calculating the number of the descriptors according to the notify information by the backend device;

[0016] The descriptor is obtained by the DMA engine of the backend device in N times, where the value of N is determined by the quantity, and N is a positive integer.

[0017] Optionally, after obtaining the packet to be sent according to the descriptor to transfer the target message to the backend device side, the method further includes:

[0018] The target message is forwarded to the network side through the DMA engine.

[0019] Optionally, after forwarding the target message to the network side by the DMA engine, the method further includes:

[0020] The used information of the descriptor is updated, and the descriptor is recycled according to the attribute of the used information by the driver module.

[0021] Optionally, after updating the used information of the descriptor, the method further includes:

[0022] MSIx interrupt information is sent to the Virtio front end through the back end device.

[0023] Optionally, the notify message includes multiple sub-notify messages. After sending the notify message to the backend device, the method further includes:

[0024] The notify information is processed by a polling algorithm, and when the number of the plurality of sub-notify messages reaches a preset value, the descriptor is obtained according to the notify information by the back-end device.

[0025] Optionally, a flag reserved field of the descriptor is provided with an identification bit, and the identification bit indicates the length of the message. After generating the descriptor, the method further includes:

[0026] Update the flag information of the descriptor according to the byte length of the target message;

[0027] Wherein, when the byte length of the target message is greater than or equal to a preset value, the value of the flag bit is updated to a first value;

[0028] When the byte length of the target message is less than a preset value, the value of the flag bit is updated to a second value.

[0029] Optionally, after updating the flag information of the descriptor according to the byte length of the target message, the method further includes:

[0030] When the byte length of the target message is greater than or equal to a preset value, storing the packet to be sent in the memory pointed to by the descriptor;

[0031] When the byte length of the target message is less than a preset value, the packet to be sent is stored in the memory in the descriptor.

[0032] Optionally, obtaining the packet to be sent according to the descriptor includes:

[0033] When the byte length of the target message is greater than or equal to a preset value, sending a read request according to the descriptor to obtain the packet to be sent from the memory pointed to by the descriptor;

[0034] When the byte length of the target message is less than a preset value, the packet to be sent is obtained from the memory of the descriptor.

[0035] In a second aspect, an embodiment of the present invention provides a transmission optimization device based on Virtio-net, characterized in that the device includes:

[0036] A generation module is used to query the driver module in the Virtio front end for packets to be sent, and if there are packets to be sent, generate a descriptor and update availidx, wherein the packets to be sent constitute the target message;

[0037] A first sending module is used to send a notify message to a backend device, wherein the notify message includes the ID information of the queue where the packet to be sent is located and the availidx;

[0038] A first acquisition module, configured to obtain the descriptor according to the notify information through the backend device;

[0039] A transport module is used to obtain the packet to be sent according to the descriptor to transport the target message to the back-end device side.

[0040] Optionally, the device further comprises:

[0041] The second sending module sends the packet to be sent to the buffer corresponding to skb.

[0042] Optionally, the first acquisition module includes:

[0043] A calculation module, configured to calculate the number of the descriptors according to the notify information through the backend device;

[0044] The first acquisition submodule is configured to obtain the descriptor N times through the DMA engine of the backend device, where the value of N is determined by the quantity and N is a positive integer.

[0045] Optionally, the device further comprises:

[0046] The third sending module is used to forward the target message to the network side through the DMA engine.

[0047] Optionally, the device further comprises:

[0048] The first updating module is used to update the used information of the descriptor and recycle the descriptor according to the attribute of the used information through the driver module.

[0049] Optionally, the device further comprises:

[0050] The fourth sending module is configured to send MSIx interrupt information to the Virtio front end through the back end device.

[0051] Optionally, the device further comprises:

[0052] The second acquisition module is configured to process the notify information through a polling algorithm, and obtain the descriptor according to the notify information through the backend device when the number of the plurality of sub-notify messages reaches a preset value.

[0053] Optionally, the device further comprises:

[0054] A second updating module, configured to update the flag information of the descriptor according to the byte length of the target message;

[0055] Wherein, when the byte length of the target message is greater than or equal to a preset value, the value of the flag bit is updated to a first value;

[0056] When the byte length of the target message is less than a preset value, the value of the flag bit is updated to a second value.

[0057] Optionally, the device further comprises:

[0058] a fifth sending module, configured to store the packet to be sent in the memory pointed to by the descriptor when the byte length of the target message is greater than or equal to a preset value;

[0059] When the byte length of the target message is less than a preset value, the packet to be sent is stored in the memory in the descriptor.

[0060] Optionally, the first acquisition module further includes:

[0061] A second acquisition submodule is configured to, when the byte length of the target message is greater than or equal to a preset value, send a read request according to the descriptor to obtain the packet to be sent from the memory pointed to by the descriptor;

[0062] When the byte length of the target message is less than a preset value, the packet to be sent is obtained from the memory of the descriptor.

[0063] An embodiment of the present invention provides a transmission optimization method based on Virtio-net, characterized in that the method includes: querying the to-be-sent packets through the driver module in the Virtio front-end, generating a descriptor and updating availidx when there are to-be-sent packets, wherein the to-be-sent packets constitute the target message, sending a notify message to the back-end device, wherein the notify message includes the ID information of the queue where the to-be-sent packets are located and availidx, and the back-end device obtains the descriptor based on the notify message, obtains the to-be-sent packets based on the descriptor, and transfers the target message to the back-end device side. In the Virtionotify mechanism provided by the embodiment of the present invention, regardless of whether the packet is large or small, since the notify content additionally carries the queue's availidx, the back-end driver implemented by the FPGA does not need to read availidx through DMA without requiring additional overhead, thus saving a DMA read operation, which can effectively improve the small packet forwarding performance and reduce latency. BRIEF DESCRIPTION OF THE DRAWINGS

[0064] Figure 1 This is a schematic diagram of Virtio's architecture;

[0065] Figure 2 This is a schematic diagram of the interaction principle of Virtio front-end and back-end;

[0066] Figure 3 This is a flow chart of a transmission optimization method based on Virtio-net provided by an embodiment of the present invention;

[0067] Figure 4 This is a diagram of the typical Virtio-net1.1 packet processing process;

[0068] Figure 5 This is a schematic diagram of a notify processing flow based on an FPGA provided by an embodiment of the present invention;

[0069] Figure 6 Schematic diagram comparing the new and old descriptor flag definitions provided by an embodiment of the present invention;

[0070] Figure 7This is a schematic diagram of the form of merge desc in the descriptor table provided by an embodiment of the present invention;

[0071] Figure 8 It is a structural diagram of a transmission optimization device based on Virtio-net provided by an embodiment of the present invention.

[0072] The realization of the objectives, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0073] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.

[0074] The terms "first," "second," and the like in the specification and claims of the present invention are used to distinguish similar objects, and are not used to describe a particular order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, such that embodiments of the present invention can be implemented in orders other than those illustrated or described herein. Furthermore, the objects distinguished by "first," "second," and the like generally refer to a class of objects and do not limit the number of objects. For example, the first object may be one or more.

[0075] The following describes in detail the Virtio-net-based transmission optimization method provided by the embodiment of the present invention through specific embodiments and application scenarios in conjunction with the accompanying drawings.

[0076] Example 1

[0077] SmartNICs integrate wired network and computing resources on a single card, typically consisting of a network interface controller, a multi-core CPU, and optionally an FPGA (Field-Programmable Gate Array). Host-side network offload on FPGA-based SmartNICs often utilizes Virtio, an I / O paravirtualization solution. Virtio is a program that virtualizes general-purpose I / O devices and abstracts a set of general-purpose I / O devices within a paravirtualized hypervisor.

[0078] like Figure 1As shown in the figure, Virtio can be divided into four layers in general, including various driver modules in the front-end client, handler modules on the back-end Hypervisor, the middle Virtio layer and Virtio-ring layer used for front-end and back-end communication. The Virtio layer implements the virtual queue interface, which is regarded as a bridge for front-end and back-end communication, while the Virtio-ring is the specific implementation of the bridge. It implements two ring buffers, which are used to store information executed by the front-end driver and the back-end handler respectively.

[0079] from Figure 1 It can also be seen that the communication between the front-end and back-end is mainly carried out through the ring of the transport layer, and the ring mainly completes the forwarding of data streams through two ring buffers, such as Figure 2 shown.

[0080] The virtual machine notifies the external KVM (Kernel-based Virtual Machine) by writing registers, which in turn notifies the Virtio backend. To optimize performance, the industry has proposed three acceleration technologies: vHost-net, vHost-user, and vDPA (Virtio Data Path Acceleration). Today's FPGA-based Smart NICs implement the Virtio backend directly within the FPGA and transparently transmit it to the virtual machine, eliminating the need for KVM / QEMU (Quick Emulator), further minimizing performance loss.

[0081] Although the Virtio backend has been accelerated through hardware implementation, and Virtio has evolved from version 1.0 to version 1.1, which is more conducive to hardware acceleration, the forwarding performance in small packet scenarios is still poor. In 100G scenarios, it can only achieve line speed processing in 256-byte scenarios. The performance for 64B is still very unsatisfactory. It can be seen that even through optimized software implementation and hardware acceleration, it is impossible to obtain better small packet forwarding performance in small packet scenarios. Therefore, it is necessary to analyze why there is a bottleneck in small packet scenarios and solve the problem from the root cause. The present invention starts with the interactive analysis of the ring implemented at the bottom layer of Virtio1.1, analyzes the entire process of message sending, analyzes the rationality and optimization points of the process, and finally achieves the improvement of small packet forwarding performance and the reduction of latency by reducing the number of front-end and back-end interactions within Virtio.

[0082] Reference Figure 3 , which shows a flow chart of a transmission optimization method based on Virtio-net provided by an embodiment of the present invention, the method includes:

[0083] S301: query the driver module in the Virtio front end for packets to be sent. If there are packets to be sent, generate a descriptor and update avail idx. The packets to be sent constitute the target message; availidx is a pointer to the ring.

[0084] Optionally, after querying the to-be-sent packet through the driver module in the Virtio front-end and before generating the descriptor, the method further includes:

[0085] The packet to be sent is sent to the buffer corresponding to skb. skb is a socket buffer.

[0086] Specifically, the target message to be sent will be divided into multiple small packets. The driver module will poll the packet to see if the user application has a packet to send. Once a packet needs to be sent, the packet will first go to the skb corresponding cache, and then generate a valid send descriptor and update the avail idx.

[0087] Optionally, in an embodiment of the present invention, Figure 4 As shown in the figure, before the driver module polls for packets, it also includes a send initialization phase, which mainly completes some register configuration and function negotiation; negotiation offload related, and is performed synchronously with the receive initialization, and finally sets the device status register (device status register). When the driver is loaded successfully, the Virtio device can start sending work.

[0088] S302: Send a notify message to the backend device, where the notify message includes the ID information of the queue where the packet to be sent is located and the avail idx;

[0089] Specifically, the driver module notifies the backend device via a notify message, which includes the queue ID and the available IDx of the packet to be sent. Unlike prior art notifications, which only transmit the two-byte queue ID, this embodiment changes the notify message from a simple queue ID to a four-byte format consisting of the queue ID and the corresponding queue's available IDx. In an iowrite, the call is changed from iowrite16 to iowrite32, without adding any additional overhead. However, the backend driver does not need to perform an additional operation to obtain the available IDx of the queue.

[0090] Alternatively, the notify function in the current kernel code can be as follows:

[0091] static void vp_notify(struct virtqueue*vq)

[0092] {

[0093] struct Virtio_pci_device*vp_dev=to_vp_device(vq->vdev);

[0094] / *we write the queue′s selector into the notification register to

[0095] *signal the other end* /

[0096] iowrite16(vq->index,vp_dev->ioaddr+VIRTIO_PCI_QUEUE_NOTIFY);

[0097] }

[0098] In the prior art, the purpose of notify is for the front end to tell the back end driver which queue has a message to be processed, and then the first direct memory access (DMA) read operation is to obtain the availidx of the queue; the second DMA read is to use the avail idx information obtained for the first time and the last avail idx saved locally to perform a difference comparison, calculate how many avail descriptors are available, and then initiate the reading of these descriptors to be transported back to the back end; the third DMA read is to consume these transported descriptors and use the descriptor information to transport the real message data. The DMA write operation after the transport is completed is for the back end driver to write back the descriptor information to inform the front end driver that these packets have been processed, the descriptors can be recycled, and the corresponding cache can be released. It can be seen that to send a message, one notify, i.e., MMIO operation, three DMA read operations and one DMA write operation are required, and in the embodiment of the present invention, one DMA read operation can be reduced by optimizing the notify function.

[0099] S303: Obtaining the descriptor according to the notify information through the backend device;

[0100] Optionally, obtaining the descriptor according to the notify information by the backend device includes:

[0101] Calculating the number of the descriptors according to the notify information by the backend device;

[0102] The descriptor is obtained by the DMA engine of the backend device in N times, where the value of N is determined by the quantity, and N is a positive integer.

[0103] Specifically, the backend device will calculate how many descriptors need to be processed for this notify based on the notify information, and the backend DMA engine will obtain the available descriptors once or several times.

[0104] S304: Obtain the packet to be sent according to the descriptor to transfer the target message to the backend device side.

[0105] Optionally, after obtaining the packet to be sent according to the descriptor to transfer the target message to the backend device side, the method further includes:

[0106] The target message is forwarded to the network side through the DMA engine.

[0107] Specifically, the back-end device side directly uses the descriptor with valid sending direction to send a read request, with the purpose of moving the message from the host side memory to the back-end device side. If a packet is relatively large, multiple requests may be issued. Then the DMA sending engine will move the data packet from the host side memory to the back-end device and forward it to the network side.

[0108] In the Virtio notify mechanism provided by the embodiment of the present invention, regardless of whether the packet being transmitted is large or small, because the notify content additionally carries the queue's avail IDx, the back-end driver implemented in the FPGA does not need to read the avail IDx through DMA without any additional overhead, saving one DMA read operation, which can reduce overhead by 2-4 μs, effectively improving small packet forwarding performance and reducing latency.

[0109] In a possible implementation, after forwarding the target message to the network side by the DMA engine, the method further includes:

[0110] The used information of the descriptor is updated, and the descriptor is recycled according to the attribute of the used information by the driver module.

[0111] Specifically, after moving the data in memory, the used information in the descriptor is written back. As the user application continues to send packets, the device will repeat steps S301-S303. It is worth noting that the Virtio specification does not require descriptors to be updated for each packet. Therefore, the device will adopt a mechanism similar to NAPI (NEW API). After transferring multiple messages from the host side, it will update multiple descriptors at once, or use the new Virtio1.1 in-order feature to update the latest information. All consumed descriptors before the descriptor can be recycled. The driver will continuously monitor the update of the used attribute of the descriptor, reclaim descriptor resources in a timely manner, and increase the number of allocable descriptors. Ultimately, it can achieve rapid recycling and reuse, thereby achieving the goal of improving performance.

[0112] In a possible implementation, after updating the used information of the descriptor, the method further includes:

[0113] MSIx interrupt information is sent to the Virtio front end through the back end device.

[0114] Specifically, after completing the flag update of the descriptor, the back-end device can send an MSIx interrupt to the front-end driver module as needed.

[0115] In a possible implementation, the notify message includes multiple sub-notify messages. After sending the notify message to the backend device, the method further includes:

[0116] The notify information is processed by a polling algorithm, and when the number of the plurality of sub-notify messages reaches a preset value, the descriptor is obtained according to the notify information by the back-end device.

[0117] Because Smart NICs implement numerous functions through SR-IOV (Single Root I / O Virtualization) or SIOV (Scalable IOV) technology, and each function can support multiple queues, a round-robin algorithm is used to process notify messages. Notify messages written by the CPU are not processed immediately in real time. Instead, they are cached in the FPGA's internal BRAM. The available IDs for the same function and queue are iterated. In high-traffic, multi-queue scenarios, the descriptor handling engine handles an accumulated number of descriptors from multiple notify messages. This reduces the total number of DMA operations required to handle the same number of descriptors.

[0118] like Figure 5 The figure shows a schematic diagram of the FPGA-based notify processing flow. In this embodiment of the present invention, the back-end driver implemented by the FPGA stacks the queue's notify. Regardless of whether the packet is large or small, each queue stacks the notify due to the use of the round-robin algorithm. This optimized mechanism allows the descriptor handling engine to fetch more descriptors at a time and supports burst reading of descriptors, eliminating the fragmented operation of traditional frequent descriptor fetching.

[0119] The descriptor structure in Virtio1.1 is as follows:

[0120] struct vring_packed_desc{

[0121] / *Buffer Address.* /

[0122] __le64 addr;

[0123] / *Buffer Length.* /

[0124] __le32 len;

[0125] / *Buffer ID.* /

[0126] __le16 id;

[0127] / *The flags depending on descriptor type.* /

[0128] __le16 flags;

[0129] };

[0130] Each descriptor is 16 bytes. In extreme cases, when a packet is notified once, the descriptor handling engine handles one descriptor per DMA read request. However, for the PCIe DMA engine inside the FPGA, its maximum request unit (maxread request size) is generally 256 / 512 bytes, and the user bus width on the user side is 64B or 128B. This means that in a DMA read request, the overhead of reading 16 bytes and reading 128 bytes is basically the same. In the small packet scenario, a notify fetches a 16-byte descriptor and then a 64-byte data packet, for a total of 80 bytes of data, but consumes the RTT (round-trip time) of two DMA reads.

[0131] To further optimize and reduce the number of DMAs in the case of small packets, in one possible implementation, the flag reserved field of the descriptor is provided with a flag bit, the flag bit indicating the length of the message, and after generating the descriptor, the method further includes:

[0132] Update the flag information of the descriptor according to the byte length of the target message;

[0133] Wherein, when the byte length of the target message is greater than or equal to a preset value, the value of the flag bit is updated to a first value;

[0134] When the byte length of the target message is less than a preset value, the value of the flag bit is updated to a second value.

[0135] Specifically, the driver module polls for packets. When the user application has a packet to send, the packet will first be placed in the skb corresponding cache, and then a valid send descriptor will be generated. The descriptor and its internal avail flag will be updated, and finally the backend will be notified in a notify manner.

[0136] In the embodiment of the present invention, the structure of the descriptor can be further optimized, thereby modifying the allocation descriptor in Virtio-net and proposing a merge-desc concept, that is, setting a merge-desc, such as Figure 6 As shown, its size is 128 bytes. In the sending process, the length information in the descriptor is used for judgment. When the length of the message sent is less than or equal to 112 bytes, we enable the merge message format. If it is greater than 112 bytes, we use the original mode, which is distinguished by the flag reserved field in the original descriptor. Figure 6 shown.

[0137] In an embodiment of the present invention, bit 3 of the original 16-bit flag is taken out as a MERGR identifier. When the byte length of the target message is greater than or equal to a preset value, the value of the flag bit is updated to a first value. When the byte length of the target message is less than the preset value, the value of the flag bit is updated to a second value.

[0138] For example, if the message to be sent is larger than 112 bytes, this bit is 0. If the message to be sent is less than or equal to 112 bytes, its value is 1. When the application requests sg through skb, the driver will directly use the in-order feature in the Virtio packed queue to fill the message content into the next 7 descriptor positions, that is, use the descriptor information to carry the message content, such as Figure 7 As shown in the figure, under this mechanism, even if the message length does not reach 112 bytes, the descriptors following the merge desc cannot be called by the application. New service messages can only be used starting from the 8th descriptor.

[0139] The corresponding driver modifications are as follows:

[0140]

[0141]

[0142]

[0143] The embodiment of the present invention introduces merge-desc and sets the MERGE bit in the flag. While being compatible with the current Virtio front-end and back-end interaction mechanism, it places messages with a length of less than or equal to 112 bytes in the descriptor table memory. Without introducing additional overhead, this further reduces one DMA read operation, that is, further reduces the overhead by 2-4 μs. In addition, the reduction in the number of DMA reads also directly speeds up the recovery of descriptors, and the delay of message processing will also be greatly reduced.

[0144] Optionally, after updating the flag information of the descriptor according to the byte length of the target message, the method further includes:

[0145] When the byte length of the target message is greater than or equal to a preset value, storing the packet to be sent in the memory pointed to by the descriptor;

[0146] When the byte length of the target message is less than a preset value, the packet to be sent is stored in the memory in the descriptor.

[0147] The obtaining the packet to be sent according to the descriptor includes:

[0148] When the byte length of the target message is greater than or equal to a preset value, sending a read request according to the descriptor to obtain the packet to be sent from the memory pointed to by the descriptor;

[0149] When the byte length of the target message is less than a preset value, the packet to be sent is obtained from the memory of the descriptor.

[0150] In this embodiment of the present invention, the concept of merge-desc is introduced. The MERGE bit is set in the reserved flag field of the existing descriptor format to distinguish long and short packets. This, combined with the in-order nature of Virtio packed queues, allows for the determination of whether the actual packet content is stored in the descriptor table's memory or the memory pointed to by the descriptor. When a packet is smaller than 112 bytes, the packet is split into the next seven descriptor segments, enabling a notify mechanism to transfer the packet from the Virtio front-end to the FPGA-based back-end. This further reduces the need for a DMA operation for small packets, improving Virtio-net's performance for small packets and reducing latency.

[0151] Example 2

[0152] Reference Figure 8 , shows a schematic structural diagram of a Virtio-net-based transmission optimization device 80 provided in an embodiment of the present invention, including:

[0153] A generation module 801 is configured to query a driver module in the Virtio front-end for packets to be sent, and if there are packets to be sent, generate a descriptor and update availidx, wherein the packets to be sent constitute a target message;

[0154] The first sending module 802 is used to send a notify message to the backend device, where the notify message includes the ID information of the queue where the packet to be sent is located and the availability;

[0155] A first acquisition module 803 is configured to obtain the descriptor according to the notify information through the backend device;

[0156] The transport module 804 is used to obtain the packet to be sent according to the descriptor to transport the target message to the back-end device side.

[0157] Optionally, the device 80 further includes:

[0158] The second sending module 805 sends the packet to be sent to the buffer corresponding to skb.

[0159] Optionally, the first acquisition module includes:

[0160] A calculation module 806 is configured to calculate the number of the descriptors according to the notify information through the backend device;

[0161] The first acquisition submodule 8031 is configured to obtain the descriptor N times through the DMA engine of the backend device, where the value of N is determined by the quantity, and N is a positive integer.

[0162] Optionally, the device 80 further includes:

[0163] The third sending module 807 is configured to forward the target message to the network side through the DMA engine.

[0164] Optionally, the device 80 further includes:

[0165] The first updating module 808 is configured to update the used information of the descriptor and reclaim the descriptor according to the attributes of the used information through the driver module.

[0166] Optionally, the device 80 further includes:

[0167] The fourth sending module 809 is configured to send MSIx interrupt information to the Virtio front end through the backend device.

[0168] Optionally, the device 80 further includes:

[0169] The second acquisition module 810 is configured to process the notify message through a polling algorithm, and obtain the descriptor according to the notify message through the backend device when the number of the plurality of sub-notify messages reaches a preset value.

[0170] Optionally, the device 80 further includes:

[0171] A second updating module 811 is configured to update the flag information of the descriptor according to the byte length of the target message;

[0172] Wherein, when the byte length of the target message is greater than or equal to a preset value, the value of the flag bit is updated to a first value;

[0173] When the byte length of the target message is less than a preset value, the value of the flag bit is updated to a second value.

[0174] Optionally, the device 80 further includes:

[0175] A fifth sending module 812 is configured to store the packet to be sent in the memory pointed to by the descriptor if the byte length of the target message is greater than or equal to a preset value;

[0176] When the byte length of the target message is less than a preset value, the packet to be sent is stored in the memory in the descriptor.

[0177] Optionally, the first acquisition module further includes:

[0178] The second acquisition submodule 8032 is configured to, when the byte length of the target message is greater than or equal to a preset value, send a read request according to the descriptor to obtain the packet to be sent from the memory pointed to by the descriptor;

[0179] When the byte length of the target message is less than a preset value, the packet to be sent is obtained from the memory of the descriptor.

[0180] The Virtio-net-based transmission optimization device 80 provided in the embodiment of the present invention can implement each process implemented in the above method embodiment. To avoid repetition, it will not be repeated here.

[0181] In an embodiment of the present invention, a generation module is used to query the packet to be sent through the driver module in the Virtio front-end, and if there is a packet to be sent, a descriptor is generated and availidx is updated. The packet to be sent constitutes a target message. The first sending module is used to send a notify message to the back-end device. The notify message includes the ID information of the queue where the packet to be sent is located and the availidx. The first acquisition module is used to obtain the descriptor according to the notify message through the back-end device. The transport module is used to obtain the packet to be sent according to the descriptor to transport the target message to the back-end device side. In the Virtionotify mechanism provided by the embodiment of the present invention, regardless of whether a large packet or a small packet is transmitted, since the content of the notify additionally carries the availidx of the queue, the back-end driver implemented by the FPGA does not need to read availidx through DMA without additional overhead, saving one DMA read operation, which can effectively improve the small packet forwarding performance and reduce latency.

[0182] The virtual system in the embodiment of the present invention may be a device, or a component, an integrated circuit, or a chip in a terminal.

[0183] In addition, it should be noted that the device embodiments described above are merely illustrative and do not limit the scope of protection of the present invention. In actual applications, technicians in this field can select some or all of the modules according to actual needs to achieve the purpose of the present embodiment, and no restrictions are imposed here.

[0184] In addition, for technical details not fully described in this embodiment, please refer to the intelligent cognitive method and system provided in any embodiment of the present invention, and will not be repeated here.

[0185] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A transmission optimization method based on Virtio-net, characterized in that: The method comprises: Querying the driver module in the Virtio front-end for packets to be sent, and if there are packets to be sent, generating a descriptor and updating avail idx, wherein the packets to be sent constitute the target message; Send a notify message to the backend device, where the notify message includes the ID information of the queue where the packet to be sent is located and the avail idx; Obtaining the descriptor according to the notify information by the backend device; The packet to be sent is obtained according to the descriptor, so as to transport the target message to the back-end device side.

2. The method according to claim 1, characterized in that After querying the to-be-sent packet through the driver module in the Virtio front end and before generating the descriptor, the method further includes: Send the packet to be sent to the buffer corresponding to skb.

3. The method according to claim 1, characterized in that Obtaining the descriptor according to the notify information by the backend device includes: Calculating the number of the descriptors according to the notify information by the backend device; The descriptor is obtained by the DMA engine of the backend device in N times, where the value of N is determined by the quantity, and N is a positive integer.

4. The method according to claim 3, characterized in that After obtaining the packet to be sent according to the descriptor to transfer the target message to the back-end device side, the method further includes: The target message is forwarded to the network side through the DMA engine.

5. The method according to claim 4, characterized in that After forwarding the target message to the network side by the DMA engine, the method further includes: The used information of the descriptor is updated, and the descriptor is recycled according to the attribute of the used information by the driver module.

6. The method according to claim 5, characterized in that After updating the used information of the descriptor, the method further includes: MSIx interrupt information is sent to the Virtio front end through the back end device.

7. The method according to claim 1, characterized in that The notify message includes a plurality of sub-notify messages. After sending the notify message to the backend device, the method further includes: The notify information is processed by a polling algorithm, and when the number of the plurality of sub-notify messages reaches a preset value, the descriptor is obtained according to the notify information by the back-end device.

8. The method according to claim 1, characterized in that The flag reserved field of the descriptor is provided with an identification bit, and the identification bit indicates the length of the message. After generating the descriptor, the method further includes: Update the flag information of the descriptor according to the byte length of the target message; Wherein, when the byte length of the target message is greater than or equal to a preset value, the value of the flag bit is updated to a first value; When the byte length of the target message is less than a preset value, the value of the flag bit is updated to a second value.

9. The method according to claim 8, characterized in that After updating the flag information of the descriptor according to the byte length of the target message, the method further includes: When the byte length of the target message is greater than or equal to a preset value, storing the packet to be sent in the memory pointed to by the descriptor; When the byte length of the target message is less than a preset value, the packet to be sent is stored in the memory in the descriptor.

10. The method according to claim 9, characterized in that The obtaining the packet to be sent according to the descriptor includes: When the byte length of the target message is greater than or equal to a preset value, a read request is sent according to the descriptor to obtain the packet to be sent from the memory pointed to by the descriptor; when the byte length of the target message is less than the preset value, the packet to be sent is obtained from the memory of the descriptor.

Citation Information

Patent Citations

  • IO virtualization device based on multi-queue gigabit Ethernet controller

    CN108920252A

  • Interaction control method and equipment system

    CN110489358A