Method for efficiently analyzing message header with any self-defined length on TOFINO chip

By adopting the 8-bit field parsing method of the custom message header on the TOFINO chip, the problem of excessive resource occupation of the TOFINO chip when facing multiple message headers is solved, efficient parsing and resource reuse are achieved, and the message forwarding efficiency of the device cluster is improved.

CN120729970APending Publication Date: 2025-09-30BEIJING SCISTOR TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510966063.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-14
Publication Date
2025-09-30

AI Technical Summary

Technical Problem

When faced with a variety of complex message headers, the TOFINO chip needs to perform complex judgments, resulting in excessive resource consumption and affecting its flexibility and efficiency.

Method used

A method for efficiently parsing message headers of arbitrary custom length on the TOFINO chip is adopted. The 8-bit field of the custom message header is used for parsing, and the message length is determined according to the bit. A combination of 8 message headers is designed to complete the parsing, saving resources.

Benefits of technology

In load traffic scenarios, it maximizes space reuse, saves chip resources, simplifies code complexity, improves message forwarding efficiency, and reduces the difficulty of message header design within the device cluster.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120729970A_ABST
    Figure CN120729970A_ABST
Patent Text Reader

Abstract

The invention discloses a method for efficiently analyzing a message header with any self-defined length on a TOFINO chip, and belongs to the field of network flow packet filtering and shunting. The method specifically comprises the following steps: firstly, customizing the type and length of a message header according to a service scene; and then, adding the message length of the original message header and the length of the user-defined message header, and filling a length field of the user-defined message header with the message length of the original message header and the length of the user-defined message header. Thirdly, integrating and inputting the user-defined message header and the original message into a TOFINO chip, analyzing according to a length field in the user-defined message header, judging whether the length of the unanalyzed message is 0 or not, and if so, skipping and directly entering the analysis of the original message; otherwise, analyzing the user-defined message header, extracting the content of the message header, storing the content in the PHV of the chip for subsequent use, and placing a message header pointer at the head of the unanalyzed message; and after the user-defined message header is completely analyzed, entering the analysis of the original message. According to the invention, the message forwarding efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of network traffic packet filtering and diversion, and specifically provides a method for efficiently parsing message headers of arbitrary custom lengths on a TOFINO chip. Background Art

[0002] Switching chips serve as the core of network devices such as switches and routers, supporting network devices to transmit massive amounts of data on "highways" such as data centers, bearer networks, and core networks, allowing data to flow smoothly between thousands of households.

[0003] With the continuous development of IT technology, upper-layer services and control software are no longer satisfied with the existing protocol stack, and their unique requirements for the underlying network are gradually emerging. This has led to the emergence of programmable chips, which can flexibly add new network protocols or new network functions to network chips. This eliminates the need to design a chip specifically for a specific service. Each upper-layer service vendor can simply update the software to modify the underlying network forwarding logic to better adapt to their own business.

[0004] Although programmable switching chips are favored by various upper-level business manufacturers for their good compatibility, their hardware carrier is still a combination of ASIC and FPGA. The hardware resources in the chip are limited and cannot be expanded. Although more resources can be obtained by updating the chip model, the cost of frequent chip replacement cannot be ignored. Moreover, the chip resources always have an upper limit. The trade-off between cost and function will always encounter resource bottlenecks. This puts higher demands on programmers who develop programmable switching chips. They must complete the development of various functions with sufficiently efficient resource utilization.

[0005] As a leader in programmable switching chips, TOFINO chips are widely used in business scenarios such as diversion switches and cloud gateway devices. Devices with various functions are connected in series through TOFINO chips, and forwarding is performed within the devices and between devices through TOFINO chips. The TOFINO chip determines the direction of traffic, thereby opening up the traffic path of the entire device cluster and realizing interoperability of devices within the device cluster.

