Method and device for improving high-concurrency forwarding performance of software and hardware
By pre-allocating shared packet storage space and description space in Ethernet or IP data exchange systems, the transmission between software and hardware without DMA is achieved, which solves the problem of memory access bandwidth occupation and improves the overall packet processing performance of the system.
Patent Information
- Application Number
- CN202510190143.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-20
- Publication Date
- 2025-05-30
AI Technical Summary
In Ethernet or IP data exchange systems, when data packets are forwarded from the data forwarding layer to the control layer, frequent memory read and write operations lead to memory access bandwidth usage, limiting the overall performance of the system.
By pre-allocating the data packet storage space and description space shared by the control layer and the data forwarding layer, the data forwarding layer stores the data packets that need to be processed by the software into a storage unit associated with the data packet description one by one, realizing DMA-free transmission between software and hardware.
It greatly reduces the memory access bandwidth usage, improves the overall packet processing performance, reduces the memory bandwidth waste caused by hardware replication, and improves system performance.
Smart Images

Figure CN120075175A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of Ethernet and IP data exchange, and particularly to a method and apparatus for improving the high-concurrency forwarding performance of software and hardware. Background Art
[0002] In an Ethernet or IP data exchange system, there are a data forwarding layer and a control layer. The data forwarding layer performs the storage and forwarding of data packets, and the control layer processes protocol data packets or control data packets. For example, in an HGU (Home Gateway Unit), a large number of control packets need to be processed by software, and unknown data packets also need to be processed by software. In the data forwarding layer, DRAM (Dynamic Random Access Memory) is mostly used for data packet storage; the control layer mostly includes a CPU (Central Processing Unit) system and is processed in a software manner. In the CPU system, DRAM is required as the data memory (also known as the memory) of the CPU system. Since the data forwarding layer is generally composed of hardware circuits or dedicated processors, the traffic forwarded at the data layer is often referred to as hardware forwarding traffic.
[0003] When a data packet enters the exchange system, it is first processed at the data forwarding layer, including packet parsing, identification, switching, etc. The data packet is forwarded according to the determined forwarding behavior. If the data packet needs to be forwarded to the control layer after processing, the data packet is forwarded to the control layer for software processing.
[0004] The common method of forwarding a data packet from the data forwarding layer to the control layer is to first store the data in the packet storage of the data layer (including the DRAM for the data forwarding layer), and then move the data packet to the memory mapping area of the control layer through DMA (Direct Memory Access) and notify the CPU to start processing. In this process, the data packet needs to be read out from the DRAM of the data layer first and then written into the CPU DRAM memory area; when the data packet is sent from the CPU to the data forwarding layer, it also needs to be moved from the CPU-visible memory to the hardware-visible storage through DMA, involving one memory read and one DRAM write operation. In some exchange systems, such as HGU, to save costs, the same DRAM is often used as both the CPU memory and the data forwarding layer memory. In these systems, when the number of data packets that require CPU participation in processing and forwarding (hereinafter referred to as software processing) increases, multiple memory reads and writes will cause a multiple occupancy of the memory access bandwidth, forming a competitive relationship with the data forwarding layer and restricting the overall performance of the system. Summary of the Invention
[0005] This application provides a method and device for improving the high - concurrency forwarding performance of software and hardware, which can solve the technical problem of memory access bandwidth occupation existing in the prior art.
[0006] In a first aspect, an embodiment of this application provides a method for improving the high - concurrency forwarding performance of software and hardware. The method includes:
[0007] The data forwarding layer analyzes the characteristics of the received data packets, and stores the data packets that need to be processed by software into the first storage unit associated with the first software packet descriptor (SWPD).
[0008] The SWPDs are associated with the first storage units one by one. The first storage units are located in the first data packet storage space, and the first data packet storage space is a pre - allocated storage space for data packets shared by the control layer and the data forwarding layer.
[0009] The SWPDs are stored in the first data packet description space, and both the data packet description space and the data packet storage space are continuous memory spaces.
[0010] In combination with the first aspect, in an implementation, when the first data packet storage space is initialized, each first storage unit is assigned a virtual address, and the associated first storage unit and the corresponding virtual address can be found through the SWPD.
[0011] In combination with the first aspect, in an implementation, when a data packet needs to be processed by software, the data forwarding layer sequentially checks each SWPD in the SWPD space. If the current SWPD is in an idle state, the data packet is stored in the first storage unit associated with the current SWPD, and the SWPD is marked as in a software - readable state.
[0012] In combination with the first aspect, in an implementation, when the data packet is being processed by software, the control layer accesses the SWPD through polling or interrupt. If the current SWPD is in a software - readable state, based on the virtual address of the first storage unit associated with the current SWPD, a socket buffer data structure is applied for and constructed from the socket buffer memory pool, and the SWPD pointer of the socket buffer data structure is pointed to this SWPD. The data buffer pointer in the socket buffer points to the virtual address associated with the current SWPD, and then it is handed over to the software protocol stack for processing. After the processing is completed, the socket buffer data structure is recycled.
[0013] In combination with the first aspect, in an implementation, after the processing is completed, recycling the socket buffer header data structure includes:
[0014] After the control layer finishes processing the socket buffer, it sets the outbound port information to the SWPD pointed to by the SWPD pointer of the socket buffer, sets the SWPD to the hardware-transmittable state, and releases the socket buffer data structure to the socket buffer memory pool.
[0015] In combination with the first aspect, in one implementation, the hardware thread sequentially checks each SWPD in the SWPD space. If the current SWPD is in the hardware-transmittable state, it sends the data packet in the first storage unit associated with the current SWPD to the egress FIFO or the next module, and marks the SWPD as the idle state.
[0016] In combination with the first aspect, in one implementation, it further includes:
[0017] The data forwarding layer stores the data packets that need to be directly forwarded by the data forwarding layer in the second storage unit associated with the second packet descriptor HWPD;
[0018] The HWPD is associated with the second storage unit one by one. The second storage unit is located in the second data packet storage space, and the second data packet storage space is a pre-allocated space for storing the data packets directly forwarded by the data forwarding layer.
[0019] In combination with the first aspect, in one implementation, when a data packet needs to be forwarded by hardware, the data forwarding layer sequentially checks each HWPD in the HWPD space. If the current HWPD is in the idle state, it stores the data packet in the second storage unit associated with this HWPD, and marks the HWPD as the hardware-transmittable state;
[0020] When the hardware thread checks that the current HWPD is in the hardware-transmittable state, it sends the data packet in the second storage unit associated with the HWPD to the egress FIFO or the next module, and marks the HWPD as the idle state.
[0021] In combination with the first aspect, in one implementation, it further includes:
[0022] The data forwarding layer stores the data packets that need to be replicated and forwarded in the third storage unit associated with the third packet descriptor HWDPD. The third storage unit is located in the third data packet storage space, and the third data packet storage space is a pre-allocated space for storing the data packets replicated and forwarded by the data forwarding layer; each third storage unit is associated with N HWDPDs, and N is the total number after replication.
[0023] In combination with the first aspect, in one implementation, when a data packet needs to be hardware-copy forwarded, the data forwarding layer sequentially checks each HWDPD in the HWDPD space, finds N consecutive HWDPDs in the idle state, marks the last one of them, and at the same time associates the N HWDPDs in the idle state with a currently idle third storage unit, and marks the N HWDPDs in the idle state as being in the hardware-sendable state;
[0024] When the hardware thread checks that the current HWDPD is in the hardware-sendable state, it sends the data packet in the third storage unit associated with the HWDPD. After sending the data packet associated with the marked HWDPD, it sets the HWDPD associated with this third storage unit to the idle state.
[0025] In combination with the first aspect, in one implementation, when a data packet needs to be hardware-copy forwarded, the data forwarding layer sequentially checks the third data packet storage space to find a currently idle third storage unit; simultaneously or successively, the data forwarding layer sequentially checks each HWDPD in the HWDPD space to find N consecutive HWDPDs in the idle state;
[0026] Set the count of the third storage unit to N, and at the same time associate the N HWDPDs in the idle state with the third storage unit, and mark the N HWDPDs in the idle state as being in the hardware-sendable state;
[0027] When the hardware thread checks that the current HWDPD is in the hardware-sendable state, it sends the data packet stored in the third storage unit. Each time it sends, the count corresponding to the third storage unit is decremented by 1. When the count reaches 0, it sets the HWDPD associated with this third storage unit to the idle state.
[0028] In combination with the first aspect, in one implementation, it further includes:
[0029] The data forwarding layer stores the data packet that needs to be copied to the control layer for software processing in the fourth storage unit associated with the fourth data packet descriptor SWDPD. The fourth storage unit is located in the fourth data packet storage space, and the fourth data packet storage space is a pre-allocated space for storing the data packets copied by the data forwarding layer to the control layer and processed by software; each fourth storage unit is associated with N SWDPDs and one SWPD, and N is the total number after replication.
[0030] In combination with the first aspect, in one implementation, the fourth data packet descriptor SWDPD is the third data packet descriptor HWDPD, the fourth storage unit is the third storage unit, and the fourth data packet storage space is the third data packet storage space.
[0031] In combination with the first aspect, in one implementation, when a data packet needs to be copied to the control layer for software processing, the data forwarding layer finds a currently idle fourth storage unit in the fourth data packet storage space, and finds N consecutive idle SWDPDs in the SWDPD space; simultaneously or successively, the data forwarding layer finds a currently idle SWPD in the SWPD space, associates the N idle SWDPDs and this SWPD with the fourth storage unit, the SWPD is no longer associated with the corresponding first storage unit, stores the data packet in the fourth storage unit, marks the N idle SWDPDs as in a hardware-transmittable state, marks this SWPD as in a software-readable state, and sets the count of the fourth storage unit to N;
[0032] The hardware thread checks that the current SWPD is in a hardware-transmittable state, sends the data packet stored in the fourth storage unit, and for each transmission, decrements the count corresponding to the fourth storage unit by 1. When the count reaches 0, marks the SWPD as in an idle state;
[0033] The control layer applies for a socket buffer data structure from the socket buffer memory pool, sets the SWPD pointer of the socket buffer data structure to point to this SWPD, sets the data buffer pointer in the socket buffer to point to the virtual address associated with the current SWPD, and then hands it over to the software protocol stack for processing; after processing is completed, recovers the socket buffer header data structure and marks this SWPD as in an idle state and associates it with the corresponding first storage unit.
[0034] In a second aspect, an embodiment of the present application provides a device based on the method for improving the high-concurrency forwarding performance of software and hardware described in any one of the above, and the device includes:
[0035] A data packet distribution module, which is arranged in the data forwarding layer and is used to analyze the characteristics of the received data packet and store the data packet that needs software processing in the first storage unit associated with the first data packet description SWPD;
[0036] A description space module, which is used to set a data packet description space, the first data packet description is stored in the first data packet description space, and the data packet description space is a continuous memory space;
[0037] A storage space module, which is used to set a storage space for data packets, the first data packet storage space is a pre-allocated storage space for data packets shared by the control layer and the data forwarding layer, the first storage unit is located in the first data packet storage space, and the SWPDs are associated with the first storage units one by one.
[0038] The beneficial effects brought by the technical solutions provided by the embodiments of the present application include:
[0039] This application pre-allocates a first data packet storage space and a first data packet description (SWPD) space shared by the control layer and the data forwarding layer. In the first data packet storage space, there are first storage units associated with each first data packet description (SWPD) one by one. When data packets need to be processed by software, the control layer and the data forwarding layer can share the storage space and the description space to achieve software-hardware transmission without DMA, greatly reducing the occupancy of the memory access bandwidth and being beneficial to improving the overall data packet processing performance. For data packets that need to be processed by software, the software and the hardware share the same storage unit, effectively reducing the waste of the memory bandwidth caused by hardware replication and being beneficial to improving the system performance. The software processing and the hardware processing share the same first storage unit, effectively reducing the waste of the memory bandwidth caused by hardware replication and improving the overall performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 It is a schematic diagram of an embodiment of the method for improving the high-concurrency forwarding performance of software and hardware in this application;
[0041] Figure 2 It is a schematic diagram of software processing of data packets in an embodiment of this application;
[0042] Figure 3 It is a flowchart of software processing of data packets in an embodiment of this application;
[0043] Figure 4 It is a schematic diagram of the first implementation scheme for hardware replication and forwarding of data packets in this application;
[0044] Figure 5 It is a schematic diagram of the second implementation scheme for hardware replication and forwarding of data packets in this application;
[0045] Figure 6 It is a schematic diagram of copying data packets to the control layer for software processing in this application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0046] In order to enable those skilled in the art to better understand the solution of this application, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are only a part of the embodiments of this application, rather than all the embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of this application.
[0047] To make the purpose, technical solutions and advantages of this application clearer, the embodiments of this application will be further described in detail below with reference to the accompanying drawings.
[0048] In a first aspect, an embodiment of this application provides a method for improving the high-concurrency forwarding performance of software and hardware.
[0049] In one embodiment, a method for improving the high-concurrency forwarding performance of software and hardware includes:
[0050] The data forwarding layer analyzes the characteristics of the received data packets, and stores the data packets that need to be processed by software into the first storage unit associated with the first packet description (hereinafter referred to as SWPD for short). Among them, SWPD is associated with the first storage unit one by one, the first storage unit is located in the first packet storage space, and the first packet storage space is a pre-allocated storage space for packets shared by the control layer and the data forwarding layer. One or more first packet storage spaces can be allocated.
[0051] SWPD is stored in the first packet description space, and both the packet description space and the packet storage space are continuous memory spaces.
[0052] Specifically, the packet description space can be understood as a management structure similar to a circular memory. Through the current packet description, the next packet description can be found, and the control layer and the data forwarding manage the first storage unit in the first packet storage space through SWPD.
[0053] In this embodiment, when the CPU executes the storage initialization program, the first packet storage space and the SWPD space are pre-allocated, and SWPD is associated with the first storage unit one by one. Further, when the first packet storage space is initialized, each first storage unit is respectively allocated a virtual address, and the associated first storage unit and the corresponding virtual address can be found through SWPD.
[0054] In this embodiment, through the pre-allocated first packet storage space and SWPD space, when the data packet needs to be processed by software, the control layer and the data forwarding layer can be shared, realizing DMA-free transmission between software and hardware, greatly reducing the occupation of memory access bandwidth, and being beneficial to improving the overall data packet processing performance.
[0055] As Figure 1 shown, further, when the data packet enters the data forwarding layer, the distributor (Deliver) of the data forwarding layer determines what processing needs to be performed on the data packet according to the characteristics of the data packet, and then selects the corresponding packet storage space. Figure 1In it, the Packet Buffer is a structure for storing and operating on data packets, mainly used for the temporary storage and forwarding of data in network communication. It usually consists of two parts: the head and the data. Whether it is a data packet that needs to be processed by software in the control layer or a data packet processed by the data forwarding layer, it is sent by the data forwarding layer when being sent. Therefore, each data packet description space can correspond to one or more sending modules. The sending module can be a hardware circuit or a dedicated processor. Each parallel operation can be understood as a hardware thread (HWTD). The hardware thread is responsible for reading the data packet from the storage unit associated with each data packet description space and handing it over to the egress FIFO or storage, etc.
[0056] As Figure 2 and Figure 3 shown, in one embodiment, when the data packet needs to be processed by software, the processing steps are as follows:
[0057] S101: The dispatcher in the data forwarding layer sequentially checks each SWPD in the SWPD space to determine whether the currently checked SWPD is in the idle state. If so, the current SWPD is in the idle state, and proceed to S102; if not, the current SWPD is not in the idle state, and proceed to S103.
[0058] S102: The dispatcher stores the data packet in the first storage unit associated with the current SWPD and marks the SWPD as in the software-readable state (rd state), and proceed to S104.
[0059] S103: The data packet is lost because there is no available SWPD, and this process ends.
[0060] S104: The data packet is processed by software. The control layer accesses the SWPD in the SWPD space through polling or interrupt to determine whether the currently checked SWPD is in the software-readable state. If so, the current SWPD is in the software-readable state, and proceed to S106; if not, proceed to S105; further, the SWPD state can be the busy state, indicating that the corresponding data packet is being processed by software, and at this time, the hardware cannot write.
[0061] S105: To ensure the sequentiality of software processing and hardware processing, block the software processing at this time and transfer to S104;
[0062] S106: The software applies for and constructs a socket buffer (hereinafter referred to as skb) data structure from the socket buffer memory pool (hereinafter referred to as skb pool) based on the virtual address of the first storage unit associated with the current SWPD, and points the SWPD pointer in the skb data structure to the current SWPD. At this time, the data buffer pointer in the skb points to the virtual address associated with the current SWPD, and then hand it over to the software protocol stack for processing.
[0063] S107: When the control layer finishes processing the socket buffer (skb) and needs to send a data packet to the outgoing port, the software sets the outgoing port information, etc. to the SWPD pointed to by the SWPD pointer in the skb data structure, then marks this SWPD as in a state where it can be sent by the hardware (i.e., the tx state), and at the same time releases the skb to the skb pool.
[0064] S108: The hardware thread (HWTD) for processing SWPDs sequentially checks each SWPD in the SWPD space to determine whether the current SWPD is in a state where it can be sent by the hardware. If it is, it proceeds to S109; if not, it repeats S108.
[0065] S109: The data packet in the first storage unit associated with the current SWPD is sent to the egress FIFO or the next module, and this SWPD is marked as in an idle state.
[0066] In the prior art, when the control layer processes data packets, it generally needs to pre - allocate skbs (including a data structure for network protocol stack management data and a data buffer for storing raw data). When a data packet in the DMA linked list is processed, it is necessary to re - allocate an skb and configure its physical address to the data forwarding layer. In this embodiment, when the control layer processes data packets, the skb is allocated from the skb pool, and the data buffer pointer directly points to the virtual address of the first storage unit associated with the current SWPD. Only when the SWPD is in an idle state, a data packet is written to the corresponding first storage unit. This method reduces the overhead caused by repeated application and release of the data buffer, reduces the waste of memory access bandwidth, improves the software processing performance, and thus improves the overall forwarding performance of the system.
[0067] As Figure 1 shown, it is a schematic diagram of an embodiment of a method for improving the high - concurrency forwarding performance of software and hardware. Further, in one embodiment, the method for improving the high - concurrency forwarding performance of software and hardware further includes the step: The data forwarding layer stores the data packets that need to be directly forwarded by the data forwarding layer into the second storage unit associated with the second packet descriptor (hereinafter simply referred to as HWPD). HWPDs are associated with the second storage units one by one, and the second storage units are located in the second packet storage space, which is a pre - allocated space for storing the data packets directly forwarded by the data forwarding layer.
[0068] In this embodiment, the second packet storage space and HWPDs are pre - allocated in the storage initialization program, and the HWPDs are associated with the second storage units one by one. The data forwarding layer can find the physical address of the corresponding data packet of each HWPD in the second packet storage space.
[0069] As can be seen from the above, the dispatcher (Deliver) in the data forwarding layer determines what processing needs to be performed on the data packet based on the characteristics of the data packet. When the data packet needs to be processed by software, it is stored in the first storage unit associated with the SWPD; when the data packet needs to be forwarded by hardware, it is stored in the second storage unit associated with the HWPD.
[0070] In this embodiment, different from the SWPD, in order to ensure the forwarding performance of the hardware, the HWPD has only an idle state and a hardware-sendable state. The dispatcher in the data forwarding layer sequentially checks each HWPD in the HWPD space (when writing for the first time, it is the first initialized HWPD) to determine whether the current HWPD is in an idle state. If the current HWPD is in an idle state, the data packet is stored in the second storage unit associated with this HWPD, and this HWPD is marked as hardware-sendable; otherwise, the data packet is lost because there is no available HWPD. The hardware thread (HWTD) for processing the HWPD sequentially checks each SWPD in the SWPD space. If the current HWPD is in a hardware-sendable state, the data packet in the second storage unit associated with this HWPD is sent to the egress FIFO or the next module, and this HWPD is marked as idle.
[0071] As Figure 1 shown, further, in one embodiment, the method for improving the high-concurrency forwarding performance of software and hardware may further include:
[0072] The dispatcher (Deliver) in the data forwarding layer stores the data packet that needs to be copied and forwarded in the third storage unit associated with the third packet description (hereinafter simply referred to as HWDPD). The third storage unit is located in the third packet storage space, and the third packet storage space is a pre-allocated space for storing the data packets copied and forwarded by the data forwarding layer; each third storage unit can be associated with N HWDPDs, where N is the total number after replication. In this embodiment, the storage initialization program pre-allocates the third packet storage space and the HWDPD, and the HWDPD and the third storage unit do not need to be associated one by one.
[0073] When the data packet needs to be hardware-copy-forwarded, two implementation schemes can be adopted. As Figure 4 shown, the first implementation scheme is:
[0074] The dispatcher (Deliver) in the data forwarding layer determines whether the current third storage unit is in an idle state. If so, it sequentially checks each HWDPD in the HWDPD space to find N consecutive idle HWDPDs, where N is the total number after replication; marks the last one of them. In this embodiment, the last HWDPD is marked as last, and at the same time, the N idle HWDPDs are all associated with a currently idle third storage unit, and the N idle HWDPDs are marked as hardware-sendable.
[0075] The hardware thread (HWTD) for processing HWDPD sequentially checks each HWDPD in the HWDPD space. If the current HWDPD is in a hardware - sendable state, it sends the data packet in the third storage unit associated with the HWDPD. After sending the data packet associated with the HWDPD with the last flag, the HWDPD associated with this third storage unit is set to the idle state.
[0076] As Figure 5 shown, the second implementation scheme is as follows:
[0077] The dispatcher (Deliver) in the data forwarding layer sequentially checks the third data - packet storage space to find the third storage unit that is currently in the idle state; the dispatcher (Deliver) in the data forwarding layer sequentially checks each HWDPD in the HWDPD space to find N consecutive HWDPDs in the idle state, where N is the total number after replication; sets the count of the third storage unit to N, and at the same time associates the N HWDPDs in the idle state with this third storage unit, and marks the N HWDPDs in the idle state as hardware - sendable. Specifically, the process of the Deliver checking the third data - packet storage space and the process of checking each HWDPD can be carried out sequentially or simultaneously. The purpose is to find the idle third storage unit and N HWDPDs in the idle state for their association. The checking order can be set according to the actual situation.
[0078] The hardware thread (HWTD) for processing HWDPD sequentially checks each HWDPD in the HWDPD space. If the current HWDPD is in a hardware - sendable state, it sends the data packet stored in the third storage unit. Each time it sends, the count corresponding to the third storage unit is decremented by 1. When the count reaches 0, the HWDPD associated with this third storage unit is set to the idle state.
[0079] Further, in an embodiment, as Figure 6 shown, the method for improving the high - concurrency forwarding performance of software and hardware can also include:
[0080] The dispatcher (Deliver) in the data forwarding layer stores the data packets that need to be copied to the control layer for software processing in the fourth storage unit associated with the fourth data - packet descriptor (hereinafter referred to as SWDPD). The fourth storage unit is located in the fourth data - packet storage space, and the fourth data - packet storage space is a pre - allocated space for storing the data packets copied from the data forwarding layer to the control layer and processed by software; each fourth storage unit can be associated with N SWDPDs and one SWPD, where N is the total number after replication. In this embodiment, the storage initialization program pre - allocates the fourth data - packet storage space and SWDPD, and the SWDPD does not need to be associated with the fourth storage unit one by one.
[0081] Specifically, when a data packet needs to be copied to the control layer for software processing, the Deliver in the data forwarding layer finds the currently idle fourth storage unit in the fourth data packet storage space, and finds N consecutive idle SWDPDs in the SWDPD space, where N is the total number after replication; simultaneously or successively, the data forwarding layer finds the currently idle SWPD in the SWPD space, and associates the N idle SWDPDs and this SWPD with the fourth storage unit; at this time, this SWPD is no longer associated with the corresponding first storage unit. Store the data packet in the fourth storage unit, mark the N idle SWDPDs and this SWPD as hardware-sendable status, and set the count of the fourth storage unit to N.
[0082] The hardware thread checks that the current SWPD is in the hardware-sendable status, sends the data packet stored in the fourth storage unit, and each time it is sent, the count corresponding to the fourth storage unit is decremented by 1. When the count reaches 0, mark the SWPD as idle status.
[0083] Furthermore, the fourth storage space can be the same space as the third storage space, that is, the fourth data packet descriptor SWDPD is the third data packet descriptor HWDPD, the fourth storage unit is the third storage unit, and the fourth data packet storage space is the third data packet storage space. The SWPD and SWDPD share the same data packet storage unit.
[0084] The control layer applies for a skb data structure from the skb pool, points the SWPD pointer in the skb data structure to the current SWPD, points the data buffer pointer in the skb to the virtual address associated with the current SWPD, and then hands it over to the software protocol stack for processing; after processing is completed, recycle the skb data structure, and mark this SWPD as idle status and associate it with the corresponding first storage unit.
[0085] In this embodiment, the software processing and the hardware processing share the same first storage unit, effectively reducing the waste of memory bandwidth caused by hardware replication and improving the overall performance.
[0086] In a second aspect, an embodiment of the present application further provides a device for improving the high-concurrency forwarding performance of software and hardware, which can be used to implement the method embodiment for improving the high-concurrency forwarding performance of software and hardware.
[0087] In one embodiment, the device for improving the high-concurrency forwarding performance of software and hardware includes a data packet distribution module, a descriptor space module, and a storage space module.
[0088] The data packet distribution module is disposed in the data packet forwarding layer and is used to analyze the characteristics of the received data packets and store the data packets that need software processing in the first storage unit associated with the SWPD.
[0089] Describe a space module for setting a data packet description space. The first data packet description is stored in the first data packet description space, and the data packet description space is a continuous memory space.
[0090] A storage space module for setting the storage space of data packets. The first data packet storage space is a pre-allocated storage space for data packets shared by the control layer and the data forwarding layer. The first storage unit is located within the first data packet storage space, and SWPD is associated with the first storage unit one by one.
[0091] Furthermore, the data packet distribution module is also used to store the data packets that need to be directly forwarded by the data forwarding layer into the second storage unit associated with the second data packet description HWPD. The description space module sets HWPD to be stored in the second data packet description space. The storage space module is also used to set that the second data packet storage space is a pre-allocated space for storing the data packets directly forwarded by the data forwarding layer. The second storage unit is located within the second data packet storage space, and HWPD is associated with the second storage unit one by one.
[0092] Furthermore, the data packet distribution module is also used to store the data packets that need to be replicated and forwarded into the third storage unit associated with the third data packet description HWDPD. The description space module sets HWDPD to be stored in the third data packet description space. The storage space module is also used to set that the third data packet storage space is a pre-allocated space for storing the data packets replicated and forwarded by the data forwarding layer. The third storage unit is located within the third data packet storage space, and each third storage unit is associated with N HWDPDs, where N is the total number of replicas.
[0093] Furthermore, the data packet distribution module is also used to store the data packets that need to be replicated to the control layer for software processing into the fourth storage unit associated with the fourth data packet description SWDPD. The description space module sets SWDPD to be stored in the fourth data packet description space. The storage space module is also used to set that the fourth data packet storage space is a pre-allocated space for storing the data packets replicated from the data forwarding layer to the control layer and processed by software. The fourth storage unit is located within the fourth data packet storage space, and each fourth storage unit is associated with N SWDPDs and one SWPD, where N is the total number of replicas.
[0094] The data packet distribution module analyzes the characteristics of the received data packets, first stores the data packets into the corresponding data packet storage units, and then performs subsequent processing. Among them, the function implementation of each module in the above device corresponds to the steps in the above embodiment of improving the high-concurrency forwarding performance of software and hardware, and its function and implementation process will not be elaborated here one by one.
[0095] It should be noted that the serial numbers of the embodiments of the present application above are only for description and do not represent the superiority or inferiority of the embodiments.
[0096] The terms "including" and "having" and any variations thereof in the description of the specification, claims and drawings of the present application are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally further includes steps or units not listed, or optionally further includes other steps or units inherent to these processes, methods, products or devices. The descriptions with terms such as "first", "second" and "third" are used to distinguish different objects, etc., and do not represent a sequence, nor do they limit that "first", "second" and "third" are different types.
[0097] In the description of the embodiments of the present application, words such as "exemplary", "for example" or "for instance" are used to represent examples, illustrations or explanations. Any embodiment or design solution described as "exemplary", "for example" or "for instance" in the embodiments of the present application should not be construed as being more preferred or having more advantages than other embodiments or design solutions. Rather, the use of words such as "exemplary", "for example" or "for instance" is intended to present the relevant concepts in a specific manner.
[0098] In the description of the embodiments of the present application, unless otherwise specified, " / " means "or". For example, A / B can represent A or B; "and / or" in the text is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone. In addition, in the description of the embodiments of the present application, "a plurality of" means two or more than two.
[0099] In some processes described in the embodiments of the present application, there are multiple operations or steps that appear in a specific order. However, it should be understood that these operations or steps may not be executed in the order in which they appear in the embodiments of the present application or may be executed in parallel. The serial numbers of the operations are only used to distinguish different operations, and the serial numbers themselves do not represent any execution order. In addition, these processes may include more or fewer operations, and these operations or steps may be executed in sequence or in parallel, and these operations or steps may be combined.
[0100] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-described embodiment methods can be implemented by means of software plus a necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art can be embodied in the form of a software product. This computer software product is stored in a storage medium as described above (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions for causing a terminal device to execute the methods described in various embodiments of the present application.
[0101] The above are only the preferred embodiments of the present application, and do not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made by using the content of the specification and drawings of the present application, or directly or indirectly applied in other related technical fields, shall be equally included in the patent protection scope of the present application.
Claims
1. A method for improving the high concurrent forwarding performance of software and hardware, characterized in that: The method comprises: The data forwarding layer analyzes the characteristics of the received data packets and stores the data packets that need to be processed by the software into the first storage unit associated with the first data packet description SWPD; The SWPD is associated one-to-one with the first storage unit, the first storage unit is located in the first data packet storage space, and the first data packet storage space is a pre-allocated storage space for data packets shared by the control layer and the data forwarding layer; The SWPD is stored in the first data packet description space, and both the data packet description space and the data packet storage space are continuous memory spaces.
2. The method for improving the high concurrent forwarding performance of software and hardware as claimed in claim 1, characterized in that: When the first data packet storage space is initialized, each first storage unit is respectively allocated a virtual address, and its associated first storage unit and the corresponding virtual address can be found through SWPD.
3. The method for improving high concurrent forwarding performance of software and hardware as claimed in claim 2, characterized in that: When a data packet needs software processing, the data forwarding layer checks each SWPD in the SWPD space in turn. If the current SWPD is in an idle state, the data packet is stored in the first storage unit associated with the current SWPD and the SWPD is marked as software readable.
4. The method for improving high concurrent forwarding performance of software and hardware as claimed in claim 3, characterized in that: When the data packet is processed by software, the control layer accesses the SWPD through polling or interruption. If the current SWPD is in a software-readable state, based on the virtual address of the first storage unit associated with the current SWPD, the socket cache data structure is applied for and constructed from the socket cache memory pool, and the SWPD pointer of the socket cache data structure is pointed to this SWPD. The data buffer pointer in the socket cache points to the virtual address associated with the current SWPD, and then it is handed over to the software protocol stack for processing; after the processing is completed, the socket cache data structure is recovered.
5. The method for improving the high concurrent forwarding performance of software and hardware as claimed in claim 4, characterized in that: After the processing is completed, the socket buffer header data structure is recovered, including: After the control layer processes the socket buffer, it sets the outgoing port information to the SWPD pointed to by the SWPD pointer of the socket buffer, sets the SWPD to the hardware sendable state, and releases the socket buffer data structure to the socket buffer memory pool.
6. The method for improving high concurrent forwarding performance of software and hardware as claimed in claim 4, characterized in that: The hardware thread checks each SWPD in the SWPD space in turn. If the current SWPD is in a hardware-sendable state, the data packet in the first storage unit associated with the current SWPD is sent to the egress FIFO or the next module, and the SWPD is marked as idle.
7. The method for improving high concurrent forwarding performance of software and hardware as claimed in claim 1, characterized in that: Also includes: The data forwarding layer stores the data packet that needs to be directly forwarded by the data forwarding layer in the second storage unit associated with the second data packet description HWPD; The HWPD is associated one-to-one with the second storage unit, and the second storage unit is located in the second data packet storage space, which is a pre-allocated space for storing data packets directly forwarded by the data forwarding layer.
8. The method for improving the high concurrent forwarding performance of software and hardware as claimed in claim 7, characterized in that: When a data packet needs to be forwarded by hardware, the data forwarding layer checks each HWPD in the HWPD space in turn. If the current HWPD is in an idle state, the data packet is stored in the second storage unit associated with the HWPD and the HWPD is marked as hardware-sendable. The hardware thread detects that the current HWPD is in a hardware-sendable state, sends the data packet in the second storage unit associated with the HWPD to the egress FIFO or the next module, and marks the HWPD as an idle state.
9. The method for improving high concurrent forwarding performance of software and hardware as claimed in claim 1, characterized in that: Also includes: The data forwarding layer will store the data packets that need to be copied and forwarded in the third storage unit associated with the third data packet description HWDPD. The third storage unit is located in the third data packet storage space, and the third data packet storage space is a pre-allocated space for storing data packets copied and forwarded by the data forwarding layer; each third storage unit is associated with N HWDPDs, where N is the total number after replication.
10. The method for improving high concurrent forwarding performance of software and hardware as claimed in claim 9, characterized in that: When a data packet needs to be copied and forwarded by hardware, the data forwarding layer checks each HWDPD in the HWDPD space in turn, finds N consecutive HWDPDs in idle state, marks the last HWDPD among them, and associates the N HWDPDs in idle state with a currently idle third storage unit, and marks the N HWDPDs in idle state as hardware sendable state; The hardware thread checks that the current HWDPD is in a hardware transmittable state, and sends the data packet in the third storage unit associated with the HWDPD. After sending the data packet associated with the marked HWDPD, the HWDPD associated with the third storage unit is set to an idle state.
11. The method for improving high concurrent forwarding performance of software and hardware as claimed in claim 9, characterized in that: When the data packet needs to be copied and forwarded by hardware, the data forwarding layer sequentially checks the third data packet storage space to find the third storage unit that is currently in an idle state; at the same time or successively, the data forwarding layer sequentially checks each HWDPD in the HWDPD space to find N consecutive HWDPDs in an idle state; Setting the count of the third storage unit to N, associating the N HWDPDs in the idle state to the third storage unit, and marking the N HWDPDs in the idle state as hardware transmittable states; The hardware thread checks that the current HWDPD is in the hardware sendable state, and sends the data packet stored in the third storage unit. Each time it is sent, the count of the corresponding third storage unit is reduced by 1 until the count is 0, and the HWDPD associated with the third storage unit is set to the idle state.
12. The method for improving high concurrent forwarding performance of software and hardware as claimed in claim 9, characterized in that: Also includes: The data forwarding layer stores the data packets that need to be copied to the control layer and handed over to the software for processing in the fourth storage unit associated with the fourth data packet description SWDPD. The fourth storage unit is located in the fourth data packet storage space, and the fourth data packet storage space is a pre-allocated space for storing data packets copied by the data forwarding layer to the control layer and handed over to the software for processing; each fourth storage unit is associated with N SWDPDs and one SWPD, where N is the total number after copying.
13. The method for improving high concurrent forwarding performance of software and hardware as claimed in claim 12, characterized in that: The fourth data packet description SWDPD is the third data packet description HWDPD, the fourth storage unit is the third storage unit, and the fourth data packet storage space is the third data packet storage space.
14. The method for improving high concurrent forwarding performance of software and hardware according to claim 12 or 13, characterized in that: When the data packet needs to be copied to the control layer for software processing, the data forwarding layer finds the fourth storage unit in the fourth data packet storage space that is currently idle, and finds N consecutive SWDPDs in idle states in the SWDPD space; at the same time or successively, the data forwarding layer finds the SWPD that is currently idle in the SWPD space, associates the N idle SWDPDs and the SWPD to the fourth storage unit, and the SWPD is no longer associated with the corresponding first storage unit, and the data packet is stored in the fourth storage unit, and the N idle SWDPDs are marked as hardware sendable, and the SWPD is marked as software readable, and the count of the fourth storage unit is set to N; The hardware thread checks that the current SWDPD is in a hardware sendable state, and sends the data packet stored in the fourth storage unit. Each time the data packet is sent, the count of the corresponding fourth storage unit is reduced by 1 until the count is 0, and the SWDPD is marked as an idle state. The control layer applies for the socket cache data structure from the socket cache memory pool, and points the SWPD pointer of the socket cache data structure to the SWPD. The data buffer pointer in the socket cache points to the virtual address associated with the current SWPD, and then hands it over to the software protocol stack for processing; After the processing is completed, the socket cache header data structure is recovered, and the SWPD is marked as idle and associated with the corresponding first storage unit.
15. A device for improving the high concurrent forwarding performance of software and hardware based on the method according to any one of claims 1 to 13, characterized in that: The device comprises: A data packet distribution module, which is arranged in the data packet forwarding layer, is used to analyze the characteristics of the received data packets and store the data packets that need to be processed by the software into the first storage unit associated with the first data packet description SWPD; A description space module, which is used to set a data packet description space, the first data packet description is stored in the first data packet description space, and the data packet description space is a continuous memory space; The storage space module is used to set the storage space of the data packet. The first data packet storage space is a pre-allocated storage space for the data packet shared by the control layer and the data forwarding layer. The first storage unit is located in the first data packet storage space, and the SWPD is associated one-to-one with the first storage unit.