A method and apparatus for processing stateful services
By acquiring and updating the connection context through the smart network interface card, generating data processing instructions, and downloading data blocks, the problem of low performance in offloading stateful services is solved, and more efficient packet processing is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HUAWEI TECH CO LTD
- Filing Date
- 2020-04-17
- Publication Date
- 2026-04-24
AI Technical Summary
In existing technologies, smart network interface cards (NICs) exhibit low processing performance for individual services when handling stateful service offloading, primarily due to reliance on context updates from the previous connection, resulting in low processing efficiency.
After receiving the connection identifier from the host, the smart network interface card (NIC) obtains and updates the connection context, generates data processing instructions, downloads data blocks from the host via DMA instructions, and performs fragmentation, editing, and encapsulation to generate multiple packets, thereby improving processing performance.
By acquiring the connection context once, the smart NIC can process multiple packets, improving the processing performance of individual stateful services and reducing the complexity and processing time of subsequent editing and encapsulation.
Smart Images

Figure CN115349121B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, and in particular to a method and apparatus for processing stateful services. Background Technology
[0002] With the continuous increase in the types of services and the volume of data in cloud networks, the execution of network or storage protocols has become a computationally intensive operation. When executing network or storage protocols, the host consumes a significant amount of central processing unit (CPU) resources, resulting in a heavy CPU load. Smart network interface cards (NICs), as high-performance network access cards with a network processor at their core, feature a multi-core, multi-threaded network processor architecture. They can handle various network or storage protocols decoupled from the host, thus greatly reducing the host's CPU load. This method of separating the relevant protocol processing from the host and having the smart NIC execute it can be called offload.
[0003] In existing technologies, a host can communicate with a smart network interface card (NIC) via a doorbell (DB) mechanism. For stateful service offloading, the process from receiving a DB from the host to sending the packet to the network port typically involves three stages. Stage 1 is DB processing: obtaining the context of the connection corresponding to the DB, retrieving the working queue element (WQE) of the connection based on the context, and generating a direct memory access (DMA) command. This DMA command carries associated data to guide how to forward and edit subsequent packets downloaded from the host. Stage 2 is DMA command execution: downloading the packet and performing associated processing. The size of the downloaded packet is typically the maximum transmission unit (MTU). Stage 3 involves packet editing and DMA command construction.
[0004] In this context, stage 1 is a stateful stage, meaning that the processing of a database (DB) is strictly dependent on the context of the same connection. Only after the core or thread corresponding to the previous DB has updated the context can the core or thread corresponding to the next DB begin processing based on the updated context. Moreover, the size of the packet downloaded for each DB is only the MTU, which results in low processing performance for a single service. Summary of the Invention
[0005] This application provides a method and apparatus for processing stateful services, which is used to improve the processing performance of individual services when the network interface card (NIC) is handling the offloading of stateful services.
[0006] To achieve the above objectives, this application adopts the following technical solution:
[0007] Firstly, a method for processing stateful services is provided, applied to a network interface card (NIC) connected to a host, for example, via a PCIe bus. The method includes: receiving an identifier of a first connection from the host, for example, the identifier of the first connection may be carried in a first doorbell database (DB) received by the NIC from the host, where the first connection is the connection containing the stateful service; obtaining the context of the first connection based on the identifier of the first connection, the context of the first connection indicating relevant information about the first connection, the context of the first connection being the updated context obtained after the previous data block of the first connection has been processed; generating a data processing instruction based on the context of the first connection, the data processing instruction being usable for processing a first data volume; downloading a data block of the first connection from the host using the transmission bandwidth corresponding to the first data volume; processing the data block of the first connection according to the data processing instruction to obtain multiple packets; and sending the multiple packets.
[0008] In the above technical solution, when the network card receives the first database carrying the identifier of the first connection, the network card can generate a data processing instruction that can be used to process the first amount of data according to the context of the first connection, and download the data block of the first connection from the host, and process the data block of the first connection according to the data processing instruction to obtain multiple packets. Thus, the network card can obtain the context of the first connection once based on the first database, and process and send multiple packets of the first connection based on the context, thereby improving the processing performance of a single stateful service.
[0009] In one possible implementation of the first aspect, the data processing instruction includes a Direct Memory Access (DMA) instruction corresponding to the first data volume, downloading a data block of the first connection from the host, comprising: downloading the data block of the first connection from the host according to the DMA instruction corresponding to the first data volume. In the above possible implementation, the smart network interface card (NIC) can generate a DMA instruction corresponding to the first data volume based on a first database (DB), thereby downloading the data block of the first connection from the host based on the DMA instruction. This allows the smart NIC to process multiple packets of the first connection based on the context of the first connection, thereby improving the processing performance of a single stateful service.
[0010] In one possible implementation of the first aspect, the data processing instruction further includes path-associated data. Processing the data block of the first connection according to the data processing instruction includes: fragmenting the data block of the first connection according to the path-associated data to obtain multiple data fragments. In the above possible implementation, the smart network interface card (NIC) can generate path-associated data corresponding to a first data volume based on a first database (DB), thereby processing the data block of the first connection based on the path-associated data. This allows the smart NIC to process multiple packets of the first connection based on the context of the first connection, thereby improving the processing performance of a single stateful service.
[0011] In one possible implementation of the first aspect, the fragmentation process includes at least one of the following: inserting multiple markers, deleting part of the header data, deleting part of the tail data, determining the message header, determining the cyclic redundancy check (CRC) of the payload, and determining the checksum (CS).
[0012] In one possible implementation of the first aspect, the data processing instruction further includes a message editing instruction. Processing the data block of the first connection according to the data processing instruction also includes: editing and encapsulating multiple data fragments to obtain multiple messages according to the message editing instruction. In the above possible implementation, the smart network interface card (NIC) can generate the message editing instruction simultaneously with the DMA instruction. This avoids waking up the core / thread corresponding to the first database in the smart NIC again when subsequently editing and encapsulating multiple data fragments, thereby further improving processing performance.
[0013] In one possible implementation of the first aspect, the message editing instructions include: header slice editing instructions, middle slice editing instructions, and tail slice editing instructions. The above possible implementations can reduce the complexity of message editing instructions.
[0014] In one possible implementation of the first aspect, before downloading the data block of the first connection from the host using the transmission bandwidth corresponding to the first data volume, the method further includes: allocating transmission bandwidth for the first DB from the available bus bandwidth, the transmission bandwidth being equal to the first data volume. In the above possible implementations, the smart network interface card (NIC) can download multiple packets of the first connection from the host at once, thereby allowing subsequent processing of these multiple packets simultaneously based on the context of the first connection, thus improving the processing performance of a single stateful service.
[0015] In one possible implementation of the first aspect, after downloading the data block of the first connection from the host using the transmission bandwidth corresponding to the first data volume, the method further includes: adjusting the transmission bandwidth based on the difference between the first data volume and the actual data volume of the data block of the first connection. The above possible implementations can improve the flexibility of bandwidth allocation and bandwidth utilization of the smart network interface card.
[0016] Secondly, a stateful service processing apparatus is provided, applied in a network interface card (NIC), which is connected to a host, for example, via a PCIe bus. The apparatus includes: an acquisition unit for receiving an identifier of a first connection from the host, for example, the identifier of the first connection may be carried in a first doorbell database (DB) received by the NIC from the host, where the first connection is the connection containing the stateful service; the acquisition unit is further configured to acquire the context of the first connection based on the identifier of the first connection, the context of the first connection indicating relevant information of the first connection, the context of the first connection being the updated context obtained after the previous data block of the first connection has been processed; a processing unit for generating a data processing instruction based on the context of the first connection, the data processing instruction being usable for processing a first data volume; the acquisition unit is further configured to download a data block of the first connection from the host using the transmission bandwidth corresponding to the first data volume; the processing unit is further configured to process the data block of the first connection according to the data processing instruction to obtain multiple packets; and a sending unit for sending multiple packets.
[0017] In one possible implementation of the second aspect, the data processing instruction includes a direct memory access (DMA) instruction corresponding to the first data amount, and the acquisition unit is further configured to: download the data block of the first connection from the host according to the DMA instruction corresponding to the first data amount.
[0018] In one possible implementation of the second aspect, the data processing instruction further includes path-associated data, and the processing unit is further configured to: perform fragmentation processing on the data block of the first connection according to the path-associated data to obtain multiple data fragments.
[0019] In one possible implementation of the second aspect, the fragmentation process includes at least one of the following: inserting multiple markers, deleting part of the header data, deleting part of the tail data, determining the message header, determining the cyclic redundancy check (CRC) of the payload, and determining the checksum (CS).
[0020] In one possible implementation of the second aspect, the data processing instruction further includes a message editing instruction, and the processing unit is further configured to: edit and encapsulate multiple data fragments according to the message editing instruction to obtain multiple messages. Optionally, the message editing instruction includes: an editing instruction for the header fragment, an editing instruction for the middle fragment, and an editing instruction for the tail fragment.
[0021] In one possible implementation of the second aspect, the apparatus further includes: a bandwidth allocation unit for allocating transmission bandwidth for the first DB from the available bus bandwidth, the transmission bandwidth being equal to the first data amount.
[0022] In one possible implementation of the second aspect, the bandwidth allocation unit is further configured to: adjust the transmission bandwidth based on the difference between the first data volume and the actual data volume of the data block of the first connection.
[0023] In another aspect of this application, a stateful service processing apparatus is provided. The apparatus is a network interface card (NIC) or a chip built into the NIC. The apparatus includes a memory and a processor coupled to the memory. The memory stores code and data. The processor executes the code in the memory to cause the apparatus to perform the stateful service processing method provided by the first aspect or any possible implementation thereof.
[0024] In another aspect of this application, a communication system is provided, the communication system including a network interface card (NIC) and a host, the NIC being connected to the host via a bus; wherein the NIC is the NIC provided in any of the above aspects, used to execute the stateful service processing method provided in the first aspect or any possible implementation of the first aspect.
[0025] In another aspect of this application, a computer-readable storage medium is provided, wherein instructions are stored therein, which, when executed on a computer, cause the computer to perform the stateful business processing method provided by the first aspect or any possible implementation thereof.
[0026] In another aspect of this application, a computer program product is provided, the computer program product including computer-executable instructions stored in a computer-readable storage medium; at least one processor of the device can read the computer-executable instructions from the computer-readable storage medium, and the at least one processor executes the computer-executable instructions to cause the device to perform the stateful business processing method provided by the first aspect or any possible implementation of the first aspect.
[0027] Understandably, any of the stateful business processing devices, computer storage media, or computer program products provided above are used to execute the corresponding methods provided above. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the corresponding methods provided above, and will not be repeated here. Attached Figure Description
[0028] Figure 1 This application provides a schematic diagram of the structure of a communication system according to an embodiment of the present application.
[0029] Figure 2 A flowchart illustrating a stateful service processing method provided in an embodiment of this application;
[0030] Figure 3 This is a schematic diagram of a segmentation process provided in an embodiment of this application;
[0031] Figure 4 This is a schematic diagram of the structure of a smart network interface card provided in an embodiment of this application;
[0032] Figure 5 This is a schematic diagram illustrating a multi-message processing method provided in an embodiment of this application.
[0033] Figure 6 A schematic diagram of the structure of a stateful service processing device provided in an embodiment of this application;
[0034] Figure 7 This is a schematic diagram of another stateful service processing device provided in an embodiment of this application. Detailed Implementation
[0035] In this application, "at least one" means one or more, and "more than one" means two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can mean: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can mean: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple. Furthermore, embodiments of this application use terms such as "first" and "second" to distinguish identical or similar items with essentially the same function and effect. For example, the first threshold and the second threshold are merely to distinguish different thresholds and do not limit their order. Those skilled in the art will understand that terms such as "first" and "second" do not limit the quantity or execution order.
[0036] It should be noted that, in this application, the terms "exemplary" or "for example" are used to indicate that something is being described as an example, illustration, or illustration. Any embodiment or design described as "exemplary" or "for example" in this application should not be construed as being more preferred or advantageous than other embodiments or design solutions. Specifically, the use of terms such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.
[0037] Figure 1This is a schematic diagram of a communication system provided in an embodiment of this application. The communication system includes a host and a network interface card (NIC), which are connected to the NIC via a bus. For example, the NIC is a smart network interface card (smart NIC), which is connected to the host via a peripheral component interconnect express (PCIe) bus. Optionally, the communication system may include one or more hosts, all of which can be connected to the smart NIC. The following description uses a smart NIC as an example to illustrate the embodiments of this application.
[0038] The host machine contains multiple virtual machines (VMs), each running one or more virtual functions (VFs). These VFs can correspond to different functions, and each VF can also correspond to one or more queues, which are used to implement the input and output mechanisms of that VF. These queues can include transmit queues and receive queues. The smart network interface card (NIC) can handle various network or storage protocols decoupled from the host machine, a process also known as protocol offloading.For example, network offloading can include virtualization I / O (Virt IO) offloading, single-root I / O virtualization (SR-IOV) offloading, user datagram protocol (UDP) / transmission control protocol (TCP) / Internet Protocol (IP) checksum (CS) offloading, receive-side scaling (RSS) offloading / TCP segment offload (TSO) / large receive offload (LRO) offloading, virtual extensible local area network (VxLAN) / generic network virtualization encapsulation (Geneve) offloading, stateful open virtual switch (OVS) offloading, IP security (IPSec) offloading, TCP offload engine (TOE) offloading, and Remote DMA over Converged Ethernet version 2 (RDMA). Storage-related offloading can include erasure coding (EC) offloading, virtual block service (VBS) offloading, T10 data integrity field (DIF) / data integrity extension (DIX) offloading, fiber channel (FC) offloading, nonvolatile memory express (NVMe) offloading, and nonvolatile memory over fabric (NVME) offloading.
[0039] Additionally, when the host needs to send packets to the Ethernet (Eth) via the smart network interface card (NIC), the host can communicate with the smart NIC through a doorbell (DB) mechanism. The smart NIC processes the relevant packets and sends the processed packets to the Eth. In one possible embodiment, the smart NIC may include: a transmit bandwidth provision (TX) module, a receive bandwidth provision (RX) module, a transmit processing (TX) module, a receive processing (RX) module, a scheduler, a processor pool including multiple processor cores, a traffic manager, a transmit port (TX port) for sending packets to the Eth, and a receive virtual machine (RX VM) for sending packets to the host. Optionally, the processor pool in the smart NIC can be an application-specific integrated circuit (ASIC) or a field-programmable gate array (FPGA), etc., and this application embodiment does not impose specific limitations on this.
[0040] Figure 2 This application provides a flowchart illustrating a method for processing stateful services, which can be applied to... Figure 1 In the communication system shown, which includes a host and a smart network interface card, the method includes the following steps.
[0041] S201: The smart network card receives the identifier of the first connection from the host. The first connection is the connection where the stateful service is located.
[0042] Here, a connection refers to a logical link established between two sessions. For example, this connection can be a TCP connection, a UDP connection, or a ROCE queue pair (QP) connection. The host can establish multiple connections with the network (Eth) through the smart network interface card (NIC). The first connection can be any one of these multiple connections, and an identifier for the first connection can be used to identify it. Optionally, the identifier for the first connection can be carried in a first database (DB). For example, the smart NIC receives a first DB from the host, and the first DB carries the identifier of the host's first connection.
[0043] Furthermore, the aforementioned stateful services correspond to stateless services. Stateless services can be defined as services where individual message processing is based solely on the message's header, with no correlation between messages. Stateful services, on the other hand, cannot determine how to process a single message; the processing depends on the state of the connection it belongs to and the message's own information. In other words, stateful services involve correlation between messages, and the connection's state information includes, but is not limited to, the sequence number of the expected next message, the ACK sequence number, receive window updates, and statistics. For clarity, we will use firewalls as an example to illustrate stateful and stateless firewalls. The firewalls mentioned here can include firewalls at different levels, such as security groups in OpenStack. Stateless firewalls filter or block network packets based on static values, such as addresses, ports, and protocols; that is, stateless firewalls do not concern themselves with the current network connection state. Stateful firewalls can distinguish the state of network connections. For example, a stateful firewall can distinguish a TCP connection and which stage of the TCP connection it is currently in. In other words, a stateful firewall can filter or block network packets based on the connection state, in addition to static values.
[0044] When the host needs to send a first connection packet to the network via the smart network interface card (NIC), it can send a first database (DB) carrying the identifier of the first connection to the NIC. Specifically, this can be sent by a first virtual machine (VF) running on the first virtual machine (VM) within the host. The first VF can be a VF used to perform tasks related to the first connection. Specifically, when the first VF running on the first VM needs to send a first connection packet to the network via the smart NIC, the first VF can post a corresponding working queue element (WQE) to its corresponding first sending queue. The first sending queue is a queue used to send packets for the first connection. This WQE can describe the size of the sent packet and its storage address in the host's memory; it can also be called a descriptor. Afterward, the first VF can send the first DB to the smart NIC, which can then receive the first DB, which carries the identifier of the first connection.
[0045] Optionally, the first database may also carry an identifier for the first virtual function (VF). The identifier for the first VF can be used to uniquely identify the first VF among multiple VFs on the host. When the first database carries only an identifier for the first connection, the identifier for the first connection can be used to uniquely identify the first connection corresponding to the first VF among multiple VFs on the host. When the first database carries both an identifier for the first connection and an identifier for the first VF, the identifier for the first VF can be used to uniquely identify the first VF among multiple VFs on the host, and the identifier for the first connection can be used to uniquely identify the first connection among multiple connections corresponding to the first VF.
[0046] S202: The smart network interface card obtains the context of the first connection based on the identifier of the first connection.
[0047] Specifically, the smart network interface card's (NIC) cache may or may not store the context of the first connection. When the smart NIC does not store the context of the first connection, it can retrieve it from the host based on the first connection's identifier. When the smart NIC stores the context of the first connection, it can retrieve it from its own cache. The context of the first connection records relevant information about the first connection, such as the address of the first transmission queue in the host's memory, the current transmission position in the first transmission queue, the transmission window, and the sequence number of the transmitted packet. Furthermore, the context of the first connection is updated after the previous data block of the first connection has been processed.
[0048] S203: The smart network card generates a data processing instruction based on the context of the first connection, which can be used to process a first amount of data.
[0049] The first data volume can be preset and is greater than the maximum transmission unit (MTU). The specific value of the first data volume can be fixed or variable, and can be set by those skilled in the art based on experience or actual conditions. For example, the first data volume can be 64KB, but this application embodiment does not specifically limit it.
[0050] Specifically, the smart network interface card (NIC) can obtain a WQE from the host's first transmission queue based on the context of the first connection. For example, it can obtain the WQE from the host's first transmission queue based on the address of the first transmission queue indicated by the context of the first connection. Then, based on the size of the transmitted packet indicated by the WQE (e.g., the first data volume) and the storage address of the transmitted packet in the host's memory, it can generate a data processing instruction corresponding to the first data volume. Optionally, the data processing instruction may further include at least one of a direct memory access (DMA) command, associated data, and packet edit (PE) instruction corresponding to the first data volume. The associated data is used to indicate fragmentation information. The packet edit instruction can be a three-segment PE instruction, specifically including an editing instruction for the header slice, an editing instruction for at least one intermediate slice, and an editing instruction for the tail slice.
[0051] Furthermore, the smart network interface card can also update the context of the first connection after executing step S203, and store the updated context of the first connection in a buffer, or send the updated context of the first connection to the host.
[0052] S204: The smart network card uses the transmission bandwidth corresponding to the first data volume to download the data block of the first connection from the host.
[0053] The transmission bandwidth corresponding to the first data volume can be equal to the first data volume. Before downloading the first connection data block from the host, the smart network interface card (NIC) can allocate the transmission bandwidth for the first DB from the available bus bandwidth (the available bus bandwidth corresponding to the PCIe bus). When the smart NIC needs to download the first connection data block from the host, it can use the transmission bandwidth to download the first connection data block from the host. The first connection data block may include data from multiple packets. Optionally, the data processing instruction may include a DMA instruction, which carries the storage address of the first connection data block in the host memory, so that the smart NIC can download the first connection data block from the host through the DMA instruction.
[0054] Furthermore, the actual data volume of the data block in the first connection can be equal to or less than the first data volume. When the actual data volume is less than the first data volume, the smart network card can reduce the transmission bandwidth based on the difference between the first data volume and the actual data volume, thereby saving the available bus bandwidth corresponding to the PCIe bus.
[0055] S205: The smart network card processes the data block of the first connection according to the data processing instruction to obtain multiple packets.
[0056] The data processing instructions may include path-associated data, which can be used to guide the smart network interface card (NIC) to fragment data according to the maximum segment size (MSS) and calculate the checksum (CS). For example, the path-associated data may include information indicating the size (MSS) of each data fragment, information indicating the calculation of the checksum for each data fragment, information indicating the interval or length of inserted markers, and information indicating the deletion of partial data. Therefore, the smart NIC can fragment the data block of the first connection according to the path-associated data to obtain multiple data fragments. This fragmentation process may include at least one of the following: inserting multiple markers, deleting part of the header data, deleting part of the tail data, determining the packet header, determining the cyclic redundancy check (CRC) of the payload, and determining the CS. Optionally, the markers may be DIF or DIX, etc.; the deleted header data may be redundant data, for example, data that has already been sent previously; the deleted tail data may be redundant data, for example, data that is insufficient for the payload of a single packet.
[0057] For example, such as Figure 3 As shown, when the data block of the first connection is a Small Computer System Interface (Internet Small Computer System Interface) Protocol Data Unit (PDU) from the CPI interface, and the iSCSI PDU includes an iSCSI header (HDR) and an iSCSI PDU payload (also called iSCSI PDU data), the smart network interface card (NIC) can insert multiple DIFs into the iSCSI PDU payload to determine that the packet header is iSCSI HDR, and to determine the CRC of the iSCSI HDR. Figure 3 The CRC of the payload is represented as HDRCRC and the CRC of the payload. Figure 3 The data is represented as CRC in the table. After that, the iSCSI PDU payload can be fragmented into multiple data fragments according to the MSS. Figure 3 PAD in this context is short for padding, which can be used to represent the data portion being filled, specifically indicated by the associated data.
[0058] In addition, the data processing instructions may also include message editing instructions. The smart network interface card (NIC) can edit and encapsulate multiple data fragments obtained from fragmentation processing to obtain multiple messages. Specifically, when the message editing instruction is a three-segment PE instruction, the smart NIC can encapsulate the first data fragment (also called the first data fragment or head fragment) among multiple data fragments according to the header fragment editing instruction, encapsulate the second to penultimate data fragments (also called intermediate data fragments or intermediate pieces) among multiple data fragments according to at least one intermediate fragment editing instruction, and encapsulate the penultimate data fragment (also called the tail data fragment or tail piece) among multiple data fragments according to the tail fragment editing instruction, thus obtaining multiple messages. Optionally, the at least one intermediate fragment editing instruction can also be used to indicate the change pattern of the message header when encoding and encapsulating the second to penultimate data fragments, such as the TCP sequence number (SN) being incremented and the IP ID being the same.
[0059] S206: The smart network card sends multiple messages.
[0060] Once the smart network interface card (NIC) receives multiple packets, it can send these packets to the network via the network port. Optionally, after sending the packets to the network, the smart NIC can also send feedback information to the host, indicating that the packets were successfully sent.
[0061] For ease of understanding, the following will be used as an example. Figure 4 Taking the structure of the smart network card shown as an example, the solution provided in the embodiments of this application will be illustrated.
[0062] The TX bandwidth allocation module of the smart network interface card (NIC) may include multiple DB queues (DB Q), a queue mapping (QM) module, and a bandwidth allocation node ( Figure 4 The schedulers (represented as vNIC in Chinese) and round-robin (RR) scheduling (in Chinese) Figure 4 (represented as RR in Chinese). Figure 4 The following example illustrates the connection between multiple DBQs and multiple hosts (i.e., the smart network card is connected to multiple hosts (e.g., H0 to H3)).
[0063] Specifically, after the host sends the first database (DB) to the smart network interface card (NIC), the first DB can be enqueued in multiple DB queues according to certain rules and mapped to the corresponding bandwidth allocation node through the queue mapping module to complete the allocation of transmission bandwidth. Then, the traffic manager (RR) allocates a processor core or a thread from the processor pool to the first DB. The allocated processor core or thread will be referred to as a core / thread below. The core / thread can obtain the context of the first connection based on the identifier of the first connection carried by the first DB, and generate DMA instructions for the first data volume, along-path associated data, and message editing instructions according to the context of the first connection. It then downloads the data block of the first connection from the host through the DMA instructions. Optionally, the core / thread can also send the difference between the first data volume and the actual data volume of the data block of the first connection to the corresponding bandwidth allocation node so that the bandwidth allocation node can adjust the transmission bandwidth of the first DB. The TX processing module can complete the fragmentation processing of the data block of the first connection according to the along-path associated data. The resulting multiple data fragments can be stored in the memory of the smart NIC. The traffic manager can schedule multiple data fragments from memory and edit and encapsulate the data fragments according to the message editing instructions. The resulting message can be sent to the network through the TX port.
[0064] Furthermore, the context of the first connection can be decomposed into multiple sub-contexts, allowing different processor cores or threads of the smart NIC to concurrently process different databases (DBs) based on different sub-contexts, thereby improving the throughput of packets in the first connection. For example, such as... Figure 5 As shown, the context of the first connection can be decomposed into four sub-contexts, denoted as S0, S1, S2, and S3, respectively. This allows the smart NIC to simultaneously process the four databases (DBs) of the first connection, denoted as DB1, DB2, DB3, and DB4. Assuming the scheduler allocates processor cores Core1, Core2, Core3, and Core4 to the four DBs, after Core1 finishes processing DB1S0, it can continue processing DB1S1, at which point Core2 can process DB2S0; after Core1 finishes processing DB1S1, it can continue processing DB1S2, at which point Core2 finishes processing DB2S0 and can begin processing DB2S1, while Core3 can begin processing DB3S0, and so on. Furthermore, if the first connection also corresponds to DB5, then after Core1 completes the processing of DB1S3, Core1 can start processing DB5S0, Core2 can start processing DB2S3, Core3 can start processing DB3S2, and Core4 can start processing DB4S1. This allows the four cores of the smart network card to participate concurrently in the context processing of the first connection, with each core processing one data block of the first connection, thereby improving the throughput of the packets in the first connection.
[0065] In this embodiment, when the smart network interface card (NIC) receives a first database (DB) carrying the identifier of the first connection, it can generate a data processing instruction for a first amount of data based on the context of the first connection, download the data block of the first connection from the host, and process the data block of the first connection according to the data processing instruction to obtain multiple packets. Thus, the smart NIC can obtain the context of the first connection once based on the first DB and process and send multiple packets of the first connection based on that context, thereby improving the processing performance of a single stateful service. Furthermore, the smart NIC can generate packet editing instructions simultaneously when generating DMA instructions. This avoids waking up the core / thread corresponding to the first DB in the smart NIC again when editing and encapsulating multiple data fragments later, further improving processing performance.
[0066] The above primarily describes the solutions provided in the embodiments of this application from the perspective of interaction between various devices. It is understood that each device, such as the host and the smart network interface card, includes corresponding hardware structures and / or software modules to perform the aforementioned functions. Those skilled in the art should readily recognize that, based on the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0067] This application embodiment can divide the smart network interface card (NIC) into functional modules according to the above method example. For example, each function can be divided into its own functional modules, or two or more functions can be integrated into one module. The integrated module can be implemented in hardware or as a software functional module. It should be noted that the module division in this application embodiment is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods. The following description uses the division of functional modules according to each function as an example.
[0068] When using integrated units, Figure 6A possible structural diagram of the stateful service processing apparatus involved in the above embodiments is shown. The apparatus can be a smart network interface card (NIC) or a chip built into a smart NIC. The apparatus includes: an acquisition unit 601, a processing unit 602, and a transmission unit 603. The acquisition unit 601 supports the apparatus in executing steps S201, S202, and S204 in the above method embodiments; the processing unit 602 supports the apparatus in executing steps S203 and S205 in the above method embodiments; and the transmission unit 603 supports the apparatus in executing step S206 in the above method embodiments. Further, the apparatus may also include a bandwidth allocation unit 604, used to support the apparatus in executing the step of allocating transmission bandwidth in the above method embodiments.
[0069] In practical applications, the processing unit 602 can be an integration of the TX processing module, scheduler, processor pool and traffic manager in the smart network card described in the above method embodiments, the bandwidth allocation unit 604 can be the TX bandwidth allocation module in the smart network card described in the above method embodiments, and the sending unit 603 can be the TX port in the smart network card described in the above method embodiments.
[0070] It should be noted that all relevant content of each step involved in the above method embodiments can be referenced to the functional description of the corresponding functional module. For details, please refer to the description in the above method embodiments. This application embodiment will not repeat the description here.
[0071] Based on hardware implementation, the processing unit 602 in this application can be the processor of the device, the acquisition unit 601 can be the receiver of the device, and the sending unit 603 can be the transmitter of the device. The receiver and the transmitter can usually be integrated together as the communication interface of the device.
[0072] like Figure 7 The diagram illustrates a possible logical structure of a stateful service processing apparatus as described in the embodiments of this application. The apparatus can be a smart network interface card (NIC) or a chip embedded in a smart NIC. The apparatus includes a processor 702 and a communication interface 703. The processor 702 controls and manages the operation of the apparatus; for example, it supports the apparatus in executing steps S203 and S205 in the above method embodiments, and / or other processes using the techniques described herein. Furthermore, the apparatus may include a memory 701 and a bus 704. The processor 702, communication interface 703, and memory 701 are interconnected via the bus 704. The communication interface 703 supports communication by the apparatus, such as communication between the apparatus and a host or network. The memory 701 stores the apparatus's program code and data.
[0073] The processor 702 can be a central processing unit, a general-purpose processor, a baseband processor, a digital signal processor, an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. The processor can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a digital signal processor and a microprocessor, etc. The bus 704 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus 704 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0074] In another aspect of this application, a communication system is provided, the communication system including a network interface card (NIC) and a host, the NIC being connected to the host via a bus; wherein the NIC is any of the NICs provided above, used to perform the steps of the NIC in the above method embodiments.
[0075] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of modules or units is merely a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another apparatus, or some features may be ignored or not executed.
[0076] The units described as separate components may or may not be physically separate. A component shown as a unit can be one or more physical units; that is, it can be located in one place or distributed in multiple different locations. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0077] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0078] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. This readable storage medium may include various media capable of storing program code, such as a USB flash drive, external hard drive, read-only memory, random access memory, magnetic disk, or optical disk. Based on this understanding, the technical solution of the embodiments of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product.
[0079] In another embodiment of this application, a readable storage medium is also provided, which stores computer-executable instructions for a device (which may be a microcontroller, chip, etc.) or a processor to execute the stateful service processing method provided in the above method embodiments.
[0080] In another embodiment of this application, a computer program product is also provided, which includes computer-executable instructions stored in a computer-readable storage medium; at least one processor of the device can read the computer-executable instructions from the computer-readable storage medium, and the at least one processor executes the computer-executable instructions to cause the device to perform the stateful service processing method provided in the above method embodiments.
[0081] Finally, it should be noted that the above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for processing stateful services, characterized in that, The method is applied to a network interface card (NIC), which is connected to a host, and includes: Receive an identifier of a first connection from the host, wherein the first connection is the connection where a stateful service resides; The context of the first connection is obtained based on the identifier of the first connection. The context of the first connection is used to indicate the relevant information of the first connection. The context of the first connection is the updated context obtained after the previous data block of the first connection has been processed. Data processing instructions are generated based on the context of the first connection, and the data processing instructions can be used to process a first amount of data. Download the data block of the first connection from the host using the transmission bandwidth corresponding to the first data volume; The data blocks of the first connection are processed according to the data processing instructions to obtain multiple messages; Send the aforementioned multiple messages.
2. The method according to claim 1, characterized in that, The data processing instructions include direct memory access (DMA) instructions corresponding to the first data volume, and the step of downloading the data block of the first connection from the host includes: According to the DMA instruction corresponding to the first data volume, download the data block of the first connection from the host.
3. The method according to claim 1, characterized in that, The data processing instructions also include associated data, and processing the data block of the first connection according to the data processing instructions includes: The data block of the first connection is fragmented based on the associated data to obtain multiple data fragments.
4. The method according to claim 3, characterized in that, The fragmentation process includes at least one of the following: Insert multiple markers, delete part of the header data, delete part of the tail data, determine the message header, determine the cyclic redundancy check (CRC) of the payload, and determine the checksum (CS).
5. The method according to claim 3 or 4, characterized in that, The data processing instructions further include message editing instructions, and the step of processing the data block of the first connection according to the data processing instructions further includes: According to the message editing instructions, the multiple data fragments are edited and encapsulated to obtain the multiple messages.
6. The method according to claim 5, characterized in that, The message editing instructions include: header slice editing instructions, middle slice editing instructions, and tail slice editing instructions.
7. The method according to claim 1, characterized in that, The identifier for receiving the first connection from the host includes: Receive a first doorbell DB from the host, the first doorbell DB carrying an identifier of a first connection in the host.
8. The method according to claim 7, characterized in that, Before downloading the data block of the first connection from the host using the transmission bandwidth corresponding to the first data volume, the method further includes: The transmission bandwidth is allocated from the available bus bandwidth to the first doorbell DB, and the transmission bandwidth is equal to the first data volume.
9. The method according to claim 8, characterized in that, After downloading the data block of the first connection from the host using the transmission bandwidth corresponding to the first data volume, the method further includes: The transmission bandwidth is adjusted based on the difference between the first data volume and the actual data volume of the data block in the first connection.
10. A stateful service processing apparatus, characterized in that, The device is used in a network interface card (NIC), which is connected to a host, and includes: The acquisition unit is used to receive the identifier of the first connection from the host, wherein the first connection is the connection where the stateful service is located. The acquisition unit is further configured to acquire the context of the first connection based on the identifier of the first connection. The context of the first connection is used to indicate the relevant information of the first connection. The context of the first connection is the context updated after the previous data block of the first connection is processed. The processing unit generates a data processing instruction based on the context of the first connection, and the data processing instruction can be used to process a first amount of data. The acquisition unit is further configured to download the data block of the first connection from the host using the transmission bandwidth corresponding to the first data volume; The processing unit is further configured to process the data block of the first connection according to the data processing instruction to obtain multiple messages; A sending unit is used to send the plurality of messages.
11. The apparatus according to claim 10, characterized in that, The data processing instructions include direct memory access (DMA) instructions corresponding to the first data volume, and the acquisition unit is further configured to: According to the DMA instruction corresponding to the first data volume, download the data block of the first connection from the host.
12. The apparatus according to claim 10, characterized in that, The data processing instructions also include associated data, and the processing unit is further configured to: The data block of the first connection is fragmented based on the associated data to obtain multiple data fragments.
13. The apparatus according to claim 12, characterized in that, The fragmentation process includes at least one of the following: inserting multiple markers, deleting part of the header data, deleting part of the tail data, determining the message header, determining the cyclic redundancy check (CRC) of the payload, and determining the checksum (CS).
14. The apparatus according to claim 12 or 13, characterized in that, The data processing instructions also include message editing instructions, and the processing unit is further configured to: According to the message editing instructions, the multiple data fragments are edited and encapsulated to obtain the multiple messages.
15. The apparatus according to claim 14, characterized in that, The message editing instructions include: header slice editing instructions, middle slice editing instructions, and tail slice editing instructions.
16. The apparatus according to claim 10, characterized in that, The acquisition unit is further configured to: Receive a first doorbell DB from the host, the first doorbell DB carrying an identifier of a first connection in the host.
17. The apparatus according to claim 16, characterized in that, The device further includes: A bandwidth allocation unit is used to allocate the transmission bandwidth to the first doorbell DB from the available bus bandwidth, the transmission bandwidth being equal to the first data amount.
18. The apparatus according to claim 17, characterized in that, The bandwidth allocation unit is further configured to: The transmission bandwidth is adjusted based on the difference between the first data volume and the actual data volume of the data block in the first connection.
19. A stateful service processing apparatus, characterized in that, The stateful service processing device is a network interface card (NIC) or a chip built into the NIC. The device includes a memory and a processor coupled to the memory. The memory stores code and data. The processor executes the code in the memory to cause the device to perform the stateful service processing method according to any one of claims 1-9.
20. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions that, when executed on a computer, cause the computer to perform the stateful service processing method according to any one of claims 1-9.
21. A computer program product, characterized in that, When the computer program product is run on the device, the device performs the stateful service processing method according to any one of claims 1-9.
Citation Information
Patent Citations
In-chip connection management-based RDMA communication method
CN103248467A
A method and device for sending messages
CN108429700A