Network card control method and device, communication equipment, readable storage medium and program product
By dividing network card memory into first and second areas, and prefetching and cacheing the send-out queue information when needed, the problem of network card performance is solved, and efficient memory utilization and performance improvement is achieved.
Patent Information
- Application Number
- CN202411785780.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-06
- Publication Date
- 2025-03-07
AI Technical Summary
The performance of existing network cards is limited and cannot be effectively improved, especially in large connection scenarios, where the memory utilization rate is low, resulting in insufficient performance.
By dividing the network card memory into a first memory area and a second memory area, the second memory area is used as a cache of the first memory area, and the extension queue information is prefetched and cached only when it is needed to use it to improve memory utilization.
It realizes that only requires very little memory to support in large connection scenarios, avoids the memory occupied by idle queue information, improves the utilization rate of network card memory, and thus improves the performance of network card without increasing memory card or replacing larger memory.
Smart Images

Figure CN119583488A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information technology, and in particular to a network card control method, device, communication equipment, computer-readable storage medium and computer program product. Background Art
[0002] Current network card technologies can transfer protocols originally processed by the host operating system to the network card for processing, without requiring the host CPU to participate too much, thereby improving performance, such as RDMA (Remote Direct Memory Access) technology. However, due to factors such as hardware costs, network card performance is limited. Summary of the invention
[0003] Based on this, it is necessary to provide a network card control method, device, computer equipment, computer readable storage medium and computer program product to improve the performance of the network card in response to the above technical problems.
[0004] In a first aspect, the present application provides a network card control method, comprising:
[0005] Acquire the sending and receiving queue information corresponding to the existing communication connection, and store the sending and receiving queue information in the first memory area of the network card; the memory of the network card is pre-divided into a first memory area and a second memory area, and the second memory area is a cache of the first memory area, and the second memory area supports direct access;
[0006] In the case where there is communication data to be processed, determining the receiving and sending queue information matching the communication data to be processed as the target queue information;
[0007] In the case where it is detected that the target queue information is missing in the second memory area, the target queue information is extracted from the first memory area, and the target queue information is cached in the second memory area;
[0008] The network card is controlled to process the communication data to be processed based on the target queue information in the second memory area.
[0009] In one embodiment, the method further comprises:
[0010] Determine the communication connection status corresponding to the target queue information;
[0011] When the communication connection state is in an active state, the target queue information is kept cached in the second memory area.
[0012] In one embodiment, the method further comprises:
[0013] When the communication connection state is in an inactive state, the target queue information is marked dirty;
[0014] When the free storage space corresponding to the second memory area reaches a preset standard and / or the dirty target queue information in the second memory area needs to be overwritten, the dirty target queue information is transferred to the first memory area.
[0015] In one of the embodiments, the method further includes: allocating corresponding connection identification information to the existing communication connection;
[0016] Determine the receiving and sending queue information matching the communication data to be processed as the target queue information, including:
[0017] According to the connection identification information, the receiving and sending queue information matching the communication data to be processed is determined as the target queue information.
[0018] In one embodiment, extracting target queue information from the first memory area includes:
[0019] Based on the connection identification information, determining the physical address corresponding to the target queue information from the physical address table corresponding to the receiving and sending queue information; the physical address table is pre-created in the first memory area and is indexed by the connection identification information;
[0020] According to the physical address, the target queue information is extracted from the first memory area.
[0021] In one of the embodiments, the method further includes: allocating corresponding cache identification information to the existing communication connection;
[0022] Cache the target queue information in the second memory area, including:
[0023] The target queue information is cached in a cache table in the second memory area using the cache identification information corresponding to the target queue information as an index; the cache table is pre-created in the second memory area and uses the cache identification information as an index.
[0024] In a second aspect, the present application further provides a network card control device, characterized in that the device comprises:
[0025] A storage module is used to obtain the receiving and sending queue information corresponding to the existing communication connection, and store the receiving and sending queue information in the first memory area of the network card; the memory of the network card is pre-divided into a first memory area and a second memory area, and the second memory area is a cache of the first memory area, and the second memory area supports direct access;
[0026] A determination module, configured to determine, when there is communication data to be processed, receiving and sending queue information matching the communication data to be processed as target queue information; when it is detected that the target queue information is missing in the second memory area, extract the target queue information from the first memory area, and cache the target queue information in the second memory area;
[0027] The control module is used to control the network card to process the communication data to be processed based on the target queue information in the second memory area.
[0028] In a third aspect, the present application further provides a communication device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the network card control method in the first aspect when executing the computer program.
[0029] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the network card control method in the aforementioned first aspect.
[0030] In a fifth aspect, the present application also provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the network card control method in the aforementioned first aspect.
[0031] The above-mentioned network card control method, device, communication equipment, computer-readable storage medium and computer program product, in this embodiment, since the network card memory can be divided into a first memory area and a second memory area, the receiving and sending queue information can be stored in the first memory area. At the same time, the second memory area, as a cache of the first memory, can cache the target queue information for direct reading by the network card. The receiving and sending queue information does not need to reside in the second memory area, but only needs to be pre-fetched in advance, so only a very small amount of memory is needed to support large connection scenarios. In this way, when the relevant receiving and sending queue information (target queue information) is needed, it is cached, which can avoid the receiving and sending queue information that is in an idle state and has no use demand occupying the network card memory, thereby improving the utilization rate of the network card memory, and then helping to improve the performance of the network card. At the same time, this does not require adding a new memory card or replacing a larger memory card, etc., so it can save hardware costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0033] Figure 1A schematic diagram of a flow chart of a network card control method in an embodiment;
[0034] Figure 2 Another schematic diagram of a flow chart of a network card control method in an embodiment;
[0035] Figure 3 A schematic diagram of network card memory division in a network card control method in one embodiment;
[0036] Figure 4 A schematic diagram of another network card memory division in a network card control method in another embodiment;
[0037] Figure 5 is a structural block diagram of a network card control device in an embodiment;
[0038] Figure 6 FIG. 4 is a diagram showing the internal structure of a communication device in one embodiment. DETAILED DESCRIPTION
[0039] In order to make the purpose, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. The multiple references herein may be two or more, unless otherwise specified. Before specifically describing the technical solutions provided by the present application, the relevant terms are described as follows:
[0040] DMA: Direct Memory Access, directly access memory, read and write memory directly without CPU intervention.
[0041] RDMA: Remote DMA, a technology that can directly access memory across the network without CPU intervention.
[0042] RNIC: RDMA NIC, a network card that supports RDMA.
[0043] SQ: Send Queue, sending queue; RQ: Receive Queue, receiving queue.
[0044] QP: Queue Paris, SQ and RQ form a pair of QP.
[0045] WQE: Work Queue Element. Connecting multiple WQEs in series to form a queue becomes an SQ or RQ.
[0046] QPC: Queue Paris Context, context information of QP.
[0047] QPN: Queue Paris Number, each QP will be assigned a unique number.
[0048] PCIe: A high-speed serial computer expansion bus standard.
[0049] Tx: sending direction; Rx: receiving direction.
[0050] Cache: Cache.
[0051] After explaining the relevant terms, the technical solution of the present application is described below in the form of multiple embodiments.
[0052] In one embodiment, Figure 1 As shown, a network card control method is provided. This embodiment uses the method applied to the hardware engine of the network card as an example, wherein the hardware engine can be a hardware module integrated on the network card. Exemplarily, the hardware engine can be dedicated to executing the control of the network card, or it can be non-dedicated. For example, it can also be responsible for tasks such as temperature management of the network card. It can be understood that the method can also be applied to the network card, and the network card can be a smart network card. In this embodiment, the method includes steps S101 to S10:
[0053] Step S101: Obtain the receiving and sending queue information corresponding to the existing communication connection, and store the receiving and sending queue information in the first memory area of the network card; the memory of the network card is pre-divided into a first memory area and a second memory area, and the second memory area is a cache of the first memory area, and the second memory area supports direct access.
[0054] The receiving and sending queue information may include receiving queue information and sending queue information, for example, QPC.
[0055] Exemplarily, the memory of the network card may be pre-divided into at least two areas: a first memory area and a second memory area, wherein one area may serve as a cache for another area, such as the second memory area being a cache for the first memory area.
[0056] For example, since the second memory area serves as a cache for the first memory area, the storage size corresponding to the first memory area can be larger than the storage size corresponding to the second memory area, thereby saving memory; of course, the storage sizes corresponding to the first memory area and the second memory area can be freely divided according to actual needs.
[0057] Exemplarily, the number of the first memory area and the number of the second memory area may be more than one, and may also be freely configured according to actual needs.
[0058] Exemplarily, for an existing communication connection established by the network card, corresponding receiving and sending queue information may be obtained and stored in the first memory area.
[0059] Exemplarily, when the network card is working, the second memory area can be directly accessed to find the required QPC.
[0060] Step S102: when there is communication data to be processed, determine the sending and receiving queue information matching the communication data to be processed as the target queue information.
[0061] The communication data to be processed may be communication data that needs to be processed by a network card.
[0062] Exemplarily, the network card needs to use a QPC to process the communication data to be processed, but the QPC used is not an arbitrary QPC, but a QPC that matches the communication data to be processed.
[0063] Step S103: when it is detected that the target queue information is missing in the second memory area, the target queue information is extracted from the first memory area, and the target queue information is cached in the second memory area.
[0064] Exemplarily, it can be known from the above steps that the second memory area in the network card memory is a cache of the first memory area and can be directly accessed, so the target queue information can be searched from the second memory area first.
[0065] Exemplarily, if it is detected that the target queue information does not exist in the second memory area, the target queue information may be extracted from the first memory area and cached in the second memory area for use in subsequent steps.
[0066] Step S104: Control the network card to process the communication data to be processed based on the target queue information in the second memory area.
[0067] In this embodiment, since the network card memory can be divided into a first memory area and a second memory area, the receiving and sending queue information can be stored in the first memory area. At the same time, the second memory area, as a cache of the first memory, can cache the target queue information for direct reading by the network card. The receiving and sending queue information does not need to reside in the second memory area, but only needs to be pre-fetched in advance, so only a small amount of memory is needed to support large connection scenarios. In this way, when the relevant receiving and sending queue information (target queue information) is needed, it is cached, which can avoid the receiving and sending queue information that is in an idle state and has no use demand from occupying the network card memory, thereby improving the utilization rate of the network card memory, and then helping to improve the performance of the network card. At the same time, this does not require adding a new memory card or replacing a larger memory card, etc., so it can save hardware costs.
[0068] In one embodiment, if Figure 2 As shown, the network card control method in the above embodiment may further include step S201 to step S202:
[0069] Step S201: Determine the communication connection state corresponding to the target queue information.
[0070] The communication connection state may be a state or situation that represents the network card processing communication data using the target queue information, which may include an active state and an inactive state.
[0071] Step S202: When the communication connection state is in an active state, keep the target queue information cached in the second memory area.
[0072] Exemplarily, the active state and the inactive state may be divided according to the data receiving and / or sending status corresponding to the communication connection.
[0073] In some possible embodiments, the active state and the inactive state can also be divided by whether the network card is using the target queue information to process communication data. The "currently" here can be understood in a broad sense, which can be the current time point, such as the current time point is 18:00; it can also be the current time period, for example, with each 10 minutes as a time period, and the current time period is from 18:00 to 18:10. As long as the network card uses the target queue information to process communication data from 18:00 to 18:10, it can be considered to be "currently".
[0074] In some possible embodiments, the active state and the inactive state can also be divided according to the frequency with which the network card uses the target queue information to process communication data. For example, target queue information with a frequency greater than 100 times / hour can be considered to be in an active state, and target queue information with a frequency less than or equal to 100 times / hour can be considered to be in an inactive state.
[0075] In this embodiment, since the target queue information cached in the second memory area may be idle, the target queue information corresponding to the active communication connection state is cached in the second memory area according to whether the communication connection state is active or not, so as to ensure the communication connection requirements.
[0076] In one embodiment, the network card control method in the aforementioned embodiment may further include: when the communication connection state is in an inactive state, marking the target queue information dirty. When the free storage space corresponding to the second memory area reaches a preset standard, and / or when the dirty target queue information in the second memory area needs to be overwritten, the dirty target queue information is transferred to the first memory area.
[0077] The dirty mark may be used to mark the target queue information to indicate that it contains information that is not suitable for being cached in the second memory area.
[0078] Exemplarily, for target queue information whose communication connection status is in an inactive state, it means that the demand for using the target queue information is low and the target queue information may be in an idle state. Therefore, it can be marked as dirty for subsequent processing of the marked dirty target queue information.
[0079] Exemplarily, as the communication connections increase, the amount of target queue information cached in the second memory area increases, but the storage space of the second memory area is limited. In this regard, idle target queue information can be cleared, for example, dirty target queue information can be transferred to the first memory area.
[0080] Exemplarily, when the free storage space corresponding to the second memory area reaches a preset standard, the dirty target queue information can be cleared. For example, the free storage space is only 1MB, and the preset standard is less than 10MB, so it can be considered that the free storage space reaches the preset standard.
[0081] Exemplarily, the dirty target queue information in the second memory area may be overwritten, for example, if the free storage space in the second memory area is zero, the dirty target queue information may be overwritten first. In this regard, the dirty target queue information is transferred to the first memory area.
[0082] In this embodiment, the target queue information corresponding to the active communication connection state is marked as dirty, so as to mark the idle target queue information. For the dirty target queue information, when the free storage space corresponding to the second memory area reaches the preset standard, and / or when it is necessary to overwrite the dirty target queue information in the second memory area, the dirty target queue information is transferred to the first memory area, thereby being able to timely clean up the idle target queue information in the second memory area and improve the utilization rate of the network card memory. At the same time, the first memory area stores the dirty target queue information, and when it needs to be reused, it can be extracted from the first memory area without affecting the processing of the related communication connection.
[0083] In one of the embodiments, the network card control method in the aforementioned embodiment may also include: allocating corresponding connection identification information to the existing communication connection; determining the receiving and sending queue information that matches the communication data to be processed as the target queue information, including: determining the receiving and sending queue information that matches the communication data to be processed as the target queue information based on the connection identification information.
[0084] In some possible embodiments, the communication terminal pre-establishes a communication connection through its built-in operating system, that is, an existing communication connection, and then the operating system unloads the relevant data of the existing communication connection (such as QPC) and sends it to the network card, which is responsible for the subsequent management of the existing communication connection. Exemplarily, the corresponding connection identification information and / or cache identification information can be allocated to the existing communication connection at the same time as the network card receives the relevant data of the existing communication connection; of course, the allocation can also be made at the same time as the aforementioned operating system establishes the existing communication connection, and there is no limitation here. As long as it does not affect the access of the target queue information in the physical address table and / or cache table.
[0085] Exemplarily, regarding the problem of how the hardware engine identifies the target queue information, while the operating system of the communication terminal uninstalls the existing communication connection and sends it to the network card, the corresponding connection identification information can be assigned to the existing communication connection. Through the connection identification information, the receiving and sending queue information that matches the communication data to be processed can be identified as the target queue information.
[0086] Exemplarily, each existing communication connection corresponds to a unique piece of connection identification information, and the connection identification information corresponding to each existing communication connection is different.
[0087] In this example, by adding the connection identification information and determining the target queue information according to the connection identification information, it is possible to accurately determine the target queue information.
[0088] In one of the embodiments, extracting the target queue information from the first memory area includes: based on the connection identification information, determining the physical address corresponding to the target queue information from the physical address table corresponding to the receiving and sending queue information; the physical address table is pre-created in the first memory area and indexed by the connection identification information; and extracting the target queue information from the first memory area according to the physical address.
[0089] Exemplarily, after the target queue information is determined in the aforementioned steps, how to extract the target queue information from the first memory area can be implemented by using physical address related technology.
[0090] For example, a physical address table corresponding to the receiving and sending queue information can be created in advance in the first memory area, and the connection identification information can be used as an index of the physical address table, and the physical address table stores the physical address of each receiving and sending queue information. Therefore, when it is necessary to extract the target queue information from the first memory area, the physical address corresponding to the target queue information can be found from the physical address table according to the connection identification information, thereby realizing the extraction of the target queue information.
[0091] Exemplarily, the physical address table can be updated in real time. For example, when the receiving and sending queue information corresponding to each physical address in the physical address table changes, such as being extracted, transferred, etc., the physical address table can change accordingly to ensure the accuracy of the physical address table.
[0092] In this embodiment, a physical address table indexed by connection identification information is pre-created to query the physical address corresponding to the target queue information, and the target queue information is extracted from the first memory area based on the physical address. This can accurately find and extract the target queue information and avoid errors in extracting the target queue information.
[0093] In one of the embodiments, the network card control method in the aforementioned embodiment may further include: allocating corresponding cache identification information to the existing communication connection;
[0094] The target queue information is cached in the second memory area, including: using the cache identification information corresponding to the target queue information as an index, caching the target queue information in a cache table in the second memory area; the cache table is pre-created in the second memory area and uses the cache identification information as an index.
[0095] Exemplarily, the number of target queue information cached in the second memory area may not be unique, and therefore, it can be distinguished by cache identification information to avoid confusion.
[0096] Exemplarily, similar to the connection identification information in the aforementioned embodiment, when the terminal operating system uninstalls the existing communication connection and sends it to the network card, the corresponding cache identification information can be allocated to the existing communication connection.
[0097] Exemplarily, the target queue information can be cached in the form of a cache table. For example, a cache table can be pre-created in the second memory area, and the cache table can be indexed by the cache identification information. After the target queue information is determined through the aforementioned steps, when the target information needs to be cached in the second memory area, the cache identification information can be used as an index to cache it.
[0098] In this embodiment, by pre-creating a cache table in the second memory area and using the cache identification information as an index of the cache table, it is possible to avoid confusion while caching the target queue information in the second memory area, thereby facilitating the subsequent accurate use of the target queue information by the network card.
[0099] In one embodiment, the allocation of corresponding connection identification information to an existing communication connection in the network card control method in the aforementioned embodiment may include:
[0100] Based on the hash algorithm, construct a mapping relationship between existing communication parameters in the existing communication connection and the connection identification information, and store the mapping relationship in a hash table in the first memory area;
[0101] extracting communication parameters from the communication data to be processed;
[0102] determining an existing communication parameter that matches the extracted communication parameter as a target communication parameter;
[0103] According to the mapping relationship corresponding to the target communication parameter, the corresponding connection identification information is determined.
[0104] Similarly, for cache identification information, in some possible embodiments, the network card control method in the aforementioned embodiment of assigning corresponding connection identification information to an existing communication connection may include: based on a hash algorithm, constructing a mapping relationship between existing communication parameters in the existing communication connection and cache identification information, and storing the mapping relationship in a hash table in the first memory area; extracting communication parameters from the communication data to be processed; determining existing communication parameters that match the extracted communication parameters as target communication parameters; and determining corresponding cache identification information according to the mapping relationship corresponding to the target communication parameters.
[0105] The communication parameters may include an IP quintuple and a QPN, and the IP quintuple may include a source IP address, a source port, a destination IP address, a destination port, and a transport layer protocol.
[0106] In this embodiment, by establishing a mapping relationship between communication parameters and connection identification information and cache identification information, the problem that the connection identification information and cache identification information cannot be obtained from a message when the network card receives the message is overcome.
[0107] In an exemplary embodiment, a network card memory control method is provided, which can be applied to an RDMA smart network card. Specifically, the RDMA smart network card can send and receive data in a multi-QP multi-concurrency scenario. The RDMA smart network card unloads the protocol originally processed by the host operating system to the network card for processing, without the host CPU being too involved, thereby improving performance. Usually, when the two ends of the RDMA smart network card establish a communication connection, the host-side driver needs to create a QP, and multiple WQEs are pre-connected to the QP. For SQ, each WQE corresponds to a segment of data to be sent, and for RQ, each WQE corresponds to a buffer of data to be received. When unloading, the host-side driver needs to send the QPC to the hardware. The QPC describes some key information of the queue, such as the first address of the head of the queue of SQ and RQ, the depth of the queue, etc. The network card will store the QPC in the memory inside the card. Subsequent access to the QPC only needs to access the memory on the card. If it is read from the host side every time, it is time-consuming. One connection corresponds to one QP, and one QP corresponds to one QPC. If the size of a QPC is calculated as 1KB (the actual size depends on the implementation), 1K connections require 1MB, and 32K connections require 32MB. It can be seen that there are at least problems: 1. The size of the memory is directly proportional to the number of QPs supported, and the consequence is that the cost also increases proportionally. When the cost is constant, the number of QPs is also small; 2. In a multi-QP scenario, often only a small number of QPs are transmitting a large amount of data, and inactive QPs occupy the majority. This part of QPC occupies a large amount of memory, but is rarely accessed, resulting in low memory utilization. The network card memory control method provided in this implementation is intended to solve the above problems. The method may include "smart memory", "pre-fetch & kick back QPC", "connection offloading", "Tx (sending direction)", "Rx (receiving direction)" and other parts. The method is described in detail below:
[0108] About the smart memory part:
[0109] 1. Combined with the hardware acceleration engine of the network card, the memory of the network card is designed as a cache of the host memory.
[0110] 2. Use the network card's memory as the host's cache (i.e., the second memory area). The QPC (i.e., the receiving and sending queue information) is actually stored on the host side (i.e., the first memory area). When the network card needs to process the message of the connection, the QPC is pre-fetched into the network card memory (i.e., the second memory area) in advance. After the processing is completed, it is kicked back to the host side at an appropriate time.
[0111] 3. Because QPC no longer resides in the network card memory and is only pre-fetched when needed, only very little memory is needed to support large connection scenarios.
[0112] About the prefetch & kickback QPC part:
[0113] 1. The memory of the network card should be designed to be partitionable and configurable. In other words, the memory can be divided into a resident memory area (i.e., the first memory area) and a cache area (i.e., the second memory area), and the number and size of the areas are configurable.
[0114] 2. When the network card sends or receives data, before processing the message, there must be a dedicated hardware engine that can identify in advance which QPC is needed and determine whether the cache can hit. If it does not hit, it needs to be pre-fetched into the network card memory in advance. If the pre-fetching cannot be completed in advance during message processing, it will cause a cache miss and performance will drop sharply.
[0115] 3. When the network card processes the message, it directly accesses the memory on the card. If the QPC is updated, the data needs to be marked dirty and then kicked back to the host side at a certain time. The timing of kicking back is very important. It is not necessary to kick back every time the message is processed, because some connections are in an active state and will keep kicking back, wasting hardware performance. It is recommended to kick back when the QPC is about to be overwritten.
[0116] Regarding the connection offloading part:
[0117] 1. When prefetching, there are these problems: how does the hardware engine identify which QPC is needed, where the QPC is prefetched from, and where is it stored after prefetching.
[0118] 2. As for how the hardware engine identifies which QPC (i.e., determines the target queue information), the solution is: each connection is assigned a Connection ID (i.e., connection identification information) by the driver when it is unloaded. This Connection ID uniquely identifies a connection. Note that this Connection ID is not equal to QPN.
[0119] 3. Where should the QPC be pre-fetched? The solution is: when unloading, the driver sends the physical address of the QPC to the network card, and the network card hardware allocates a QPC GPA Table (physical address table) in the resident memory area. The size is the specification of the number of connections, and the Connection ID is used as the index. Because the GPA address is at most 8 bytes, it does not occupy much memory, so the resident memory can be used. When sending data, just specify the Connection ID in WQE. When receiving data, because only the IP quintuple and QPN can be extracted from the message, a mapping relationship from the IP quintuple and QPN to the Connection ID can be created during unloading. Because the Connection ID is used as an index, the allocation of the Connection ID is a bitmap algorithm, so it is not the same concept as QPN.
[0120] 4. Where to store after pre-fetching? The solution is to create a QPC Cache Table (i.e., cache table) in the network card memory cache area, the size of which is much smaller than the number of connections, so that it takes up very little memory. Each connection is assigned a Cache ID (cache identification information) by the hardware engine when unloading, and this ID is the index of the QPC Cache Table. Because the actual number of QPCs in a large connection and multi-concurrency scenario is much larger than the size of the QPC Cache Table, multiple QPCs hit the same cache. Therefore, the Cache ID allocation algorithm is particularly important, and conflicts should be avoided as much as possible. If the conflict is serious, the performance will be greatly reduced. However, the specific allocation algorithm will not be discussed here. When sending data, specify the Cache ID in WQE. However, similar to the Connection ID, the Cache ID cannot be obtained from the message when receiving, so it is necessary to create a mapping relationship from the IP quintuple and QPN to the Cache ID when unloading.
[0121] 5. Because it is necessary to create a mapping relationship from the IP five-tuple and QPN to the Connection ID and Cache ID when unloading, the HASH algorithm can be used to create a HASHTable in the resident memory area of the network card to store this mapping relationship. The size is equal to the specification of the number of connections. Because the entire table does not occupy a large amount of memory, the resident memory can be used. Among them, the IP five-tuple can include the source IP address, source port, destination IP address, destination port and transport layer protocol.
[0122] About Tx part:
[0123] 1. The driver initializes the Connection ID, Cache ID, and data storage address of WQE in SQ, and then knocks DoorBell to notify the network card hardware.
[0124] 2. The NIC obtains WQE from SQ and parses it. It indexes QPC CacheTable according to the Cache ID in WQE to determine whether the QPN recorded in the QPC is consistent with the QPN in WQE. If they are consistent, it means that the cache hits and no prefetching is required. If they are inconsistent, it means that other connections have been cached. If the data is dirty, it is kicked back to the host side, and then the QPC GPA Table is indexed according to the Connection ID to find the physical address of the QPC, so as to prefetch it into the QPC CacheTable.
[0125] 3. When the network card is processing and sending messages, it can directly access the QPC from the cache area of the memory. If the QPC has been changed, it needs to be marked dirty and wait for the next new connection to cover it before kicking it back to the host side.
[0126] About the Rx part:
[0127] 1. The network card receives the message, parses the message header, extracts the IP quintuple and QPN, queries the HASH Table, and finds the Connection ID and Cache ID.
[0128] 2. The subsequent pre-fetch QPC process is similar to data sending and will not be described in detail.
[0129] 3. Similarly, when the subsequent network card processes the received message, it directly accesses the QPC from the memory cache area. If the QPC has been changed, it needs to be marked dirty and wait for the next new connection to cover it before kicking it back to the host side.
[0130] like Figure 3 As shown, a schematic diagram of the division of a network card memory is provided. In the figure, the host side memory is HOST memory, and the network card side memory is RNIC memory. These two memories store the same number of QPCs, that is, the network card needs to store the same number of QPCs.
[0131] like Figure 4 As shown, another schematic diagram of the division of the network card memory is provided. In the figure, the number of QPCs stored in the network card side memory is greater than the number of QPCs stored in the host side memory. The network card only needs to store m QPCs, where m is much smaller than n. In some possible embodiments, when a QPC needs to be used, it is first searched from the memory on the network card side (the second memory area). If it is found, it is used directly; if it is not found, it can be extracted from the host side memory (the first memory area) and cached in the network card side memory for use.
[0132] The network card control method provided in this embodiment optimizes the usage of the network card memory. Through the collaboration of software and hardware, less memory can support more connections, and the performance is close to that of QPC resident memory. Because the layout of the network card memory is configurable, it can be adjusted according to the actual scenario, which is more flexible. For inactive connections, QPC will not be resident in the memory, so the memory utilization rate is higher, which helps to improve the network card performance. At the same time, this does not require adding a new memory card or replacing a larger memory card, etc., so it can save hardware costs.
[0133] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0134] Based on the same inventive concept, the embodiment of the present application also provides a network card control device for implementing the network card control method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more network card control device embodiments provided below can refer to the limitations of the network card control method above, and will not be repeated here.
[0135] In an exemplary embodiment, Figure 5 As shown, a network card control device 500 is provided, comprising:
[0136] The storage module 501 is used to obtain the receiving and sending queue information corresponding to the existing communication connection, and store the receiving and sending queue information in the first memory area of the network card; the memory of the network card is pre-divided into a first memory area and a second memory area, and the second memory area is a cache of the first memory area, and the second memory area supports direct access;
[0137] The determination module 502 is used to determine the receiving and sending queue information matching the communication data to be processed as the target queue information when there is communication data to be processed; if it is detected that the target queue information is missing in the second memory area, extract the target queue information from the first memory area, and cache the target queue information in the second memory area;
[0138] The control module 503 is used to control the network card to process the communication data to be processed based on the target queue information in the second memory area.
[0139] In one embodiment, the determination module 502 is further used to determine the communication connection state corresponding to the target queue information;
[0140] When the communication connection state is in an active state, the target queue information is kept cached in the second memory area.
[0141] In one embodiment, the determination module 502 is also used to mark the target queue information dirty when the communication connection state is in an inactive state; when the free storage space corresponding to the second memory area reaches a preset standard, and / or when the target queue information marked dirty in the second memory area needs to be overwritten, the target queue information marked dirty is transferred to the first memory area.
[0142] In one embodiment, the determination module 502 is also used to assign corresponding connection identification information to the existing communication connection; determine the receiving and sending queue information matching the communication data to be processed as the target queue information, including: determining the receiving and sending queue information matching the communication data to be processed as the target queue information based on the connection identification information.
[0143] In one embodiment, the determination module 502 is also used to extract the target queue information from the first memory area, including: based on the connection identification information, determining the physical address corresponding to the target queue information from the physical address table corresponding to the sending and receiving queue information; the physical address table is pre-created in the first memory area and indexed by the connection identification information; according to the physical address, extracting the target queue information from the first memory area.
[0144] In one of the embodiments, the determination module 502 is also used to assign corresponding cache identification information to an existing communication connection when the network card unloads the existing communication connection; cache the target queue information in the second memory area, including: caching the target queue information in a cache table in the second memory area with the cache identification information corresponding to the target queue information as an index; the cache table is pre-created in the second memory area and is indexed with the cache identification information.
[0145] In one embodiment, the determination module 502 is also used to construct a mapping relationship between existing communication parameters and connection identification information and cache identification information based on a hash algorithm, and store the mapping relationship in a hash table in the first memory area; extract communication parameters from the communication data to be processed; determine existing communication parameters that match the extracted communication parameters as target communication parameters; and determine corresponding connection identification information and cache identification information based on the mapping relationship corresponding to the target communication parameters.
[0146] Each module in the network card control device 500 can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0147] In an exemplary embodiment, a communication device is provided. The communication device may be a server, and its internal structure diagram may be as shown in FIG. Figure 6 As shown. The communication device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the communication device is used to provide computing and control capabilities. The memory of the communication device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the communication device is used to store relevant data required for network card control, such as receiving queue information, physical address table, etc. The input / output interface of the communication device is used to exchange information between the processor and an external device. The communication interface of the communication device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a network card control method is implemented.
[0148] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a partial structure related to the scheme of the present application, and does not constitute a limitation on the communication device to which the scheme of the present application is applied. The specific communication device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0149] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.
[0150] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0151] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0152] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0153] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0154] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A network card control method, characterized in that: The method comprises: Acquire the sending and receiving queue information corresponding to the existing communication connection, and store the sending and receiving queue information in a first memory area of the network card; the memory of the network card is pre-divided into the first memory area and the second memory area, and the second memory area is a cache of the first memory area, and the second memory area supports direct access; In the case where there is communication data to be processed, determining the receiving and sending queue information matching the communication data to be processed as the target queue information; In the case where it is detected that the target queue information is missing from the second memory area, extracting the target queue information from the first memory area and caching the target queue information in the second memory area; The network card is controlled to process the communication data to be processed based on the target queue information in the second memory area.
2. The method according to claim 1, characterized in that The method further comprises: Determine the communication connection state corresponding to the target queue information; When the communication connection state is in an active state, the target queue information is kept cached in the second memory area.
3. The method according to claim 2, characterized in that The method further comprises: When the communication connection state is in an inactive state, marking the target queue information in the second memory area as dirty; When the free storage space corresponding to the second memory area reaches a preset standard, and / or when the dirty target queue information in the second memory area needs to be overwritten, the dirty target queue information is transferred to the first memory area.
4. The method according to claim 1, characterized in that: The method further comprises: allocating corresponding connection identification information to the existing communication connection; The determining the sending and receiving queue information matching the communication data to be processed as the target queue information includes: The sending and receiving queue information matching the communication data to be processed is determined according to the connection identification information as the target queue information.
5. The method according to claim 4, characterized in that The extracting the target queue information from the first memory area includes: Based on the connection identification information, determining the physical address corresponding to the target queue information from a physical address table corresponding to the receiving and sending queue information; the physical address table is pre-created in the first memory area and is indexed by the connection identification information; The target queue information is extracted from the first memory area according to the physical address.
6. The method according to claim 1, characterized in that The method further comprises: allocating corresponding cache identification information to the existing communication connection; The step of caching the target queue information in the second memory area includes: The target queue information is cached in a cache table in the second memory area using the cache identification information corresponding to the target queue information as an index; the cache table is pre-created in the second memory area and uses the cache identification information as an index.
7. A network card control device, characterized in that: The device comprises: A storage module, used for obtaining the sending and receiving queue information corresponding to the existing communication connection, and storing the sending and receiving queue information in a first memory area of the network card; the memory of the network card is pre-divided into a first memory area and a second memory area, and the second memory area is a cache of the first memory area, and the second memory area supports direct access; a determination module, configured to, when there is communication data to be processed, determine the receiving and sending queue information matching the communication data to be processed as the target queue information; and, when it is detected that the target queue information is missing from the second memory area, extract the target queue information from the first memory area, and cache the target queue information in the second memory area; A control module is used to control the network card to process the communication data to be processed based on the target queue information in the second memory area.
8. A communication device, comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Cache implementation method with prediction mechanism
CN112463654A
Data transmission method, chip and equipment
CN113900972A
Network card packet receiving processing method and device
CN114003366A
Message sending method, message receiving method, network card and computing device
CN117176834A
Network card information processing method and chip
WO2021042782A1