[0006] The TOFINO chip uses a pipeline mechanism for message parsing. Messages sent to the chip are divided into different pipelines for processing according to the pipeline structure, as byte streams. First, the parser parses part of the byte stream into the PHV according to a pre-written process. The PHV is a special hardware with storage capabilities used to store and process header information and metadata extracted from network messages. The PHV is then passed to the subsequent matching action unit, which modifies existing fields in the message or adds new message headers. Finally, the chip repackages the processed message into a byte stream and sends it out.

[0007] Implementing this complex business logic requires equally complex internal protocols and headers during internal message transmission. However, with so many different headers, the TOFINO chip needs to make complex judgments on all the protocols and headers during message parsing, which consumes a lot of resources and seriously affects TOFINO's flexibility.

[0008] Therefore, an efficient message parsing algorithm is needed to parse this complex internal transmission protocol. Summary of the Invention

[0009] To address the above problems, the present invention provides a method for efficiently parsing message headers of arbitrary custom length on a TOFINO chip, which occupies very few resources, has strong compatibility, and can be directly embedded in any business processing flow with or without simple modification.

[0010] The method for efficiently parsing a message header of any custom length on a TOFINO chip comprises the following specific steps:

[0011] Step 1: Based on the business scenario, the type of the custom message header is an 8-bit byte. The first 4 bits indicate the message parsing method, and the last 4 bits indicate the message type.

[0012] Step 2: Parse the original message to the outer or innermost IP layer, and add the message length of the original message header to the length of the custom message header, and fill in the length field of the custom message header.

[0013] Step 3: Integrate the custom message header and the original message and input them into the TOFINO chip;

[0014] Step 4: Parse the message entering the TOFINO chip according to the length field in the custom message header to determine whether the unparsed message length is 0. If so, skip and directly enter the parsing of the original message; otherwise, enter step 5;

[0015] Step 5: Parse the custom message header, extract the content of the message header, store it in the PHV of the chip for subsequent use, and place the message header pointer at the head of the unparsed message;

[0016] Specifically: when all 8 bits of the unparsed message header are 1, that is, the length of the message header is 1, 2, 4, 8, 16, 32, 64, 128 bytes, 8 judgments are performed in sequence, 8 message headers are designed, and the combination completes the parsing of the custom message header.

[0017] Judge each bit in order from high to low. If a bit is 1, the number of subsequent bytes is at least 2. n , n represents the current bit.

[0018] The specific parsing process is as follows:

[0019] First, determine whether the 7th bit is 1. If so, the length of the subsequent custom header is greater than 128 bytes, and the 128 bytes are parsed first. The 128-byte message is parsed starting from the message header pointer and placed into the 128-byte message header in the PHV. The message header pointer is reset to the unparsed message header, and then the next bit is determined. Otherwise, the next bit is determined directly.

[0020] Continue to judge whether the 6th bit is 1. If so, the length of the subsequent custom header is greater than 64 bytes, and the 64 bytes are parsed first. The 64-byte message is parsed starting from the message header pointer and placed into the 64-byte message header in the PHV. The message header pointer is reset to the unparsed message header, and then the next bit is judged; otherwise, it is 0, and the next bit is judged directly.

[0021] Continue to judge whether the 5th bit is 1. If so, the length of the subsequent custom header is greater than 32 bytes, and 32 bytes are parsed first. The 32-byte message is parsed starting from the message header pointer and placed into the 32-byte message header in the PHV. The message header pointer is reset to the unparsed message header, and then the next bit is judged; otherwise, it is 0, and the next bit is judged directly.

[0022] Continue to judge whether the 4th bit is 1. If so, the length of the subsequent custom header is greater than 16 bytes, and the 16 bytes are parsed first. The 16-byte message is parsed starting from the message header pointer and placed into the 16-byte message header in the PHV. The message header pointer is reset to the unparsed message header, and then the next bit is judged; otherwise, it is 0, and the next bit is judged directly.

[0023] Continue to judge whether the third bit is 1. If so, the length of the subsequent custom header is greater than 8 bytes, and the 8 bytes are parsed first. The 8-byte message is parsed starting from the message header pointer and placed into the 8-byte message header in the PHV. The message header pointer is reset to the unparsed message header, and then the next bit is judged; otherwise, it is 0, and the next bit is judged directly.

