WO2019024763A1 - 报文处理 - Google Patents

报文处理 Download PDF

Info

Publication number
WO2019024763A1
WO2019024763A1 PCT/CN2018/097254 CN2018097254W WO2019024763A1 WO 2019024763 A1 WO2019024763 A1 WO 2019024763A1 CN 2018097254 W CN2018097254 W CN 2018097254W WO 2019024763 A1 WO2019024763 A1 WO 2019024763A1
Authority
WO
WIPO (PCT)
Prior art keywords
block
message
storage space
packet
blocks
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Ceased
Application number
PCT/CN2018/097254
Other languages
English (en)
French (fr)
Inventor
�田�浩
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
New H3C Technologies Co Ltd
Original Assignee
New H3C Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by New H3C Technologies Co Ltd filed Critical New H3C Technologies Co Ltd
Priority to EP18840257.2A priority Critical patent/EP3657744B1/en
Priority to US16/635,529 priority patent/US11425057B2/en
Priority to JP2020505176A priority patent/JP7074839B2/ja
Publication of WO2019024763A1 publication Critical patent/WO2019024763A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • H—ELECTRICITY
    • H04—ELECTRIC COMMUNICATION TECHNIQUE
    • H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L49/00—Packet switching elements
    • H04L49/25—Routing or path finding in a switch fabric
    • H04L49/252—Store and forward routing
    • G—PHYSICS
    • G06—COMPUTING OR CALCULATING; COUNTING
    • G06F—ELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601—Interfaces specially adapted for storage systems
    • G06F3/0602—Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/061—Improving I/O performance
    • G—PHYSICS
    • G06—COMPUTING OR CALCULATING; COUNTING
    • G06F—ELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601—Interfaces specially adapted for storage systems
    • G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638—Organizing or formatting or addressing of data
    • G06F3/064—Management of blocks
    • G—PHYSICS
    • G06—COMPUTING OR CALCULATING; COUNTING
    • G06F—ELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601—Interfaces specially adapted for storage systems
    • G06F3/0668—Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/067—Distributed or networked storage systems, e.g. storage area networks [SAN], network attached storage [NAS]
    • G—PHYSICS
    • G06—COMPUTING OR CALCULATING; COUNTING
    • G06F—ELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00—Arrangements for program control, e.g. control units
    • G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46—Multiprogramming arrangements
    • G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • H—ELECTRICITY
    • H04—ELECTRIC COMMUNICATION TECHNIQUE
    • H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L49/00—Packet switching elements
    • H04L49/90—Buffering arrangements
    • H04L49/901—Buffering arrangements using storage descriptor, e.g. read or write pointers
    • H—ELECTRICITY
    • H04—ELECTRIC COMMUNICATION TECHNIQUE
    • H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L49/00—Packet switching elements
    • H04L49/90—Buffering arrangements
    • H04L49/9042—Separate storage for different parts of the packet, e.g. header and payload
    • H—ELECTRICITY
    • H04—ELECTRIC COMMUNICATION TECHNIQUE
    • H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/22—Parsing or analysis of headers

