A message processing method and device, an intelligent network card and a server
By acquiring the feature values and data of the smart network card, Ethernet packets are parsed and stored, solving the problem of poor performance and latency in CPU packet processing. This enables the smart network card to process packets efficiently, and addresses the issues of excessive CPU load and high development and maintenance costs in existing technologies.
Patent Information
- Application Number
- CN202211645713.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-19
- Publication Date
- 2025-11-28
- Estimated Expiration
- 2042-12-19
AI Technical Summary
In existing technologies, server CPUs suffer from poor performance and latency when processing network packets, resulting in high development and maintenance costs. Smart NIC offloading methods also suffer from frequent interruptions, unbalanced loads, and high hardware resource consumption.
The feature acquisition process and data acquisition process in the smart network card parse the feature values of Ethernet packets and match them with preset target feature values. The packets are then sent to the data acquisition process and stored in the target cache for application processing, reducing the CPU load.
This approach offloads most packet parsing and processing to the smart network interface card, freeing up CPU computing resources, improving packet processing performance, and reducing development and maintenance costs.
Smart Images

Figure CN115866103B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of communication technology, and in particular to a message processing method and device, an intelligent network card and a server. BACKGROUND
[0002] With the growth of data center traffic, the port rate supported by the server network port is also getting larger and larger, gradually developing from the traditional 10G, 25G to 100G, 200G or even higher rates. The dramatic increase in network bandwidth and the number of connections makes the computing power of the server CPU (Central Processing Unit / Processor) be largely consumed in network message processing. The intelligent network card is a network acceleration device specially designed for data centers, which can offload the network message processing work on the server CPU to the network card for processing.
[0003] Currently, there are mainly three ways to offload the network message processing work on the CPU to the network card for processing: one is that after the intelligent network card receives a network message, the received message is placed in the host RingBuffer (Ring Buffer) cache through DMA (Direct Memory Access), then the network card sends an interrupt request to the CPU to notify the CPU that the message has arrived, and then the TCP / IP protocol stack (Transmission Control Protocol / Internet Protocol) of the operating system is used for analysis and processing; two is that based on the characteristics of the intelligent network card supporting five-tuple splitting, based on the IP number, port number, protocol type and other information in the message header, the received network message is split to the specified network card queue, and the network message is processed through the multi-queue mode, thereby reducing network resource competition and improving processing delay; three is the processing mode of OVS (Open Virtual Switch) full hardware offloading, which offloads the flow table to the intelligent network card, and the intelligent network card matches the message according to the pre-defined packet processing rules in the flow table, and the matched message is processed by sending, forwarding, discarding and the like.
[0004] However, the method of processing network messages through the TCP / IP protocol stack frequently triggers interrupts, causing context switching of interrupt processing, and when the network message is large, the message processing performance and latency are poor; and the method of processing messages through the five-tuple distribution method classifies network messages to a certain extent, but messages with the same five-tuple information are distributed to the same queue, and load balancing is difficult to achieve, and the distributed messages still need to be processed through the TCP / IP protocol stack; the method of processing network messages through the OVS full hardware offloading method can well offload network traffic processed by the host CPU to hardware for processing, but the method is difficult to develop and adapt, difficult to deploy and maintain, consumes more hardware resources, and increases the use and maintenance cost. SUMMARY
[0005] Embodiments of the present application provide a message processing method and device, an intelligent network card and a server to solve the problems of poor data message processing performance and latency, high development and maintenance cost in related technologies.
[0006] To solve the above technical problems, the embodiments of the present application provide a message processing method applied to an intelligent network card, comprising:
[0007] receiving an Ethernet message;
[0008] calling a characteristic value obtaining process to obtain a first characteristic value of the Ethernet message, and in the case that the first characteristic value matches a preset target characteristic value, sending the Ethernet message to a data obtaining process; the target characteristic value is a characteristic value matched with an application program in a host;
[0009] calling the data obtaining process to obtain an original data packet according to the Ethernet message, and storing the original data packet in a target cache matched with the target characteristic value, so that the application program extracts the original data packet from the target cache for processing according to the target characteristic value.
[0010] Optionally, before the receiving an Ethernet message, further comprising:
[0011] receiving a target characteristic value issued by a host, and storing the target characteristic value in a storage area of the intelligent network card; the target characteristic value is generated by the host according to the application program.
[0012] Optionally, the target characteristic value is generated by the host according to an IP address of the host and a port number of the application program.
[0013] Optionally, the calling a characteristic value obtaining process to obtain a first characteristic value of the Ethernet message comprises:
[0014] parsing the Ethernet message according to a data link layer protocol to obtain an IP message;
[0015] parsing the IP message according to an IP protocol to obtain a TCP message and a destination IP address in a message header of the IP message;
[0016] parsing the TCP message according to a TCP protocol to obtain a destination port number in a TCP message header;
[0017] calculating the first characteristic value according to the destination IP address and the destination port number.
[0018] Optionally, after receiving the Ethernet message, the method further comprises:
[0019] storing the Ethernet message in a first receiving buffer;
[0020] in a case where the first characteristic value matches a preset target characteristic value, sending the Ethernet message to a data acquisition process, comprising:
[0021] in a case where the first characteristic value matches a preset target characteristic value, storing the Ethernet message in a second receiving buffer for processing by the data acquisition process; the second receiving buffer is different from the first receiving buffer;
[0022] calling the data acquisition process to acquire an original data packet according to the Ethernet message, comprising:
[0023] calling the data acquisition process to acquire the Ethernet message from the second receiving buffer and acquire the original data packet from the Ethernet message.
[0024] Optionally, calling the data acquisition process to acquire an original data packet according to the Ethernet message, comprising:
[0025] acquiring fragmentation information in an IP header in the Ethernet message;
[0026] in a case where the fragmentation information is less than or equal to a maximum transmission unit value, acquiring the original data packet from a data segment of the Ethernet message;
[0027] in a case where the fragmentation information is greater than the maximum transmission unit value, performing IP fragmentation reassembly operation and / or TCP rearrangement operation on a plurality of Ethernet messages based on the IP protocol and / or the TCP protocol to acquire the original data packet.
[0028] To solve the above technical problems, an embodiment of the present application further provides a data processing method applied to a host, wherein the host is installed with an application program, and the method comprises:
[0029] acquiring, by the application program, a target feature value of the application program;
[0030] acquiring, by the application program according to the target feature value, an original data packet from a target cache corresponding to the target feature value; the original data packet in the target cache is acquired and stored by a data acquisition process of the smart NIC according to the Ethernet message; the Ethernet message is sent to the data acquisition process by a feature value acquisition process of the smart NIC in a case that a first feature value matches a preset target feature value; the first feature value is acquired by the feature value acquisition process according to the Ethernet message;
[0031] processing, by the application program, the original data packet.
[0032] Optionally, the acquiring, by the application program according to the target feature value, an original data packet from a target cache corresponding to the target feature value, comprises:
[0033] calling, by the application program according to the target feature value, a preset interface of a NIC driver to acquire the original data packet from the target cache corresponding to the target feature value.
[0034] To solve the above technical problems, the embodiment of the application further provides a message processing device applied to a smart NIC, comprising:
[0035] a receiving module configured to receive an Ethernet message;
[0036] a first calling module configured to call a feature value acquisition process to acquire a first feature value of the Ethernet message, and send the Ethernet message to a data acquisition process in a case that the first feature value matches a preset target feature value; the target feature value is a feature value matched with an application program in a host.
[0037] a second calling module configured to call the data acquisition process to acquire an original data packet according to the Ethernet message, and store the original data packet in a target cache matched with the target feature value, so that the application program extracts the original data packet from the target cache according to the target feature value for processing.
[0038] To solve the above technical problems, the embodiment of the application further provides a data processing device applied to a host, wherein the host is installed with an application program, comprising:
[0039] a first acquiring module configured to acquire, by the application program, a target feature value of the application program;
[0040] The second obtaining module is configured to obtain, by the application program, an original data packet from a target cache corresponding to the target characteristic value according to the target characteristic value; the original data packet in the target cache is obtained and stored by a data obtaining process of the intelligent network card according to the Ethernet message; the Ethernet message is sent to the data obtaining process by a characteristic value obtaining process of the intelligent network card in a case where the first characteristic value matches a preset target characteristic value; and the first characteristic value is obtained by the characteristic value obtaining process according to the Ethernet message.
[0041] The processing module is configured to process the original data packet by the application program.
[0042] To solve the above technical problems, the embodiment of the present application further provides an intelligent network card for implementing the message processing method.
[0043] To solve the above technical problems, the embodiment of the present application further provides a server comprising the intelligent network card.
[0044] In the embodiment of the present application, the first characteristic value of the received Ethernet message is obtained by calling the characteristic value obtaining process, and the Ethernet message is sent to the data obtaining process in a case where the first characteristic value matches the preset target characteristic value; the original data packet is obtained according to the Ethernet message by calling the data obtaining process, and the original data packet is stored in the target cache matched with the target characteristic value, so as to be extracted by the application program from the target cache according to the target characteristic value for processing. Since the preset target characteristic value is the characteristic value matched with the application program in the host, the analysis processing of the Ethernet message with the first characteristic value matching the preset target characteristic value can be completed by the characteristic value obtaining process and the data obtaining process in the intelligent network card, the analysis processing of most of the Ethernet messages received by the intelligent network card is unloaded to the intelligent network card for processing, and the original data packet obtained by the intelligent network card can be used for processing by the application program in the host, so that the CPU computing resource is released.
[0045] The above description is only a summary of the technical scheme of the present application, in order to more clearly understand the technical means of the present application, the specific embodiments of the present application can be implemented according to the content of the specification, and in order to make the above and other purposes, characteristics and advantages of the present application more obvious and easy to understand, the following specific embodiments of the present application are described. BRIEF DESCRIPTION OF DRAWINGS
[0046] Figure 1 is a step flow chart of a message processing method provided by the embodiment of the present application;
[0047] Figure 2is a step flow chart of a data processing method provided by an embodiment of the present application;
[0048] Figure 3 is a step flow chart of another packet processing method provided by an embodiment of the present application;
[0049] Figure 4 is a logic block diagram of a packet processing device provided by an embodiment of the present application;
[0050] Figure 5 is a logic block diagram of a data processing device provided by an embodiment of the present application;
[0051] Figure 6 is a structural schematic diagram of an intelligent network card provided by an embodiment of the present application;
[0052] Figure 7 is a structural schematic diagram of a server provided by an embodiment of the present application.
[0053] Reference signs:
[0054] 600: intelligent network card; 610: receiving cache; 620: field programmable gate array (FPGA); 621: feature value acquisition process; 622: data acquisition process; 630: network card hard disk; 700: server; 710: central processing unit; 720: hard disk; 730: target cache. DETAILED DESCRIPTION
[0055] Exemplary embodiments of the present application will be described in greater detail below with reference to the accompanying drawings. Although exemplary embodiments of the present application are shown in the drawings, it is understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided so that the present application can be more thoroughly understood, and the scope of the present application can be accurately conveyed to those skilled in the art.
[0056] In order for those skilled in the art to better understand the present application, the following describes the concepts related to the present application:
[0057] Transmission Control Protocol / Internet Protocol (TCP / IP): or network communication protocol, is the most basic communication protocol in the use of the network. TCP / IP protocol for the standard and method of communication in the Internet parts are specified. And, TCP / IP protocol is to ensure the timely and complete transmission of network data information of two important protocols. TCP / IP protocol is strictly a four-layer architecture, respectively, the application layer, transport layer, network layer and data link layer. TCP / IP protocol is not only refers to the TCP and IP two protocols, but refers to a protocol cluster composed of FTP, SMTP, TCP, UDP and IP protocols, only because in the TCP / IP protocol TCP protocol and IP protocol is the most representative, so called TCP / IP protocol.
[0058] Ethernet message: Ethernet message is usually composed of a message header and an application data packet generated by an application program in the application layer. The message header of the Ethernet message can be divided into a MAC header, an IP header and a TCP header from outside to inside. The MAC header includes source MAC address and destination MAC address information, belongs to the category of L2 layer network, and with the MAC header information, the Ethernet message can be learned and forwarded by the switch. Meanwhile, the intelligent network card can also judge whether the received Ethernet message is sent to the intelligent network card based on the MAC header information. The IP header includes source IP address and destination IP address information, belongs to the category of L3 layer network, and with the IP information, the router can forward the Ethernet message to the target IP address according to the routing table. Meanwhile, the IP header also includes IP fragmentation information. Ethernet messages larger than the MTU (Maximum Transmission Unit) value of the network card will be fragmented. This IP fragmentation information is usually processed by the network layer in the TCP / IP protocol stack. In addition, the IP header also includes protocol number information, which is used to identify which type the Ethernet message belongs to, such as TCP / UDP / ICMP. The TCP header includes port number information, which is used for application programs to receive and send data.
[0059] FPGA (Field-Programmable Gate Array, Field Programmable Gate Array) : FPGA is a new type of high-performance programmable logic device developed on the basis of CPLD (Complex Programmable Logic Device). FPGA generally adopts SRAM (Static Random-Access Memory) technology, and some special devices adopt Flash technology or Anti-Fuse technology. FPGA has high integration, and the device density varies from tens of thousands of system gates to hundreds of millions of system gates, which can complete extremely complex timing and combinational logic circuit functions, and is suitable for high-speed, high-density high-end digital logic circuit design field.
[0060] CheckSum check: when transmitting data packets in the network, in order to ensure the correctness of the transmitted data, CheckSum is used to check whether the data is correct, and the MAC header, IP header and TCP header in the header of the Ethernet message have their own CheckSum values respectively, which are used to check whether the message is abnormal in the transmission process. The CheckSum value is generally a CRC16 check value, and the check process of the CRC16 value can be performed in the intelligent network card.
[0061] DMA (Direct Memory Access, Direct Memory Access) : a communication mechanism that allows different speed hardware devices to communicate without relying on the heavy interrupt load of the CPU. DMA transmission copies data from one address space to another address space. When the CPU initializes the transmission action, the transmission action itself is implemented and completed by the DMA controller. A typical example is to move a block of external memory to the faster internal memory area. Such operations do not delay the processor, but can be rescheduled to handle other work. DMA transmission is of great significance to high-performance embedded system algorithms and networks.
[0062] In the embodiment of the application, Figure 1 A step flow chart of a message processing method provided by the embodiment of the application is shown, which is applied to the intelligent network card 600, as shown in the figure, Figure 1 The method can include:
[0063] Step S110, receiving an Ethernet message.
[0064] In the embodiment of the present application, the intelligent network card 600 is in a communication connection with a server host, and the second device sends an Ethernet message to the receiving port of the intelligent network card 600, wherein the original data sent by the second device is encapsulated with a message header information layer by layer to obtain an Ethernet message in the process of transmission to the Ethernet, and the Ethernet message is received by the intelligent network card 600 through the receiving port of the intelligent network card 600.
[0065] Specifically, the second device is any device other than the server host connected with the intelligent network card 600.
[0066] Specifically, the intelligent network card 600 and the server host are in a communication connection through a DMA communication mechanism.
[0067] In step S120, the characteristic value obtaining process 621 is called to obtain a first characteristic value of the Ethernet message, and in the case that the first characteristic value matches a preset target characteristic value, the Ethernet message is sent to the data obtaining process 622.
[0068] In the embodiment of the present application, the intelligent network card 600 is installed with an FPGA 620, and the characteristic value obtaining process 621 and the data obtaining process 622 are instantiated in the FPGA 620 through a modification of a program language; wherein the characteristic value obtaining process 621 is used to analyze the message header information of the received Ethernet message and obtain a first characteristic value of the Ethernet message; and the data obtaining process 622 is used to obtain an original data packet of the Ethernet message and store the original data packet in a target cache 730 matched with the target characteristic value in the case that the first characteristic value matches the preset target characteristic value, so that the application program extracts the original data packet from the target cache 730 according to the target characteristic value for processing.
[0069] In the embodiment of the present application, after the characteristic value obtaining process 621 is called, before the first characteristic value of the Ethernet message is obtained, the Ethernet message can also be analyzed, specifically, the message header of the Ethernet message is analyzed.
[0070] Specifically, the analysis of the message header of the Ethernet message can include the following steps:
[0071] The MAC header information, the IP header information and the TCP header information of the Ethernet message are obtained, wherein the MAC header information includes a MAC header CheckSum value and a destination MAC address, the IP header information includes an IP header CheckSum value, a source IP address, a destination IP address and a transport layer protocol type, and the TCP header information includes a TCP header CheckSum value, a source port number and a destination port number.
[0072] checking the MAC header CheckSum value, the IP header CheckSum value and the TCP header CheckSum value respectively;
[0073] in case that the MAC header CheckSum value is checked, matching the destination MAC address of the Ethernet message with the local MAC address of the intelligent network card 600;
[0074] in case that the destination MAC address of the Ethernet message is consistent with the local MAC address of the intelligent network card 600, putting the Ethernet message into the receiving buffer 610 of the intelligent network card 600;
[0075] in case that the destination MAC address of the Ethernet message is not consistent with the local MAC address of the intelligent network card 600, discarding the Ethernet message;
[0076] in case that the IP header CheckSum value is checked, recording the destination IP address;
[0077] in case that the TCP header CheckSum value is checked, recording the destination port number;
[0078] in case that any one of the MAC header CheckSum value, the IP header CheckSum value and the TCP header CheckSum value is not checked, discarding the Ethernet message.
[0079] Optionally, the calling feature value obtaining process 621, obtaining the first feature value of the Ethernet message, can include the following steps:
[0080] analyzing the Ethernet message according to the data link layer protocol to obtain an IP message;
[0081] analyzing the IP message according to the IP protocol to obtain a TCP message and the destination IP address in the message header of the IP message;
[0082] analyzing the TCP message according to the TCP protocol to obtain the destination port number in the TCP message header;
[0083] calculating the first feature value according to the destination IP address and the destination port number.
[0084] In the embodiment of the present application, the first characteristic value of the Ethernet message is obtained based on the analysis result by the characteristic value obtaining process 621, the destination IP address and the destination port number of the Ethernet message are obtained, a hash algorithm is called, the destination IP address and the destination port number of the Ethernet message are taken as input values of the hash function, and a characteristic code based on the destination IP address and the destination port number of the Ethernet message is obtained after hash calculation. The characteristic code is the first characteristic value in the embodiment of the present application. Therefore, the first characteristic value of the Ethernet message corresponds to the host IP address of the receiving device of the Ethernet message and the port number corresponding to the application program in the host.
[0085] In the embodiment of the present application, after the first characteristic value of the Ethernet message is obtained, the first characteristic value is matched with the preset target characteristic value in the intelligent network card 600, and in the case that the first characteristic value matches the preset target characteristic value, the Ethernet message is sent to the data obtaining process 622; in the case that the first characteristic value does not match the preset target characteristic value, the Ethernet message is stored in the third receiving buffer.
[0086] Optionally, after the Ethernet message is received, the Ethernet message is further stored in the first receiving buffer.
[0087] In the case that the first characteristic value matches the preset target characteristic value, the Ethernet message is sent to the data obtaining process 622, which can include:
[0088] In the case that the first characteristic value matches the preset target characteristic value, the Ethernet message is stored in the second receiving buffer for processing by the data obtaining process 622; the second receiving buffer is different from the first receiving buffer.
[0089] In the embodiment of the present application, the first receiving buffer, the second receiving buffer and the third receiving buffer are the receiving buffer 610 of the intelligent network card 600, but the storage contents of the first receiving buffer, the second receiving buffer and the third receiving buffer are different from each other. The Ethernet message received by the intelligent network card 600 through the receiving port is stored in the first receiving buffer, the Ethernet message with the first characteristic value matching the preset target characteristic value is stored in the second receiving buffer, and the Ethernet message with the first characteristic value not matching the preset target characteristic value is stored in the third receiving buffer.
[0090] Optionally, before the Ethernet message is received, the target characteristic value issued by the host can be received, and the target characteristic value is stored in the storage area of the intelligent network card 600; the target characteristic value is generated by the host according to the application program.
[0091] Optionally, the target feature value is generated by the host according to an IP address of the host and a port number of the application program.
[0092] In the embodiment of the application, the application program is an application program in a server host, and the application program can be divided into a special application program and a general application program. The special application program in the embodiment of the application is an application program written by a user host and related to a business of the user host, and the general application program in the embodiment of the application is a general computer application program that can be downloaded from the Internet.
[0093] Specifically, in the embodiment of the application, most of the application programs of the host are special application programs, and the special application programs are assigned with exclusive port numbers after deployment, and the exclusive port numbers are used for socket communication between networks, and each special application program uses an exclusive port number for communication between networks.
[0094] In the embodiment of the application, the host generates a target feature value according to an IP address of the host and a port number of the special application program, and the host sends the target feature value to the intelligent network card 600, and the intelligent network card 600 stores the target feature value in a storage area of the intelligent network card 600 as a preset target feature value, and matches the first feature value of the received Ethernet message with the preset target feature value. Therefore, in the case that the first feature value matches the preset target feature value, the Ethernet message corresponding to the first feature value matches the special application program with the specified port number in the host; in the case that the first feature value does not match the preset target feature value, the Ethernet message corresponding to the first feature value does not match any special application program in the host, so the Ethernet message is stored in the third receiving cache of the intelligent network card 600 and is processed by the TCP / IP protocol stack of the host and then is directly processed by the general application program.
[0095] In step S130, the data acquisition process 622 is called to acquire an original data packet according to the Ethernet message, and the original data packet is stored in a target cache 730 matched with the target feature value, so that the application program extracts the original data packet from the target cache 730 according to the target feature value for processing.
[0096] Optionally, the calling of the data acquisition process 622 to acquire an original data packet according to the Ethernet message can include: calling the data acquisition process 622 to acquire the Ethernet message from the second receiving cache, and acquiring an original data packet from the Ethernet message.
[0097] In the embodiment of the present application, one or more preset target characteristic values are arranged in the intelligent network card 600, and one or more sub-receiving buffers corresponding to the one or more different target characteristic values in the intelligent network card 600 are arranged in the second receiving buffer. Specifically, in the case that the first characteristic value matches the preset target characteristic value, the Ethernet message with the same first characteristic value is stored in the sub-receiving buffer of the same second receiving buffer, and the Ethernet message with different first characteristic values is stored in the sub-receiving buffer of different second receiving buffers.
[0098] In the embodiment of the present application, the original data packet is the application data part left after removing the message header in the Ethernet message. The original data packet is the original application data generated by the application program in the application layer.
[0099] In the embodiment of the present application, the data acquisition process 622 is called to acquire the original data packet from the Ethernet message and store the original data packet in the target buffer 730 corresponding to the target characteristic value. Specifically, the data acquisition process 622 is called to acquire the original data packet from the Ethernet message according to the IP fragmentation information and IP protocol and / or TCP protocol information of the Ethernet message, and store the original data packet in the corresponding sub-receiving buffer of the second receiving buffer corresponding to the preset target characteristic value, and store the original data packet in the receiving buffer 610 into the target buffer 730 corresponding to the target characteristic value in the host through the DMA communication mechanism.
[0100] Optionally, the calling of the data acquisition process 622 to acquire the original data packet from the Ethernet message can further include the following steps:
[0101] Acquiring the fragmentation information in the IP header in the Ethernet message;
[0102] In the case that the fragmentation information is less than or equal to the maximum transmission unit value, the original data packet is acquired from the data segment of the Ethernet message;
[0103] In the case that the fragmentation information is greater than the maximum transmission unit value, IP fragmentation reorganization operation and / or TCP rearrangement operation are performed on a plurality of Ethernet messages based on the IP protocol and / or TCP protocol to acquire the original data packet.
[0104] In the embodiment of the present application, when the length of the original data packet sent by the second device is greater than the MTU value of the network card, the original data packet will be fragmented based on the IP protocol and IP fragmentation information will be generated in the IP header information. After the smart network card 600 receives the Ethernet message, and when the first characteristic value matches the preset target characteristic value, the data acquisition process 622 will fragment and reassemble the data packet corresponding to the Ethernet message according to the fragmentation information in the IP header of the Ethernet message, and rearrange the data packet that needs to be fragmented and reassembled according to the TCP protocol, so as to ensure that the order of the data packet after fragmentation and reassembly corresponds to the order of the original data packet sent by the second device.
[0105] Figure 2 A step flowchart of a data processing method provided by an embodiment of the present application is shown, which is applied to a host computer, such as Figure 2 As shown in the figure, the method can include:
[0106] Step S210: obtaining, by the application program, a target characteristic value of the application program.
[0107] In the embodiment of the present application, the target characteristic value of the special application program is obtained by the special application program, and the target characteristic value corresponds to the IP of the host computer where the special application program is located and the port number exclusive to the special application program.
[0108] Step S220: obtaining, by the application program, an original data packet from a target cache 730 corresponding to the target characteristic value according to the target characteristic value; the original data packet in the target cache 730 is obtained and stored by the data acquisition process 622 of the smart network card 600 according to the Ethernet message; the Ethernet message is sent to the data acquisition process 622 by the characteristic value acquisition process 621 of the smart network card 600 when the first characteristic value matches the preset target characteristic value; and the first characteristic value is obtained by the characteristic value acquisition process 621 according to the Ethernet message.
[0109] In the embodiment of the present application, one or more different target caches 730 corresponding to different target characteristic values are arranged in the host computer, and the target cache 730 and the special application program are one-to-one corresponding through the target characteristic value. Specifically, the special application program obtains an original data packet from a target cache 730 corresponding to the target characteristic value according to the target characteristic value corresponding to the special application program.
[0110] Optionally, the step of obtaining, by the application program, an original data packet from a target cache 730 corresponding to the target characteristic value according to the target characteristic value can further include the following steps:
[0111] The application program calls a preset interface of a network card driver according to the target characteristic value, and obtains original data packets from a target cache 730 corresponding to the target characteristic value.
[0112] In the embodiment of the application, the smart network card 600 corresponds to a specific driver, and when the smart network card 600 establishes a communication connection with the host computer, the specific driver corresponding to the smart network card 600 is installed in the host computer.
[0113] In the embodiment of the application, the cache of the host computer includes the target cache 730 corresponding to the target characteristic value, and also includes a general cache which is not divided according to the target characteristic value, and the general cache is used to store Ethernet messages with a first characteristic value not matching the preset target characteristic value in the third receiving cache of the smart network card 600, and the Ethernet messages in the third receiving cache are stored in the general cache in the host computer by the data acquisition process of the smart network card 600 through a DMA communication mechanism.
[0114] In the embodiment of the application, after the data acquisition process 622 of the smart network card 600 stores the original data packets and / or Ethernet messages in the receiving cache 610 in the target cache 730 in the host computer through a DMA communication mechanism, the method further includes:
[0115] The specific driver classifies and processes data in the cache of the host computer, and the data in the cache of the host computer can be classified into two categories, which are original data packets corresponding to the target characteristic value stored in the target cache 730 of the host computer and Ethernet messages with a first characteristic value not matching the target characteristic value stored in the general cache of the host computer.
[0116] Since the original data packets corresponding to the target characteristic value stored in the target cache 730 of the host computer are original data packets processed by the characteristic value acquisition process 621 and the data acquisition process 622 in the smart network card 600, the original data packets can be directly acquired and processed by a special application program in the host computer, and therefore the specific driver does not process the original data packets corresponding to the target characteristic value stored in the target cache 730 of the host computer.
[0117] For the Ethernet messages with the first characteristic value not matching the target characteristic value stored in the general cache of the host computer, the specific driver notifies a TCP / IP protocol stack to analyze and process the Ethernet messages stored in the general cache of the host computer by calling an interrupt processing function, and the general original data packets processed by the TCP / IP protocol stack are directly given to a general application program in the host computer for processing.
[0118] In the embodiment of the present application, the target cache 730 in the host can be a RingBuffer cache. Specifically, two pointers are arranged in the RingBuffer cache, which are a head pointer and a tail pointer. The head pointer is used to point to the position of next reading, and the tail pointer is used to point to the position of next writing. The RingBuffer cache can be stored by an array, and the memory addresses of the elements in the array are continuous, that is, at the hardware level, the elements in the array are preloaded, so that the CPU does not need to load the next element in the array from the main memory from time to time. Through the movement of the head pointer and the tail pointer, the ring access of data in the array can be realized.
[0119] Step S230, processing the original data packet by the application program.
[0120] In the embodiment of the present application, the original data packet in the target cache 730 is processed by the special application program. Specifically, the special application program searches whether there is an original data packet to be processed in the target cache 730 according to the target characteristic value corresponding to the application program, and if there is an original data packet to be processed in the target cache 730, the special application program processes the original data packet; if there is no original data packet to be processed in the target cache 730, the special application program searches for an original data packet to be processed in the target cache 730 at the beginning of the next period.
[0121] In the embodiment of the present application, Figure 3 A step flow chart of another packet processing method provided by the embodiment of the present application is shown in Fig. 6. Figure 3 As shown in Fig. 6, the method comprises the following steps:
[0122] Step S310, receiving an Ethernet packet.
[0123] In the embodiment of the present application, the intelligent network card 600 receives the Ethernet packet sent by the second device through the receiving port, and stores the Ethernet packet in the first receiving cache of the intelligent network card 600.
[0124] Step S320, calling the characteristic value obtaining process 621 to obtain the first characteristic value of the Ethernet packet.
[0125] In the embodiment of the present application, the intelligent network card 600 first calls the eigenvalue obtaining process 621 to parse the message header of the Ethernet message and perform CheckSum verification, and in the case that the CheckSum verification passes, the destination IP address and the destination port number in the message header are obtained, and the first eigenvalue of the Ethernet message is obtained based on the destination IP address and the destination port number.
[0126] Step S330: It is judged whether the first eigenvalue matches the preset target eigenvalue.
[0127] In the embodiment of the present application, in the case that the first eigenvalue does not match the preset target eigenvalue, the Ethernet message is handed over to the host for processing.
[0128] In the embodiment of the present application, in the case that it is determined that the first eigenvalue does not match the preset target eigenvalue, the Ethernet message is stored in the third receiving buffer of the intelligent network card 600, and then the data obtaining process 622 stores the Ethernet message in the third receiving buffer in the general buffer of the host through a DMA communication mechanism.
[0129] Step S340: The interrupt processing function is called by the specific driver to inform the TCP / IP protocol stack to perform message parsing.
[0130] In the embodiment of the present application, for the Ethernet message whose first eigenvalue does not match the target eigenvalue and which is stored in the general buffer of the host, the specific driver informs the TCP / IP protocol stack to perform parsing processing on the Ethernet message stored in the general buffer of the host by calling the interrupt processing function, and the general raw data packet after the TCP / IP protocol stack parsing processing is directly handed over to the general application in the host for processing.
[0131] Step S350: The general application directly obtains the general raw data packet after the TCP / IP protocol stack parsing and processes the general raw data packet.
[0132] Step S360: In the case that the first eigenvalue matches the preset target eigenvalue, the data obtaining process 622 is called to obtain a raw data packet from the Ethernet message, and the raw data packet is stored in the target buffer 730 matched with the target eigenvalue, so that the application extracts the raw data packet from the target buffer 730 for processing according to the target eigenvalue.
[0133] In the embodiment of the present application, in the case that the first characteristic value is determined to match the preset target characteristic value, the data acquisition process 622 is invoked to acquire the original data packet according to the Ethernet message, and the method further comprises:
[0134] storing the Ethernet message in a second receiving buffer of the intelligent network card 600;
[0135] invoking the data acquisition process 622 to acquire the original data packet from the second receiving buffer according to the Ethernet message.
[0136] In the embodiment of the present application, the data acquisition process 622 is invoked to acquire the original data packet according to the Ethernet message, and the method further comprises:
[0137] acquiring fragmentation information in an IP header in the Ethernet message;
[0138] in the case that the fragmentation information is less than or equal to a maximum transmission unit value, acquiring the original data packet from a data segment of the Ethernet message;
[0139] in the case that the fragmentation information is greater than the maximum transmission unit value, performing IP fragmentation reassembly operation and / or TCP rearrangement operation on a plurality of Ethernet messages based on IP protocol and / or TCP protocol to acquire the original data packet.
[0140] In the embodiment of the present application, after the data acquisition process 622 is invoked to acquire the original data packet according to the Ethernet message, the data acquisition process 622 stores the original data packet in a corresponding sub-receiving buffer of a second receiving buffer corresponding to the preset target characteristic value, and stores the original data packet in the receiving buffer 610 into a target buffer 730 corresponding to the target characteristic value in the host through a DMA communication mechanism.
[0141] In step S370, the specific driver does not process the original data packet in the target buffer 730.
[0142] In the embodiment of the present application, since the original data packet corresponding to the target characteristic value stored in the target buffer 730 of the host is the original data packet processed by the characteristic value acquisition process 621 and the data acquisition process 622 in the intelligent network card 600, the original data packet can be directly acquired and processed by a special application in the host, and therefore the specific driver does not process the original data packet corresponding to the target characteristic value stored in the target buffer 730 of the host.
[0143] In step S380, the special application program acquires the original data packet from the target cache 730 corresponding to the target characteristic value according to the target characteristic value and processes the original data packet.
[0144] In the embodiment of the application, the original data packet in the target cache 730 is polled and processed by the special application program. Specifically, the special application program checks whether there is a to-be-processed original data packet in the target cache 730 according to the target characteristic value corresponding to the application program, and if there is a to-be-processed original data packet in the target cache 730, the special application program processes the original data packet; if there is no to-be-processed original data packet in the target cache 730, the special application program checks for a to-be-processed original data packet in the target cache 730 at the beginning of the next period.
[0145] In the embodiment of the application, the first characteristic value of the received Ethernet message is acquired by calling the characteristic value acquisition process 621, and the Ethernet message is sent to the data acquisition process 622 if the first characteristic value matches the preset target characteristic value; the original data packet is acquired from the Ethernet message by calling the data acquisition process 622, and the original data packet is stored in the target cache 730 corresponding to the target characteristic value, so that the original data packet is extracted from the target cache 730 according to the target characteristic value for processing by the application program. Since the preset target characteristic value is a characteristic value matched with the application program in the host, the analysis processing of the Ethernet message with the first characteristic value matching the preset target characteristic value can be completed by the characteristic value acquisition process 621 and the data acquisition process 622 in the intelligent network card 600, and the analysis processing of most of the Ethernet messages received by the intelligent network card 600 is offloaded to the intelligent network card 600 for processing, and the original data packet obtained by the intelligent network card 600 can be used for processing by the application program in the host, thereby releasing the computing resources of the CPU.
[0146] Figure 4 A logic block diagram of a message processing device provided by an embodiment of the application is shown, which is applied to an intelligent network card 600, as shown in the figure, the message processing device comprises: Figure 4
[0147] The receiving module 410 is configured to receive an Ethernet message.
[0148] The first calling module 420 is configured to call the characteristic value acquisition process 621 to acquire the first characteristic value of the Ethernet message, and send the Ethernet message to the data acquisition process 622 if the first characteristic value matches the preset target characteristic value; the target characteristic value is a characteristic value matched with the application program in the host.
[0149] The second calling module 430 is configured to call the data acquisition process 622, acquire the raw data packet from the Ethernet message, and store the raw data packet in the target cache 730 matched with the target characteristic value, so that the application extracts the raw data packet from the target cache 730 for processing according to the target characteristic value.
[0150] Optionally, the receiving module 410 comprises:
[0151] The receiving sub-module is configured to receive the target characteristic value issued by the host and store the target characteristic value in the storage area of the intelligent network card 600; the target characteristic value is generated by the host according to the application.
[0152] Optionally, the first calling module 420 comprises:
[0153] The first acquisition sub-module is configured to acquire the first characteristic value of the Ethernet message.
[0154] The sending sub-module is configured to send the Ethernet message to the data acquisition process 622 when the first characteristic value matches the preset target characteristic value; the target characteristic value is a characteristic value matched with the application in the host.
[0155] Optionally, the first acquisition sub-module comprises:
[0156] The parsing unit is configured to parse the Ethernet message according to a data link layer protocol to obtain an IP message.
[0157] The first acquisition unit is configured to parse the IP message according to an IP protocol to obtain a TCP message and a destination IP address in a message header of the IP message.
[0158] The second acquisition unit is configured to parse the TCP message according to a TCP protocol to acquire a destination port number in the TCP message header.
[0159] The calculation unit is configured to calculate the first characteristic value according to the destination IP address and the destination port number.
[0160] Optionally, the second calling module 430 comprises:
[0161] The second acquisition module is configured to acquire fragmentation information in an IP header in the Ethernet message.
[0162] The third acquisition module is configured to acquire the raw data packet from a data segment of the Ethernet message when the fragmentation information is less than or equal to a maximum transmission unit value.
[0163] The fourth obtaining module is configured to, in the case that the fragmentation information is greater than a maximum transmission unit value, perform IP fragmentation reassembly operation and / or TCP rearrangement operation on the plurality of Ethernet messages based on an IP protocol and / or a TCP protocol to obtain the original data packet.
[0164] Optionally, the apparatus further comprises:
[0165] The first storage module is configured to store the Ethernet message into a first receiving buffer.
[0166] The second storage module is configured to, in the case that the first characteristic value matches a preset target characteristic value, store the Ethernet message into a second receiving buffer for processing by the data obtaining process 622; the second receiving buffer is different from the first receiving buffer.
[0167] Figure 5 A logic block diagram of a data processing apparatus provided by an embodiment of the application is shown, which is applied to a host computer, such as Figure 5 As shown in the figure, the data processing apparatus comprises:
[0168] The first obtaining module 510 is configured to obtain, by the application program, a target characteristic value of the application program.
[0169] The second obtaining module 520 is configured to obtain, by the application program, an original data packet from a target buffer 730 corresponding to the target characteristic value according to the target characteristic value; the original data packet in the target buffer 730 is obtained and stored by a data obtaining process 622 of the intelligent network card 600 according to the Ethernet message; the Ethernet message is sent to the data obtaining process 622 by a characteristic value obtaining process 621 of the intelligent network card 600 in the case that a first characteristic value matches a preset target characteristic value; the first characteristic value is obtained by the characteristic value obtaining process 621 according to the Ethernet message.
[0170] The processing module 530 is configured to process, by the application program, the original data packet.
[0171] Optionally, the second obtaining module 520 comprises:
[0172] The first obtaining sub-module is configured to, by the application program, call a preset interface of a network card driver to obtain an original data packet from a target buffer 730 corresponding to the target characteristic value according to the target characteristic value.
[0173] An embodiment of the application provides an intelligent network card 600, as shown in the figure, Figure 6 As shown in the figure, Figure 6A structure schematic diagram of an intelligent network card 600 provided by the embodiment of the present application is shown, the intelligent network card 600 can include a receiving cache 610, a programmable logic device 620 and a network card hard disk 630, wherein the programmable logic device 620 can include a characteristic value acquisition process 621 and a data acquisition process 622; the receiving cache 610 can include a first receiving cache, a second receiving cache and a third receiving cache, the first receiving cache is used for storing the Ethernet message received by the intelligent network card 600 through a receiving port, the second receiving cache is used for storing the Ethernet message with the first characteristic value matching the preset target characteristic value, and the third receiving cache is used for storing the Ethernet message with the first characteristic value not matching the preset target characteristic value.
[0174] The embodiment of the present application further provides a server 700, as shown in the following. Figure 7 Figure 7 A structure schematic diagram of a server 700 provided by the embodiment of the present application is shown, the server 700 can include a central processing unit 710, a hard disk 720, a target cache 730 and one or more intelligent network cards 600 connected with the server 700 host, wherein the central processing unit 710 can include one or more sub-processors, the target cache 730 is used for storing the original data packet sent by the intelligent network card 600, further, the target cache 730 can include one or more sub-target caches corresponding to the target characteristic value respectively, the server can further include a general cache used for storing the Ethernet message with the first characteristic value not matching the preset target characteristic value sent by the intelligent network card 600, the intelligent network card 600 is used for receiving the Ethernet message, and the first target characteristic value is acquired by analyzing the Ethernet message, in the case that the first target characteristic value matches the target characteristic value preset in the intelligent network card 600, the original data packet of the Ethernet message is acquired, and the original data packet is stored in the target cache 730 corresponding to the target characteristic value in the host through the DMA communication mechanism.
[0175] Other embodiments of the application will be apparent to those skilled in the art from consideration of the specification and practice of the application disclosed herein. It is intended that the specification and examples be considered as exemplary only, with the true scope and spirit of the application being indicated by the following claims.
[0176] It should be understood that the application is not limited to the precise construction that has been described above and shown in the accompanying drawings, and that various modifications and changes can be made by those skilled in the art without departing from the scope of the application. The scope of the application is indicated only by the appended claims.
Claims
1. A message processing method, characterized in that, Applications in smart network interface cards (NICs) include: Receive Ethernet packets; The feature value acquisition process is invoked to obtain the first feature value of the Ethernet packet, and if the first feature value matches a preset target feature value, the Ethernet packet is sent to the data acquisition process; the target feature value is a feature value that matches the application in the host. The data acquisition process is invoked to obtain the raw data packet based on the Ethernet message, and the raw data packet is stored in the target cache that matches the target feature value, so that the application can extract the raw data packet from the target cache based on the target feature value for processing; The process of invoking the feature value acquisition process to acquire the first feature value of the Ethernet packet includes: The Ethernet packet is parsed according to the data link layer protocol to obtain the IP packet; The IP packet is parsed according to the IP protocol to obtain the TCP packet and the destination IP address in the packet header; Parse the TCP packet according to the TCP protocol to obtain the destination port number in the TCP packet header; The first feature value is calculated based on the destination IP address and destination port number.
2. The method according to claim 1, characterized in that, Before receiving the Ethernet message, the method further includes: The system receives the target feature value sent by the host and stores the target feature value in the storage area of the smart network card; the target feature value is generated by the host according to the application.
3. The method according to claim 1, characterized in that, The target feature value is generated by the host based on the host's IP address and the application's port number.
4. The method according to claim 1, characterized in that, After receiving the Ethernet message, the method further includes: The Ethernet packet is stored in the first receive buffer; The step of sending the Ethernet packet to the data acquisition process when the first feature value matches a preset target feature value includes: If the first feature value matches a preset target feature value, the Ethernet packet is stored in a second receive buffer for processing by the data acquisition process; the second receive buffer is different from the first receive buffer. The invocation of the data acquisition process to obtain the raw data packet based on the Ethernet message includes: The data acquisition process is invoked to read the Ethernet packet from the second receive buffer and to obtain the raw data packet from the Ethernet packet.
5. The method according to claim 1, characterized in that, The invocation of the data acquisition process to obtain the raw data packet based on the Ethernet message includes: Obtain the fragmentation information from the IP header of the Ethernet packet; If the fragmentation information is less than or equal to the maximum transmission unit value, the original data packet is obtained from the data segment of the Ethernet message; If the fragmentation information is greater than the maximum transmission unit value, IP fragmentation and reassembly operations and / or TCP rearrangement operations are performed on multiple Ethernet packets based on the IP protocol and / or TCP protocol to obtain the original data packet.
6. A data processing method, characterized in that, Applied to a host computer on which an application is installed, including: The target feature value of the application is obtained by the application. The application retrieves the original data packet from the target cache corresponding to the target feature value based on the target feature value. The original data packet in the target cache is retrieved and stored by the data acquisition process of the smart network card based on Ethernet packets. The Ethernet packets are sent to the data acquisition process by the feature value acquisition process of the smart network card if the first feature value matches a preset target feature value. The first feature value is obtained by the feature value acquisition process based on the Ethernet packets. The first feature value is calculated from the destination IP address and the destination port number. The destination port number is obtained by parsing the header of a TCP packet. The TCP packet is obtained by parsing an IP packet according to the IP protocol. The destination IP address is obtained by parsing the header of an IP packet. The IP packet is obtained by parsing an Ethernet packet according to the data link layer protocol. The application processes the raw data packet.
7. The method according to claim 6, characterized in that, The step of the application retrieving the original data packet from the target cache corresponding to the target feature value based on the target feature value includes: The application calls a preset interface of the network card driver based on the target feature value to obtain the original data packet from the target cache corresponding to the target feature value.
8. A message processing apparatus, characterized in that, Applications in smart network interface cards (NICs) include: The receiving module is used to receive Ethernet packets; The first calling module is used to call the feature value acquisition process to acquire the first feature value of the Ethernet packet, and send the Ethernet packet to the data acquisition process if the first feature value matches a preset target feature value; the target feature value is a feature value that matches the application in the host. The second calling module is used to call the data acquisition process, acquire the raw data packet according to the Ethernet message, and store the raw data packet into a target cache that matches the target feature value, so that the application can extract the raw data packet from the target cache according to the target feature value for processing; The first calling module includes: The first acquisition submodule is used to acquire the first feature value of the Ethernet packet; The first acquisition submodule includes: The parsing unit is used to parse the Ethernet packet according to the data link layer protocol to obtain the IP packet; The first acquisition unit is used to parse the IP packet according to the IP protocol to obtain the TCP packet and the destination IP address in the packet header of the IP packet; The second acquisition unit is used to parse the TCP packet according to the TCP protocol and obtain the destination port number in the TCP packet header; The calculation unit is used to calculate the first feature value based on the destination IP address and the destination port number.
9. A data processing apparatus, characterized in that, Applied to a host computer on which an application is installed, including: The first acquisition module is used to acquire the target feature value of the application by the application. The second acquisition module is used by the application to acquire raw data packets from a target cache corresponding to the target feature value, based on the target feature value. The raw data packets in the target cache are acquired and stored by the smart network card's data acquisition process based on Ethernet packets. The Ethernet packets are sent to the data acquisition process by the smart network card's feature value acquisition process when a first feature value matches a preset target feature value. The first feature value is acquired by the feature value acquisition process based on the Ethernet packets. The first feature value is calculated from the destination IP address and destination port number. The destination port number is obtained by parsing the TCP packet header. The TCP packet is obtained by parsing the IP packet according to the IP protocol. The destination IP address is obtained by parsing the IP packet header. The IP packet is obtained by parsing the Ethernet packet according to the data link layer protocol. A processing module is used for processing the raw data packets by the application.
10. A smart network interface card, characterized in that, The smart network interface card is used to implement the message processing method as described in any one of claims 1 to 5.
11. A server, characterized in that, The server includes the smart network interface card as described in claim 10.
Citation Information
Patent Citations
Data message processing method based on FPGA, intelligent network card and CDN server
CN109936513A
Data message processing method and network card
CN109992405A