[0024] Continue to judge whether the second bit is 1. If so, the length of the subsequent custom header is greater than 4 bytes, and the 4 bytes are parsed first. The byte message parsed starting from the message header pointer is placed in the 4-byte message header in the PHV, and the message header pointer is reset to the unparsed message header, and then the next bit is judged; otherwise, it is 0, and the next bit is judged directly.

[0025] Continue to judge whether the first bit is 1. If so, the length of the subsequent custom header is greater than 2 bytes, and the 2 bytes are parsed first. The 2-byte message is parsed starting from the message header pointer and placed into the 2-byte message header in the PHV. The message header pointer is reset to the unparsed message header, and then the next bit is judged; otherwise, it is 0, and the next bit is judged directly.

[0026] Continue to determine whether the 0th bit is 1. If so, the length of the subsequent custom header is only 1 byte. First parse out the 1 byte, parse the 1-byte message starting from the message header pointer and put it into the 1-byte message header in the PHV, reset the message header pointer to the unparsed message header, and then enter the subsequent processing flow; otherwise, it is 0, which proves that the custom header has been parsed and directly enters the subsequent processing flow.

[0027] Step 6: After all the custom message headers are parsed, the pointer enters the parsing of the original message.

[0028] The advantages of the present invention are:

[0029] The present invention provides a method for efficiently parsing message headers of arbitrary custom lengths on a TOFINO chip. When faced with a load flow parsing scenario, for content that does not need to be processed, there is no need to additionally define message headers whose space cannot be reused. Instead, a unified definition is performed according to length, thereby reusing space to the greatest extent. This can save a large amount of chip resources, simplify code complexity, reduce the difficulty of designing internal message headers in a large device cluster, and improve message forwarding efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Figure 1 This is a flow chart of the present invention for efficiently parsing a message header of any custom length on a TOFINO chip;

[0031] Figure 2 This is a flow chart of the present invention for parsing a custom message header; DETAILED DESCRIPTION

[0032] In order to make the purpose, technical solutions and advantages of the present invention more clear, the technical solutions of the present invention are further described in detail below with reference to the accompanying drawings and implementation examples.

[0033] The method for efficiently parsing a message header of any custom length on a TOFINO chip is as follows: Figure 1 The specific steps are as follows:

[0034] Step 1: Design a custom message header based on the business scenario;

[0035] The custom packet header type is an 8-bit byte. The first 4 bits indicate the packet parsing method, and the last 4 bits indicate the packet type; for example, IPv4, IPv6, or non-IP packet.

[0036] Step 2: Parse the original message to the outer or innermost IP layer, and add the message length of the original message header to the length of the custom message header, and fill in the length field of the custom message header.

[0037] The message received by the TOFINO chip should be a combination of the complete custom header and the original message. The original message may contain complex tunneling situations. In order to save the resources of the TOFINO chip, a more advanced device can parse the original message to the outer or innermost IP layer according to business needs, calculate the message length of the original message header plus the length of the custom header, and fill in the length field in the custom header.

[0038] Step 3: Integrate the custom message header and the original message and input them into the TOFINO chip;

[0039] Step 4: Parse the message entering the TOFINO chip according to the length field in the custom message header to determine whether the unparsed message length is 0. If so, skip and directly enter the parsing of the original message; otherwise, enter step 5;

[0040] Step 5: Parse the custom message header, extract the content of the message header, store it in the PHV of the chip for subsequent use, and place the message header pointer at the head of the unparsed message;

[0041] Determine the parsing method based on the first 4 bits of the custom header type;

[0042] Specifically: when all 8 bits of the unparsed message header are 1, that is, the length of the message header is 1, 2, 4, 8, 16, 32, 64, 128 bytes, 8 judgments are performed in sequence, 8 message headers are designed, and the combination completes the parsing of the custom message header.

[0043] Judge each bit in order from high to low. If a bit is 1, the number of subsequent bytes is at least 2. n , n represents the current bit.