Definitions

  • the network device When receiving a packet, the network device caches the packet to an external storage unit according to the queue to which the packet belongs. When the network device sends a packet, it can also read the packet from the external storage unit and send it according to the queue to which the packet belongs.
  • PKT PACKET, message entity
  • PD Packet Description, message descriptor
  • the network device can store the PKT in a DDR SDRAM (Dual Data Rate Synchronous Dynamic Random Access Memory, DDR for short) and store the PD in a QDR SRAM (Quad Data Rate Static Random Access Memory, Quadruple data rate static random access memory (hereinafter referred to as QDR). Since the QDR is used to store the PD, the design cost of the board is increased and the wiring pressure is increased. In addition, when transmitting a message, the network device first reads the PD from the QDR and then reads the PKT from the DDR using the PD. Since PD and PKT are read separately in two steps, the reading efficiency is low.
  • DDR SDRAM Direct Data Rate Synchronous Dynamic Random Access Memory
  • QDR SRAM Quadruple data rate static random access memory
  • FIGS. 1A-1C are schematic diagrams of application scenarios in an implementation manner of the present application.
  • FIG. 2A is a schematic flowchart of message storage in an embodiment of the present application.
  • FIG. 2B is a schematic flowchart of determining a second block to be occupied by a message in an embodiment of the present application.
  • 2C is a schematic flowchart of reading a message in an embodiment of the present application.
  • 3A-3E are schematic diagrams of application scenarios in another embodiment of the present application.
  • FIG. 4 is a structural diagram of a message processing apparatus in an embodiment of the present application.
  • 5A and 5B are hardware structural diagrams of a network device in an embodiment of the present application.
  • first, second, third, etc. may be used to describe various information in the embodiments of the present application, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other.
  • first information may also be referred to as the second information without departing from the scope of the present application.
  • second information may also be referred to as the first information.
  • word “if” may be interpreted to mean “at time” or "when” or "in response to determination.”
  • a packet processing method is provided in the embodiment of the present application, and can be applied to a network device.
  • a network device processes a message, it involves the process of storing and reading the message.
  • the body of the message to be stored may also be referred to as a PKT, which may also be referred to as a message
  • the PD is used to record key information of the message, such as the length of the message, queue information, and storage address.
  • the length of the PD is much smaller than the length of the packet, and the amount of information of the PD is relatively small.
  • the packet and the PD are stored in the same memory, such as DDR memory, to fully utilize the DDR memory resources, thereby effectively reducing the design cost of the board and reducing the wiring pressure.
  • the message and the PD are stored in the same memory, when the message needs to be sent, the message and the PD can be read from the same memory, and the reading efficiency is relatively high.
  • the memory (such as DDR memory) is divided into a plurality of first blocks, and each of the first blocks is further divided into a plurality of second blocks, and each of the second blocks may be a burst.
  • Each of the second blocks is further divided into two storage spaces of different sizes, that is, a first storage space and a second storage space, wherein the first storage space may be larger than the second storage space. Based on this, the message can be stored in the first storage space, and the PD is stored in the second storage space, so that the message and the PD are stored in the same memory.
  • the DDR memory can be divided into a plurality of first blocks, each of which is 2 Kbytes of large block memory.
  • each first block can be divided into 32 second blocks, each of which is 64 bytes of small block memory, that is, each 2K byte of the first block is divided into 32 blocks.
  • the second block of 64 bytes, each of the second blocks can be a burst.
  • the above 2K bytes, 32 bytes, 64 bytes, etc. are only an example of the present application, and the numerical values are not limited.
  • the first block can be divided into 16 second blocks.
  • the first block can be divided into 64 second blocks. And so on.
  • the following is an example in which the first block of 2K bytes is divided into 32 64-byte second blocks.
  • each second block may also be divided into two pieces of storage space of different sizes.
  • the larger first storage space may be, for example, 56 bytes, and the first storage space is used to store messages.
  • the smaller second storage space may be, for example, 8 bytes, and the second storage space is used to store the PD.
  • the second block can store both the message and the PD. For example, if it is necessary to store 4 messages (such as message 0, message 1, message 2, message 3), and the size of 4 messages is 96 bytes, then message 0 is stored in the second area.
  • the message 0 can occupy 56 bytes of the first storage space of the second block 0, occupy 40 bytes in the first storage space of the second block 1, and in the second block A PD is stored in the second storage space of the first 8 bytes of 0, and a PD is also stored in the second storage space of the first 8 bytes of the second block 1. And so on.
  • FIG. 1C See Figure 1C for an example of a PD.
  • the PDs stored in different second blocks may be the same or different.
  • the information field in the PD in the second block is needed. LEN and SOP assignment. For example, when the value of the information field SOP in the PD stored in a certain second block is 0, it indicates that the second block is the first second block in which the message is stored.
  • the value of the information field SOP (hereinafter also referred to as the first flag) is 1, it indicates that the second block is not the first second block in which the message is stored.
  • the value of the information field LEN is the length of the message stored in the second block corresponding to the PD.
  • the second flag For the last second block of all the second blocks that the message needs to occupy, it is necessary to assign a value to the information field EOP (hereinafter also referred to as the second flag) in the PD in the second block. For example, when the value of the information field EOP in the PD stored in a certain second block is 0, it indicates that the second block is the last second block of the stored message. When the value of the information field EOP is 1, it indicates that the second block is not the last second block of the stored message.
  • the information field BV in the PD in the second block needs to be valid. For example, when the value of the information field BV in the PD stored in a certain second block is 0, it indicates that the second block is valid. However, when the value of the information field BV is 1, it indicates that the second block is invalid.
  • the information fields VAL, NBA, and NBN in the PD in the second block need to be assigned.
  • the information field VAL may indicate whether the information domain NBA is valid. For example, when the value of the information field VAL in the PD stored in a certain second block is 0, it indicates that the information field NBA in the PD is valid; however, when the value of the information field VAL in the PD is At 1 o'clock, it indicates that the information field NBA in the PD is invalid.
  • NBA Next Block Address
  • NBN Next Block Number
  • message 1 occupies second block 2, second block 3, and second block 4.
  • the first second block of all the second blocks that need to be occupied by the message 1 is the second block 2, and the value of the information field LEN in the PD corresponding to the second block 2 is, for example, 120, to indicate The total length of message 1 is 120 bytes.
  • the value of the information field SOP in the PD in the second block 2 is 0 to indicate that the second block 2 is the first second block occupied by the message 1.
  • the simplified view in FIG. 1C is only shown by taking the second block 3 as an example.
  • the information field BV in the PD corresponding to the second block 3 takes a value of 0 to indicate that the second block 3 is valid.
  • the last second block of all the second blocks that need to be occupied by the message 1 is the second block 4, and the information field EOP in the PD in the second block 4 has a value of 0 to indicate the first Block 2 is the last second block occupied by message 1.
  • the message 2 occupies the second block 5 to the second block 31 in the first block 0 and the second block 0 and the second block 1 in the first block 1.
  • the first second block of all the second blocks that need to be occupied by the message 2 is the second block 5 in the first block 0, and the PD corresponding to the second block 5 in the first block 0
  • the value of the information field LEN within is, for example, 1560, to indicate that the total length of the message 2 is 1560 bytes.
  • the information field SOP in the PD in the second block 5 in the first block 0 takes a value of 0 to indicate that the second block 5 is the first second block occupied by the message 2.
  • any one of the second blocks that need to be occupied for the message 2 (such as the second block 5 to the second block 31 in the first block 0, and the second block 0 and the second in the first block 1) Block 1), the value of the information field BV in the PD corresponding to the second block is 0, to indicate that these second blocks are valid.
  • the second block 31 in the first block 0 occupied by the message 2 is the last second block in the first block 0, and the second block 31 in the first block 0 corresponds to the PD in the second block 31.
  • the information field NBA records the next first block occupied by the message 2, that is, the pointer of the first block 1, such as the address of the second block 0 of the first block 1.
  • the information field NBN in the PD corresponding to the second block 31 in the first block 0 takes a value of 2 to record the number of second blocks occupied by the message 2 in the first block 1.
  • the information field VAL in the PD corresponding to the second block 31 in the first block 0 takes a value of 0 to indicate that the information field NBA is valid.
  • the last second block of all the second blocks that need to be occupied by the message 2 is the second block 1 in the first block 1, and the second block 1 in the first block 1 corresponds to the PD.
  • the information field EOP takes a value of 0 to indicate that the second block 1 in the first block 1 is the last second block occupied by the message 2.
  • FIG. 2A a schematic flowchart for storing a message.
  • Step 201 Obtain a message to be stored.
  • Step 202 Determine, according to the length of the packet and the length of the first storage space, one or more second blocks that the packet needs to occupy.
  • Step 203 Store the message in the first storage space of the determined second block.
  • Step 204 Generate, for each second block determined, a PD corresponding to the second block, and store the PD in a second storage space of the second block.
  • step 202 "determining one or more second blocks that the message needs to occupy” may include, but is not limited to, the following:
  • Step 2021 Determine a queue corresponding to the packet.
  • step 2022 it is determined whether the queue corresponds to a tail pointer. If yes, go to step 2023, otherwise go to step 2024.
  • Step 2023 if the queue corresponds to the tail pointer, starting from the second block pointed by the tail pointer, determining the second block that the message needs to occupy;
  • Step 2024 If the queue does not have a corresponding tail pointer, the first block that is idle may be selected, and the second block that needs to be occupied by the packet is determined from the first second block in the selected first block. .
  • the number N of the second blocks that the packet needs to occupy may be determined according to the length of the packet and the length of the first storage space. Then, starting from the second block pointed by the tail pointer or starting from the first second block in the selected first block, the N second blocks that the message needs to occupy are determined.
  • Each second block is configured to store a message fragment of the message. For example, if the message needs to occupy three second blocks, the message can be divided into three message fragments, each message fragment. Take up a second block.
  • the network device can use the queue to store packets, and each queue has a unique queue identifier.
  • the manner in which packets are stored in a queue is only an example.
  • the network device can also store packets in other manners. By storing packets in a queue, you can efficiently store different types of packets to different queues.
  • the network device includes three queues (such as FIFO (First-In First-Out) queues), and the queue identifiers of the three queues are queue A, queue B, and queue C, respectively.
  • the queue A is used to store the packet with the feature A (for example, the outbound interface is the interface A), and the queue B is configured to store the packet with the feature B (for example, the outbound interface is the interface B), and the queue C is used for storing the feature C. (For example, the outbound interface is interface C).
  • the network device may first determine the queue corresponding to the packet. If the packet is the first packet corresponding to the queue, the queue does not have a corresponding tail pointer and a head pointer. If the packet is not the first packet corresponding to the queue, the queue corresponds to a tail pointer and a head pointer.
  • the head pointer indicates a pointer to the first packet header corresponding to the queue, such as the start address or the starting position of the first packet in the queue.
  • the tail pointer indicates a pointer to the end of the last message corresponding to the queue, such as the end address or end position of the last message in the queue.
  • the queue is empty, if the message 1 to be stored is obtained, the message 1 is stored in the queue, and the head pointer of the queue is updated to point to the start address of the message 1, and the tail pointer of the queue is updated. To point to the end address of message 1. Then, if the message 2 to be stored in the queue is obtained, the message 2 is stored in the queue, and the tail pointer of the queue is updated to point to the end address of the message 2.
  • the tail pointer of the queue can be updated each time a message of the queue is received.
  • the process of storing a message is to store the message sequentially from the tail pointer of the queue, and the process of reading the message is to read the message sequentially from the head pointer of the queue.
  • the step 2023 may include: starting from the next second block of the second block pointed by the tail pointer, selecting N second blocks, where the N is according to the length of the packet and the length of the first storage space. definite. For example, if the tail pointer points to the second block 10 in the first block 1, and the packet needs to occupy two second blocks according to the length of the message of 100 bytes and the length of the first storage space of 56 bytes, Then, the second block to be occupied by the message is the second block 11 and the second block 12 in the first block 1. For another example, if the tail pointer points to the second block 30 in the first block 1, and according to the length of the message 100 bytes and the length of the first storage space is 56 bytes, the message needs to occupy two second blocks.
  • the idle first block such as the first block 3
  • the second block to be occupied by the message may be the second block 31 in the first block 1 and the second block 0 in the first block 3.
  • the tail pointer of the queue may also be updated to point to the end address of the last second block occupied by the message, such as pointing to the second block.
  • the step 2024 may include: starting from the first second block in the selected idle first block, selecting N second blocks, where the N is according to the length of the packet and the length of the first storage space. definite. For example, if the first block 2 that is idle is selected, and the packet needs to occupy two second blocks according to the length of the packet and the length of the first storage space of 56 bytes, the message is occupied.
  • the second block may be the second block 0 and the second block 1 in the first block 2.
  • the head pointer of the queue may be updated to point to the start address of the first second block to be occupied by the message, and the queue is updated.
  • the tail pointer is the end address of the last second block to be used for the message.
  • the network device can maintain a pool of free addresses for storing all of the free first blocks.
  • the free block may be selected from the free address pool in units of the first block, that is, one or more first blocks need to be applied each time, instead of directly applying one or more second blocks.
  • Block When reclaiming memory, it is also reclaimed in units of the first block, that is, one or more first blocks are reclaimed into the free address pool instead of reclaiming one or more second blocks into the free address pool.
  • the message when the message is stored in the first storage space of the determined second block in step 203, if the message needs to occupy N second blocks, the message can be divided into N reports. a text segment, and the N message fragments can be separately stored in the first storage space of the N second blocks. For example, if the length of the message is 100 bytes and the message needs to occupy the second block 11 and the second block 12, the first 56 bytes of the message can be divided into the message fragment 1 and The message fragment 1 is stored in the first storage space of the second block 11; the last 44 bytes of the message are divided into the message segment 2, and the message segment 2 is stored in the second region. The first storage space of block 12.
  • the step of generating the PD corresponding to the second block may include, but is not limited to, if the second block is a message.
  • the block is the last second block occupied by the message.
  • the flag indicating whether the current block is occupied in the PD of the second block needs to be valid.
  • any mark within the PD can be set by way of assignment.
  • the information field SOP, the information field EOP, the information field BV, and the like can be assigned separately.
  • the second block is the last second block occupied by the message in a certain first block
  • the information field NBA in the PD of the second block needs to be assigned a pointer to the next first block to be occupied by the packet, and the information field NBN is assigned to the second required to be occupied by the message in the next first block.
  • the number of blocks and the information field VAL are valid.
  • the process of generating the PD may be as shown in FIG. 1C, and details are not described herein again.
  • the packet when the packet is stored in the second storage space of the second block in step 204, it is determined that the message needs to occupy the second block 11 and the second block 12, then it is determined that the message is to be received.
  • the length is stored in the second storage space of the second block 11 at the position corresponding to the information field LEN of the PD, and the information field SOP corresponding to the PD in the second storage space of the second block 11 is assigned to represent the second block 11
  • the first second block occupied by the message, and the information field BV corresponding to the PD in the second storage space of the second block 11 is assigned to indicate that the second block 11 is occupied by the message;
  • the information field EOP corresponding to the PD in the second storage space of the block 12 is assigned to indicate that the second block 12 is the last second block occupied by the message, and is in the second storage space of the second block 12.
  • the information field BV corresponding to the PD is assigned to indicate that the second block 12 is occupied by the message.
  • each first block is divided into a plurality of second blocks by dividing the DDR memory into a plurality of first blocks, and each of the second blocks includes a first storage space and a second storage space.
  • the message can be stored in the first storage space and the PD is stored in the second storage space. In this way, the message and the PD can be stored in the same memory, which can fully utilize the DDR resources, and effectively reduce the design cost of the board and reduce the wiring pressure.
  • a schematic flowchart for reading a message includes:
  • Step 210 Determine one or more second blocks to be read according to a start address of the message to be read.
  • Step 211 Read a message segment from the first storage space of each second block to be read.
  • Step 212 Read the PD from the second storage space of the second block.
  • Step 213 The read PD segment is used to form a packet by using the read PD.
  • Step 214 sending a composed message.
  • Steps 210 to 214 shown in FIG. 2C are a process of reading a message and a process of transmitting a message.
  • the PD is read from the second storage space of each second block to be read, and the second block corresponding to the PD in which the information field SOP is valid is determined as the initial second block, and the information domain EOP is The second block corresponding to the valid PD is determined to terminate the second block.
  • the PD is read from the second storage space of the last second block in the first block, according to the PD in the PD
  • the information field NBA obtains a pointer to the next first block, acquires the number of second blocks occupied by the message in the next first block according to the information field NBN in the PD, and according to the pointer and the second The number of blocks reads the PD from the second storage space of the second block in the next first block.
  • the second block corresponding to the PD in which the information field EOP is valid is determined to terminate the second block. Reading a message fragment from a first storage space of each second block between the starting second block and the terminating second block, and forming the read message fragment into a message, and transmitting the packet Message.
  • the head pointer of the queue is queried, and the head pointer points to the head of the first message in the queue, for example, the start address of the first message, and the start The address can be the address of the second block. Then, the first block to which the second block belongs is determined, and the PD is read from the second storage space of the second block of the first block.
  • the information field SOP in the PD of the second block 0 in the first block 0 is valid
  • the information field EOP in the PD of the second block 1 in the first block 0 is valid
  • the second block 0 in a block 0 is determined to be the start second block
  • the second block 1 in the first block 0 is determined to terminate the second block.
  • the message fragment is read from the first storage space of the second block 0 and the second block 1 in the first block 0, and the read message fragment is composed into the message 0, and the report is sent. Text 0.
  • the information field SOP in the PD of the second block 2 in the first block 0 is valid
  • the information field EOP in the PD of the second block 4 in the first block 0 is valid
  • the first block 0 is the first
  • the second block 2 is determined to be the starting second block
  • the second block 4 in the first block 0 is determined to terminate the second block.
  • the message fragment is read from the first storage space of the second block 2, the second block 3, and the second block 4 in the first block 0, and the read message fragments are reported. Text 1, and send the message 1.
  • the second block 5 in the first block 0 is determined as the start second block. Since in the first block 0, the information fields EOP in the PDs of the second blocks 6-31 after the second block 5 are not valid, the information fields NBA in the PD of the second block 31 are obtained.
  • Pointer to the next first block obtain the number M of the second block occupied by the message in the next first block from the information field NBN in the PD of the second block 31, and determine the next one according to the obtained pointer
  • the address of the first block (exemplified by the first block 1 in the figure), from the first M second blocks in the first block 1 (exemplified by the second block 0 and the second block 1 in the figure)
  • the second storage space reads the PD. Since the information field EOP in the PD of the second block 1 in the first block 1 is valid, the second block 1 in the first block 1 is determined to terminate the second block.
  • the message fragment is read from the second block 5 in the first block 0, the second block 31, the second block 0 in the first block 1, and the first storage space of the second block 1. And the read message fragment is composed into message 2, and the message 2 is sent.
  • the read after reading the message segment from the first storage space of each second block between the starting second block and the terminating second block, the read may also be released.
  • the first block When the first storage space of each second block in a certain first block is released, the first block may be reclaimed as the idle first block, for example, the first block is Reclaimed to the free address pool.
  • the network device can then use this first block to store new message fragments.
  • the network device may further update the head pointer of the queue according to the address of the next first block pointed by the first block.
  • the second storage space of each of the second blocks in the first block may also be released.
  • the second storage space of each second block in the first block may not be released, but the first Inverted mark of a block.
  • the current inversion flag of the first block to which the second block belongs may be obtained, and determining that the PD corresponding to the second block includes the inversion mark.
  • the inversion flag when the first block is used twice in succession is different.
  • the inversion flag of the first block when it is used for the first time is 0, and the inversion flag when it is used for the second time after being reclaimed as idle is modified to be different from 0 (for example, 1).
  • the inversion flag when used for the third time after being reclaimed as idle is modified to be different from 1 (for example, 0 or 2), and so on.
  • the second storage space of each second block in the first block 1 is written to the PD.
  • FIG. 3A an example of writing a PD for the second storage space is shown. After the read operation for the first block 1 is completed, if these PDs are not processed, an error occurs. It is assumed that, when the first block 1 is used to store the message for the second time, only the message fragment and the second block 0, the second block 1, and the second block 2 in the first block 1 are written. The PD, without the message fragment and the PD, is written in the other second block in the first block 1.
  • the message fragment can only be read from the second block 0, the second block 1, and the second block 2, but can be from the second block 0.
  • the second block 31 reads the PD so that an error occurs when the read message fragments are grouped using these PDs.
  • the PD of the second storage space of each of the second blocks in the first block 1 is deleted.
  • the PD of the second storage space of each second block of the first block 1 needs to be deleted, resulting in the second block. Repeat operations and reduce the processing performance of network devices.
  • an inversion flag is set for each first block, which may be a first value, such as 0 or a second value, such as one. Based on this, each time the read operation of the first block is completed, when the first block is reclaimed as idle, if the previous inversion of the first block is marked as the first value, the first The current inversion flag of a block is modified to a second value; conversely, if the previous inversion flag of the first block is a second value, the current inversion flag of the first block may be modified to be the first Value.
  • the PD may further include a current inversion flag of the first block.
  • the PD in the second storage space of the second block may include the information field SEL in addition to the information fields LEN, SOP, EOP, BV, VAL, NBA, NBN described above.
  • the PD in the second storage space of the second block may include two sets of information fields LEN, SOP, EOP, BV, VAL, NBA, NBN.
  • the current inversion flag corresponding to the first block is the first value
  • the information fields LEN1, SOP1, EOP1, BV1, VAL1, NBA1, NBN1 When valid, it indicates that the current inversion flag corresponding to the first block is the second value.
  • the information field SEL in the corresponding PD may take a value of 0 as shown in FIG. 3B, and is simplified as "SEL0" in FIG. 3B to Indicates that the current inversion flag of the first block is 0.
  • the information fields SOP0, EOP0, NBN0, and NBA0 in the corresponding PD are valid.
  • a "0" in the information fields SOP0, EOP0, NBN0, NBA0 indicates that the current inversion flag of the first block is 0.
  • the current inversion flag of the first block is modified to 1.
  • the information field SEL in the corresponding PD may be The value shown as 1 in FIG. 3D is simplified as "SEL1" in FIG. 3D to indicate that the current inversion flag of the first block is 1.
  • the information fields SOP1 and EOP1 in the corresponding PD are valid.
  • a "1" in the information fields SOP1, EOP1 indicates that the current inversion flag of the first block is 1.
  • the PD can be read from the second block 0 to the second block 31, but only the second block 0 and the second block 1
  • the value of the information field SEL in the PD corresponding to the second block 2 is 1, that is, only the second block 0, the second block 1, and the second block 2 are the current inversion marks in the first block. 1 is used, so only the PDs in the second storage space of the second block 0, the second block 1, and the second block 2 are used to group the read message fragments without error.
  • FIG. 3C with FIG. 3E it is also possible to group the read message segments using only the PDs in the second storage space of the second block 0, the second block 1, and the second block 2. package.
  • the embodiment of the present application further provides a message processing apparatus, wherein the memory is divided into a plurality of first blocks, and each of the first blocks is divided into a plurality of second blocks.
  • Each of the second blocks includes a first storage space and a second storage space.
  • the device includes:
  • the writing module 401 is configured to obtain a first packet to be stored, and determine, according to the length of the first packet and the length of the first storage space, a second block that the first packet needs to occupy, and And storing, by the first packet, the first storage space of the determined second block; and for each of the determined second blocks, generating a message descriptor PD corresponding to the second block, and Storing the PD to a second storage space of the second block;
  • the reading module 402 is configured to determine, according to a start address of the second message to be read, a second block to be read, and read a message fragment from the first storage space of the second block to be read. And reading the PD from the second storage space of the second block to be read, and using the read PD to form the read message segment into the second message. According to an example, the reading module 402 is further configured to transmit the composed second message. It should be noted that the first packet to be stored and the second packet to be read may be the same packet, or may be different packets, which is not limited in this disclosure.
  • the determining module 401 is configured to: determine a queue corresponding to the first packet, in a process of determining a second block that is to be occupied by the first packet; If there is a tail pointer, the second block that the first message needs to occupy is determined from the second block pointed by the tail pointer; if the queue does not have a corresponding tail pointer, the idle first block is selected. And determining, according to the first second block in the selected first block, the second block that the first packet needs to occupy.
  • the writing module 401 is specifically configured to: if the second block is the first second required to be occupied by the first packet Block, the length of the first packet is recorded in the PD corresponding to the second block, and the first flag in the PD corresponding to the second block is set to be valid to indicate the second block And storing the first second block of the first packet; if the second block is the last second block that needs to be occupied by the first packet, the PD corresponding to the second block is The second flag is asserted to indicate that the second block is the last second block storing the first message.
  • the process of the writing module 401 generating the PD corresponding to the second block Specifically, if the second block is the last second block of the current first block, but is not the last second block that needs to be occupied by the first packet, then in the second area Recording, in the PD corresponding to the block, a pointer to the next first block to be occupied by the first packet, and recording the first packet in the next first area in the PD corresponding to the second block The number of second blocks that need to be occupied in the block.
  • the writing module 401 is configured to: obtain a current inversion flag of the first block to which the second block belongs, in the process of generating the PD corresponding to the second block, so that the current inversion flag of the first block to which the second block belongs is obtained.
  • the PD corresponding to the second block includes a current inversion flag of the first block. Among them, the inversion flag when the first block is used twice in succession is different.
  • the reading module 402 is configured to: read a PD from a second storage space of each second block of the current first block to which the second block to be read belongs, and validate the first label
  • the second block corresponding to the PD is determined to store the first block of the second packet, and the second block corresponding to the PD with the second flag is determined to store the termination of the second packet.
  • a second block if the PD of the second tag is not read from the current first block, the PD is read from the second storage space of the last second block in the current first block, Obtaining a pointer pointing to the next first block from the PD, and acquiring a second block number occupied by the second message in the next first block, and according to the pointer and the The number of two blocks reads the PD from the second storage space of the second block in the next first block.
  • the reading module 402 is further configured to: after reading the message fragment in the first storage space of each second block between the starting second block and the terminating second block, releasing the read The first storage space occupied by the captured message fragment; when the first storage space of each second block in a certain first block is released, the first block is reclaimed as idle; After the first block is reclaimed as idle, the second storage space of each second block in the first block is released, or the current inversion flag of the first block is adjusted.
  • the network device includes a forwarding chip 510 and a storage unit 520.
  • the storage unit 520 is separately disposed from the forwarding chip 510.
  • the storage unit 520 may be a DDR memory, and the storage unit 520 may also be other. Type of storage unit, no restrictions on this.
  • the memory of the storage unit 520 is divided into a plurality of first blocks, each of the first blocks is divided into a plurality of second blocks, and each of the second blocks includes a first storage space and a second storage.
  • the forwarding chip 510 is configured to obtain a first packet to be stored, and determine, according to the length of the first packet and the length of the first storage space, a second block that needs to be occupied by the first packet. And storing, by the first packet, the first storage space of the determined second block in the storage unit 520; and generating, for each of the determined second blocks, a report corresponding to the second block a descriptor PD, and storing the PD in a second storage space of the second block; and determining a second block to be read according to a start address of the second message to be read, from the storage unit
  • the first storage space of the second block to be read in 520 reads the message fragment, reads the PD from the second storage space of the second block to be read in the storage unit 520, and uses the read
  • the fetched PD forms a second packet and reads the second packet.
  • the forwarding chip 510 can implement the foregoing packet processing method, including performing various operations of the foregoing packet processing method. For example, the process for implementing the packet processing method described above may be written to the forwarding chip 510, so that the forwarding chip 510 can perform various operations of the packet processing method, and details are not described herein.
  • the forwarding chip 510 may include, but is not limited to, an FPGA (Field-Programmable Gate Array), a CPLD (Complex Programmable Logic Device), and the like. Restrictions, as long as the above functions can be achieved.
  • FPGA Field-Programmable Gate Array
  • CPLD Complex Programmable Logic Device
  • the forwarding chip 510 can be read from the same memory of the storage unit 520 by storing the message and the PD in the same memory.
  • the reading efficiency is relatively high.
  • the forwarding chip 510 may further include a forwarding engine 511 and a TM (Traffic Manage) module 512.
  • the forwarding engine 511 can perform traffic classification 511-1 and traffic policing (such as a CAR (Committed Access Rate) rate limit operation) 511-2, and output the packet to the packet 511-2.
  • TM module 512 can perform traffic classification 511-1 and traffic policing (such as a CAR (Committed Access Rate) rate limit operation) 511-2, and output the packet to the packet 511-2.
  • traffic classification 511-1 and traffic policing such as a CAR (Committed Access Rate) rate limit operation
  • the TM module 512 can perform operations such as congestion avoidance 512-1, congestion management 512-2, traffic shaping 512-3, and the like.
  • the congestion avoidance 512-1 may include, for example, WRED (Weighted Random Early Detection), tail drop, and the like;
  • the congestion management 512-2 may include, for example, PQ (Priority Queue) scheduling, WFQ (Weighted Fair) Queuing, weighted fair queues, scheduling, etc.
  • the TM module 512 can buffer the message into the storage unit 520 according to the queue to which the message belongs.
  • the TM module 512 needs to send a message
  • the TM module 512 reads the message from the storage unit 520 according to the queue to which the message belongs and transmits it.
  • the TM module 512 caches the message to the storage unit 520, and the TM module 512 reads the message from the storage unit 520 and sends the message, which is the message processing method, and details are not described herein again.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Human Computer Interaction (AREA)
  • Computer Security & Cryptography (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

网络设备的内存被划分成多个第一区块,每个第一区块被划分成多个第二区块,每个第二区块均包括第一存储空间和第二存储空间。在存储报文时,根据报文的长度和第一存储空间的长度,确定报文需要占用的第二区块,并将所述报文存储到所确定的第二区块的第一存储空间。针对所确定的每个第二区块,生成该第二区块对应的PD,并将所述PD存储到该第二区块的第二存储空间。在读取报文时,根据待读取报文的开始地址确定要读取的第二区块,并从所确定的第二区块的第一存储空间读取报文片段,将所读取的报文片段组成报文,并发送组成的报文。

Description

报文处理
相关申请的交叉引用
本专利申请要求于2017年7月31日提交的、申请号为201710638401.3、发明名称为“一种报文处理方法、装置和网络设备”的中国专利申请的优先权,该申请的全文以引用的方式并入本文中。
背景技术
网络设备在接收到报文时,可根据报文所属的队列,将报文缓存到外部的存储单元中。网络设备在发送报文时,也可根据报文所属的队列,从外部的存储单元中读出报文并发送。在报文的存取过程中存在两个关键元素,分别为PKT(PACKET,报文实体)和PD(Packet Description,报文描述符)。
网络设备可将PKT存储到DDR SDRAM(Dual Data Rate Synchronous Dynamic Random Access Memory,双倍速率同步动态随机存取存储器,后续简称DDR),并将PD存储到QDR SRAM(Quad Data Rate Static Random Access Memory,四倍数据速率静态随机存取存储器,后续简称QDR)。由于使用QDR存储PD,提高了单板设计成本,增加了布线压力。此外,在发送报文时,网络设备先从QDR读取PD,然后利用PD从DDR读取PKT。由于分两次分别读取PD和PKT,读取效率较低。
附图说明
图1A-图1C是本申请一种实施方式中的应用场景示意图。
图2A是本申请一种实施方式中的报文存储的示意性流程图。
图2B是本申请一种实施方式中的确定报文需要占用的第二区块的示意性流程图。
图2C是本申请一种实施方式中的报文读取的示意性流程图。
图3A-图3E是本申请另一种实施方式中的应用场景示意图。
图4是本申请一种实施方式中的报文处理装置的结构图。
图5A和图5B是本申请一种实施方式中的网络设备的硬件结构图。
具体实施方式
在本申请实施例使用的术语仅仅是出于描述特定实施例的目的,而非限制本申请。本申请和权利要求书中所使用的单数形式的“一种”、“所述”和“该”也旨在包括多数形式,除非上下文清楚地表示其它含义。还应当理解,本文中使用的术语“和/或”是指包含一个或多个相关联的列出项目的任何或所有可能组合。
应当理解,尽管在本申请实施例可能采用术语第一、第二、第三等来描述各种信息,但这些信息不应限于这些术语。这些术语仅用来将同一类型的信息彼此区分开。例如,在不脱离本申请范围的情况下,第一信息也可以被称为第二信息,类似地,第二信息也可以被称为第一信息。取决于语境,此外,所使用的词语“如果”可以被解释成为“在……时”或“当……时”或“响应于确定”。
本申请实施例中提出一种报文处理方法,可以应用于网络设备。网络设备在处理报文时,会涉及报文的存储和读取过程。在报文的存取过程中,会存在两个关键元素,分别为待存储的报文本身和PD。待存储的报文本身也可以称为PKT,以下也可简称为报文;而PD用于记录报文的关键信息,如报文的长度、队列信息、存储地址等。PD的长度远小于报文的长度,PD的信息量比较小。
本申请实施例中,将报文和PD存储到同一个内存、如DDR内存,以充分利用DDR内存资源,从而有效降低单板设计成本、减少布线压力。而且,由于将报文和PD存储到同一个内存,在需要发送报文时,可以从同一个内存中读取到报文和PD,读取效率相对很高。
本申请实施例中,内存(如DDR内存)被划分成多个第一区块,每个第一区块又被划分成多个第二区块,每个第二区块可以为一个burst。每个第二区块又被划分成为大小不等的两段存储空间,即第一存储空间和第二存储空间,其中,第一存储空间可以大于第二存储空间。基于此,可以将报文存储到第一存储空间,将PD存储到第二存储空间,从而将报文和PD存储到同一个内存。
在一个例子中,参见图1A所示,DDR内存可以被划分成了多个第一区块,每个第一区块为2K字节的大块内存。此外,每个第一区块可以被划分成32个第二区块,每个第二区块为64字节的小块内存,即每个2K字节的第一区块被划分成32个64字节的第二区块,每一个第二区块可以为一个burst。
其中,上述2K字节、32个、64字节等,只是本申请的一个示例,对此数值不做限 制。例如,假设第一区块为2K字节,第二区块为128字节时,则第一区块可以被划分成16个第二区块。又例如,假设第一区块为4K字节,第二区块为64字节时,则第一区块可以被划分成64个第二区块。以此类推。为了方便描述,后续以2K字节的第一区块被划分成32个64字节的第二区块为例。
其中,在将第一区块划分成32个第二区块之后,还可以将每个第二区块划分为大小不等的两段存储空间。较大的第一存储空间可以为例如56字节,第一存储空间用于存储报文。较小的第二存储空间可以为例如8字节,第二存储空间用于存储PD。参见图1B所示,第二区块可以同时存储报文和PD。例如,假设需要存储4个报文(如报文0、报文1、报文2、报文3),且4个报文的大小均是96字节,则报文0存储在第二区块0和第二区块1,报文0可以占用第二区块0的第一存储空间56字节,占用第二区块1的第一存储空间内40字节,且在第二区块0的前8字节的第二存储空间中存储有PD,在第二区块1的前8字节的第二存储空间中也存储有PD。以此类推。
参见表1,为PD所包括的信息域的一个示例。
Figure PCTCN2018097254-appb-000001
表1
参见图1C所示,为PD的一个示例。为了简化视图,图1C中仅示出了PD中存在有效值的部分信息域。不同第二区块中存储的PD可能相同,也可能不同。例如,当一个报文占用一个或多个第二区块时,对于占用的所有第二区块中的第一个第二区块,则需要对该第二区块中的PD内的信息域LEN和SOP赋值。例如,当某个第二区块中存 储的PD内的信息域SOP的取值为0时,表示该第二区块是存储报文的第一个第二区块。当信息域SOP(下文中也可称为第一标记)的取值为1时,表示该第二区块不是存储报文的第一个第二区块。信息域LEN的取值为该PD对应的第二区块所存储的报文的长度。
对于报文需要占用的所有第二区块中的最后一个第二区块,则需要对该第二区块中的PD内的信息域EOP(下文中也可称为第二标记)赋值。例如,当某个第二区块中存储的PD内的信息域EOP的取值为0时,表示该第二区块是存储报文的最后一个第二区块。当信息域EOP的取值为1时,表示该第二区块不是存储报文的最后一个第二区块。
对于报文需要占用的任一第二区块,则需要将该第二区块中的PD内的信息域BV赋值为有效。例如,当某个第二区块中存储的PD内的信息域BV的取值为0时,表示该第二区块有效。然而,当信息域BV的取值为1时,表示该第二区块无效。
此外,当一个报文需要占用的多个第二区块属于至少两个第一区块时,若第二区块是该报文需要占用的当前第一区块中的最后一个第二区块、但不是该报文需要占用的最后一个第二区块,则需要对该第二区块中的PD内的信息域VAL、NBA和NBN赋值。其中,信息域VAL可以表示信息域NBA是否有效。例如,当某个第二区块中存储的PD内的信息域VAL的取值为0时,则表示该PD内的信息域NBA有效;然而,当该PD内的信息域VAL的取值为1时,则表示该PD内的信息域NBA无效。信息域NBA(Next Block Address,下一块地址)的取值为该报文需要占用的下一个第一区块的指针地址。信息域NBN(Next Block Number,下一块数量)的取值为该报文在下一个第一区块中占用的第二区块数量。
例如,在图1C中,报文1占用第二区块2、第二区块3和第二区块4。报文1需要占用的所有第二区块中的第一个第二区块为第二区块2,该第二区块2对应的PD内的信息域LEN的取值为例如120,以表示报文1的总长度是120字节。该第二区块2中的PD内的信息域SOP的取值为0,以表示该第二区块2为报文1占用的第一个第二区块。针对报文1需要占用的任意一个第二区块(如第二区块2、第二区块3和第二区块4,图1C中为简化视图仅以第二区块3为例示出了BV),该第二区块3对应的PD内的信息域BV的取值为0,以表示该第二区块3有效。报文1需要占用的所有第二区块中的最后一个第二区块为第二区块4,该第二区块4中的PD内的信息域EOP的取值为0,以表示该第二区块4为报文1占用的最后一个第二区块。
在这个示例中,第二区块2中的PD可以记录:LEN=120;SOP=0;BV=0;第二区块4中的PD可以记录:EOP=0;BV=0。第二区块3中的PD可以记录:BV=0。
又例如,报文2占用第一区块0中的第二区块5至第二区块31以及第一区块1中的第二区块0、第二区块1。报文2需要占用的所有第二区块中的第一个第二区块为第一区块0中的第二区块5,该第一区块0中的第二区块5对应的PD内的信息域LEN的取值为例如1560,以表示报文2的总长度是1560字节。该第一区块0中的第二区块5中的PD内的信息域SOP的取值为0,以表示该第二区块5为报文2占用的第一个第二区块。针对报文2需要占用的任意一个第二区块(如第一区块0中的第二区块5至第二区块31、以及第一区块1中的第二区块0和第二区块1),这些第二区块对应的PD内的信息域BV的取值均为0,以表示这些第二区块有效。报文2占用的第一区块0中的第二区块31为第一区块0中的最后一个第二区块,该第一区块0中的第二区块31对应的PD中的信息域NBA记录了报文2占用的下一个第一区块、即第一区块1的指针,如第一区块1的第二区块0的地址。第一区块0中的第二区块31对应的PD中的信息域NBN的取值为2,以记录报文2在第一区块1中占用的第二区块数量。第一区块0中的第二区块31对应的PD内的信息域VAL的取值为0,以表示信息域NBA有效。报文2需要占用的所有第二区块中的最后一个第二区块为第一区块1中的第二区块1,该第一区块1中的第二区块1对应的PD内的信息域EOP取值为0,以表示该第一区块1中的第二区块1为报文2占用的最后一个第二区块。
在这个示例中,第一区块0中的第二区块5的PD可以记录:LEN=1560;SOP=0;BV=0;第一区块0中的第二区块31的PD可以记录:BV=0;NBA=0x8049324(其表示占用的下一个第一区块的指针地址);NBN=2;VAL=0;对于其它第二区块的PD,在此不再赘述。
在上述应用场景下,参见图2A所示,为报文存储的示意性流程图。
步骤201,获得待存储的报文。
步骤202,根据该报文的长度和第一存储空间的长度,确定该报文需要占用的一个或多个第二区块。
步骤203,将该报文存储到确定的第二区块的第一存储空间。
步骤204,针对确定的每个第二区块,生成该第二区块对应的PD,并将该PD存储到该第二区块的第二存储空间。
在一个例子中,如图2B所示,在步骤202“确定该报文需要占用的一个或多个第二区块”可以包括但不限于如下方式:
步骤2021,确定该报文对应的队列。
步骤2022,判断该队列是否对应有尾指针。如果有,则进入步骤2023,否则进入步骤2024。
步骤2023,若该队列对应有尾指针,则从该尾指针指向的第二区块开始,确定该报文需要占用的第二区块;
步骤2024,若该队列没有对应尾指针,则可以选取空闲的第一区块,并从选取的第一区块中的首个第二区块开始,确定该报文需要占用的第二区块。
其中,可以先根据该报文的长度和第一存储空间的长度,确定该报文需要占用的第二区块的数量N。然后,从该尾指针指向的第二区块开始或者从选取的第一区块中的首个第二区块开始,确定该报文需要占用的N个第二区块。每个第二区块用于存储该报文的一个报文片段,例如,若报文需要占用3个第二区块,则可以将报文划分为3个报文片段,每个报文片段占用一个第二区块。
其中,网络设备可以采用队列存储报文,每个队列具有唯一的队列标识。当然,采用队列存储报文的方式只是一个示例,网络设备还可以采用其它方式存储报文。通过队列存储报文,可以有效的将不同类型的报文存储到不同的队列。例如,网络设备包括三个队列(如FIFO(First-In First-Out,先进先出)队列),这三个队列的队列标识分别为队列A、队列B和队列C。其中,队列A用于存储具有特征A(如出接口为接口A)的报文,队列B用于存储具有特征B(如出接口为接口B)的报文,队列C用于存储具有特征C(如出接口为接口C)的报文。
网络设备在获得待存储的报文之后,可以先确定该报文对应的队列。若该报文是该队列对应的首个报文,则该队列没有对应尾指针和头指针,若该报文不是该队列对应的首个报文,则该队列对应有尾指针和头指针。
其中,头指针表示指向队列对应的第一个报文头部的指针,如队列中第一个报文的开始地址或者开始位置。尾指针表示指向队列对应的最后一个报文尾部的指针,如队列中最后一个报文的结束地址或者结束位置。
例如,在队列为空的情况下,若获得待存储的报文1,则在队列中存储报文1,并更新该队列的头指针为指向报文1的开始地址,更新该队列的尾指针为指向报文1的结束地址。然后,若获得待存储到该队列的报文2,则在该队列中存储报文2,并更新该队列的尾指针为指向报文2的结束地址。以此类推,每接收到该队列的报文,就可以更新 该队列的尾指针。
若需要读取队列中的报文,则从队列的头指针开始读取。例如,在报文1读取完成后,则从该队列中删除报文1,并更新该队列的头指针为指向报文2的开始地址。以此类推,每从队列中读取并删除一个报文,就可以更新该队列的头指针。综上所述,存储报文的过程,是从队列的尾指针开始依次存储报文,读取报文的过程,是从队列的头指针开始依次读取报文。
其中,步骤2023可以包括:从该尾指针指向的第二区块的下一个第二区块开始,选取N个第二区块,所述N是根据报文的长度以及第一存储空间的长度确定的。例如,若尾指针指向第一区块1中的第二区块10,且根据报文的长度100字节、第一存储空间的长度56字节确定该报文需要占用两个第二区块,则该报文要占用的第二区块为第一区块1中的第二区块11和第二区块12。又例如,若尾指针指向第一区块1中的第二区块30,且根据报文的长度100字节、第一存储空间的长度56字节确定该报文需要占用两个第二区块,则由于第一区块1已经不存在两个空闲的第二区块,从而重新申请空闲的第一区块、如第一区块3。基于此,该报文要占用的第二区块可以为第一区块1中的第二区块31和第一区块3中的第二区块0。
此外,在步骤2023中,在确定报文需要占用的第二区块之后,还可以更新队列的尾指针为指向该报文占用的最后一个第二区块的结束地址,如指向第二区块12的结束地址。
其中,步骤2024可以包括:从选取的空闲的第一区块中的首个第二区块开始,选取N个第二区块,所述N是根据报文的长度以及第一存储空间的长度确定的。例如,若选取空闲的第一区块2,且根据报文的长度100字节、第一存储空间的长度56字节确定该报文需要占用两个第二区块,则该报文要占用的第二区块可以为第一区块2中的第二区块0和第二区块1。
此外,在步骤2024中,在确定该报文需要占用的第二区块之后,还可以更新队列的头指针为指向该报文要占用的第一个第二区块的开始地址,以及更新队列的尾指针为指向该报文要占用的最后一个第二区块的结束地址。
网络设备可以维护空闲地址池,该空闲地址池用于存储所有空闲的第一区块。在申请空闲区块时,可以以第一区块为单位从空闲地址池中选取该空闲区块,即每次需要申请一个或者多个第一区块,而不是直接申请一个或者多个第二区块。在回收内存时,也 是以第一区块为单位回收,即将一个或者多个第一区块回收到空闲地址池,而不是将一个或者多个第二区块回收到空闲地址池。
在一个例子中,在步骤203“将报文存储到确定的第二区块的第一存储空间”时,若报文需要占用N个第二区块,则可以将报文划分为N个报文片段,并可以将这N个报文片段分别存储到N个第二区块的第一存储空间。例如,以报文的长度是100字节、报文需要占用第二区块11和第二区块12为例,则可以将该报文的前56个字节划分到报文片段1,并将该报文片段1存储到该第二区块11的第一存储空间;将该报文的后44个字节划分到报文片段2,并将该报文片段2存储到该第二区块12的第一存储空间。
在一个例子中,当报文需要占用一个或多个第二区块时,在步骤204“生成该第二区块对应的PD”可以包括但不限于:若该第二区块是报文需要占用的所有第二区块中的第一个第二区块,则需要在该第二区块的PD中记录该报文的长度,以及将该第二区块的PD内的第一标记置为有效,以表示该第二区块为报文占用的第一个第二区块。若该第二区块是报文需要占用的所有第二区块中的最后一个第二区块,则需要将该第二区块的PD内的第二标记置为有效,以表示该第二区块为报文占用的最后一个第二区块。若第二区块是报文需要占用的任一第二区块,则需要将该第二区块的PD内的指示当前区块是否被占用的标记置为有效。在本公开示例中,PD内的任意标记均可通过赋值的形式来被设置。例如,可以对信息域SOP、信息域EOP、信息域BV等等分别进行赋值。
此外,当报文需要占用的所有第二区块属于至少两个第一区块时,若该第二区块是报文在某个第一区块中占用的最后一个第二区块,则需要将该第二区块的PD内的信息域NBA赋值为指向报文需要占用的下一个第一区块的指针,信息域NBN赋值为报文在下一个第一区块中需要占用的第二区块数量、信息域VAL赋值为有效。
上述PD的生成过程可以参见图1C所示,在此不再重新赘述。
在一个例子中,在步骤204“将该PD存储到该第二区块的第二存储空间”时,假设报文需要占用第二区块11和第二区块12,则确定要将报文长度存储到第二区块11的第二存储空间中对应PD的信息域LEN的位置处,对第二区块11的第二存储空间中对应PD的信息域SOP赋值以表示第二区块11为报文占用的第一个第二区块,并对第二区块11的第二存储空间中对应PD的信息域BV赋值以表示第二区块11被报文占用;确定要对第二区块12的第二存储空间中对应PD的信息域EOP赋值以表示第二区块12为报文占用的最后一个第二区块,并对并对第二区块12的第二存储空间中对应PD的信息域BV赋值以表示第二区块12被报文占用。
基于上述技术方案,通过将DDR内存划分成多个第一区块,每个第一区块被划分成多个第二区块,每个第二区块包括第一存储空间和第二存储空间,可以将报文存储到第一存储空间,并将PD存储到第二存储空间。这样,可以将报文和PD存储到同一个内存,可充分利用DDR资源,并有效降低了单板设计成本,减少了布线压力。
相应地,参见图2C所示,为报文读取的示意性流程图,包括:
步骤210,根据要读取的报文的开始地址确定要读取的一个或多个第二区块。
步骤211,从要读取的各第二区块的第一存储空间读取报文片段。
步骤212,从该第二区块的第二存储空间读取PD。
步骤213,利用读取的PD将读取的报文片段组成报文。
步骤214,发送组成的报文。
其中,图2C所示步骤210至步骤214是报文的读取过程,以及报文的发送过程。
具体的,从每个要读取的第二区块的第二存储空间读取PD,并将信息域SOP有效的PD对应的第二区块确定为起始第二区块,将信息域EOP有效的PD对应的第二区块确定为终止第二区块。若从当前的第一区块未读取到信息域EOP有效的PD,则从所述第一区块中的最后一个第二区块的第二存储空间读取PD,以根据该PD中的信息域NBA获取指向下一个第一区块的指针、根据该PD中的信息域NBN获取报文在下一个第一区块中占用的第二区块数量,并根据所述指针和所述第二区块数量,从下一个第一区块中的第二区块的第二存储空间读取PD。以此类推,直至读取到信息域EOP有效的PD为止,并将信息域EOP有效的PD对应的第二区块确定为终止第二区块。从起始第二区块与终止第二区块之间的每个第二区块的第一存储空间读取报文片段,并将所读取的报文片段组成报文,并发送所组成的报文。
在需要发送某个队列中的报文时,查询出该队列的头指针,这个头指针指向该队列中的第一个报文的头部、例如第一个报文的开始地址,且这个开始地址可以是第二区块的地址。然后,确定该第二区块所属的第一区块,并从该第一区块的该第二区块的第二存储空间读取PD。
参见图1C所示,由于第一区块0中第二区块0的PD内的信息域SOP有效,第一区块0中第二区块1的PD内的信息域EOP有效,因此将第一区块0中第二区块0确定为起始第二区块,并将第一区块0中第二区块1确定为终止第二区块。相应地,从第一 区块0中第二区块0、第二区块1的第一存储空间中读取报文片段,并将读取的报文片段组成报文0,并发送该报文0。
由于第一区块0中第二区块2的PD内的信息域SOP有效,第一区块0中第二区块4的PD内的信息域EOP有效,因此将第一区块0中第二区块2确定为起始第二区块,将第一区块0中第二区块4确定为终止第二区块。相应地,从第一区块0中的第二区块2、第二区块3、第二区块4的第一存储空间中读取报文片段,并将读取的报文片段组成报文1,并发送该报文1。
又例如,由于第一区块0中第二区块5的PD内的信息域SOP有效,因此将第一区块0中第二区块5确定为起始第二区块。由于在第一区块0中,第二区块5后的各第二区块6-31的PD内的信息域EOP均不是有效,因此从第二区块31的PD中的信息域NBA获取指向下一个第一区块的指针、从第二区块31的PD中的信息域NBN获取报文在下一个第一区块占用的第二区块数量M,并根据获取到的指针确定下一个第一区块的地址(图中示例为第一区块1),从第一区块1中前M个第二区块(图中示例为第二区块0和第二区块1)的第二存储空间读取PD。由于第一区块1中的第二区块1的PD内的信息域EOP有效,因此将第一区块1中的第二区块1确定为终止第二区块。然后,从第一区块0中的第二区块5-第二区块31、第一区块1中的第二区块0和第二区块1的第一存储空间读取报文片段,并将读取的报文片段组成报文2,并发送该报文2。
在一个例子中,在“从起始第二区块与终止第二区块之间的每个第二区块的第一存储空间中读取报文片段”之后,还可以释放所读取的报文片段占用的第一存储空间。当某个第一区块中的每个第二区块的第一存储空间均被释放时,则可以将所述第一区块回收为空闲的第一区块,例如将这个第一区块回收到空闲地址池。然后,网络设备可以使用这个第一区块存储新的报文片段。此外,网络设备还可以根据该第一区块指向的下一个第一区块的地址,更新队列的头指针。
在一个例子中,在将所述第一区块回收为空闲的第一区块后,还可以释放所述第一区块中的每个第二区块的第二存储空间。
或者,在将所述第一区块回收为空闲的第一区块后,还可以不释放所述第一区块中的每个第二区块的第二存储空间,而是调整所述第一区块的反转标记。例如,网络设备在每次生成第二区块对应的PD时,可以获取该第二区块所属的第一区块当前的反转标记,并确定该第二区块对应的PD包括该反转标记。其中,第一区块连续两次被使用时的反转标记不同。例如,第一区块在第一次被使用时的反转标记为0,在被回收为空闲 后的第二次被使用时的反转标记被修改为与0不同(例如可为1),在再次被回收为空闲后的第三次被使用时的反转标记被修改为与1不同(例如可为0或2),以此类推。
例如,在第一次使用第一区块1存储报文时,在第一区块1中的每个第二区块的第二存储空间写入PD。参见图3A所示,为第二存储空间写入PD的示例。在针对第一区块1的读操作完成后,如果不对这些PD进行处理,就会出现错误。假设,在第二次使用第一区块1存储报文时,只在第一区块1中的第二区块0、第二区块1、第二区块2中写入报文片段和PD,而不在第一区块1中的其它第二区块中写入报文片段和PD。这样,在再次针对第一区块1进行读操作时,只能从第二区块0、第二区块1、第二区块2读取到报文片段,但可以从第二区块0至第二区块31读取到PD,从而使得在使用这些PD对读取到的报文片段进行组包时会出现错误。
针对上述发现,在一个例子中,在针对第一区块1的读操作完成后,删除第一区块1中的每个第二区块的第二存储空间的PD。但是,在该方式下,每次针对第一区块1的读操作完成后,均需要删除第一区块1的每个第二区块的第二存储空间的PD,导致第二区块的反复操作,并降低网络设备的处理性能。
在另一个例子中,为每个第一区块设置反转标记,该反转标记可以为第一数值、例如0或者第二数值、例如1。基于此,每次针对第一区块的读操作完成之后,在将该第一区块回收为空闲时,若该第一区块的前次反转标记为第一数值,则可以将该第一区块的当前反转标记修改为第二数值;反之,若该第一区块的前次反转标记为第二数值,则可以将该第一区块的当前反转标记修改为第一数值。
在此基础上,每次在第一区块中的第二区块的第二存储空间存储PD时,所述PD还可以包括该第一区块的当前反转标记。例如,如图3B和3D所示,第二区块的第二存储空间中的PD除了包括上述的信息域LEN、SOP、EOP、BV、VAL、NBA、NBN之外,还可包括信息域SEL以记录对应的第一区块的当前反转标记。或者,如图3C和3E所示,第二区块的第二存储空间中的PD可包括两套信息域LEN、SOP、EOP、BV、VAL、NBA、NBN。其中,信息域LEN0、SOP0、EOP0、BV0、VAL0、NBA0、NBN0有效时表示对应第一区块的当前反转标记为第一数值,信息域LEN1、SOP1、EOP1、BV1、VAL1、NBA1、NBN1有效时表示对应第一区块的当前反转标记为第二数值。
这样,若第一区块的当前反转标记为0,针对图3A,对应的PD内的信息域SEL可以如图3B所示取值为0,图3B中简化示出为“SEL0”,以表示第一区块当前的反转标记为0。或者如图3C所示,对应的PD内的信息域SOP0、EOP0、NBN0、NBA0有 效。信息域SOP0、EOP0、NBN0、NBA0中的“0”表示第一区块当前的反转标记为0。
然后,在将第一区块回收为空闲的第一区块时,由于第一区块对应的前次反转标记为0,因此将该第一区块的当前反转标记修改为1。再次使用该第一区块存储报文时,若只在第二区块0、第二区块1、第二区块2中写入报文和PD,则对应的PD内的信息域SEL可以如图3D所示取值为1,图3D中简化示出为“SEL1”,以表示第一区块当前的反转标记为1。或者如图3E所示,对应的PD内的信息域SOP1、EOP1有效。信息域SOP1、EOP1中的“1”表示第一区块当前的反转标记为1。
通过对比图3D和图3B,在针对第一区块进行读操作时,可以从第二区块0至第二区块31读取到PD,但是只有第二区块0、第二区块1、第二区块2对应的PD内的信息域SEL的取值为1,即只有第二区块0、第二区块1、第二区块2是在第一区块当前的反转标记1下被使用的,因此只使用第二区块0、第二区块1、第二区块2的第二存储空间中的PD对读取到的报文片段进行组包,不会发生错误。同理,通过对比图3C和图3E,也可以只使用第二区块0、第二区块1、第二区块2的第二存储空间中的PD对读取到的报文片段进行组包。
基于与上述方法同样的申请构思,本申请实施例中还提出一种报文处理装置,内存被划分成多个第一区块,每个第一区块被划分成多个第二区块,每个第二区块均包括第一存储空间和第二存储空间,如图4所示,所述装置包括:
写入模块401,用于获得待存储的第一报文,根据所述第一报文的长度和所述第一存储空间的长度确定所述第一报文需要占用的第二区块,并将所述第一报文存储到所述确定的第二区块的第一存储空间;针对所述确定的每个第二区块,生成该第二区块对应的报文描述符PD,并将所述PD存储到该第二区块的第二存储空间;
读取模块402,用于根据待读取的第二报文的开始地址确定要读取的第二区块,从所述要读取的第二区块的第一存储空间读取报文片段,从所述要读取的第二区块的第二存储空间读取PD,并利用所读取的PD将所读取的报文片段组成所述第二报文。根据一个示例,读取模块402还用于发送所组成的所述第二报文。需要说明的是,待存储的第一报文与待读取的第二报文可为同一报文,也可为不同的报文,本公开对此不做限定。
在一个例子中,所述写入模块401在确定所述第一报文需要占用的第二区块的过程中,具体用于:确定所述第一报文对应的队列;若所述队列对应有尾指针,则从所述尾指针指向的第二区块开始确定所述第一报文需要占用的第二区块;若所述队列没有对应 尾指针,则选取空闲的第一区块,并从选取的第一区块中的首个第二区块开始确定所述第一报文需要占用的第二区块。
在一个例子中,所述写入模块401在生成该第二区块对应的PD的过程中,具体用于:若该第二区块是所述第一报文需要占用的第一个第二区块,则在该第二区块对应的PD内记录所述第一报文的长度,并将该第二区块对应的PD内的第一标记置为有效,以表示该第二区块为存储该第一报文的第一个第二区块;若该第二区块是所述第一报文需要占用的最后一个第二区块,则将该第二区块对应的PD内的第二标记置为有效,以表示该第二区块为存储该第一报文的最后一个第二区块。
在一个例子中,当所述第一报文需要占用的所有第二区块属于至少两个不同的第一区块时,所述写入模块401在生成该第二区块对应的PD的过程中,具体用于:若该第二区块是当前第一区块的最后一个第二区块、但不是所述第一报文需要占用的最后一个第二区块,则在该第二区块对应的PD内记录指向所述第一报文需要占用的下一个第一区块的指针,在该第二区块对应的PD内记录所述第一报文在所述下一个第一区块中需要占用的第二区块数量。
在一个例子中,所述写入模块401在用于生成该第二区块对应的PD的过程中,具体用于:获取该第二区块所属的第一区块当前的反转标记,使该第二区块对应的PD包括所述第一区块当前的反转标记。其中,第一区块连续两次被使用时的反转标记不同。
所述读取模块402,具体用于:从所述要读取的第二区块所属的当前第一区块的每个第二区块的第二存储空间读取PD,将第一标记有效的PD对应的第二区块确定为存储所述第二报文的起始第二区块,将第二标记有效的PD对应的第二区块确定为存储所述第二报文的终止第二区块;若从所述当前第一区块未读取到第二标记有效的PD,则从所述当前第一区块中的最后一个第二区块的第二存储空间读取PD,以从该PD获取指向下一个第一区块的指针、以及获取所述第二报文在所述下一个第一区块中占用的第二区块数量,并根据所述指针和所述第二区块数量,从所述下一个第一区块中的第二区块的第二存储空间读取PD。以此类推,直至读取到第二标记有效的PD,并将第二标记有效的PD对应的第二区块确定为存储所述第二报文的终止第二区块;从起始第二区块与终止第二区块之间的每个第二区块的第一存储空间中读取报文片段,并将所读取的报文片段组成所述第二报文,并发送所组成的所述第二报文。
所述读取模块402,还用于:在从起始第二区块与终止第二区块之间的每个第二区块的第一存储空间中读取报文片段之后,释放所读取的报文片段占用的第一存储空间; 当某个第一区块中的每个第二区块的第一存储空间均被释放时,将所述第一区块回收为空闲;在将所述第一区块回收为空闲后,释放所述第一区块中的每个第二区块的第二存储空间,或者,调整所述第一区块的当前反转标记。
基于与上述方法同样的申请构思,本申请实施例中还提出一种网络设备,本申请实施例提供的网络设备,从硬件层面而言,硬件架构示意图具体参见图5A所示。所述网络设备包括转发芯片510和存储单元520,所述存储单元520是与所述转发芯片510分开部署的,如所述存储单元520可以是DDR内存,当然所述存储单元520也可以是其它类型的存储单元,对此不做限制。
其中,所述存储单元520的内存被划分成多个第一区块,每个第一区块被划分成多个第二区块,每个第二区块均包括第一存储空间和第二存储空间。
所述转发芯片510,用于获得待存储的第一报文,根据所述第一报文的长度和所述第一存储空间的长度,确定所述第一报文需要占用的第二区块,将所述第一报文存储到存储单元520中的所述确定的第二区块的第一存储空间;针对所述确定的每个第二区块,生成该第二区块对应的报文描述符PD,并将所述PD存储到该第二区块的第二存储空间;以及,根据待读取的第二报文的开始地址确定要读取的第二区块,从存储单元520中所述要读取的第二区块的第一存储空间读取报文片段,从存储单元520中所述要读取的第二区块的第二存储空间读取PD,并利用读取的PD将读取的报文片段组成第二报文,并发送组成的第二报文。
其中,转发芯片510可以实现上述报文处理方法,包括执行上述报文处理方法的各个操作。例如,可以将用于实现上述报文处理方法的流程写入到转发芯片510,使转发芯片510可以执行上述报文处理方法的各个操作,在此不再赘述。
其中,转发芯片510可以包括但不限于:FPGA(Field-Programmable Gate Array,现场可编程门阵列)、CPLD(Complex Programmable Logic Device,复杂可编程逻辑器件)等,对此转发芯片510的类型不做限制,只要能够实现上述功能即可。
在一个例子中,由于存储单元520是转发芯片510的片外存储器、例如DDR,因此,通过将报文和PD存储到同一个内存,使得转发芯片510可以从存储单元520的同一个内存中读取到报文和PD,读取效率相对很高。
在另一个例子中,参见图5B所示,上述转发芯片510还可以包括转发引擎511和TM(Traffic Manage,流量管理)模块512。转发引擎511在接收到报文后,可以对报 文进行流分类511-1和流量监管(如CAR(Committed Access Rate,承诺访问速率)限速操作等)511-2,并将报文输出给TM模块512。
TM模块512在接收到报文后,可以对报文进行拥塞避免512-1、拥塞管理512-2、流量整形512-3等操作。其中,拥塞避免512-1可包括如WRED(Weighted Random Early Detection,加权随机早期检测)、尾丢弃等;拥塞管理512-2可包括如PQ(Priority Queue,优先级队列)调度、WFQ(Weighted Fair Queuing,加权公平队列)调度等。此外,TM模块512在接收到报文时,可以根据报文所属的队列,将报文缓存到存储单元520中。TM模块512在需要发送报文时,根据报文所属的队列,从存储单元520中读出报文并发送。
而TM模块512将报文缓存到存储单元520、TM模块512从存储单元520中读出报文并发送的过程,也就是上述报文处理方法,在此不再重复赘述。
以上所述仅为本申请的实施例而已,并不用于限制本申请。对于本领域技术人员来说,本申请可以有各种更改和变化。凡在本申请的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在本申请的权利要求范围之内。

Claims (15)

  1. 一种报文处理方法,其特征在于,内存被划分成多个第一区块,每个所述第一区块被划分成多个第二区块,每个所述第二区块均包括第一存储空间和第二存储空间,所述方法包括:
    获得待存储的第一报文;
    根据所述第一报文的长度和所述第一存储空间的长度,确定所述第一报文需要占用的一个或多个第二区块;
    将所述第一报文存储到所述确定的第二区块的第一存储空间;
    针对所述确定的每个第二区块,生成该第二区块对应的报文描述符PD,并将所述PD存储到该第二区块的第二存储空间;
    根据待读取的第二报文的开始地址确定要读取的一个或多个第二区块;
    从所述要读取的各第二区块的第一存储空间读取报文片段,从所述要读取的第二区块的第二存储空间读取PD;
    利用所读取的PD将所读取的报文片段组成所述第二报文,并发送所述第二报文。
  2. 根据权利要求1所述的方法,其特征在于,确定所述第一报文需要占用的一个或多个第二区块的过程,具体包括:
    确定所述第一报文对应的队列;
    若所述队列有尾指针,则从所述尾指针指向的第二区块开始,确定所述第一报文需要占用的第二区块;
    若所述队列没有尾指针,则选取空闲的第一区块,并从选取的第一区块中的首个第二区块开始,确定所述第一报文需要占用的第二区块。
  3. 根据权利要求1所述的方法,其特征在于,生成该第二区块对应的PD的过程,具体包括:
    若该第二区块是所述第一报文需要占用的第一个第二区块,则在该第二区块对应的PD内记录所述第一报文的长度,并将该第二区块对应的PD内的第一标记置为有效以表示该第二区块为存储所述第一报文的第一个第二区块;
    若该第二区块是所述第一报文需要占用的最后一个第二区块,则将该第二区块对应的PD内的第二标记置为有效以表示该第二区块为存储所述第一报文的最后一个第二区块。
  4. 根据权利要求1所述的方法,其特征在于,生成该第二区块对应的PD,包括:
    若该第二区块是当前第一区块的最后一个第二区块、但不是所述第一报文需要占用 的最后一个第二区块,则在该第二区块对应的PD内记录指向所述第一报文需要占用的下一个第一区块的指针,并在该第二区块对应的PD内记录所述第一报文在所述下一个第一区块中需要占用的第二区块数量。
  5. 根据权利要求1所述的方法,其特征在于,生成该第二区块对应的PD的过程,具体包括:
    获取该第二区块所属的第一区块当前的反转标记,其中,所述第一区块连续两次被使用时的反转标记不同;并
    确定该第二区块对应的PD包括所述第一区块当前的反转标记。
  6. 根据权利要求1所述的方法,其特征在于,从所述要读取的第二区块的第一存储空间读取报文片段,从所述要读取的第二区块的第二存储空间读取PD,具体包括:
    从所述要读取的第二区块所属的当前第一区块的每个第二区块的第二存储空间读取PD,将第一标记有效的PD对应的第二区块确定为存储所述第二报文的起始第二区块;
    若从所述当前第一区块读取到第二标记有效的PD,则将第二标记有效的PD对应的第二区块确定为存储所述第二报文的终止第二区块;
    若从所述当前第一区块未读取到第二标记有效的PD,则从所述当前第一区块的最后一个第二区块的第二存储空间读取PD,以从该PD获取指向下一个第一区块的指针、从该PD获取所述第二报文在所述下一个第一区块中占用的第二区块数量,根据所述指针和所述第二区块数量从所述下一个第一区块的第二区块的第二存储空间读取PD,并将第二标记有效的PD对应的第二区块确定为存储所述第二报文的终止第二区块;
    从所述起始第二区块与所述终止第二区块之间的每个第二区块的第一存储空间中读取报文片段。
  7. 根据权利要求6所述的方法,其特征在于,还包括:
    释放所读取的报文片段占用的第一存储空间;
    当所述当前第一区块中的每个第二区块的第一存储空间均被释放时,将所述当前第一区块回收为空闲,并释放所述当前第一区块中的每个第二区块的第二存储空间或调整所述当前第一区块的反转标记。
  8. 一种报文处理装置,其特征在于,内存被划分成多个第一区块,每个所述第一区块被划分成多个第二区块,每个所述第二区块均包括第一存储空间和第二存储空间,所述装置包括:
    写入模块,用于获得待存储的第一报文,并根据所述第一报文的长度和所述第一存 储空间的长度,确定所述第一报文需要占用的一个或多个第二区块,并将所述第一报文存储到所述确定的第二区块的第一存储空间;针对所述确定的每个第二区块,生成该第二区块对应的报文描述符PD,并将所述PD存储到该第二区块的第二存储空间;
    读取模块,用于根据待读取的第二报文的开始地址确定要读取的一个或多个第二区块,从所述要读取的各第二区块的第一存储空间读取报文片段,并从所述要读取的第二区块的第二存储空间读取PD,并利用所读取的PD将所读取的报文片段组成所述第二报文,并发送所组成的所述第二报文。
  9. 根据权利要求8所述的装置,其特征在于,所述写入模块,具体用于:
    确定所述第一报文对应的队列;
    若所述队列有尾指针,则从所述尾指针指向的第二区块开始,确定所述第一报文需要占用的第二区块;
    若所述队列没有尾指针,则选取空闲的第一区块,并从选取的第一区块中的首个第二区块开始,确定所述第一报文需要占用的第二区块。
  10. 根据权利要求8所述的装置,其特征在于,所述写入模块,具体用于:
    若该第二区块是所述第一报文需要占用的第一个第二区块,则在该第二区块对应的PD内记录所述第一报文的长度,并将该第二区块对应的PD内的第一标记置为有效以表示该第二区块为存储所述第一报文的第一个第二区块;
    若该第二区块是所述第一报文需要占用的最后一个第二区块,则将该第二区块对应的PD内的第二标记置为有效,以表示该第二区块为存储所述第一报文的最后一个第二区块。
  11. 根据权利要求8所述的装置,其特征在于,所述写入模块,具体用于:
    若该第二区块是当前第一区块的最后一个第二区块、但不是所述第一报文需要占用的最后一个第二区块,则在该第二区块对应的PD内记录指向所述第一报文需要占用的下一个第一区块的指针,在该第二区块对应的PD内记录所述第一报文在所述下一个第一区块中需要占用的第二区块数量。
  12. 根据权利要求8所述的装置,其特征在于,所述写入模块,具体用于:
    获取该第二区块所属的第一区块当前的反转标记,其中,所述第一区块连续两次被使用时的反转标记不同;并
    确定该第二区块对应的PD包括所述第一区块当前的反转标记。
  13. 根据权利要求8所述的装置,其特征在于,所述读取模块,具体用于:
    从所述要读取的第二区块所属的当前第一区块的每个第二区块的第二存储空间读 取PD,将第一标记有效的PD对应的第二区块确定为存储所述第二报文的起始第二区块;
    若从所述当前第一区块读取到第二标记有效的PD,则将第二标记有效的PD对应的第二区块确定为存储所述第二报文的终止第二区块;
    若从所述当前第一区块未读取到第二标记有效的PD,则从所述当前第一区块的最后一个第二区块的第二存储空间读取PD,以从该PD获取指向下一个第一区块的指针、从该PD获取所述第二报文在所述下一个第一区块中占用的第二区块数量,根据所述指针和所述第二区块数量从所述下一个第一区块的第二区块的第二存储空间读取PD,并将第二标记有效的PD对应的第二区块确定为存储所述第二报文的终止第二区块;
    从所述起始第二区块与所述终止第二区块之间的每个第二区块的第一存储空间中读取报文片段。
  14. 根据权利要求13所述的装置,其特征在于,所述读取模块,还用于:
    释放所读取的报文片段占用的第一存储空间;
    当所述当前第一区块中的每个第二区块的第一存储空间均被释放时,将所述当前第一区块回收为空闲,并释放所述当前第一区块中的每个第二区块的第二存储空间或调整所述当前第一区块的反转标记。
  15. 一种网络设备,包括:
    存储单元,所述存储单元的内存被划分成多个第一区块,每个所述第一区块被划分成多个第二区块,每个所述第二区块均包括第一存储空间和第二存储空间;
    转发芯片,用于
    获得待存储的第一报文,并根据所述第一报文的长度和所述第一存储空间的长度,确定所述第一报文需要占用的一个或多个第二区块,将所述第一报文存储到所述存储单元中的所述确定的第二区块的第一存储空间;针对所述确定的每个第二区块,生成该第二区块对应的报文描述符PD,并将所述PD存储到该第二区块的第二存储空间;
    根据待读取的第二报文的开始地址确定要读取的一个或多个第二区块,从所述存储单元中的所述要读取的各第二区块的第一存储空间读取报文片段,从所述存储单元中的所述要读取的第二区块的第二存储空间读取PD,并利用所读取的PD将所读取的报文片段组成所述第二报文,并发送所组成的所述第二报文。
PCT/CN2018/097254 2017-07-31 2018-07-26 报文处理 Ceased WO2019024763A1 (zh)

Priority Applications (3)

Application Number Priority Date Filing Date Title
EP18840257.2A EP3657744B1 (en) 2017-07-31 2018-07-26 Message processing
US16/635,529 US11425057B2 (en) 2017-07-31 2018-07-26 Packet processing
JP2020505176A JP7074839B2 (ja) 2017-07-31 2018-07-26 パケット処理

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710638401.3A CN108462652B (zh) 2017-07-31 2017-07-31 一种报文处理方法、装置和网络设备
CN201710638401.3 2017-07-31

Publications (1)

Publication Number Publication Date
WO2019024763A1 true WO2019024763A1 (zh) 2019-02-07

Family

ID=63220935

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/097254 Ceased WO2019024763A1 (zh) 2017-07-31 2018-07-26 报文处理

Country Status (5)

Country Link
US (1) US11425057B2 (zh)
EP (1) EP3657744B1 (zh)
JP (1) JP7074839B2 (zh)
CN (1) CN108462652B (zh)
WO (1) WO2019024763A1 (zh)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109802897B (zh) * 2017-11-17 2020-12-01 华为技术有限公司 一种数据传输方法及通信设备
US11552907B2 (en) * 2019-08-16 2023-01-10 Fungible, Inc. Efficient packet queueing for computer networks
US11483131B2 (en) * 2020-01-09 2022-10-25 Eternal Paradise Limited Ability to forget in blockchain
CN113991839B (zh) * 2021-10-15 2023-11-14 许继集团有限公司 一种提升遥控开出可靠性的装置及方法
CN114567413B (zh) * 2022-02-17 2023-06-30 中国银联股份有限公司 一种数据存储方法及装置
CN114726920A (zh) * 2022-06-07 2022-07-08 恒生电子股份有限公司 Tcp数据的处理方法及装置
CN116032861B (zh) * 2023-01-09 2025-03-07 苏州盛科通信股份有限公司 一种报文处理方法及装置
CN121144216A (zh) * 2024-06-13 2025-12-16 长江存储科技有限责任公司 管理存储器空间分配
CN120416276B (zh) * 2025-04-22 2026-04-10 盐城市燃气事业发展中心 基于物联网的燃气泄漏检测与安全控制系统及方法

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101621469A (zh) * 2009-08-13 2010-01-06 杭州华三通信技术有限公司 数据报文存取控制装置和方法
US20150095439A1 (en) * 2012-05-29 2015-04-02 Alcatel-Lucent Message handling extension using context artifacts
CN105099948A (zh) * 2015-06-30 2015-11-25 杭州华三通信技术有限公司 一种报文信息处理方法及装置
WO2016078212A1 (zh) * 2014-11-20 2016-05-26 中兴通讯股份有限公司 一种报文处理方法、装置及存储介质

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH024067A (ja) 1988-06-17 1990-01-09 Fujitsu Ltd パケット多重化回路
US6724767B1 (en) * 1998-06-27 2004-04-20 Intel Corporation Two-dimensional queuing/de-queuing methods and systems for implementing the same
GB2382898B (en) 2000-12-29 2005-06-29 Zarlink Semiconductor Ltd A method of managing data
DE10119754B4 (de) * 2001-04-23 2007-11-29 Infineon Technologies Ag Verfahren und Vorrichtung zum Speichern von Datenpaketen
JP2003174475A (ja) 2001-12-06 2003-06-20 Nippon Telegr & Teleph Corp <Ntt> 信号処理装置間の通信方法及びパケット交換システム
WO2004066571A1 (ja) 2003-01-20 2004-08-05 Fujitsu Limited ネットワークスイッチ装置およびネットワークスイッチ方法
US7773630B2 (en) * 2005-11-12 2010-08-10 Liquid Computing Corportation High performance memory based communications interface
US8542693B2 (en) 2007-08-01 2013-09-24 Texas Instruments Incorporated Managing free packet descriptors in packet-based communications
JP5748287B2 (ja) 2011-12-27 2015-07-15 日本電信電話株式会社 パケットバッファ装置およびパケットバッファ制御方法
EP3166269B1 (en) 2014-08-07 2019-07-10 Huawei Technologies Co., Ltd. Queue management method and apparatus
US9990307B1 (en) * 2014-10-29 2018-06-05 Netronome Systems, Inc. Split packet transmission DMA engine

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101621469A (zh) * 2009-08-13 2010-01-06 杭州华三通信技术有限公司 数据报文存取控制装置和方法
US20150095439A1 (en) * 2012-05-29 2015-04-02 Alcatel-Lucent Message handling extension using context artifacts
WO2016078212A1 (zh) * 2014-11-20 2016-05-26 中兴通讯股份有限公司 一种报文处理方法、装置及存储介质
CN105099948A (zh) * 2015-06-30 2015-11-25 杭州华三通信技术有限公司 一种报文信息处理方法及装置

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP3657744A4 *

Also Published As

Publication number Publication date
JP7074839B2 (ja) 2022-05-24
JP2020529166A (ja) 2020-10-01
EP3657744A4 (en) 2020-07-22
US20200259766A1 (en) 2020-08-13
EP3657744A1 (en) 2020-05-27
EP3657744B1 (en) 2022-04-20
CN108462652A (zh) 2018-08-28
CN108462652B (zh) 2019-11-12
US11425057B2 (en) 2022-08-23

Similar Documents

Publication Publication Date Title
US11425057B2 (en) Packet processing
US12341686B2 (en) System and method for facilitating efficient utilization of an output buffer in a network interface controller (NIC)
CN113535633B (zh) 一种片上缓存装置和读写方法
US8656071B1 (en) System and method for routing a data message through a message network
WO2016179968A1 (zh) 一种队列管理方法、装置及存储介质
CN103647726B (zh) 一种报文调度方法及装置
CN104065588B (zh) 一种数据包调度和缓存的装置及方法
CN101635682B (zh) 一种存储管理的方法和系统
CN107783727B (zh) 一种内存设备的访问方法、装置和系统
CN106325758B (zh) 一种队列存储空间管理方法及装置
WO2018107681A1 (zh) 一种队列操作中的处理方法、装置及计算机存储介质
CN111274173B (zh) 一种基于zynq的多节点srio通信设计方法及装置
WO2019056253A1 (zh) 一种缓存状态上报方法、终端和计算机存储介质
CN102957629B (zh) 队列管理的方法和装置
CN111949568A (zh) 一种报文处理方法、装置及网络芯片
US20250175441A1 (en) Packet forwarding apparatus and method, communication chip, and network device
CN111181874B (zh) 一种报文处理方法、装置及存储介质
WO2017219993A1 (zh) 报文调度
CN105516023A (zh) 一种报文转发方法和装置
WO2018000820A1 (zh) 一种队列管理方法和装置
TWI223747B (en) Increasing memory access efficiency for packet applications
CN120416368A (zh) 数据传输方法、装置、电子设备、可读存储介质和程序产品
CN115080258A (zh) 数据传输系统及相关设备
CN102523168B (zh) 一种传输报文的方法及装置
CN100531123C (zh) 一种实现数据包模式到信元帧模式转换的装置及其方法

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18840257

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2020505176

Country of ref document: JP

Kind code of ref document: A

NENP Non-entry into the national phase

Ref country code: DE

ENP Entry into the national phase

Ref document number: 2018840257

Country of ref document: EP

Effective date: 20200221