Network card device, network data transmission method, apparatus, and system, device, and medium
By using programmable devices and memory expansion technology in network card devices, the transmission method is determined based on the message type of network data and directly stored in extended memory, solving the problem of low network data transmission efficiency in the prior art and achieving more efficient data transmission.
Patent Information
- Application Number
- PCT/CN2024/135313
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-12-22
- Filing Date
- 2024-11-28
- Publication Date
- 2025-06-26
AI Technical Summary
In the prior art, in the process of network data transmission, the use of DMA modules for data transfer is not efficient, especially for data that does not require host processing, resulting in low data transmission efficiency of the entire network.
By utilizing programmable devices and memory expansion technology, the host configures the memory in the programmable devices as extended memory, determines the optimal data transmission method according to the type of packets to be transmitted, and stores it directly into the extended memory, avoiding storage in the host memory through the DMA module.
It effectively improves the transmission efficiency of network data, especially for data that does not require host processing, which can be directly stored in extended memory, reducing unnecessary data transfer operations.
Smart Images

Figure CN2024135313_26062025_PF_FP_ABST
Abstract
Description
Network card device, network data transmission method, device, system, equipment and medium
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application claims priority to the Chinese patent application filed with the China Patent Office on December 22, 2023, with application number 202311786763.9, and application name “Network card equipment, network data transmission method, device, system, equipment and medium”, all contents of which are incorporated by reference in this application. Technical Field
[0003] The present application relates to the field of Internet technology, and in particular to a network card device, a network data transmission method, an apparatus, a system, an electronic device, and a non-volatile readable storage medium. Background Art
[0004] Network data is data transmitted on the Internet and other network environments. It can be structured and organized data information, raw data that has not been processed in any way, or published and received audio and video data.
[0005] During the transmission and reception of network data, related technologies use the network card's DMA (Direct Memory Access) module to move data. When sending network data, the DMA module transfers data from the host's memory to the receiving device's cache. When receiving network data, the DMA module transfers data from the sending end's cache to the host's memory. However, for certain application scenarios, such as data that doesn't require host processing, using the DMA module to move network data is inefficient, resulting in lower overall network data transmission efficiency. Summary of the Invention
[0006] The present application provides a network card device, a network data transmission method, an apparatus, a system, an electronic device and a non-volatile readable storage medium, which can effectively improve the transmission efficiency of network data.
[0007] To solve the above technical problems, this application provides the following technical solutions:
[0008] Some embodiments of the present application provide a network device, including a programmable device, wherein the programmable device builds a network platform based on a memory extension method, which includes a network interface, a target memory, and a network component;
[0009] The programmable device is connected to the network through a network interface and exchanges data with the host through a memory expansion method. The host sets the target memory of the programmable device as the extended memory of the host based on the memory expansion method. The network component transmits data using a data transmission method that matches the data packet type of the data to be transmitted.
[0010] The data to be transmitted is the target network data received or the network data to be sent by the host; the data message type is determined according to the data type and data length of the data to be transmitted; and the extended memory is used to store the data to be transmitted that belongs to the message type processed by the network card.
[0011] In some embodiments, the network components include a media access control layer module, a direct memory access module, a buffer, and a packetizer;
[0012] The media access control layer module is used to store the target network data received from the network into the buffer, and is also used to send the to-be-sent network data in the buffer to the network;
[0013] The packetizer is used to identify the data packet type of the target network data and determine the corresponding storage location according to the data packet type of the target network data; it is also used to store the to-be-sent network data read from the target memory or from the host memory through the direct memory access module into the transmission buffer; wherein the storage location includes the host memory and the target memory.
[0014] In some embodiments, the central processing unit of the host accesses the target memory through a memory copy method; the message type processed by the network card includes a data message type whose data length is less than a length threshold;
[0015] If the data to be transmitted is target network data and the data length of the data to be transmitted is less than the length threshold, the network component stores the data to be transmitted in the target memory and sends a message data read instruction to the host;
[0016] If the data to be transmitted is network data to be sent, and the data length of the data to be transmitted is less than the length threshold, the host moves the data to be transmitted to the target memory through a memory copy method.
[0017] In some embodiments, the network component includes a direct memory access module, and the central processing unit of the host accesses the target memory through direct memory access; the message type processed by the network card does not include a data message type whose data length is greater than a length threshold;
[0018] If the data to be transmitted is target network data and the data length of the data to be transmitted is greater than the length threshold, the network component moves the data to be transmitted to the memory of the host through the direct memory access module;
[0019] If the data to be transmitted is network data to be sent, and the data length of the data to be transmitted is greater than the length threshold, the host stores the data to be transmitted in the host's memory and sends a message data read instruction to the network component.
[0020] In some embodiments, the programmable device uses a field programmable logic gate array and a network platform is built based on computing high-speed interconnect technology;
[0021] The host configures the target memory of the field programmable logic gate array as an extended memory by computing a high-speed interconnection technology;
[0022] The data to be transmitted is the target network data, and the field programmable logic gate array identifies the data message type of the data to be transmitted. If the data to be transmitted belongs to the target preset data type and / or the data length of the data to be transmitted is less than the length threshold, the data to be transmitted is stored in the target memory; the data to be transmitted is the network data to be sent, and the host identifies the data message type of the data to be transmitted. If the data to be transmitted belongs to the target preset data type and / or the data length of the data to be transmitted is less than the length threshold, the data to be transmitted is stored in the target memory of the field programmable logic gate array through memory copy.
[0023] Some embodiments of the present application provide a network data transmission method, including:
[0024] Get the data to be transmitted;
[0025] Based on any of the above network card devices, a matching data transmission mode is determined according to the data message type of the data to be transmitted, so as to perform network transmission on the data to be transmitted according to the data transmission mode.
[0026] In some embodiments, the data to be transmitted is target network data received from a network, and the network card device identifies a data packet type of the data to be transmitted; and determines a matching data transmission mode according to the data packet type of the data to be transmitted, including:
[0027] If the data message type of the data to be transmitted belongs to the message type processed by the network card, the data to be transmitted is stored in the target memory of the network card device, and a message data read instruction is sent to the host;
[0028] If the data message type of the data to be transmitted belongs to the host processing message type, the data to be transmitted is stored in the host memory through the direct memory access module.
[0029] In some embodiments, determining a matching data transmission mode according to the data packet type of the data to be transmitted includes:
[0030] If the data type of the data to be transmitted is a preset data type, the data message type of the data to be transmitted belongs to the network card processing message type; wherein the preset data type is data that is not stored in the memory of the host;
[0031] If the data length of the data to be transmitted is less than the length threshold, the data message type of the data to be transmitted belongs to the message type processed by the network card.
[0032] In some embodiments, the host accesses the target memory through a memory copy method, including:
[0033] If the data to be transmitted belongs to the first preset data type, the host reads the data to be transmitted and directly discards the data to be transmitted;
[0034] If the data to be transmitted belongs to the second preset data type, the host reads the data to be transmitted and forwards the data to be transmitted;
[0035] If the data length of the data to be transmitted is less than the length threshold, the host calls the memory copy function to copy the data to be transmitted to the host's memory, so that the host can access the target memory through the memory copy method.
[0036] In some embodiments, the host accesses the target memory through a memory copy method, including:
[0037] If the data to be transmitted is cyclic redundancy check code data, the host reads the data to be transmitted and directly discards the data to be transmitted;
[0038] If the data to be transmitted is a message to be forwarded, the host reads the data to be transmitted and forwards the data to be transmitted to the target address.
[0039] In some embodiments, before determining a matching data transmission mode according to the data packet type of the data to be transmitted, the method further includes:
[0040] Perform data transmission on test data of different data lengths based on memory copy mode and direct memory access mode respectively, and calculate the corresponding transmission time;
[0041] Compare and analyze the transmission time required for test data of the same data length transmitted by the memory copy method and the direct memory access method, and determine the data length corresponding to the same transmission time required by the memory copy method and the direct memory access method, which is used as the length threshold.
[0042] In some embodiments, before determining a matching data transmission mode according to the data packet type of the data to be transmitted, the method further includes:
[0043] When a length threshold configuration instruction input by a user is received, the length threshold is obtained by parsing the length threshold configuration instruction, and the length threshold is stored in a target location.
[0044] In some embodiments, the data to be transmitted is network data to be sent by the host. The host identifies the data packet type of the data to be transmitted and determines a matching data transmission mode according to the data packet type of the data to be transmitted, including:
[0045] If the data message type of the data to be transmitted belongs to the message type processed by the network card, the data to be transmitted is stored in the target memory of the network card device, and a message data reading instruction is sent to the network card device;
[0046] If the data message type of the data to be transmitted belongs to the host processing message type, the data to be transmitted is stored in the host memory, and a message data reading instruction is sent to the network card device.
[0047] In some embodiments, determining a matching data transmission mode according to the data packet type of the data to be transmitted includes:
[0048] Pre-constructing storage data index information in the target memory of the network card device; the storage data index information is used to record storage location information of received and sent messages;
[0049] Based on the data message type of the data to be transmitted, update the stored data index information;
[0050] The data transmission mode corresponding to the data to be transmitted is determined according to the stored data index information and the sender information of the data to be transmitted.
[0051] In some embodiments, the data to be transmitted is target network data, and determining the data transmission mode corresponding to the data to be transmitted based on the stored data index information and the sender information of the data to be transmitted includes:
[0052] Preliminarily constructing a network card message receiving queue in the target memory of the network card device and a host message receiving queue in the memory of the host;
[0053] The queue pointers of the receiving producers corresponding to the network card message receiving queue and the host message receiving queue are respectively pointed to the corresponding initialization positions in advance; the receiving producers include the buffer producer and the direct memory access module producer;
[0054] Based on the receiving queue that stores data index information, if the data to be transmitted belongs to the network card processing message type, the data to be transmitted is stored in the pointer position of the buffer producer in the network card message receiving queue, and the pointer of the buffer producer is moved down; if the data to be transmitted belongs to the host processing message type, the data to be transmitted is stored in the pointer position of the direct memory access module producer in the host message receiving queue, and the pointer of the direct memory access module producer is moved down.
[0055] In some embodiments, after the data to be transmitted is transmitted over the network according to the data transmission mode, the method further includes:
[0056] The queue pointers of the receiving consumers corresponding to the network card message receiving queue and the host message receiving queue are respectively pointed to the corresponding initialization positions in advance; the receiving consumer is the message data receiving and sending thread of the host; the pointer position of the receiving consumer is smaller than the pointer position of the receiving producer;
[0057] The host determines the storage position of the storage queue corresponding to the data to be transmitted according to the receiving queue, reads the data to be transmitted according to the storage position of the data to be transmitted, and moves the pointer of the receiving consumer downward.
[0058] In some embodiments, the data to be transmitted is network data to be sent, and determining the data transmission mode corresponding to the data to be transmitted according to the stored data index information and the sender information of the data to be transmitted includes:
[0059] Preliminarily constructing a network card message sending queue in the target memory of the network card device and a host message sending queue in the memory of the host;
[0060] The queue pointers of the sending producers corresponding to the network card message receiving queue and the host message receiving queue are respectively pointed to the corresponding initialization positions in advance; the sending producer is the message data sending and receiving thread of the host;
[0061] The queue pointer of the sending producer corresponding to the sending queue storing the data index information is pointed to the corresponding initialization position in advance, and the pointer position of the sending producer is moved down when the sending queue is updated;
[0062] Based on the sending queue that stores data index information, if the data to be transmitted belongs to the network card processing message type, the data to be transmitted will be stored in the network card message receiving queue, and the pointer of the sending producer will be moved down; if the data to be transmitted belongs to the host processing message type, the data to be transmitted will be stored in the host message receiving queue, and the pointer of the sending producer will be moved down.
[0063] In some embodiments, after the data to be transmitted is transmitted over the network according to the data transmission mode, the method further includes:
[0064] The queue pointers of the sending consumers corresponding to the network card message sending queue and the host message sending queue are respectively pointed to corresponding initialization positions in advance; the sending consumers are buffer consumers and direct memory access module consumers; the pointer position of the sending consumer is smaller than the pointer position of the sending producer;
[0065] Based on the sending queue of the stored data index information, if the data to be stored belongs to the network card processing message type, the data to be stored is read from the network card message sending queue and the pointer of the cache consumer is moved down; if the data to be stored belongs to the host processing message type, the data to be stored is read from the host message sending queue and the pointer of the direct memory access module consumer is moved down.
[0066] Some embodiments of the present application provide a network data transmission device, including:
[0067] A data acquisition module, used to acquire data to be transmitted;
[0068] The network transmission module is used to determine a matching data transmission mode according to the data message type of the data to be transmitted based on any of the above network card devices, so as to perform network transmission on the data to be transmitted according to the data transmission mode.
[0069] Some embodiments of the present application further provide an electronic device comprising a processor, wherein the processor is configured to implement the steps of any of the foregoing network data transmission methods when executing a computer program stored in a memory.
[0070] Some embodiments of the present application further provide a non-volatile readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of any of the above network data transmission methods are implemented.
[0071] Some embodiments of the present application provide a network data transmission system, including a host, a network card device as described in the previous item, and a processor;
[0072] The processor is used to implement the steps of any of the above network data transmission methods when executing the computer program stored in the memory.
[0073] The advantage of the technical solution provided by the present application is that the function of a high-performance network card is realized by using programmable devices and memory expansion technology. The host configures a piece of memory in the programmable device as an extended memory that it can use through memory expansion technology. The extended memory can be used to store network data of pre-specified message types without having to be stored in the host's memory. Some network data that does not require host processing and has low data transfer efficiency using a direct memory access module can be directly stored in the extended memory. That is, the optimal data transmission method is determined according to the message data type of the data to be transmitted, thereby effectively improving the transmission efficiency of network data.
[0074] In addition, the present application also provides corresponding network data transmission methods, implementation devices, systems, electronic devices and non-volatile readable storage media for network card devices, further making the network card devices more practical and feasible. The network data transmission methods, devices, electronic devices, systems and non-volatile readable storage media have corresponding advantages.
[0075] It should be understood that the foregoing general description and the following detailed description are merely illustrative and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0076] In order to more clearly illustrate the technical solutions of the present application or related technologies, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0077] FIG1 is a schematic diagram of a data receiving process of a network card device in the related art provided by this application;
[0078] FIG2 is a schematic diagram of a data transmission process of a network card device in the related art provided by this application;
[0079] FIG3 is a schematic diagram of a structural framework of a specific embodiment of a network card device provided by the present application;
[0080] FIG4 is a schematic diagram of the structural framework of another specific embodiment of the network card device provided by the present application;
[0081] FIG5 is a schematic diagram of a host accessing extended memory provided by the present application;
[0082] FIG6 is a flow chart of a network data transmission method provided by the present application;
[0083] FIG7 is a schematic diagram of the structural framework of the network transmission system provided by the present application in an exemplary embodiment;
[0084] FIG8 is a schematic diagram of a message data receiving process based on FIG7 provided by the present application;
[0085] FIG9 is a schematic diagram of a host data reading process based on FIG7 provided by the present application;
[0086] FIG10 is a schematic diagram of a message data sending process based on FIG7 provided by the present application;
[0087] FIG11 is a schematic diagram of the host data sending process based on FIG7 provided by this application;
[0088] FIG12 is a structural diagram of a specific embodiment of the network data transmission device provided by the present application;
[0089] FIG13 is a structural diagram of a specific embodiment of an electronic device provided by this application;
[0090] FIG14 is a structural diagram of another specific implementation of the network data transmission system provided in this application. DETAILED DESCRIPTION
[0091] In order to enable those skilled in the art to better understand the technical solution of the present application, the present application is further described in detail below in conjunction with the accompanying drawings and specific embodiments. Among them, the terms "first", "second", "third", "fourth", etc. in the specification, claims, and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. The term "exemplary" means "used as an example, embodiment, or illustrative." Any embodiment described here as "exemplary" is not necessarily to be interpreted as being superior or better than other embodiments.
[0092] It is understandable that a network card is a piece of computer hardware that enables a computer host to communicate on a computer network. Traditionally, a network card is plugged into the host bus as an expansion card. However, due to its low price and the ubiquity of the Ethernet standard, computer hosts now have network interfaces integrated into their motherboards. These motherboards either integrate Ethernet functionality into the motherboard processor, or connect a cheap network card to the host motherboard via the PCI-Express (Peripheral Component Interconnect Express) bus.
[0093] For a network transmission system that connects a network card to a host via a PCI-Express bus, the host performs preliminary initialization: it allocates two memory spaces in its local memory, namely, memory space 1 and memory space 2, which are used to store received and transmitted data packets, respectively. After initialization, network data packet transmission and reception operations begin. The corresponding data packet reception process is shown in Figure 1 and includes: 1. The network card receives network data through the network port and caches the data in the MAC (Media Access Control) module; 2. The MAC module sends a data transfer command to the DMA (Direct Memory Access) module to perform the data transfer. 3. The DMA module transfers the received message data to the host's first memory block and then notifies the host's message data transmission and reception thread to read the corresponding data. This thread then retrieves the corresponding message data from the first memory block. The corresponding data packet transmission process, shown in Figure 2, includes: 1. The message data transmission and reception thread stores the transmitted message data in the second memory block and sends a data read instruction to the network card. 2. The NIC's DMA module retrieves the transmit data from the host's secondary memory and stores it in the NIC's cache. 3. The MAC module retrieves the transmit data from the cache and begins processing the data. 4. The network port completes the data transmission process.
[0094] Combining Figures 1 and 2, it can be seen that the related art uses a DMA module to move data during both the reception and transmission of network data. Transmission is performed from the host's memory to the network card's cache, and reception is performed from the network card's cache to the host's memory. During network transmission, some network data that does not require host processing, such as data with CRC (Cyclic Redundancy Check) errors, does not need to be moved to the host's memory and can be processed and discarded on the network card. Some message data is forwarded and does not need to be copied to the host's memory; it can be processed directly in the network card's memory. Furthermore, due to the DMA module's inherent operating properties, it is more suitable for moving large data. However, some data packets are too short, making DMA inefficient. Therefore, the related art's use of network cards for network data transmission is inefficient and fails to meet the actual needs of users.
[0095] In view of this, the present application utilizes programmable devices and memory expansion technology to realize the function of a high-performance network card. The host configures a piece of memory in the programmable device as an extended memory that it can use through the memory expansion technology. For some network data that does not need to be processed by the host and has low efficiency in moving data using the direct memory access module, it can be directly stored in the extended memory. There is no need to store all data in the host through the DMA module, thereby effectively improving the transmission efficiency of network data. After introducing the technical solution of the present application, various non-limiting embodiments of the present application are described in detail below. In order to better illustrate the present application, numerous specific details are given in the specific embodiments below. Those skilled in the art should understand that without these specific details, the present application can also be implemented. In other examples, the methods, means, components and circuits well known to those skilled in the art are not described in detail in order to highlight the main purpose of the present application.
[0096] First, please refer to FIG3 , which is a schematic diagram of a structural framework of a network card device provided in some embodiments of the present application in an exemplary implementation manner. Some embodiments of the present application may include the following contents:
[0097] The network card device may include a programmable device 31 , which builds a network platform based on a memory expansion method. The network platform built by the programmable device 31 may include a network interface 310 , a target memory 311 and a network component 312 .
[0098] In some embodiments of the present application, the programmable device 31 is connected to the network via a network interface 310. This network interface 310 can be pre-programmed to implement the transmission and reception of network data, that is, it can both receive target network data sent by the network and send network data to be sent by the host to the network. The entire process may include: receiving data packets from the network through a physical layer interface (such as an Ethernet interface), demodulating and decoding the received data packets at the physical layer, converting them into digital signals, and then passing the digital signals to a receive buffer. The data packets in the receive buffer are transmitted to a data processing unit. The data processing unit parses the data packets and extracts information such as the destination address, source address, and protocol type. Based on the protocol type, the data processing unit passes the data packets to the corresponding protocol processing unit, such as the TCP / IP (Transmission Control Protocol / Internet Protocol) protocol stack. The protocol processing unit performs protocol parsing and processing on the data packets, such as layered processing in the TCP / IP protocol stack. The protocol processing unit processes the data packets according to the protocol rules, such as checking checksums, fragment reassembly, and error detection. It can also perform some advanced functions such as packet filtering and flow control. After protocol processing, the data packets are transmitted to the send buffer. The data packets in the transmit buffer are transferred to the transmit data unit, which converts the data packets into digital signals and sends them to the network through the physical layer interface.
[0099] In some embodiments of the present application, the programmable device 31 is inserted into the host as a network card device, and the host can exchange data with the host through a memory expansion method. At the same time, when the host initializes and configures the programmable device 31, it can set the target memory 311 of the programmable device 31 as the host's extended memory based on the memory expansion method, so that the host can read and write to the extended memory. The programmable device 31 can be any device that can be programmed and can handle a large amount of complex transmission. The memory expansion method can be any memory expansion method provided by any memory expansion technology that can match the programmable device 31 and the host, which does not affect the implementation of the present application. Among them, the network component 312 is a set of hardware for implementing data transmission and reception. It can use a data transmission method that matches the data packet type of the data to be transmitted for data transmission. In some embodiments of the present application, the data to be transmitted is the target network data received from the network or the network data to be sent by the host received from the host end. The data packet type is determined according to the data type and data length of the data to be transmitted. That is, different data types of the data to be transmitted correspond to different data transmission methods, and different data lengths of the data to be transmitted correspond to different data transmission methods. In some embodiments of the present application, the data transmission mode refers to whether the data received from the data sending end is stored in the host memory or the target memory of the programmable device 31, that is, the extended memory. That is, the data transmission mode includes two transmission modes, one is to store the data received from the data sending end in the host memory, and the other is to store the data received from the data sending end in the extended memory of the programmable device 31. As for whether to store it in the host memory or the extended memory, it is determined by the data type and data length of the data to be transmitted. The data message type can be defined in advance and a unique identification number can be set for identification. For ease of description, in some embodiments of the present application, the data message type corresponding to the data received from the data sending end stored in the extended memory of the programmable device 31 is defined as a network card processing message type. The data to be transmitted corresponding to this network card processing message type either does not require host processing or is transferred to the host memory through the DMA module, which takes a long time. Therefore, in order to improve the efficiency of network data transmission, it is directly stored in the extended memory. The host can access the data in the extended memory and perform corresponding processing.
[0100] As can be seen from the above, some embodiments of the present application utilize programmable devices and memory expansion technology to realize the functions of a high-performance network card. The host configures a piece of memory in the programmable device as an extended memory that it can use through memory expansion technology. The extended memory can be used to store network data of pre-specified message types without having to be stored in the host's memory. For some network data that does not require host processing and has low data transfer efficiency using a direct memory access module, it can be directly stored in the extended memory. That is, the optimal data transmission method is determined according to the message data type of the data to be transmitted, thereby effectively improving the transmission efficiency of network data.
[0101] The above embodiment does not limit the structure of the network component 312 of the programmable device 31. Some embodiments of the present application further provide an exemplary implementation, as shown in FIG4 , which may include the following contents:
[0102] Network component 312 may include a media access control layer module 3120, a direct memory access module 3121, a buffer 3122, and a depacketizer 3123. The media access control layer module 3120 comprises a hardware controller and the MAC communication protocol. The direct memory access module 3121 is used to achieve efficient data transmission in the computer system without CPU intervention or data replication. The buffer 3122 is a cache space within the programmable device 31. The depacketizer 3123 is a device that incorporates a computer program for identifying data packet types and distributing data to be transmitted.
[0103] In some embodiments of the present application, the media access control layer module 3120 is configured to store target network data received from the network into a buffer 3122 and to transmit the network data to be transmitted from the buffer 3122 to the network. The packetizer 3123 is configured to identify the data packet type of the target network data and determine a corresponding storage location based on the data packet type of the target network data; the storage locations include the host's memory and the target memory. The packetizer 3123 is further configured to store the network data to be transmitted, read from the target memory or from the host's memory via the direct memory access module 3121, into the transmission buffer 3122.
[0104] On this basis, the host can access the extended memory on the programmable device 31 in two ways. As shown in Figure 5, the host's central processing unit can access the target memory through a memory copy method. For example, the extended memory can be accessed by calling a memory copy function such as memcpy (i.e., a memory copy function used in C and C++). For example, for the network card processing message type including a data message type whose data length is less than a length threshold, the implementation process of the memory copy method includes: if the data to be transmitted is the target network data, and the data length of the data to be transmitted is less than the length threshold, the network component stores the data to be transmitted in the target memory and sends a message data read instruction to the host; if the data to be transmitted is the network data to be sent, and the data length of the data to be transmitted is less than the length threshold, the host moves the data to be transmitted to the target memory through a memory copy method. Another access method is to move data through the DAM module, that is, to access the target memory in a direct memory access manner. Exemplarily, the network component includes a direct memory access module, and the network card processing message type does not include a data message type whose data length is greater than a length threshold; the implementation process of accessing the target memory by direct memory access may include: if the data to be transmitted is the target network data, and the data length of the data to be transmitted is greater than the length threshold, the network component moves the data to be transmitted to the host's memory through the direct memory access module; if the data to be transmitted is the network data to be sent, and the data length of the data to be transmitted is greater than the length threshold, the host stores the data to be transmitted in the host's memory and sends a message data read instruction to the network component. It can be seen that the two access methods provided in some embodiments of the present application are applicable to data of different lengths. The memory copy (such as memcpy function) method is more efficient when the data is short, and the DMA move is more efficient when the data is long. From the above, it can be seen that the network components of some embodiments of the present application can realize efficient transmission of the network data to be sent from the host and the target network data from the network through the MAC module, DMA module, buffer and packetizer.
[0105] It is understood that FPGAs (Field-Programmable Gate Arrays) implement a variety of logical functions through programming. This flexibility and reconfigurability allow FPGAs to be customized and optimized according to user needs, leading to their widespread application. Network cards need to process large amounts of data streams, including the reception, processing, and transmission of data packets. FPGAs have parallel processing capabilities. By designing efficient data paths and parallel computing units, high-speed data processing and transmission can be achieved. In other words, FPGAs have high-speed data processing capabilities, which can support the data processing capabilities required by network cards. FPGAs can be programmed and configured according to specific needs to implement a variety of logical functions. For network cards, data processing and transmission logic can be customized and optimized according to different network protocols and requirements to improve performance and efficiency. FPGAs can support a variety of interfaces and protocols, such as Ethernet and PCIe, through hardware design and programming. Furthermore, by designing adapters and interface circuits, FPGAs can connect and communicate with computer systems and networks. In other words, FPGAs can implement the interfaces and protocols required by network cards. Based on this, as an exemplary embodiment, the programmable device 31 described above can be an FPGA. In addition, CXL (Compute Express Link) can provide high-bandwidth, low-latency connections and can be used to connect FPGAs with processors, accelerators, storage and other devices. Therefore, some embodiments of the present application can combine it with FPGA to realize the function of a network card. Accordingly, the programmable device 31 can also include a CXL module as a functional module. The CXL module can interconnect the FPGA and CXL to realize the host's memory expansion function for the programmable device 31, which can realize high-performance network card functions and support high-speed data transmission and processing. The host configures the target memory of the FPGA as extended memory through the computing high-speed interconnection technology, that is, the CXL module. For the data receiving process, that is, the data to be transmitted is the target network data, the FPGA identifies the data message type of the data to be transmitted. If the data to be transmitted belongs to the target preset data type and / or the data length of the data to be transmitted is less than the length threshold, the data to be transmitted is stored in the target memory. For the data sending process, that is, the data to be transmitted is the network data to be sent by the host, the host identifies the data message type of the data to be transmitted. If the data to be transmitted belongs to the target preset data type and / or the data length of the data to be transmitted is less than the length threshold, the host stores the data to be transmitted in the target memory of the FPGA through memory copying. That is, the host stores the data to be sent to the network directly in its extended memory, rather than in its local memory.
[0106] Furthermore, consider that CXL's Type 3 (third generation) devices are a set of memory modules that provide persistent, volatile, or a combination of memory and support the .io (Input / Output) and .mem (memory) protocols. The CXL.io protocol can be used for device discovery, enumeration, error reporting, and management, allowing the device to be used for other I / O-specific applications. In the CXL.mem protocol, the host's CPU acts as the master device, sending requests, and the device acts as a slave device to reply. Therefore, Type 3 devices can be used as memory expanders for the host. Because there is no cache, the host's CPU does not need to snoop the device cache and can use the streamlined .mem protocol. Therefore, the host can expand memory by configuring CXL in TPYE3 mode.
[0107] As can be seen from the above, some embodiments of the present application can be programmed and optimized according to specific needs by leveraging the flexibility and customizability of FPGAs. By utilizing CXL to provide high-speed interconnection and interface support, high-bandwidth, low-latency connections with other devices can be achieved. Thus, the combination of FPGA and CXL can realize high-performance network card functions.
[0108] In addition, based on the network card device provided in the above embodiment, the present application also provides an implementation process for sending and receiving data based on the network card device, that is, a network data transmission method. Please refer to Figure 6, which is a flow chart of a network data transmission method provided in some embodiments of the present application. Some embodiments of the present application may include the following:
[0109] S601: Acquire data to be transmitted.
[0110] The data to be transmitted may be target network data received from the network or network data to be sent from the host.
[0111] S602: Determine a matching data transmission mode according to the data message type of the data to be transmitted, and perform network transmission on the data to be transmitted according to the data transmission mode.
[0112] Some embodiments of the present application are based on the network card device as described in any of the previous embodiments to determine the corresponding data transmission method for the data to be transmitted, and the data transmission includes a data sending process and a data receiving process. Among them, if the data to be transmitted is the target network data received from the network, then the data transmission is a data receiving process, that is, the target network data is stored in a location accessible by the host, which can be the host's memory or the target memory of the programmable device, that is, the host's extended memory. If the data to be transmitted is the network data to be sent from the host side, then the data transmission is a data sending process, that is, the data to be transmitted is read from the host's memory or extended memory, and then sent to the network through the network interface of the network card device.
[0113] In the technical solutions provided in some embodiments of the present application, programmable devices and memory expansion technology are used to realize the functions of a high-performance network card. The host configures a piece of memory in the programmable device as an extended memory that it can use through memory expansion technology. The extended memory can be used to store network data of pre-specified message types without having to be stored in the host's memory. Some network data that does not require host processing and has low data transfer efficiency using a direct memory access module can be directly stored in the extended memory. That is, the optimal data transmission method is determined according to the message data type of the data to be transmitted, thereby effectively improving the transmission efficiency of network data.
[0114] In the above embodiment, there is no limitation on the entire process of determining a matching data transmission mode according to the data packet type of the data to be transmitted. The present application also provides an exemplary implementation method, which may include the following content:
[0115] Some embodiments of the present application define the message data type of the data to be transmitted as a network card processing message type and a host processing message type. The network card processing message type is a data message type that does not need to be stored in the host's memory, and the host processing message type is a data message type that needs to be stored in the host's memory.
[0116] For example, to further enhance practicality, the network card processing message types in some embodiments of the present application may include two types: preset data types and data lengths less than a length threshold. The remaining types are all host processing message types. Accordingly, the process for identifying the message data type of the data to be transmitted may be as follows: if the data type of the data to be transmitted is a preset data type, then the data message type of the data to be transmitted belongs to the network card processing message type; wherein the preset data type is data not stored in the host's memory; if the data length of the data to be transmitted is less than the length threshold, then the data message type of the data to be transmitted belongs to the network card processing message type. Furthermore, the preset data types can be divided into two categories: one is data that requires subsequent processing, and the other is data that does not require subsequent processing. The host processor processes these two types of data as follows: if the data to be transmitted belongs to the first preset data type, the host reads the data to be transmitted and directly discards it. The first preset data type may be, for example, cyclic redundancy check code data. Accordingly, if the data to be transmitted is cyclic redundancy check code data, the host reads the data to be transmitted and directly discards it. If the data to be transmitted belongs to the second preset data type, the host reads the data to be transmitted and forwards it. The second preset data type may be, for example, a message to be forwarded. Accordingly, if the data to be transmitted is a message to be forwarded, the host reads the data to be transmitted and forwards it to the destination address. For a message type processed by the network card where the data length is less than a length threshold, if the data length of the data to be transmitted is less than the length threshold, the host calls a memory copy function to copy the data to be transmitted to the host's memory.
[0117] As can be seen from the above, some embodiments of the present application store messages in the network card device when there are messages with CRC errors in the received messages, thereby eliminating the need to use the DMA module to move the erroneous data to the host memory. When the received data message is forwarded data, this message is also stored in the network card device to facilitate the forwarding of such data. For message data with a shorter length during the sending and receiving process, the host is used to directly move the data, without the need for the DMA module to move the data, thereby effectively improving the transmission efficiency of network data.
[0118] For the length threshold in the above-mentioned embodiments, in some embodiments of the present application, it can be pre-set based on artificial prior knowledge or a default value such as 1KB bytes can be set and stored locally. That is, when a length threshold configuration instruction input by the user is received, the length threshold is obtained by parsing the length threshold configuration instruction, and the length threshold is stored in the target location. However, this method is not accurate and is not conducive to efficient transmission of network data.
[0119] In some embodiments of the present application, the length threshold can be determined by a convergence test: test transmission data of different data lengths are transmitted based on the memory copy method and the direct memory access method respectively, and the corresponding transmission time is counted; the transmission time required for the test transmission data of the same data length by the memory copy method and the direct memory access method is compared and analyzed, and the corresponding data length when the transmission time required by the memory copy method and the direct memory access method is the same is determined as the length threshold. For ease of description, the method in which the host's central processing unit moves data from the extended memory to the host memory by calling the memory copy function is defined as the memory copy method, and the method in which the data in the buffer of the network card device is moved to the host's memory through the DMA module is defined as the direct memory access method. During the convergence test process, when the data length of the speed test transmission data is equal to the length threshold, the DMA operation, i.e., the direct memory access method, and the memory copy operation, i.e., the memory copy method, take the same time. When it is greater than the length threshold, the data moving operation using the direct memory access method takes less time, and when it is less than the length threshold, the operation using the memory copy method takes less time. The test process may include: starting a timer with a test transmission data length of 1KB, moving the test transmission data using both direct memory access and memory copy methods, and ending the timer when the data is successfully moved. The transmission times required by the two methods are compared. If the direct access method takes longer, the test transmission data length needs to be increased; if the memory copy method takes longer, the test transmission data length needs to be reduced. In this way, a convergence test is performed to find a data length that is consistent between the direct memory access and memory copy methods, and this length is used as the length threshold.
[0120] It can be seen that some embodiments of the present application can maximize the transmission efficiency of network data by determining the data migration operation mode to be adopted according to the length threshold.
[0121] Regarding the data receiving process, that is, the data to be transmitted is the target network data received from the network, and the process of determining a matching data transmission method based on the data packet type of the data to be transmitted may include: the network card device receives the target network data from the network and uses the packetizer of the network card device to identify the data packet type of the data to be transmitted. If the data packet type of the data to be transmitted belongs to the network card processing message type, the data to be transmitted is stored in the target memory of the network card device, that is, the extended memory of the host, and a message data read instruction is sent to the host. For data that needs to be copied to the host memory, the host copies the corresponding data to the host memory through a memory copy method, such as calling a memory copy function and accessing the target memory. For data that does not need to be copied to the host, the host can directly read the corresponding data and then perform corresponding operations according to the data type. If the data packet type of the data to be transmitted belongs to the host processing message type, the data to be transmitted can be stored in the host memory through the direct memory access module of the network card device.
[0122] For the data sending process, that is, the data to be transmitted is the network data to be sent by the host to the network, the host identifies the data packet type to which the data to be transmitted belongs. If the data packet type of the data to be transmitted belongs to the network card processing message type, the data to be transmitted is stored in the target memory of the network card device, that is, the extended memory of the host, and a message data read instruction is sent to the packetizer of the network card device, so that the packetizer reads the data to be transmitted and stores it in the buffer, and the buffer uses it based on the MAC module and sends it to the network through the network interface. If the data packet type of the data to be transmitted belongs to the host processing message type, the data to be transmitted is stored in the host's memory, and a message data read instruction is sent to the network card device. In this way, the packetizer reads the data to be transmitted through the DMA module and stores it in the buffer, and the buffer uses it based on the MAC module and sends it to the network through the network interface.
[0123] It can be seen that in some embodiments of the present application, during the process of sending and receiving network data, whether the data to be transmitted is stored in the host memory or the host's extended memory is determined according to the different message data types, thereby achieving the most efficient data transmission.
[0124] Furthermore, to improve network data transmission efficiency, based on the above embodiment, before sending and receiving data packets, the host of the present application can initialize and configure the network card device. The initialization process may include: the host applying for memory for a host message receiving queue for storing messages received by the host and a host message sending queue for storing messages sent by the host. The host can apply for space in the extended memory for a network card message receiving queue for storing messages received by the network card device and a network card message sending queue for storing messages to be sent by the network card device. The host can apply for space in the extended memory for storing data index information.
[0125] Based on the above configuration process, an exemplary method for determining the data transmission mode corresponding to the data to be transmitted is: constructing storage data index information in the target memory of the network card device in advance; updating the storage data index information based on the data packet type of the data to be transmitted; and determining the data transmission mode corresponding to the data to be transmitted according to the storage data index information and the sending end information of the data to be transmitted. In some embodiments of the present application, the storage data index information can be used to record the storage location information of the received message and the sent message. For example, the storage location information can be represented by a message descriptor. Accordingly, the storage data index information may include a sending queue and a receiving queue. The sending queue is used to record the sending message descriptor, and the receiving queue can be used to record the receiving message descriptor. The sending end information is whether the data to be transmitted is data sent by the host or data from the network. When the source of the data is determined, it can be determined whether the data is in the sending process or the receiving process. In combination with the data storage location recorded in the storage data index information, it can be determined whether the data to be transmitted is stored in the host's memory or in the host's extended memory.
[0126] The reading implementation method of the network data involved in the process of determining the data transmission mode corresponding to the data to be transmitted during the receiving process can be as follows: if the data to be transmitted is the target network data, a network card message receiving queue is pre-built in the target memory of the network card device, and a host message receiving queue is pre-built in the memory of the host; the queue pointers of the receiving producers corresponding to the network card message receiving queue and the host message receiving queue are pre-pointed to the corresponding initialization positions; the receiving producers include a buffer producer and a direct memory access module producer; based on the receiving queue storing data index information, if the data to be transmitted belongs to the network card processing message type, the data to be transmitted is stored in the pointer position of the buffer producer in the network card message receiving queue, and the pointer of the buffer producer is moved down; if the data to be transmitted belongs to the host processing message type, the data to be transmitted is stored in the pointer position of the direct memory access module producer in the host message receiving queue, and the pointer of the direct memory access module producer is moved down. After the data to be transmitted is stored in the corresponding position, in order to facilitate data reading and data storage, the movement trajectory can be recorded based on the position of the pointer, so as to know the starting position for the next time. The process of the host reading the data to be transmitted can be: pre-point the queue pointers of the receiving consumers corresponding to the network card message receiving queue and the host message receiving queue to the corresponding initialization positions; the receiving consumer is the host's message data sending and receiving thread; the pointer position of the receiving consumer is smaller than the pointer position of the receiving producer; the host determines the storage position of the storage queue corresponding to the data to be transmitted based on the receiving queue, reads the data to be transmitted according to the storage position of the data to be transmitted, and moves the pointer of the receiving consumer down.
[0127] In the process of determining the data transmission mode corresponding to the data to be transmitted, the reading implementation method of the network data involved in the sending process can be as follows: the data to be transmitted is the network data to be sent, and a network card message sending queue is pre-built in the target memory of the network card device, and a host message sending queue is pre-built in the memory of the host; the queue pointers of the sending producers corresponding to the network card message receiving queue and the host message receiving queue are pre-pointed to the corresponding initialization positions; the sending producer is the message data sending and receiving thread of the host; the queue pointer of the sending producer corresponding to the sending queue storing data index information is pre-pointed to the corresponding initialization position, and when the sending queue is updated, the pointer position of the sending producer is moved down; based on the sending queue storing data index information, if the data to be transmitted belongs to the network card processing message type, the data to be transmitted is stored in the network card message receiving queue, and the pointer of the sending producer is moved down; if the data to be transmitted belongs to the host processing message type, the data to be transmitted is stored in the host message receiving queue, and the pointer of the sending producer is moved down. After the data to be transmitted is stored in the corresponding position, in order to facilitate data reading and data storage, the movement trajectory can be recorded based on the position of the pointer, so as to know the starting position for the next time. The process of the network card device reading the data to be transmitted can be: pre-set the queue pointers of the sending consumers corresponding to the network card message sending queue and the host message sending queue to the corresponding initialization positions; the sending consumers are the buffer consumers and the direct memory access module consumers; the pointer position of the sending consumer is smaller than the pointer position of the sending producer; based on the sending queue of the stored data index information, if the data to be stored belongs to the network card processing message type, the data to be stored is read from the network card message sending queue, and the pointer of the buffer consumer is moved down; if the data to be stored belongs to the host processing message type, the data to be stored is read from the host message sending queue, and the pointer of the direct memory access module consumer is moved down.
[0128] In order to make the technical solution of the present application more clear to those skilled in the art, the present application also provides an exemplary implementation method, which may include the following contents:
[0129] As shown in Figure 7, the network card device of some embodiments of the present application is an FPGA + CXL. The FPGA's network components include a buffer, a DMA module, a packetizer, and a MAC module. The host configures the CXL to TPYE3 mode for memory expansion. The functional module implementing memory expansion is the CXL module. The host's memory includes a host message receive queue and a host message transmit queue. The host's expanded memory includes a network card message receive queue, a network card message transmit queue, and stored data index information. The stored data index information includes the transmit queue and the receive queue. Initialize the host message receiving queue, the host message sending queue, the network card message receiving queue, the network card message sending queue, the sending queue and the receiving queue that store data index information, so that each queue stores the corresponding data in sequence, such as the host message receiving queue stores the first frame receiving data, the second frame receiving data, the fifth frame receiving data, the seventh frame receiving data and the Nth frame receiving data in sequence, the host message sending queue stores the first frame sending data, the second frame sending data, the sixth frame sending data, the seventh frame sending data and the Nth frame sending data in sequence, the network card message receiving queue stores the third frame receiving data, the fourth frame sending data, the sixth frame sending data, the eighth frame sending data and the Nth frame receiving data in sequence, the network card message sending queue stores the third frame sending data, the fourth frame sending data, the fifth frame sending data, the eighth frame sending data and the Nth frame sending data in sequence, the sending queue and the receiving queue respectively record the location of the data to be transmitted, and the receiving queue For example, the first frame of received data is stored in the host message receive queue, which can be represented by 1: RX-H; the second frame of received data is stored in the host message receive queue, which can be represented by 2: RX-H; the third frame of received data is stored in the network card message receive queue, which can be represented by 3: RX-C; the fourth frame of received data is stored in the network card message receive queue, which can be represented by 4: RX-C; the fifth frame of received data is stored in the host message receive queue, which can be represented by 5: RX-H; the sixth frame of received data is stored in the network card message receive queue, which can be represented by 6: RX-C; the seventh frame of received data is stored in the host message receive queue, which can be represented by 7: RX-H; the eighth frame of received data is stored in the network card message receive queue, which can be represented by 8: RX-C; the Nth frame of received data can be stored in both the network card message receive queue and the host message queue, which can be represented by N: RX-N.For example, the first frame of the sending queue sends data and is stored in the host message sending queue, which can be represented by 1: TX-H. The second frame sends data to the host message sending queue, which can be represented by 2: TX-H. The third frame sends data to the network card message sending queue, which can be represented by 3: TX-C. The fourth frame sends data to the network card message sending queue, which can be represented by 4: TX-C. The fifth frame sends data to the network card message sending queue, which can be represented by 5: TX-C. The sixth frame sends data to the host message sending queue, which can be represented by 6: TX-H. The seventh frame sends data to the host message sending queue, which can be represented by 7: TX-H. The eighth frame sends data to the network card message sending queue, which can be represented by 8: TX-C. The Nth frame sends data and can be stored in both the network card message sending queue and the host message queue, which can be represented by N: TX-N.
[0130] Based on the network data transmission system shown in Figure 7, when the data to be transmitted is the target network data from the network, the message data type of the data to be transmitted is first identified, and different message data types are classified and processed. The processing method of the data message type queried by the packetizer is as follows: If the data to be transmitted is CRC data, the message is stored locally in the FPGA, and the host's message data receiving and sending thread can directly discard the error message when it finds it. If the data to be transmitted is a forwarding message set by the host's message data receiving and sending thread, the message is stored locally in the FPGA, and the host's message data receiving and sending thread can directly forward it. If the data length of the data to be transmitted is less than the length threshold, the message is stored locally in the FPGA, and the host's message data receiving and sending line program performs data movement operations through the memory copy function. The message data receiving process is shown in Figure 8, and may include the following processes:
[0131] 1. The MAC module stores the data to be transmitted in the FPGA cache.
[0132] 2. The packetizer determines the data type of the data to be transmitted and marks the corresponding data type of the data.
[0133] 3. The packetizer updates the receiving queue in the extended memory according to the data type of the message to be transmitted. For example, as shown in Figure 7, message 1: stored in the host memory, message 2: stored in the host memory, and message 3: stored in the local memory.
[0134] 4. The packetizer uses the DMA module to store the cached data to be transmitted into the host message receiving queue.
[0135] 5. The packetizer stores the cached data to be transmitted in the network card message receiving queue of the local extended memory and notifies the host to read the message data.
[0136] 6. The data transceiver thread of the host reads the sending queue table in the extended memory of the network card device and finds the location of the corresponding queue where the corresponding message exists.
[0137] 7. The host reads the message from the host message receiving queue in the local memory, and reads the message from the memory network card message receiving queue in the extended memory on the network card device. The operation process of the host's message data receiving and sending thread to obtain the message is shown in Figure 9:
[0138] The host's message receiving and sending process initializes the receiving queue to point the queue pointers of the producer and consumer to the initial position of the receiving queue. The direct memory access module producer stores the data at the pointer position of the direct memory access module producer, which is also the host message receiving queue, and moves the direct memory access module producer pointer downward after storage. The buffer producer stores the data at the pointer position of the buffer producer, which is also the network card message receiving queue, and moves the buffer producer pointer downward after storage. After the host's message data receiving and sending thread as a consumer receives the notification from the network card device, the host's message data receiving and sending thread first reads the location of the message from the receiving queue on the extended memory. For example, if a message exists in the host message sending queue of the host memory, the host's message data receiving and sending thread reads the data from the host message sending queue and moves the pointer corresponding to the message data receiving and sending thread as a consumer downward. Among them, the consumer's pointer must be smaller than the producer's pointer, and after reaching the end of the sending queue, the pointer will be looped back to the initial position.
[0139] Based on the network data transmission system shown in Figure 7, when the data to be transmitted is network data to be sent from the host, the host's message data transceiver thread classifies the message data type of the data to be transmitted. If the data length of the data to be transmitted is greater than the length threshold, the data to be transmitted is stored in the host message sending queue and subsequently moved using the DMA module. When the data length of the data to be transmitted is less than the length threshold, it is directly copied to the extended memory network card message sending queue. The message data sending process is shown in Figure 10 and may include the following processes:
[0140] 1. The host's message data transceiver thread classifies the data messages to be sent and updates the sending queue in the extended memory. For example, message 1 is stored in the host message sending queue in the host memory.
[0141] 2. The classified messages are placed in the corresponding queues. Messages exceeding the length threshold are stored in the host's message send queue. Messages less than the length threshold are copied by the host's message data transceiver thread to the network card's message send queue in extended memory.
[0142] 3. The host notifies the packetizer to obtain the sending data message. The packetizer reads the sending queue and finds the corresponding message according to the direction of the sending queue.
[0143] 4. The packetizer stores the messages in the network card message sending queue in the buffer for subsequent sending.
[0144] 5. The packetizer uses the DMA module to transfer the messages in the host message sending queue to the buffer for subsequent transmission.
[0145] 6. Send the message in the buffer.
[0146] Among them, the operation process of the host's message data transceiver thread sending a message is shown in Figure 11. The message data transceiver thread initializes the sending queue to point the queue pointers of the producer and consumer to the initial position of the sending queue. The message data transceiver thread of the host as a producer writes the location information of the message to the sending queue in the extended memory and moves the storage pointer position downward. Different types of messages are stored in the corresponding host message sending queue and network card message sending queue, and the corresponding storage pointer position is moved downward. Notify the DMA module as a consumer, that is, the direct memory access module consumer, to move the message data to the cache and move the pointer position downward. The host directly stores the message data in the cache and moves the pointer position of the consumer's buffer, that is, the buffer consumer, downward.
[0147] As can be seen from the above, some embodiments of the present application use CXL to expand the memory of the host and create a network card message sending queue and a network card message receiving queue for storing data messages. A sending queue and a receiving queue are created in the extended memory as index information so that the message sending and receiving program can find the location of the corresponding data message. Based on the length threshold of the DMA data transfer length between the host and the FPGA tested according to different device environments, if the message length is greater than the length threshold, the DMA is used to move the message, and if the message length is less than the length threshold, the host copy method is used to further improve the network data storage efficiency. In the process of receiving data messages, the FPGA will store the CRC error message, the forwarding message set by the host, and the message whose data message is less than the length threshold in the extended memory of the FPGA. The host's message data sending and receiving thread can access the data message through the extended memory, further improving the processing efficiency of network data. When the FPGA is sending data messages, the host's message data receiving and sending thread will determine the message storage location based on the data message length. Data with a length greater than the length threshold will be stored in the host message sending queue in the local memory. Data with a length less than the length threshold will be directly copied to the network card message sending queue in the extended memory, thereby effectively improving the transmission efficiency of the entire network data.
[0148] The present application also provides a corresponding device for the network data transmission method, which further makes the method more practical. Among them, the device can be described from the perspective of functional modules and hardware. The network data transmission device provided by the present application is introduced below. The device is used to implement the network data transmission method provided by the present application. In some embodiments of the present application, the network data transmission device may include or be divided into one or more program modules, and the one or more program modules are stored in a storage medium and executed by one or more processors to complete the network data transmission method disclosed in Example 1. The program module referred to in some embodiments of the present application refers to a series of computer program instruction segments that can perform specific functions, which is more suitable for describing the execution process of the network data transmission device in the storage medium than the program itself. The following description will specifically introduce the functions of each program module in some embodiments of the present application. The network data transmission device described below and the network data transmission method described above can be referenced to each other.
[0149] From the perspective of functional modules, see FIG12 , which is a structural diagram of a network data transmission device provided in some embodiments of the present application under a specific implementation manner. The device may include:
[0150] The data acquisition module 121 is used to acquire data to be transmitted;
[0151] The network transmission module 122 is configured to determine a matching data transmission mode according to the data message type of the data to be transmitted based on the network card device, so as to perform network transmission on the data to be transmitted according to the data transmission mode.
[0152] In some embodiments of the present application, the network transmission module 122 may also be used to:
[0153] The data to be transmitted is the target network data received from the network, and the network card device identifies the data message type of the data to be transmitted; if the data message type of the data to be transmitted belongs to the network card processing message type, the data to be transmitted is stored in the target memory of the network card device, and a message data read instruction is sent to the host, so that the host accesses the target memory through a memory copy method; if the data message type of the data to be transmitted belongs to the host processing message type, the data to be transmitted is stored in the host memory through a direct memory access module, so that the host accesses the target memory through a direct memory access method.
[0154] In some embodiments of the present application, the network transmission module 122 may be further configured to:
[0155] If the data type of the data to be transmitted is a preset data type, the data message type of the data to be transmitted belongs to the network card processing message type; wherein the preset data type is data that is not stored in the memory of the host;
[0156] If the data length of the data to be transmitted is less than the length threshold, the data message type of the data to be transmitted belongs to the message type processed by the network card.
[0157] In some embodiments of the present application, the network transmission module 122 may be further configured to:
[0158] If the data to be transmitted belongs to the first preset data type, the host reads the data to be transmitted and directly discards the data to be transmitted;
[0159] If the data to be transmitted belongs to the second preset data type, the host reads the data to be transmitted and forwards the data to be transmitted;
[0160] If the data length of the data to be transmitted is less than the length threshold, the host calls the memory copy function to copy the data to be transmitted to the host's memory.
[0161] In some embodiments of the present application, the network transmission module 122 may be further configured to:
[0162] If the data to be transmitted is cyclic redundancy check code data, the host reads the data to be transmitted and directly discards the data to be transmitted;
[0163] If the data to be transmitted is a message to be forwarded, the host reads the data to be transmitted and forwards the data to be transmitted to the target address.
[0164] In some embodiments of the present application, the network transmission module 122 may also be used to:
[0165] Perform data transmission on test data of different data lengths based on memory copy mode and direct memory access mode respectively, and calculate the corresponding transmission time;
[0166] Compare and analyze the transmission time required for test data of the same data length transmitted by the memory copy method and the direct memory access method, and determine the data length corresponding to the same transmission time required by the memory copy method and the direct memory access method, which is used as the length threshold.
[0167] In some embodiments of the present application, the network transmission module 122 may also be used to:
[0168] When a length threshold configuration instruction input by a user is received, the length threshold is obtained by parsing the length threshold configuration instruction, and the length threshold is stored in a target location.
[0169] In some embodiments of the present application, the network transmission module 122 may also be used to:
[0170] The data to be transmitted is the network data to be sent by the host, and the host identifies the data message type of the data to be transmitted;
[0171] If the data message type of the data to be transmitted belongs to the message type processed by the network card, the data to be transmitted is stored in the target memory of the network card device through memory copy mode, and a message data reading instruction is sent to the network card device;
[0172] If the data message type of the data to be transmitted belongs to the host processing message type, the data to be transmitted is stored in the host memory, and a message data reading instruction is sent to the network card device to read the corresponding data through direct access.
[0173] In some embodiments of the present application, the network transmission module 122 may also be used to:
[0174] Pre-constructing storage data index information in the target memory of the network card device; the storage data index information is used to record storage location information of received and sent messages;
[0175] Based on the data message type of the data to be transmitted, update the stored data index information;
[0176] The data transmission mode corresponding to the data to be transmitted is determined according to the stored data index information and the sender information of the data to be transmitted.
[0177] In some embodiments of the present application, the network transmission module 122 may be further configured to:
[0178] Preliminarily constructing a network card message receiving queue in the target memory of the network card device and a host message receiving queue in the memory of the host;
[0179] The queue pointers of the receiving producers corresponding to the network card message receiving queue and the host message receiving queue are respectively pointed to the corresponding initialization positions in advance; the receiving producers include the buffer producer and the direct memory access module producer;
[0180] The data to be transmitted is the target network data. Based on the receiving queue that stores the data index information, if the data to be transmitted belongs to the network card processing message type, the data to be transmitted is stored in the pointer position of the buffer producer in the network card message receiving queue, and the pointer of the buffer producer is moved down; if the data to be transmitted belongs to the host processing message type, the data to be transmitted is stored in the pointer position of the direct memory access module producer in the host message receiving queue, and the pointer of the direct memory access module producer is moved down.
[0181] In some embodiments of the present application, the network transmission module 122 may be further configured to:
[0182] The queue pointers of the receiving consumers corresponding to the network card message receiving queue and the host message receiving queue are respectively pointed to the corresponding initialization positions in advance; the receiving consumer is the message data receiving and sending thread of the host; the pointer position of the receiving consumer is smaller than the pointer position of the receiving producer;
[0183] The host determines the storage position of the storage queue corresponding to the data to be transmitted according to the receiving queue, reads the data to be transmitted according to the storage position of the data to be transmitted, and moves the pointer of the receiving consumer downward.
[0184] In some embodiments of the present application, the network transmission module 122 may be further configured to:
[0185] Preliminarily constructing a network card message sending queue in the target memory of the network card device and a host message sending queue in the memory of the host;
[0186] The queue pointers of the sending producers corresponding to the network card message receiving queue and the host message receiving queue are respectively pointed to the corresponding initialization positions in advance; the sending producer is the message data sending and receiving thread of the host;
[0187] The queue pointer of the sending producer corresponding to the sending queue storing the data index information is pointed to the corresponding initialization position in advance, and the pointer position of the sending producer is moved down when the sending queue is updated;
[0188] Based on the sending queue that stores data index information, if the data to be transmitted belongs to the network card processing message type, the data to be transmitted will be stored in the network card message receiving queue, and the pointer of the sending producer will be moved down; if the data to be transmitted belongs to the host processing message type, the data to be transmitted will be stored in the host message receiving queue, and the pointer of the sending producer will be moved down.
[0189] In some embodiments of the present application, the network transmission module 122 may be further configured to:
[0190] The queue pointers of the sending consumers corresponding to the network card message sending queue and the host message sending queue are respectively pointed to corresponding initialization positions in advance; the sending consumers are buffer consumers and direct memory access module consumers; the pointer position of the sending consumer is smaller than the pointer position of the sending producer;
[0191] Based on the sending queue of the stored data index information, if the data to be stored belongs to the network card processing message type, the data to be stored is read from the network card message sending queue and the pointer of the cache consumer is moved down; if the data to be stored belongs to the host processing message type, the data to be stored is read from the host message sending queue and the pointer of the direct memory access module consumer is moved down.
[0192] The functions of the various functional modules of the network data transmission device in some embodiments of the present application can be specifically implemented according to the methods in the above-mentioned method embodiments. The specific implementation process can refer to the relevant description of the above-mentioned method embodiments and will not be repeated here.
[0193] It can be seen from the above that some embodiments of the present application can effectively improve the transmission efficiency of network data.
[0194] The network data transmission device mentioned above is described from the perspective of functional modules. This application also provides an electronic device described from a hardware perspective, as shown in Figure 13. This electronic device includes a memory 130 for storing computer programs; a processor 131 for executing the computer programs to implement the steps of the network data transmission method described in any of the above embodiments. In some embodiments, the electronic device may also include a display 132, an input / output interface 133, a communication interface 134, a power supply 135, a communication bus 136, and sensors 137 for implementing various functions.
[0195] Among them, the processor 131 may include one or more processing cores, which may be a controller, a microcontroller, a microprocessor or an artificial intelligence processor for processing computing operations related to machine learning. The memory 130 may include one or more computer non-volatile readable storage media, high-speed random access memory and non-volatile memory, and may be an internal storage unit or an external storage device. The memory 130 can store application software installed on the electronic device and various types of data, such as: program code in the process of executing the network data transmission method, etc., and can also temporarily store data that has been output or is to be output. In some embodiments of the present application, the memory 130 is at least used to store a computer program 1301 that can implement the relevant steps of the network data transmission method disclosed in any of the previous embodiments after being loaded and executed by the processor 131. The resources stored therein may also include an operating system 1302 and data 1303. The operating system 1302 may include Windows, Unix, Linux, etc. The data 1303 may include but is not limited to data corresponding to the network data transmission results.
[0196] It is understandable that if the network data transmission method in the above embodiment is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer non-volatile readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the relevant technology or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium and executes all or part of the steps of the various embodiments of the present application. Based on this, the present application also provides a non-volatile readable storage medium that stores a computer program, which, when executed by a processor, performs the steps of the network data transmission method in any of the above embodiments.
[0197] Finally, the present application provides a network data transmission system. Please refer to FIG14 , which is a schematic diagram of the structural framework of the network data transmission system in an exemplary embodiment, and may include the following contents:
[0198] The network data transmission system of some embodiments of the present application may include a host 141, a network card device 142, and a processor 131. Host 141 may be any small or medium-sized single server, a data center server, a personal computer, or the like capable of connecting to an external network card device. Network card device 142 may be any of the aforementioned embodiments. Processor 131 may be configured to execute a computer program stored in memory to implement the method steps described in any of the network data transmission method embodiments.
[0199] The functions of the various functional modules of the network data transmission system in the embodiment of the present application can be specifically implemented according to the method in the above method embodiment. The specific implementation process can refer to the relevant description of the above method embodiment, which will not be repeated here.
[0200] As can be seen from the above, some embodiments of the present application can effectively improve the transmission efficiency of the host's network data by deploying the above-mentioned network card device for the host.
[0201] The above describes in detail a network card device, network data transmission method, apparatus, system, electronic device, and non-volatile readable storage medium provided by this application. Without departing from the principles of this application, various improvements and modifications may be made to this application, and such improvements and modifications also fall within the scope of protection of the claims of this application.
Claims
1. A network card device, characterized in that: It includes a programmable device, which builds a network platform based on a memory expansion method, and includes a network interface, a target memory and a network component; The programmable device is connected to the network through the network interface, and exchanges data with the host through the memory expansion method; the host sets the target memory of the programmable device as the extended memory of the host based on the memory expansion method; the network component uses a data transmission method that matches the data message type of the data to be transmitted to perform data transmission; Wherein, the data to be transmitted is the received target network data or the network data to be sent by the host; The data message type is determined according to the data type and data length of the data to be transmitted; the extended memory is configured to store the data to be transmitted belonging to the message type processed by the network card.
2. The network card device according to claim 1, characterized in that: The network components include a media access control layer module, a direct memory access module, a buffer and a packetizer; The media access control layer module is configured to store the target network data received from the network into the buffer, and is also configured to send the to-be-sent network data in the buffer to the network; The packetizer is configured to identify the data packet type of the target network data and determine the corresponding storage location according to the data packet type of the target network data; it is also configured to store the network data to be sent read from the target memory or from the host memory through the direct memory access module to the buffer for transmission; wherein the storage location includes the host memory and the target memory.
3. The network card device according to claim 1, characterized in that: The central processing unit of the host accesses the target memory by means of memory copy; the message type processed by the network card includes a data message type whose data length is less than a length threshold; If the data to be transmitted is the target network data, and the data length of the data to be transmitted is less than the length threshold, the network component stores the data to be transmitted in the target memory, and sends a message data read instruction to the host; If the data to be transmitted is the network data to be sent, and the data length of the data to be transmitted is less than the length threshold, the host moves the data to be transmitted to the target memory through the memory copy method.
4. The network card device according to claim 1, characterized in that: The network component includes a direct memory access module, and the central processing unit of the host accesses the target memory through a direct memory access mode; the message type processed by the network card does not include a data message type whose data length is greater than a length threshold; If the data to be transmitted is the target network data, and the data length of the data to be transmitted is greater than the length threshold, the network component moves the data to be transmitted to the memory of the host through the direct memory access module; If the data to be transmitted is the network data to be sent, and the data length of the data to be transmitted is greater than the length threshold, the host stores the data to be transmitted in the memory of the host, and sends a message data read instruction to the network component.
5. The network card device according to any one of claims 1 to 4, characterized in that: The programmable device uses a field programmable logic gate array and builds a network platform based on computing high-speed interconnect technology; The host configures the target memory of the field programmable logic gate array as the extended memory through the computing high-speed interconnect technology; The data to be transmitted is the target network data, the field programmable logic gate array identifies the data message type of the data to be transmitted, and if the data to be transmitted belongs to the target preset data type and / or the data length of the data to be transmitted is less than the length threshold, the data to be transmitted is stored in the target memory; The data to be transmitted is the network data to be sent, and the host identifies the data message type of the data to be transmitted. If the data to be transmitted belongs to the target preset data type and / or the data length of the data to be transmitted is less than the length threshold, the data to be transmitted is stored in the target memory of the field programmable logic gate array through memory copy.
6. A network data transmission method, characterized in that: include: Get the data to be transmitted; Based on the network card device according to any one of claims 1 to 5, a matching data transmission mode is determined according to the data message type of the data to be transmitted, so as to perform network transmission on the data to be transmitted according to the data transmission mode.
7. The network data transmission method according to claim 6, characterized in that: The data to be transmitted is target network data received and sent by the network, and the network card device identifies the data message type of the data to be transmitted; The determining a matching data transmission mode according to the data message type of the data to be transmitted includes: If the data message type of the data to be transmitted belongs to the message type processed by the network card, the data to be transmitted is stored in the target memory of the network card device, and a message data reading instruction is sent to the host; If the data message type of the data to be transmitted belongs to the host processing message type, the data to be transmitted is stored in the memory of the host through a direct memory access module.
8. The network data transmission method according to claim 7, characterized in that: The determining a matching data transmission mode according to the data message type of the data to be transmitted includes: If the data type of the data to be transmitted is a preset data type, the data message type of the data to be transmitted belongs to the network card processing message type; wherein the preset data type is a data type that is not stored in the memory of the host; If the data length of the data to be transmitted is less than the length threshold, the data message type of the data to be transmitted belongs to the network card processing message type.
9. The network data transmission method according to claim 8, characterized in that: The host accesses the target memory by means of a memory copy, including: If the data to be transmitted belongs to the first preset data type, the host reads the data to be transmitted and directly discards the data to be transmitted; If the data to be transmitted belongs to a second preset data type, the host reads the data to be transmitted and forwards the data to be transmitted; If the data length of the data to be transmitted is less than the length threshold, the host calls a memory copy function to copy the data to be transmitted to the host's memory, so that the host accesses the target memory through the memory copy method.
10. The network data transmission method according to claim 9, characterized in that: The host accesses the target memory by means of a memory copy, including: If the data to be transmitted is cyclic redundancy check code data, the host reads the data to be transmitted and directly discards the data to be transmitted; If the data to be transmitted is a message to be forwarded, the host reads the data to be transmitted and forwards the data to be transmitted to a target address.
11. The network data transmission method according to claim 6, characterized in that: Before determining the matching data transmission mode according to the data message type of the data to be transmitted, the method further includes: Perform data transmission on test data of different data lengths based on memory copy mode and direct memory access mode respectively, and count the corresponding transmission time; A comparative analysis is performed on the transmission time required for test transmission data of the same data length transmitted by the memory copy method and the direct memory access method, and the data length corresponding to the time required for transmission of the memory copy method and the direct memory access method when the transmission time is the same is determined as the length threshold.
12. The network data transmission method according to claim 6, characterized in that: Before determining the matching data transmission mode according to the data message type of the data to be transmitted, the method further includes: When a length threshold configuration instruction input by a user is received, the length threshold is obtained by parsing the length threshold configuration instruction, and the length threshold is stored in a target location.
13. The network data transmission method according to claim 6, characterized in that: The data to be transmitted is network data to be sent by the host, the host identifies the data message type of the data to be transmitted, and the matching data transmission mode is determined according to the data message type of the data to be transmitted, including: If the data message type of the data to be transmitted belongs to the message type processed by the network card, the data to be transmitted is stored in the target memory of the network card device, and a message data reading instruction is sent to the network card device; If the data message type of the data to be transmitted belongs to the host processing message type, the data to be transmitted is stored in the memory of the host, and a message data reading instruction is sent to the network card device.
14. The network data transmission method according to any one of claims 6 to 13, characterized in that: The determining a matching data transmission mode according to the data message type of the data to be transmitted includes: Preliminarily constructing storage data index information in the target memory of the network card device; the storage data index information is configured to record storage location information of received messages and sent messages; Based on the data message type of the data to be transmitted, updating the stored data index information; A data transmission mode corresponding to the data to be transmitted is determined according to the stored data index information and the sender information of the data to be transmitted.
15. The network data transmission method according to claim 14, characterized in that: The data to be transmitted is target network data, and determining the data transmission mode corresponding to the data to be transmitted according to the stored data index information and the sender information of the data to be transmitted includes: Preliminarily constructing a network card message receiving queue in the target memory of the network card device and a host message receiving queue in the memory of the host; Pre-setting the queue pointers of the receiving producers corresponding to the network card message receiving queue and the host message receiving queue to corresponding initialization positions respectively; the receiving producers include a buffer producer and a direct memory access module producer; Based on the receiving queue storing the data index information, if the data to be transmitted belongs to the network card processing message type, the data to be transmitted is stored in the pointer position of the buffer producer in the network card message receiving queue, and the pointer of the buffer producer is moved down; if the data to be transmitted belongs to the host processing message type, the data to be transmitted is stored in the pointer position of the direct memory access module producer in the host message receiving queue, and the pointer of the direct memory access module producer is moved down.
16. The network data transmission method according to claim 15, characterized in that: After the data to be transmitted is transmitted over the network according to the data transmission mode, the method further includes: The queue pointers of the receiving consumers corresponding to the network card message receiving queue and the host message receiving queue are respectively pointed to corresponding initialization positions in advance; the receiving consumer is the message data receiving and sending thread of the host; the pointer position of the receiving consumer is smaller than the pointer position of the receiving producer; The host determines the storage position of the storage queue corresponding to the data to be transmitted according to the receiving queue, reads the data to be transmitted according to the storage position of the data to be transmitted, and moves the pointer of the receiving consumer downward.
17. The network data transmission method according to claim 14, characterized in that: The data to be transmitted is network data to be sent, and determining the data transmission mode corresponding to the data to be transmitted according to the stored data index information and the sender information of the data to be transmitted includes: Preliminarily constructing a network card message sending queue in the target memory of the network card device and a host message sending queue in the memory of the host; Preliminarily respectively point the queue pointers of the sending producers corresponding to the network card message receiving queue and the host message receiving queue to the corresponding initialization positions; the sending producer is the message data receiving and sending thread of the host; Pre-setting the queue pointer of the sending producer corresponding to the sending queue storing the data index information to the corresponding initialization position, and moving the pointer position of the sending producer downward when updating the sending queue; Based on the sending queue that stores the data index information, if the data to be transmitted belongs to the network card processing message type, the data to be transmitted is stored in the network card message receiving queue, and the pointer of the sending producer is moved down; if the data to be transmitted belongs to the host processing message type, the data to be transmitted is stored in the host message receiving queue, and the pointer of the sending producer is moved down.
18. The network data transmission method according to claim 17, characterized in that: After the data to be transmitted is transmitted over the network according to the data transmission mode, the method further includes: Preliminarily respectively point the queue pointers of the sending consumers corresponding to the network card message sending queue and the host message sending queue to the corresponding initialization positions; the sending consumers are buffer consumers and direct memory access module consumers; the pointer position of the sending consumer is smaller than the pointer position of the sending producer; Based on the sending queue of the stored data index information, if the data to be stored belongs to the network card processing message type, the data to be stored is read from the network card message sending queue, and the pointer of the cache consumer is moved down; if the data to be stored belongs to the host processing message type, the data to be stored is read from the host message sending queue, and the pointer of the direct memory access module consumer is moved down.
19. A network data transmission device, characterized in that: include: A data acquisition module, configured to acquire data to be transmitted; The network transmission module is configured to determine a matching data transmission mode according to the data packet type of the data to be transmitted based on the network card device as described in any one of claims 1 to 5, so as to perform network transmission on the data to be transmitted according to the data transmission mode.
20. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the processor is configured to implement the steps of the network data transmission method according to any one of claims 6 to 18 when executing a computer program stored in the memory.
21. A non-volatile readable storage medium, characterized in that: The non-volatile readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the network data transmission method according to any one of claims 6 to 18 are implemented.
22. A network data transmission system, characterized in that: It comprises a host, a network card device as claimed in any one of claims 1 to 5, and a processor; Wherein, the processor is configured to implement the steps of the network data transmission method as claimed in any one of claims 6 to 18 when executing the computer program stored in the memory.
Citation Information
Patent Citations
Memory extension method and device, equipment and storage medium
CN114020655A
Network connection method and system based on CXL protocol
CN115174409A
Computing device, message receiving method, programmable network card and storage medium
CN115733832A
Method for GPU to access CPU extended memory and graphic processing system
CN116664381A
Network card equipment, network data transmission method, device, system, equipment and medium
CN117768248A