[0044] The specific parsing process is as follows:

[0045] First, determine whether the 7th bit is 1. If so, the length of the subsequent custom header is greater than 128 bytes, and the 128 bytes are parsed first. The 128-byte message is parsed starting from the message header pointer and placed into the 128-byte message header in the PHV. The message header pointer is reset to the unparsed message header, and then the next bit is determined. Otherwise, the next bit is determined directly.

[0046] Continue to judge whether the 6th bit is 1. If so, the length of the subsequent custom header is greater than 64 bytes, and the 64 bytes are parsed first. The 64-byte message is parsed starting from the message header pointer and placed into the 64-byte message header in the PHV. The message header pointer is reset to the unparsed message header, and then the next bit is judged; otherwise, it is 0, and the next bit is judged directly.

[0047] Continue to judge whether the 5th bit is 1. If so, the length of the subsequent custom header is greater than 32 bytes, and 32 bytes are parsed first. The 32-byte message is parsed starting from the message header pointer and placed into the 32-byte message header in the PHV. The message header pointer is reset to the unparsed message header, and then the next bit is judged; otherwise, it is 0, and the next bit is judged directly.

[0048] Continue to judge whether the 4th bit is 1. If so, the length of the subsequent custom header is greater than 16 bytes, and the 16 bytes are parsed first. The 16-byte message is parsed starting from the message header pointer and placed into the 16-byte message header in the PHV. The message header pointer is reset to the unparsed message header, and then the next bit is judged; otherwise, it is 0, and the next bit is judged directly.

[0049] Continue to judge whether the third bit is 1. If so, the length of the subsequent custom header is greater than 8 bytes, and the 8 bytes are parsed first. The 8-byte message is parsed starting from the message header pointer and placed into the 8-byte message header in the PHV. The message header pointer is reset to the unparsed message header, and then the next bit is judged; otherwise, it is 0, and the next bit is judged directly.

[0050] Continue to judge whether the second bit is 1. If so, the length of the subsequent custom header is greater than 4 bytes, and the 4 bytes are parsed first. The byte message parsed starting from the message header pointer is placed in the 4-byte message header in the PHV, and the message header pointer is reset to the unparsed message header, and then the next bit is judged; otherwise, it is 0, and the next bit is judged directly.

[0051] Continue to judge whether the first bit is 1. If so, the length of the subsequent custom header is greater than 2 bytes, and the 2 bytes are parsed first. The 2-byte message is parsed starting from the message header pointer and placed into the 2-byte message header in the PHV. The message header pointer is reset to the unparsed message header, and then the next bit is judged; otherwise, it is 0, and the next bit is judged directly.

[0052] Continue to determine whether the 0th bit is 1. If so, the length of the subsequent custom header is only 1 byte. First parse out the 1 byte, parse the 1-byte message starting from the message header pointer and put it into the 1-byte message header in the PHV, reset the message header pointer to the unparsed message header, and then enter the subsequent processing flow; otherwise, it is 0, which proves that the custom header has been parsed and directly enters the subsequent processing flow.

[0053] Step 6: After all the custom message headers are parsed, the pointer enters the parsing of the original message.

[0054] Example:

[0055] When parsing traffic load, the first part of the custom header should be designed uniformly, covering at least the type and length of the custom header. Ideally, the original packet type should also be added to the custom header by the upstream device to support parsing of a wider range of packet types. The length should be from the first part to the original packet, or to the IP layer of the original packet, to facilitate direct use of the IP layer for subsequent forwarding load balancing.

[0056] Then, the custom header is parsed based on its length. The message parsing process in TOFINO requires listing all protocol types. Each protocol type corresponds to a message header, which requires a resource. The chip does not determine whether message headers can coexist, and each one will occupy a resource. Resources cannot be reused. Therefore, if you want to occupy the least resources to parse the custom header, you need to use an algorithm to ensure that resources can be fully reused.

[0057] This example analyzes the most complex resource reuse scenario. It assumes that there are an unlimited number of custom header types, and that all custom headers have a common first part, which includes the length of the subsequent custom headers, ranging from 0 to 255 bytes.

[0058] This example uses a custom header with a maximum length of 255 bytes and parses it based on the length. It only needs to be traversed once according to the algorithm without applying for additional resources. All 255 bytes of resources can be reused, and there will only be a maximum of 8 state machine jumps, which greatly saves TOFINO chip resources and effectively improves resource utilization and chip processing performance.

[0059] In this example, all 8 bits are 1, and the maximum length is 255 bytes. Each bit can be judged separately starting from the high bit. This method of judging based on the bit position can completely cover all possible byte numbers from 0 to the maximum byte number, and there is no need to design an additional message header, and resources can be fully reused.

[0060] like Figure 2 As shown, first, the custom header must be parsed, the length of the custom header must be obtained, and then the subsequent parsing must be performed based on the length. If the length is 0, this part is skipped and the subsequent parsing of the original message is performed directly.

[0061] This example requires eight judgments and designs eight message headers with lengths of 1, 2, 4, 8, 16, 32, 64, and 128 bytes, respectively. The custom header is then parsed using a combination of these message headers.

[0062] If the 7th bit of the length is 1, the length of the subsequent custom header must be greater than 128 bytes. You can parse out 128 bytes and put them into the 128-byte message header, and then proceed to the next bit judgment; if it is 0, proceed directly to the next bit judgment.

[0063] If the sixth bit of the length is 1, the length of the subsequent custom header must be greater than 64 bytes. The 64 bytes can be parsed and put into the 64-byte message header, and then the next bit is judged. If it is 0, the next bit is judged directly.

[0064] If the fifth bit of the length is 1, the length of the subsequent custom header must be greater than 32 bytes. The 32 bytes can be parsed and put into the 32-byte message header, and then the next bit is judged. If it is 0, the next bit is judged directly.

[0065] If the fourth bit of the length is 1, the length of the subsequent custom header must be greater than 16 bytes. The 16 bytes can be parsed and put into the 16-byte message header, and then the next bit is judged. If it is 0, the next bit is judged directly.

[0066] If the third bit of the length is 1, the length of the subsequent custom header must be greater than 8 bytes. The 8 bytes can be parsed and put into the 8-byte message header, and then the next bit is judged. If it is 0, the next bit is judged directly.

[0067] If the second bit of the length is 1, the length of the subsequent custom header must be greater than 4 bytes. The 4 bytes can be parsed and put into the 4-byte message header, and then the next bit is judged. If it is 0, the next bit is judged directly.

[0068] If the first bit of the length is 1, the length of the subsequent custom header must be greater than 2 bytes. The 2 bytes can be parsed and put into the 2-byte message header, and then the next bit is judged; if it is 0, the next bit is judged directly.

[0069] If the 0th bit of the length is 1, the length of the subsequent custom header must be only 1 byte, which can be parsed out and put into the 1-byte message header, and then enter the subsequent processing flow; if it is 0, it proves that the custom header has been parsed and can directly enter the subsequent processing flow.

[0070] The above examples are intended to illustrate the present invention only and are not intended to limit the present invention. Those skilled in the art should understand that modifications, variations, or equivalent substitutions to the present invention that do not depart from the spirit and scope of the present invention should be included in the claims of the present invention to make the objectives, technical solutions, and advantages of the present invention more clearly understood. The embodiments of the present invention will be further described in detail below with reference to the accompanying drawings.

Claims

1. A method for efficiently parsing message headers of arbitrary custom length on a TOFINO chip, characterized in that: The specific steps are as follows: Step 1: Based on the business scenario, the custom message header type is an 8-bit byte. The first 4 bits indicate the message parsing method, and the last 4 bits indicate the message type. Step 2: Parse the original message to the outer or innermost IP layer, and add the message length of the original message header to the length of the custom message header, and fill in the length field of the custom message header; Step 3: Integrate the custom message header and the original message and input them into the TOFINO chip; Step 4: Parse the message entering the TOFINO chip according to the length field in the custom message header to determine whether the unparsed message length is 0. If so, skip and directly enter the parsing of the original message; otherwise, enter step 5; Step 5: Parse the custom message header, extract the content of the message header, store it in the PHV of the chip for subsequent use, and place the message header pointer at the head of the unparsed message; The specific parsing process is as follows: First, determine whether the 7th bit is 1. If so, the length of the subsequent custom header is greater than 128 bytes, and the 128 bytes are parsed first. The 128-byte message is parsed starting from the message header pointer and placed into the 128-byte message header in the PHV. The message header pointer is reset to the unparsed message header, and then the next bit is determined. Otherwise, the next bit is determined directly. Continue to judge whether the sixth bit is 1. If so, the length of the subsequent custom header is greater than 64 bytes, and the 64 bytes are parsed first. The 64-byte message is parsed starting from the message header pointer and placed into the 64-byte message header in the PHV. The message header pointer is reset to the unparsed message header, and then the next bit is judged. Otherwise, it is 0, and the next bit is judged directly. Continue to judge whether the fifth bit is 1. If it is, the length of the subsequent custom header is greater than 32 bytes, and 32 bytes are parsed first. The 32-byte message is parsed starting from the message header pointer and placed into the 32-byte message header in the PHV. The message header pointer is reset to the unparsed message header, and then the next bit is judged. Otherwise, it is 0, and the next bit is judged directly. Continue to judge whether the fourth bit is 1. If so, the length of the subsequent custom header is greater than 16 bytes, and the 16 bytes are parsed first. The 16-byte message is parsed starting from the message header pointer and placed into the 16-byte message header in the PHV. The message header pointer is reset to the unparsed message header, and then the next bit is judged. Otherwise, it is 0, and the next bit is judged directly. Continue to judge whether the third bit is 1. If it is, the length of the subsequent custom header is greater than 8 bytes, and the 8 bytes are parsed first. The 8-byte message is parsed starting from the message header pointer and placed into the 8-byte message header in the PHV. The message header pointer is reset to the unparsed message header, and then the next bit is judged. Otherwise, it is 0, and the next bit is judged directly. Continue to judge whether the second bit is 1. If so, the length of the subsequent custom header is greater than 4 bytes, and the 4 bytes are parsed first. The message with bytes parsed starting from the message header pointer is placed into the 4-byte message header in the PHV, and the message header pointer is reset to the unparsed message header, and then the next bit is judged; otherwise, it is 0, and the next bit is judged directly; Continue to judge whether the first bit is 1. If it is, the length of the subsequent custom header is greater than 2 bytes, and the 2 bytes are parsed first. The 2-byte message is parsed starting from the message header pointer and placed into the 2-byte message header in the PHV. The message header pointer is reset to the unparsed message header, and then the next bit is judged. Otherwise, it is 0, and the next bit is judged directly. Continue to check whether the 0th bit is 1. If so, the length of the subsequent custom header is only 1 byte. First parse out the 1 byte, parse the 1-byte message starting from the message header pointer and put it into the 1-byte message header in the PHV, reset the message header pointer to the unparsed message header, and then enter the subsequent processing flow; Otherwise, if it is 0, it means that the custom header has been parsed and directly enters the subsequent processing flow; Step 6: After all the custom message headers are parsed, the pointer enters the parsing of the original message.

2. A method for efficiently parsing a message header of arbitrary custom length on a TOFINO chip according to claim 1, characterized in that: In step 5, when all 8 bits of the unparsed message header are 1, that is, the length of the message header is 1, 2, 4, 8, 16, 32, 64, and 128 bytes, 8 judgments are performed in sequence, and 8 message headers are designed and combined to complete the parsing of the custom message header.

3. A method for efficiently parsing a message header of arbitrary custom length on a TOFINO chip according to claim 1, characterized in that: In step 5, each bit is judged in descending order. If a bit is 1, the number of subsequent bytes is at least 2. n , n represents the current bit.