Flexible header changes in network devices

By introducing a programmable header change engine into network equipment and combining hardware and software technologies, the flexibility and efficiency problems of the header change engine in the existing technology are solved, and efficient packet processing and multi-functional header change capabilities are achieved.

CN111490969BActive Publication Date: 2024-09-17MARVELL ISRAEL (M L S L) LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010079124.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2020-01-27
Filing Date
2020-02-03
Publication Date
2024-09-17
Estimated Expiration
2040-02-03

AI Technical Summary

Technical Problem

The packet header change engine in existing network equipment lacks flexibility and cannot support high enough packet rates and diverse header change operations. The flexibility of hardware implementation is limited, and the software implementation cannot meet line speed and multi-functional requirements.

Method used

Employs a programmable header change engine, combined with a hardware input processor and a programmable header change processor, to dynamically bypass or process packet headers by executing computer-readable instructions stored in program memory to support line-speed header changes and through hardware The checksum accelerator calculates the checksum.

Benefits of technology

It implements flexible header change operations, supports efficient packet processing, meets line speed requirements, improves the processing capabilities of multiple header changes, and enhances the processing power of network equipment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111490969B_ABST
    Figure CN111490969B_ABST
Patent Text Reader

Abstract

Embodiments of the present disclosure relate to flexible header changes in a network device. A packet header of a packet received by the network device is provided to at least a programmable header change engine, which includes a hardware input processor and a programmable header change processor implemented in hardware, and the programmable header change processor is configured to execute computer-readable instructions stored in a program memory. The hardware input processor determines whether the packet header will be provided to a processing path coupled to the programmable header change processor or will be transferred to a bypass path that bypasses the programmable header change processor, and the packet header is provided to the processing path or the bypass path based on the determination. The packet header is selectively i) processed by the programmable header change processor when the packet header is provided to the processing path, and ii) not processed by the programmable header change processor when the packet header is provided to the bypass path.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] CROSS-REFERENCE TO RELATED APPLICATIONS

[0002] This disclosure claims the benefit of U.S. Provisional Patent Application No. 62 / 798,240, filed on January 29, 2019, entitled “Programmable Header Alteration,” which is incorporated herein by reference in its entirety. Technical Field

[0003] The present invention relates generally to network devices, such as network switches, bridges, routers, etc., and more particularly to processing packets in network devices. Background Art

[0004] Network devices such as bridges and routers forward packets through a network based on addresses in the headers of the packets. Network devices typically include multiple ports coupled to different network links. A network device typically receives a packet via one port and processes at least the header of the packet to determine which other port or ports the network device should send the packet via. The network device then forwards the packet to the determined other port or ports.

[0005] During the processing of a packet, a network device typically performs a header change to modify the headers of at least some of the packets in the packet before the transmission of the packet. Typically, a hardware engine capable of performing header modification operations at line speed is used to perform header changes. Such hardware header change engines typically implement certain predetermined header change operations and lack the flexibility to support various types of headers and multi-function header change processing sets. Although software implementations of header change engines that utilize processors to perform header changes based on programmable instructions are more flexible, pure software implementations cannot support sufficiently high packet rates and / or cannot support sufficiently diverse header change operations. Summary of the invention

[0006] In an embodiment, a method for processing a packet in a network device comprises: receiving, at a packet processor of the network device, a packet received by the network device from a network link; determining, using the packet processor, at least one egress interface via which the packet is to be transmitted by the network device; providing at least a packet header of the packet to a programmable header alteration engine of the packet processor, the programmable header alteration engine comprising: i) a hardware input processor implemented in hardware and ii) a programmable header alteration processor coupled to a program memory, the programmable header alteration processor being configured to execute computer-readable instructions stored in the program memory to perform one or more header alteration operations on the received packet; determining, using the programmable header alteration engine, at least a packet header of the packet; A hardware input processor of a header change engine determines whether a packet header will be provided to a processing path coupled to a programmable header change processor or will be transferred to a bypass path that bypasses the programmable header change processor; using the hardware input processor of the programmable header change engine, based on the determination of whether the packet header will be provided to the processing path or will be transferred to the bypass path, the packet header is provided to the processing path or the bypass path; selectively i) when the packet header is provided to the processing path, the packet header is processed by the programmable header change processor, ii) when the packet header is provided to the bypass path, the packet header is not processed by the programmable header change processor; and using a network device to send the packet via at least one egress interface of the network device.

[0007] In another embodiment, a network device includes a packet processor and a programmable header alteration engine, the packet processor being configured to: i) receive a packet from a network link, and ii) determine at least one egress interface via which the packet is to be transmitted by the network device, the programmable header alteration engine comprising i) a hardware input processor implemented in hardware, and ii) a programmable header alteration processor coupled to a program memory, the programmable header alteration processor being configured to execute computer-readable instructions stored in the program memory to perform one or more header alteration operations on the received packet. The hardware input processor is configured to determine whether a packet header of the packet is to be provided to a processing path coupled to the programmable header alteration processor or is to be transferred to a bypass path that bypasses the programmable header alteration processor, and based on the determination that the packet header is to be provided to the processing path or is to be transferred to the bypass path, provide the packet header to the processing path or the bypass path. The programmable header alteration processor is configured to selectively: i) process the packet header when the header is provided to the processing path, and ii) not process the packet header when the packet header is provided to the bypass path. The packet processor is also configured to cause the packet to be transmitted via at least one egress interface of the network device.

[0008] In yet another embodiment, a method for processing packets in a network device includes: receiving, at a packet processor of the network device, a packet received by the network device from a network link; determining, using the packet processor, at least one egress interface via which the packet will be transmitted by the network device; processing a packet header of the packet using a programmable header change processor coupled to a program memory, the programmable header change processor being configured to execute computer-readable instructions stored in the program memory to perform one or more header change operations on the received packet, the processing including triggering a hardware checksum accelerator engine to calculate a checksum for a bit string corresponding to at least a portion of the packet header, wherein triggering the hardware checksum accelerator engine includes: i) dividing the bit string into a plurality of segments of the bit string, and ii) transmitting the plurality of segments of the bit string to the hardware checksum accelerator engine; using the hardware checksum accelerator, incrementally calculating a checksum by at least incrementally summing corresponding segments of the plurality of segments of the bit string transmitted to the hardware checksum accelerator engine; and sending a packet having a modified header including a checksum via at least one egress interface of the network device.

[0009] In yet another embodiment, a network device includes a packet processor and a programmable header alteration processor, the packet processor being configured to i) receive a packet from a network link, the packet including a packet header and a payload, and ii) determine at least one egress interface through which the packet is to be transmitted by the network device, the programmable header alteration processor being coupled to a program memory, the programmable header alteration processor being configured to execute computer-readable instructions stored in the program memory to perform one or more header alteration operations on a packet header of a received packet, the programmable header alteration processor being configured to trigger a hardware checksum accelerator engine during processing of a packet header of the received packet to calculate a checksum of a bit string corresponding to at least a portion of the packet header. The programmable header alteration processor is configured to segment the bit string into a plurality of segments of the bit string and transmit the plurality of segments of the bit string to the hardware checksum acceleration engine. The hardware checksum accelerator engine is configured to incrementally calculate a checksum by at least incrementally summing corresponding segments of the plurality of segments of the bit string transmitted to the hardware checksum accelerator engine. The packet processor is further configured to cause the packet having the modified header including the checksum to be sent via at least one egress interface of the network device. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] Figure 1 is a block diagram of an example network device including a programmable header alteration engine according to an embodiment.

[0011] Figure 2 According to the embodiment Figure 1A block diagram of an input processing unit of a programmable header alteration engine of a network device.

[0012] Figure 3 According to an embodiment, Figure 1 Flowchart of a method for a programmable header modification engine to determine whether a packet will bypass header modifications.

[0013] Figure 4A is a diagram showing the Figure 1 Schematic diagram of a process performed by a programmable header alteration engine to extract headers accessible to a header alteration processor from a packet header.

[0014] Figure 4B is executed according to an embodiment to Figure 1 Schematic diagram of the process of a programmable header modification engine processing a header modification to generate a processed packet header after an accessible header.

[0015] Figure 5 According to the embodiment Figure 1 Block diagram of a header change processor of a programmable header change engine.

[0016] Figure 6 According to the embodiment Figure 5 A block diagram of an example packet processing node included in a header change processor.

[0017] Figure 7 According to the embodiment Figure 6 A block diagram of an example memory map used by a processor of a packet processing node.

[0018] Figure 8A-B is a diagram showing the Figure 7 FIG. 2 is a diagram of several example accelerator engine trigger instructions issued by a processor of a packet processing node of FIG.

[0019] Fig. 9 According to an embodiment, Figure 1 A flowchart of an example method for processing packets in a network device.

[0020] Fig.10 According to an embodiment, Figure 1 A flowchart of an example method for processing packets in a network device. DETAILED DESCRIPTION

[0021] In the embodiments described below, a network device includes a programmable header alteration engine including a programmable header alteration processor coupled to a program memory and configured to implement header alteration operations by executing computer-readable instructions stored in the program memory. In general, since header alteration is performed using the programmable header alteration processor to execute computer-readable instructions stored in the program memory, the header alteration engine is flexibly programmable / configurable to perform necessary header alteration operations, for example, depending on the specific packets being processed and / or the specific scenarios in which the network device is used.

[0022] In various embodiments described herein, the programmable header change engine includes various capabilities that allow the programmable header change engine to support header changes at line speed. For example, the programmable header change engine includes the ability to dynamically bypass header changes for certain packets that may not require header changes by the programmable header change processor, thereby, in an embodiment, allowing these packets to quickly pass through the programmable header change engine while also increasing the processing power available to process packets that require header changes by the programmable header change processor. In order to quickly and efficiently process packet headers that require header changes by the programmable header change engine, the programmable header change engine is configured to perform one or more of the following: i) select one or more portions of the packet header and provide the selected portions rather than the entire packet header to the processor to perform header change operations on the packet header; ii) segment the packet header (or one or more portions of the selected packet header) so that one or more portions of the packet header can be efficiently transmitted to the processor; iii) identify a specific instruction thread for processing one or more portions of the packet header, and provide the identified instruction thread to the processor. The programmable header change processor includes the following mechanisms: 1) providing an indication so that instructions can be started more quickly (e.g., immediately) when the processor receives the packet header; 2) efficiently distributing packet headers among multiple packet processing nodes of the programmable header change processor in a manner that allows packets that require a relatively slower (e.g., longer) processing thread to be processed without blocking packets that require a relatively faster (e.g., shorter) processing thread to be processed; 3) providing packet headers of different packets to different packet processing nodes of the programmable packet header change processor in parallel for concurrent processing of packet headers; 4) efficiently triggering an external accelerator engine to perform certain processing operations during processing of the packet header, etc. These and other mechanisms described herein allow the programmable header change engine to provide flexibility in programmable header changes while also allowing header changes to be performed quickly enough, such as to support packet line rate header changes.

[0023] Figure 11 is a simplified block diagram of an exemplary network device 100 according to an embodiment, which is configured to use the packet header change technology of the present disclosure. The network device 100 typically forwards packets between two or more computer systems, network segments, subnets, etc. For example, in one embodiment, the network device 100 is a router. However, it should be noted that the network device 100 is not necessarily limited to a specific protocol layer or a specific network technology (e.g., Internet Protocol). For example, in other embodiments, the network device 100 is appropriately a bridge, a switch, a virtual private network (VPN) concentrator, etc.

[0024] The network device 100 includes a plurality of network interfaces (eg, ports) 102 configured to be coupled to corresponding network links. Figure 1 102, but in various embodiments, the network device 100 includes any suitable number of network interfaces 102. The network device 100 also includes a packet processor 104 coupled to the network interface 102. In one embodiment, packets received by the network device 100 are provided by the packet processor 104 for processing packets. In some embodiments, the packets are stored in a packet memory (not shown), and data units corresponding to the packets (rather than the packets themselves) are provided to the packet processor 104 for processing the packets. In some embodiments, in addition to or in lieu of the packet descriptors, portions of the packets (e.g., packet headers) are provided to the packet processor 104, while the remainder of the packets are stored in the packet memory. For ease of explanation, the term "packet" is used herein to refer to any combination of the following: the packet itself, the packet header of the packet, and the packet descriptor corresponding to the packet.

[0025] In general, the packet processor 104 is configured to receive and process packets received via an ingress network interface 102, determine a corresponding egress network interface 102 via which the packet is to be sent, and cause the packet to be sent via the determined egress network interface 102. In one embodiment, the packet processor 104 includes a forwarding engine 106 and a packet classifier 108. The forwarding engine 106 is configured to analyze header information in a packet received via a network interface 102 to determine a network interface 102 (referred to herein as a "destination port") via which the packet is to be sent. As an illustrative example only, the forwarding engine 106 is configured to use a destination address in a header of a packet to perform a lookup in a forwarding database (not shown) that stores a correspondence between a destination address and a network interface 102 to determine a specific network interface 102 via which the packet is to be transmitted. As another illustrative example, forwarding engine 106 is configured to use the VLAN ID in the packet header to perform a lookup in a forwarding database (not shown) that stores correspondences between VLAN IDs and network interfaces 102 (e.g., the same forwarding database discussed above or a different forwarding database) to determine a specific set of destination network interfaces 102 for the packet. According to one embodiment, forwarding engine 106 is configured to store an ID of a destination port (or a set of multiple destination ports) in a packet descriptor corresponding to the packet.

[0026] According to one embodiment, the packet classifier 108 is configured to determine which packet flow the packet belongs to by analyzing at least information in the packet header of the packet. In some embodiments, the packet classifier 108 is configured to determine which packet flow the packet belongs to by additionally or alternatively analyzing other information associated with the packet (e.g., an identifier of the network interface 102 via which the packet is received). A packet flow corresponds to a packet that shares certain shared features. As an example, some flows (e.g., Internet Protocol (IP) Transmission Control Protocol (TCP) / User Datagram Protocol (UDP) flows) are generally defined by a 5-tuple in the network industry, such as {destination IP address, source IP address, L4 protocol, UDP / TCP destination port, UDP / TCP source port}. As another example, in an embodiment, a specific packet flow can be defined as a packet with a header having a specific source address and a specific destination address. In various embodiments, a packet flow can be defined as a packet with a header having specific public information, such as one or more of the following items: i) a specific source address, ii) a specific destination address, iii) a specific virtual local area network (VLAN) identifier (ID), iv) a specific priority, v) a specific packet type, etc. According to one embodiment, the classifier 108 is configured to assign a respective flow ID to at least some of the packets, wherein the flow ID indicates the respective flow to which the packet belongs. According to one embodiment, the packet classifier 108 is configured to store the flow ID assigned to the packet in a packet descriptor corresponding to the packet.

[0027] In some embodiments, the packet classifier 108 (or another unit) is configured to additionally determine the type of the packet, for example, by analyzing an initial portion of a packet header of the packet and / or information obtained in addition to forming the packet header, for example, an identifier of a source port through which the network device 100 receives the packet, an identifier of a destination port (or a set of multiple destination ports) through which the network device 100 sends the data packet, a flow ID assigned to the data packet, etc. In various embodiments, the packet classifier 108 (or another unit) determines the packet type of the packet based on one or more of the following: the destination of the packet, the flow to which the packet belongs, the Ethernet type of the packet, whether the packet is a virtual local area network (VLAN) tagged packet, etc. According to an embodiment, the packet classifier 108 (or another unit) is configured to assign a corresponding packet type ID to at least some of the packets, wherein the packet type ID indicates the packet type of the packet. According to one embodiment, the packet classifier 108 (or another unit) is configured to store the packet type ID assigned to the packet in a packet descriptor corresponding to the packet.

[0028] In one embodiment, the packet processor 104 further includes a programmable header alteration engine 110. The programmable header alteration engine 110 is configured to perform header alteration operations to modify headers of at least some of the packets processed by the packet processor 104. In various embodiments, for example, the header alteration operations performed by the programmable header alteration engine 110 include: setting an explicit congestion notification (ECN) flag in a header of a packet, setting a channelized flow control indication in a header of a packet, inserting or updating a timestamp in a header of a packet, adding a forwarding flag to a header of a packet, removing a forwarding flag from a header of a packet, updating a forwarding flag in a header of a packet, updating a transparent clock correction field in a header of a packet, changing a next hop address in a header of a packet, adding an encapsulation header, removing an encapsulation header, etc.

[0029] The programmable header alteration engine 110 includes a programmable header alteration processor 112. In one embodiment, the programmable header alteration processor 112 includes a packet processing array (PPA) having a plurality of packet processing nodes 114 coupled to a program memory 116. In one embodiment, each packet processing node 114 of the programmable header alteration processor 112 includes a packet header processor (e.g., a small general-purpose central processing unit (CPU)) configured to execute computer-readable instructions stored in the program memory 116 to perform header alteration operations. In one embodiment, the small CPU included in each packet processing node 114 is a CPU available from Tensilica (e.g., an Xtensa LX5 CPU) or other suitable CPU (e.g., ARC, RISCV, ARM, MIPS, etc.). In one embodiment, the CPU includes a single instruction interface for reading instructions from a program memory (e.g., program memory 116), 7 processing pipe stages for implementing instructions, and a single read / write interface for interacting with a data memory. In one embodiment, the CPU further includes one or more logic control units (LCUs) and a plurality of (e.g., 8, 16, 32, etc.) registers, such as 32-bit registers or other registers of suitable size. In other embodiments, other suitable CPU architectures are used.

[0030] In some embodiments, the programmable header alteration engine 110 additionally includes or is coupled to a pure hardware header alteration engine (not shown) that is configured to perform header alteration operations in hardware. In various embodiments, for example, the pure hardware header alteration engine is coupled to an input of the programmable header alteration engine 110 or an output of the programmable header alteration engine 110. In such embodiments, the pure hardware header alteration engine is hardwired to implement certain header alteration operations, while the programmable header alteration engine 110 may be configured to implement other header alteration operations that are not hardwired to the pure hardware header alteration engine.

[0031] In one embodiment, the programmable header change engine 110 also includes an input processor 118, a unified bypass buffer 120, an output processor 122, and a stream merger 124. In one embodiment, the input processor 118 is implemented in hardware, and the input processor 118 is sometimes referred to herein as a "hardware input processor" 118. In one embodiment, the hardware input processor 118 is implemented using one or more integrated circuits configured to operate as described herein. In other embodiments, the input processor 118 is implemented in other suitable ways. In one embodiment, the input processor 118 is configured to perform pre-processing of the packet header provided to the programmable header change engine 110. In one embodiment, the pre-processing of the packet header includes determining a processing thread identifier (thread ID) that indicates the type of processing to be performed on the packet header by the programmable header change engine 110. In one embodiment, the input processor 118 determines the thread ID based on the packet flow associated with the packet and / or based on the packet type of the packet. In one embodiment, the input processor 118 is coupled to a configuration memory 119 that stores associations between packet flows and / or packet types and thread IDs, and the input processor 118 is configured to obtain a header from the configuration memory 119, in an embodiment, a thread ID corresponding to the packet based on a packet flow ID associated with the packet and / or a packet type ID associated with the packet. In one embodiment, preprocessing of the packet header also includes making a bypass decision on the packet header to determine whether the packet header is provided to the programmable header change processor 112 for processing or bypassed by the programmable header change processor 112. In one embodiment, the input processor 118 is configured to make a bypass decision based at least in part on the packet flow and / or packet type associated with the packet. In an embodiment, the input processor 118 is configured to make a bypass decision based at least in part on the thread ID obtained for the packet and / or based on other configuration attributes (e.g., statistical attributes) that the input processor 118 can obtain for the packet from the configuration memory 119. In some embodiments, the input processor 118 additionally or alternatively makes a bypass decision based on a congestion state of the programmable header change processor 112. Referring below Figure 3 An example method implemented by input processor 118 to make bypass decisions according to one embodiment is described in more detail.

[0032] In one embodiment, when the input processor 118 determines that the packet is a bypass packet that will bypass processing by the programmable header alteration processor 112, the input processor writes the packet header to the unified bypass buffer 120. In an embodiment, when the input processor 118 determines that the packet is a non-bypass packet that will be provided to the programmable header alteration processor 112, the input processor 118 provides the packet header to the programmable header alteration processor 112. In another embodiment, the input processor 118 selects one or more portions of the packet header and provides the selected one or more portions of the packet header to the programmable header alteration processor 112 instead of the entire packet header. In some embodiments, the input processor 118 additionally generates metadata corresponding to the packet and provides the metadata to the programmable header alteration processor 112 along with the selected one or more portions of the packet header. In an embodiment, the metadata includes an identifier of a processing thread (e.g., a thread ID) used by the programmable header alteration processor 112 for processing the packet header. In some embodiments, the metadata also includes other information used by the programmable header alteration processor 112 for processing the packet header. In an embodiment, metadata is provided to the programmable header change processor 112 before the packet header is provided to the programmable header change processor 112 to allow the processor of the packet processing node 114 of the programmable header change processor 112 to obtain computer-readable instructions corresponding to the identified processing thread from the program memory 116 based on instructions included before receiving the packet header, so that, in an embodiment, processing of the packet header can be started immediately when the processor receives the packet header.

[0033] In an embodiment, the input processor 118 also writes the entire packet header, or at least the remaining portion of the packet header that was not provided to the programmable header alteration processor 112, to the unified bypass buffer 120. As will be explained in more detail below, in an embodiment, after the selected one or more portions of the packet header are processed by the programmable header alteration processor 112, the entire packet header, or at least the portion of the packet header that was not provided to the programmable header alteration processor 112, is retrieved from the unified bypass buffer so that the packet header can be reconstructed.

[0034] In an embodiment, the input processor 118 is configured to write bypass packets in a queue (e.g., a first-in-first-out (FIFO) queue or a linked list queue) in the unified bypass buffer 120. For example, in an embodiment, the input processor 118 is configured to maintain a linked list of bypass packets stored in the unified bypass buffer 120. In operation, in an embodiment, when the input processor 118 is to write a bypass packet to the unified bypass buffer 120, the input processor 118 obtains an identifier of a buffer (“buffer ID”) from a pool of free buffer IDs 121 maintained by the input processor 118. In an embodiment, a free buffer ID in the pool of free buffer IDs 121 identifies a free buffer position in the unified bypass buffer 120. In an embodiment, the input processor 118 then places the buffer ID at the end of the linked list and writes the packet header to the identified buffer position in the unified bypass buffer 120. As the input processor 118 stores the bypass packets in a queue, the programmable header alteration engine 110 maintains the order of the bypass packets and subsequently outputs the bypass packets in the order in which the packets were received by the programmable header alteration engine 110 .

[0035] On the other hand, in an embodiment, the order of the non-bypass packets provided to the programmable header alteration processor 112 is maintained by the programmable header alteration processor 112 when necessary. Accordingly, the input processor 118 does not need to maintain a queue of non-bypass packets in the unified bypass buffer 120. In an embodiment, when the input processor 118 is to write a processing flow packet to the unified bypass buffer 120, the input processor 118 obtains a buffer ID from a pull of free buffer IDs, including the buffer ID generated for the packet in the metadata, and writes the packet to the identified buffer in the unified bypass buffer 120. In an embodiment, subsequently, when the programmable header alteration processor 112 completes processing of the selected one or more portions of the packet header, the packet is retrieved from the buffer location indicated by the buffer ID included in the metadata corresponding to the packet. In an embodiment, because bypass packets are stored in a queue in the unified bypass buffer 120 and processing flow packets are stored in a non-queue buffer location in the unified bypass buffer 120, the unified bypass buffer 120 acts as a queue buffer (e.g., a FIFO buffer or a linked list buffer) for bypass packets and acts as a random access memory (RAM) for packets processed by the programmable header change processor 112.

[0036] Continue to refer Figure 1, the packet headers provided to the programmable header alteration processor 112 are distributed among the processing nodes 114 for packet processing. In an embodiment, the programmable header alteration processor 112 implements a recycling mechanism to distribute the packet headers among the processing nodes 114 and subsequently obtain the processed packet headers from the processing nodes 114 so that the order within the packet flow is maintained as the packets flow through the programmable header alteration processor 112. In an embodiment, as described in more detail below, the recycling mechanism allows: while maintaining the packet order within the packet flow, a packet flow that requires a relatively shorter processing time by the programmable header alteration processor 112 is not blocked by a packet flow that requires a relatively longer processing time by the programmable header alteration processor 112.

[0037] In an embodiment, the output processor 122 is configured to perform post-processing on packets processed by the programmable header change processor 112. In an embodiment, the output processor 122 is implemented in hardware, and the output processor 122 is sometimes referred to herein as a "hardware output processor" 122. In an embodiment, the hardware output processor 122 is implemented using one or more integrated circuits configured to operate as described herein. In other embodiments, the output processor 122 is implemented in other suitable ways. In an embodiment, the output processor 122 is configured to perform one or more checks on the processed packets to detect errors that may be caused by the processing of the packets by the programmable header change processor 112. In an embodiment. In an embodiment, the output processor 122 is configured to obtain the corresponding packet from the unified bypass buffer 120 and reconstruct the packet header by incorporating the processed one or more portions of the packet header into the packet header obtained from the unified bypass buffer 120.

[0038] In an embodiment, flow merger 124 merges the packet flow output by output processor 122 with the bypass packet flow obtained from unified bypass buffer 120. In an embodiment, programmable header modification engine 110 provides the merged flow for further processing of the packet and / or transmission of the packet from network device 100. For example, in an embodiment, programmable header modification engine 110 provides the merged flow to egress queue and shaping unit 128, which queues the packet in an egress queue corresponding to the egress network interface 102 via which the packet is to be transmitted, and subsequently causes the packet to be transmitted via the corresponding egress network interface 102.

[0039] In general, in at least some embodiments, because the programmable header modification engine 110 is configured to perform header modification functions using a processor executing computer-readable instructions, the header modification engine 110 can be flexibly configured to perform necessary header modification operations with respect to various packets being processed by the network device 100, e.g., at least compared to a system in which packet header modifications are implemented entirely in hardware. Further, in various embodiments, the programmable header modification engine 110 includes various capabilities described herein that allow the programmable header modification engine 110 to provide this flexibility while performing necessary header modifications quickly enough, e.g., to support packet line rates.

[0040] Figure 2 is a block diagram of an input processor 200 suitable for use with a programmable header alteration engine of a network device according to an embodiment. In an embodiment, the input processor 200 is used with Figure 1 The input processor 200 corresponds to the input processor 118 of the programmable header modification engine 110 of the network device 100. For exemplary purposes, the input processor 200 is referred to below as Figure 1 However, in other embodiments, input processor 200 is used with a network device other than programmable header alteration engine 110 and / or other than network device 100.

[0041] The input processor 200 includes a thread identifier 204. The thread identifier 204 is configured to determine a thread ID for a packet header based at least in part on a flow and / or a packet type. In an embodiment, the thread identifier 204 is configured to access a thread ID table 212 stored in the memory 210 and obtain a thread ID for the packet from the thread ID table 212. In an embodiment, the thread identifier 204 is configured to identify an entry in the thread ID table 212 based on one or a combination of two or more of the following: (i) a source port of the packet, (ii) a destination port of the packet, (iii) a flow of the packet, (iv) a type of packet, etc.; and obtain the thread ID from the identified entry in the thread ID table 212.

[0042] In an embodiment, the input processor 200 further includes a bypass decision unit 206 configured to determine whether the packet is provided to the programmable header alteration processor 112 via a processing path or is diverted to a bypass path that bypasses the programmable header alteration processor 112 .

[0043] Figure 3 1 is a flow chart of a method 300 for determining whether a packet is provided to a programmable header modification processor via a processing path or is transferred to a bypass path that bypasses the programmable header modification processor according to an embodiment. In an embodiment, the method 300 is composed of Figure 2 For example, in an embodiment, at least a portion of the method 300 is implemented by the input processing unit 200. Figure 2 For ease of explanation, refer to Figure 2 However, in some embodiments, the method 300 is performed by a different input processing unit 200. Figure 2 The input processing unit 200 is implemented as a suitable processing unit.

[0044] At block 302, the input processor 200 (e.g., the bypass decision engine 206) determines whether the thread ID associated with the packet indicates that the packet belongs to a bypass flow that bypasses the programmable header change processor 112. For example, the bypass decision engine 206 checks whether the thread ID associated with the packet is equal to a specific value (e.g., thread ID=0) indicating that the packet belongs to a bypass flow. If the bypass decision engine 206 determines at block 302 that the packet belongs to a bypass flow, the method 300 terminates at block 304, where it is determined that the packet will bypass the programmable header change processor 112.

[0045] On the other hand, in an embodiment, if the bypass determination engine 206 determines at block 302 that the packet belongs to a processing flow, the input processor 200 (e.g., the first-level thread configuration unit 208) obtains additional bypass configuration information, and the bypass determination engine 206 additionally determines whether the packet will be transferred to the bypass path based on the bypass configuration information. To obtain the additional bypass configuration information, in an embodiment, the first-level thread configuration unit 208 accesses the bypass thread configuration table 214 in the memory 202 based on the thread ID associated with the packet, and obtains one or more bypass attributes configured for the corresponding processing thread from the bypass thread configuration table 214, such as: i) a statistical factor configured for the corresponding processing thread, ii) a statistical processing mode configured for the corresponding processing thread, and iii) a stall mode configured for the corresponding processing thread.

[0046] The method 300 then proceeds to block 306, where the bypass decision engine 206 obtains a pseudo-random generated number (PRGN) (e.g., from a pseudo-random number generator included in or coupled to the bypass decision engine 206) and compares the PRGN to a statistical factor for a corresponding processing thread. Based on the comparison between the PRGN and the statistical factor for the corresponding processing thread, the bypass decision engine 206 determines whether to statistically select the packet to bypass the programmable header alteration processor 112. For example, in an embodiment, if the bypass decision engine 206 determines at block 306 that the PRGN is greater than or equal to the statistical factor for the corresponding processing thread, this indicates that the packet is to be statistically selected by the programmable header alteration processor 112 for header alteration, and the method 300 proceeds to block 308. On the other hand, in an embodiment, if the bypass decision engine 206 determines at block 306 that the PRGN is less than the statistical factor of the corresponding processing thread, this indicates that the packet will be statistically selected to bypass the programmable header alteration processor 112 and the method 300 continues at block 310 .

[0047] At block 310, the bypass decision engine 206 determines whether the statistical processing module is enabled for the corresponding processing thread based on the statistical processing mode configured for the corresponding processing thread. If the bypass decision engine 206 determines at block 310 that the statistical processing mode is enabled for the corresponding processing thread (e.g., if the statistical processing mode is set to a logical 1), the method 300 terminates at the bypass block 304, thereby statistically diverting the packet to the bypass path. On the other hand, in an embodiment, if the bypass decision engine 206 determines at block 310 that the statistical processing mode is not enabled for the corresponding processing thread (e.g., if the statistical processing mode is set to a logical 0), the bypass decision engine 206 does not statistically select the packet to be diverted to the bypass path, and the method 300 proceeds to block 311, where the thread ID corresponding to the packet is remapped to a "do nothing" thread. In an embodiment, the method 300 then returns to block 308.

[0048] At block 308, the bypass decision engine 206 determines a congestion level of the programmable header alteration processor 112. In an embodiment, the bypass decision engine 206 determines the congestion level based on a feedback signal (e.g., a back pressure signal) from the programmable header alteration processor 112. If the bypass decision engine 206 determines that the programmable header alteration processor 112 is not busy, or the congestion level of the programmable header alteration processor 112 is sufficiently low, the method 300 terminates at block 318, where a decision is made to provide the packet to the programmable header alteration processor 112. On the other hand, in an embodiment, if the bypass decision engine 206 determines that the programmable header alteration processor 112 is busy, or the congestion level of the programmable header alteration processor 112 is not sufficiently low, the method 300 proceeds to blocks 312-316, where further determinations are made to determine whether the packet bypasses the programmable header alteration processor 112.

[0049] At block 312, the bypass decision engine 206 determines, based on the stall mode configured for the corresponding processing thread, whether the processing thread allows the packet to bypass header changes while the programmable header change processor 112 is busy. If the bypass decision engine 206 determines at block 312 that the processing thread does not allow the packet to bypass header changes (e.g., if the thread stall mode ID is set to logic 00), the method 300 terminates at block 318, where it is determined that the packet will be provided to the programmable header change processor 112. On the other hand, if the bypass decision engine 206 determines at block 312 that the processing thread allows the packet to bypass header change processing (e.g., if the thread stall mode ID is not set to logic 00), the method 300 proceeds to block 314, where the bypass decision engine 206 determines, based on the stall mode of the processing thread, whether the processing thread allows the packet to bypass processing of the programmable header change processor 112 to be dropped by the network device 100. If the bypass decision engine 206 determines at block 314 that the stall pattern of the processing thread indicates that packets associated with the processing thread that are not header-modified by the programmable header modification processor 112 will be discarded by the network device 100, the method 300 terminates at bypass block 304, indicating that the packets will subsequently be discarded by the network device 100.

[0050] On the other hand, if the bypass decision engine 206 determines at block 314 that the stall pattern of the processing thread indicates that packets associated with the processing thread that are not being processed by the programmable header alteration processor 112 are not being dropped by the network device 100, the method 300 proceeds to block 316, where the bypass decision engine 206 determines whether the stall pattern of the processing thread indicates that packets that are not being processed by the programmable header alteration processor 112 are: i) still to be provided to the programmable header alteration processor 112 to maintain the proper order of packets associated with the processing thread as packets flow through the programmable header alteration engine 110, ii) to be redirected to the bypass path and not provided to the programmable header alteration processor 112. In an embodiment, if it is determined at block 316 that the packet is still to be provided to the programmable header alteration processor 112, the method 300 proceeds to block 317, where the thread ID corresponding to the packet is remapped to a "do nothing" thread. In an embodiment, the packet method 300 then terminates at block 318, where a decision is made to provide the packet to the programmable header alteration processor 112 such that the packet flows through the programmable header alteration processor 112 without being processed by the programmable header alteration processor 112. On the other hand, if it is determined at block 316 that the packet is to be redirected to a bypass path and not provided to the programmable header alteration processor 112, the method 300 terminates at block 304 with a bypass decision to redirect the packet to the bypass path.

[0051] Reference again Figure 2 In an embodiment, the input processor 200 further includes a second level configuration unit 210, a metadata generator 212, and a header extractor 214, which are configured to perform additional pre-processing operations on packets that do not bypass the processing of the programmable header change processor 112. In an embodiment, the second level configuration unit 210 is configured to access the second level thread configuration table 216 in the memory 202 based on the thread ID corresponding to the packet, and obtain thread configuration information, which will be used for the processing of the packet by the programmable header change processor 112. Additionally or alternatively, in an embodiment, the second level configuration unit 210 is configured to access the source port configuration table 218 based on an indicator of a source port and / or access the target port configuration table 220 based on an indicator of a target port, at which the packet is received and via which the packet is transmitted to obtain configuration information, which will be used by the programmable header change processor 112 for processing packets received via the source port and / or packets transmitted via the target port. In other embodiments, other suitable configuration information is obtained by the second level configuration unit 210. In an embodiment, the metadata generator 212 is configured to generate metadata for the packet to include at least the configuration information obtained by the second-level configuration unit 210 .

[0052] In an embodiment, the packet extractor 214 is configured to extract one or more portions of a packet header of the packet, and the generation alteration processor may access the header to include the one or more portions extracted from the packet header. Figure 4A-4B 1 are diagrams respectively illustrating extraction of one or more portions of a packet header 400 to generate a change processor-accessible header 402, and generation of a processed packet header 450 after processing of the change processor-accessible header 400 by a programmable header change processor 112, according to an embodiment. In an embodiment, the packet header 400 corresponds to an unaltered header of a received packet being processed by the network device 100. In another embodiment, where the programmable header change engine 110 is preceded by a pure hardware header change engine coupled to an input of the programmable header change engine 110, the packet header 400 corresponds to a header of a received packet that is altered (in at least some scenarios) by the pure hardware header change engine. Referring to Figure 1 and Figure 2 According to an embodiment, the input processor 118 (e.g., Figure 2 The header extractor 208 in the packet generator generates a change processor accessible header 402, and the output processor 122 subsequently generates a processed packet header 450 after the change processor accessible header 402 is processed by the programmable header change processor 112. By way of example, in Figure 4A-4B in Figure 1 The change processor is illustrated in the context of the network device 100 of FIG. 100 and can access the header extraction and processed header generation. In other embodiments, Figure 4A-4B The change processor illustrated in the figure can access the header extraction and processed header generation by different Figure 1 The network device 100 is executed by the network device.

[0053] In an embodiment, the input processor 118 identifies a change processor accessible header portion 404 that is to be extracted from the packet header 400 based on an accessible header anchor 406, which indicates a starting position (e.g., the first bit) and a length of a single portion to be extracted from the packet header 400. In an embodiment, the accessible header anchor 406 is associated with a processing thread that is to be used to process the packet header 400. In an embodiment, the input processor 118 identifies a change processor accessible header portion 404 that is to be extracted from the packet header 400 based on an accessible header anchor 406 that indicates a starting position (e.g., the first bit) and a length of a single portion to be extracted from the packet header 400. In an embodiment, the accessible header anchor 406 is associated with a processing thread that is to be used to process the packet header 400. In an embodiment, the input processor 118 identifies a change processor accessible header portion 404 that is to be extracted from the packet header 400 based on a thread ID associated with the packet header 400 (e.g., via Figure 24 (determined by the thread identifier 204 of the packet header 400) to obtain the accessible header anchor 406 from the configuration processor 116. In an embodiment, the input processor 118 starts at the position indicated by the accessible header anchor 406 and extracts the change processor accessible header portion 404 of the length indicated by the accessible header anchor 406, and generates the change processor accessible header 402 to include the change processor accessible header portion 404 extracted from the packet header 400.

[0054] In an embodiment, the input processor 118 provides the change processor accessible header 402 to the programmable header change processor 112 for processing. Additionally, in an embodiment, the input processor 118 stores the entire packet header 400 in the unified bypass buffer 120. In another embodiment, the input processor 118 stores the pre-accessible header portion 410 and the post-accessible header portion 412 of the packet header 412 in the unified bypass buffer 120 instead of the entire packet header 400.

[0055] Reference now Figure 4B In an embodiment, the programmable header change processor 112 processes the change processor accessible header 402 to generate a post-processing change processor accessible header 454. In an embodiment, the post-processing change processor accessible header 452 includes the change processor accessible header 404 that is changed according to the processing thread with which the packet header 400 is associated. In an embodiment, the post-processing change processor accessible header 452 is provided to the output processor 112, and the output processor 112 generates a processed packet header 450 by incorporating the post-processing change processor accessible header 454 into the packet header 400. For example, in an embodiment, the output processor 122 obtains the entire packet header 400 from the unified bypass buffer 120 and replaces the change processor accessible header portion 404 with the post-processing change processor accessible header 454. In another embodiment, the output processor 112 obtains the pre-accessible header portion 410 and the post-accessible header portion 412 from the unified bypass buffer 120, and generates a processed packet header 450 by appropriately combining the pre-accessible header portion 410 and the post-accessible header portion 412 with the post-processing change processor accessible header 454.

[0056] Continue to refer to Figure 4A-4B , despite the change handler accessible header 402 in Figure 4A4. The input processor 118 is illustrated as including only a single change processor accessible header portion 404 extracted from the packet header 400, but in other embodiments, the change processor accessible header 402 includes multiple change processor accessible portions 404 extracted from the packet header 400. In an embodiment, at least some of the multiple change processor accessible portions 404 are non-contiguous portions of the packet header 400. For example, the input processor 118 obtains (e.g., based on a thread ID associated with the packet header 400) multiple accessible header anchors 406, wherein each of the multiple accessible header anchors indicates a start position and length of a corresponding change processor accessible portion of the multiple (e.g., non-contiguous) change processor accessible portions 404 to be included in the change processor accessible header 402. In an embodiment, the input processor 118 then extracts the multiple change processor accessible portions 404 from the packet header 400, and generates the change processor accessible header 402 to include the multiple change processor accessible portions 402 extracted from the packet header 400. In an embodiment, the programmable header alteration processor 112 processes the alteration processor accessible header 402 to generate a post-processing alteration processor accessible header 452, which includes a plurality of post-processing alteration processor accessible header portions. In an embodiment, the output processor 122 then generates the processed packet header 450 by incorporating the plurality of post-processing alteration processor accessible header portions included in the post-processing alteration processor accessible header 452 into corresponding post-processing alteration processor accessible header portions 454 of the processed packet header 450.

[0057] In some embodiments, where the programmable header alteration engine 110 is followed by a pure hardware header alteration engine, the pure hardware header alteration engine then operates on the processed packet header 450 to implement one or more additional header alteration operations on the processed packet header 450 .

[0058] Figure 5 is a block diagram of a programmable header change processor 500 according to an embodiment. In an embodiment, the programmable header change processor 500 and Figure 1 The programmable header change processor 112 of the network device 100 corresponds to the programmable header change processor 112 of the network device 100, and for the purpose of explanation, the Figure 1 The programmable header change processor 500 is described in the context of the network device 100. However, in other embodiments, the programmable header change processor 500 is used in conjunction with the network device 100. Figure 1 Another suitable network device other than the network device 100 may be used together.

[0059] The programmable header change processor 500 is configured to receive a packet header from the input processor 118 and implement a corresponding processing thread to process the packet header. In an embodiment, the programmable header change processor 500 receives a change processor accessible header (e.g., Figure 4A The change processor accessible header 402 is a header that can be accessed by the change processor, rather than the entire packet header, and processes the change processor accessible header. For ease of explanation, the term "packet header" used herein refers to the packet header or the change processor accessible header extracted from the packet header.

[0060] Programmable header alteration processor 500 includes a plurality of packet processing nodes (PPNs) 502 coupled to memory 504 and configured to implement computer readable instructions stored in processor 504. In the illustrated embodiment, PPNs 502 are arranged in a packet processing node group 506. In an embodiment, PPNs 502 of a packet processing node group 506 share certain resources. For example, although Figure 5 Only a single memory 504 is illustrated in FIG. 5 , but in some embodiments, corresponding groups 506 of PPNs 502 are coupled to corresponding memories 504 .

[0061] In an embodiment, the programmable header alteration processor 500 further includes a distributor 508 configured to distribute packet headers among the packet processing nodes 502 for processing the packet headers. The distributor 508 generally operates by cycling through the PPNs 502 to distribute the packet headers to the PPNs 502 in the order in which the packet headers are received by the distributor 508. In an embodiment, the distributor 508 distributes the packet headers to the PPNs according to a distribution scheme that allows data headers associated with processing threads that require relatively less processing time from the PPNs 502 to not be blocked or delayed by data headers associated with processing threads that require relatively less processing time from the PPNs 502. According to the distribution scheme, the distributor 508 distributes the packet headers by cycling through the PPN 502 according to the recycle numbers assigned to the processing threads to be used to process the packet headers, wherein a smaller recycle number (e.g., recycle number 1) is assigned to a processing thread having a relatively shorter processing time, and a larger recycle number (e.g., recycle numbers 2, 3, 4, etc.) is assigned to a processing thread having a relatively longer processing time. In an embodiment, when the distributor 508 cycles through the PPN 502, if the recycle number is greater than 1, the distributor 508 skips the PPN 502 during one or more cycles according to the recycle numbers assigned to the processing threads implemented by the PPN 502. Therefore, in an embodiment, for example, when the packet header is associated with the processing thread having the recycle number 2 distributed to a particular PPN, the distributor 508 skips the particular PPN during the next distribution cycle. Accordingly, during the next distribution cycle, instead of distributing the packet header to a specific PPN, the distributor 508 distributes the packet header to another PPN 502 that can be used to process the packet header, thereby avoiding the packet header being blocked by a relatively longer processing time of a processing thread implemented by the specific PPN 502.

[0062] In an embodiment, in addition to the packet headers distributed to the PPN 502, the distributor 508 also provides a packet descriptor associated with the corresponding packet, and metadata generated by the input processor 118, in an embodiment. The programmable header change processor 500 also includes a plurality of splitters 510, which are configured to break up the packet headers, packet descriptors, and metadata to be provided to the PPN 502 into chunks so that the information is delivered to the PPN 502 in chunks. The delivery of information in chunks to the PPN 502 is performed using a suitable narrow interface (e.g., a bus) between the splitters 510 and the PPN 502, while still allowing a relatively large amount of header information (e.g., a selected header portion) and metadata corresponding to the packet header to be transmitted. In an embodiment, each information chunk associated with the packet (including, for example, the packet header, the packet descriptor, and the metadata) has a size corresponding to or narrower than the interface (e.g., a bus) between the splitters 510 and the PPN 502. For example, in an embodiment, when the bitstream enters separator 510, the bitstream including information corresponding to packets, packet headers, and metadata corresponding to packet descriptors is broken into blocks, where each block corresponds to or is narrower than an interface (e.g., a bus) between separator 510 and PPN 502. Passing information to PPN 502 in units of blocks also allows blocks of information corresponding to packets (e.g., blocks of packet headers, packet descriptors, metadata, etc., corresponding to previous packet headers processed by PPN 502) to be transferred to PPN 502 concurrently with blocks of information already processed by PPN 502 being transferred out of PPN 502.

[0063] Although only a single partitioner corresponding to each PPN group 506 is Figure 5502, but in some embodiments, the programmable header change processor 500 includes a plurality of splitters 510 corresponding to each of the packet processing node groups 506. In an embodiment, the splitters 510 in the splitters 510 operate in parallel to decompose the packet header, packet descriptor, and metadata and pass the packet header, packet descriptor, and metadata to different PPNs 502. In an embodiment, each specific splitter 510 operates on the packet header, packet descriptor, and metadata corresponding to a specific packet at any given time and generates a block of the packet header, packet descriptor, and metadata corresponding to the specific packet. In an embodiment, the block generated by the splitter 510 is provided to a specific PPN 502 for processing of the specific header. In an embodiment, in this way, the information blocks (packet headers, packet descriptors, and metadata) corresponding to a specific packet are passed to the specific PPN in series, thereby supporting the transmission of relatively large amounts of information via an appropriately narrow communication bus. On the other hand, in an embodiment, information blocks corresponding to different packets (packet headers, packet descriptors, and metadata) are delivered to different PPNs 102 in parallel.

[0064] In an embodiment, the segmenter 510 causes at least a portion of metadata corresponding to the packet header to be passed to the PPN 502 before passing the corresponding header information to the PPN 502. In an embodiment, for example, an initial block (e.g., a first block) corresponding to the packet header passed from the segmenter 610 to the PPN 502 includes at least a portion of the metadata. In an embodiment, at least a portion of the metadata passed to the PPN 502 includes a thread ID associated with the packet header, or other indicator of a processing thread to be used by the PPN 502 to process the packet header, such as a pointer to a memory location of a starting point of the processing thread stored in the memory 504. Accordingly, in an embodiment, the PPN 502 receives the thread ID or other indicator of the processing thread before receiving the header information to be processed using the processing thread. In an embodiment, the PPN 502 retrieves at least initial instructions corresponding to the processing thread from the memory 504 before receiving the header information. In an embodiment, after receiving the header information, the PPN 502 then immediately begins implementing the processing thread. In an embodiment, upon receiving the first block including header information, PPN 502 immediately begins implementing a processing thread.

[0065] In an embodiment, the programmable header alteration processor 500 also includes a plurality of accumulators 512 and aggregators 514. In an embodiment, the blocks of packet headers processed by the PPN 502 are passed to the accumulators 512 which assemble the blocks. Figure 55. Only a single accumulator 512 corresponding to each packet processing node group 506 is illustrated in FIG. 5, but in an embodiment, the programmable header modification processor 500 generally includes a plurality of accumulators 512 corresponding to each packet processing node group 506 in the packet processing node group 506. In an embodiment, the individual accumulators 510 in the accumulators 510 operate in parallel to receive and assemble processed header blocks from different PPNs 502.

[0066] In an embodiment, aggregator 514 aggregates packet headers distributed to PPN 502 into a stream of processed packet headers. In an embodiment, in order to maintain the order of packet headers processed by PPN 502 as the packet headers travel through programmable header change processor 500, aggregator 514 utilizes an aggregation scheme that corresponds to the distribution scheme used by distributor 506. According to the aggregation scheme, aggregator 514 aggregates packet headers by cycling through PPN 502 according to the recycle number used by distributor 506 to distribute the packet headers. Thus, in an embodiment, when aggregator 514 cycles through PPN 502, aggregator 514 skips PPN 502 during one or more cycles according to the recycle number used by distributor 506 when distributing the packet headers, thereby maintaining the order of the packet headers.

[0067] The programmable header alteration processor 500 operates at a faster clock than the core clock used to operate the rest of the packet processor 104, which includes components of the programmable header alteration engine 110 other than the programmable header alteration processor 500. Accordingly, in an embodiment, the header alteration processor 500 includes an input synchronization component, such as a synchronization FIFO 520, and an output synchronization component, such as a synchronization FIFO 522, to synchronize between the two clock domains. In an embodiment, in at least some scenarios, operating the programmable header alteration processor 500 at a faster clock relative to the core clock allows the programmable header alteration processor 500 to implement a relatively longer processing thread to perform header alterations on packets flowing through the packet processor 110 without slowing down the flow of traffic through the packet processor 110.

[0068] Continue to refer to Figure 5In an embodiment, during processing of a packet header, the PPN 502 engages one or more hardware accelerator engines 530 to perform specific processing operations on the packet header. In some embodiments, although the PPNs 502 share a single set of hardware accelerator engines 530, the programmable header alteration processor 500 includes multiple sets of header alterations 530. For example, in an embodiment, each PPN 502 includes a respective set of hardware accelerator engines 530 implemented in hardware. In an embodiment, the hardware accelerator engines 530 are implemented using one or more integrated circuits configured to operate as described herein. In other embodiments, the hardware accelerator engines 530 are implemented in other suitable ways.

[0069] In an embodiment, one or more hardware accelerator engines 530 are configured to perform corresponding specific operations that will consume significantly longer time (e.g., twice as long, four times as long, one hundred times as long, etc.) via computer readable instructions. For example, one or more hardware accelerator engines 530 are configured to perform corresponding information movement operations to move fields in packet headers, such as for inserting labels into packet headers and / or for removing labels from packet headers. As a more specific example, in an embodiment, one or more hardware accelerator engines 530 include a bit movement operation accelerator engine 530-1 and a byte movement operation accelerator engine 530-2, the bit movement operation accelerator engine 530-1 being configured to move a field in a packet header by a given number of bits, and in an embodiment, the byte movement operation accelerator engine 530-2 being configured to move a field in a packet header by a given number of bytes. As another example, in an embodiment, the accelerator engine 530 includes a checksum accelerator engine 530-3, which is configured to calculate an incremental update to a checksum field of a packet header. In other embodiments, the accelerator engine 530 additionally or alternatively includes an accelerator engine 530 that is configured to perform other suitable operations. In at least some embodiments, the engagement of the hardware accelerator engine 530 to perform processing operations allows the PPN 502 to, for example, insert a label (e.g., a forwarding label) into a packet header faster and / or strip a label (e.g., a forwarding label) from a packet header faster than an implementation where a processor executing computer-readable instructions does not engage a hardware engine to perform operations (e.g., information movement operations). In at least some embodiments, the engagement of the hardware accelerator engine 502 to perform processing operations permits the PPN 502 to perform header modification processing of packet headers at the full line rate at which the network device 100 receives packets.

[0070] As described above, in an embodiment, the checksum accelerator engine 530-3 is configured to calculate an incremental update to the checksum field of the packet header. In an embodiment, the PPN 502 that is processing the packet header of the packet is configured to trigger the checksum accelerator engine 530-3 to calculate the checksum based on the bit string extracted from the packet header. In an embodiment, the bit string corresponds to a specific part of the packet header, for example, depending on the type of packet to which the packet header corresponds. As an example, in an embodiment and / or in a scenario, the bit string corresponds to an IP header included in the packet header, such as an IPv4 or IPv6 header. In this case, in an embodiment, the PPN 502 triggers the checksum accelerator engine 530-3 to generate a checksum to be included in the checksum field of the IP header. As another example, in another embodiment and / or in another scenario, the bit string corresponds to a UDP header included in the packet header, and the PPN 502 triggers the checksum accelerator engine 530-3 to generate a checksum to be included in the checksum field of the UDP header. As yet another example, in another embodiment and / or in another scenario, the bit string corresponds to a Generic UDP Encapsulation (GUE) header included in the packet header, and the PPN 502 triggers the checksum accelerator engine 530-3 to generate a checksum to be included in the checksum field of the GUE header. In other embodiments, the bit string corresponds to other suitable portions of the header.

[0071] In an embodiment, in order to trigger the checksum accelerator engine 530-3, the PPN 502 is configured to divide the bit string into a plurality of segments, and generate corresponding trigger instructions to sequentially pass a plurality of corresponding segments in the segments to the checksum accelerator engine 530-3. As an example, the PPN 502 is configured to divide the bit string into a maximum of four segments, each segment including 16 bits, and generate corresponding trigger instructions to serially pass a corresponding segment in the 16-bit segment to the checksum accelerator engine 530-3. In other embodiments, other suitable numbers of segments and / or other suitable sizes of segments are utilized. In an embodiment, the checksum accelerator engine 530-3 is configured to gradually add the segments to each other and accumulate the calculated sums. For example, in an embodiment, the checksum accelerator engine 530-3 includes one or more adders (e.g., serial adders, such as 16-bit serial adders) and accumulators. In an embodiment, one or more adders are configured to incrementally determine the sum of each segment in the plurality of summing stages by providing the sum generated in each accumulation stage to the accumulator and then adding the next segment in the accumulator to the current sum. In at least some embodiments, because the segments of the bit string are serially passed to the checksum accelerator engine 530-3 and are used to incrementally generate checksums by the checksum accelerator engine 530-3, a smaller checksum accelerator engine 530-3 can be used in terms of size, power consumption, etc., compared to a system in which the entire bit string is provided to the checksum engine in the same clock cycle (especially when a relatively long bit string is required).

[0072] In some embodiments, the checksum accelerator engine 530-3 is configured to pack one or more "carries" from the sum generated by the calculation in the adder into the accumulator in the same clock cycle in which the calculation is performed, thereby eliminating the need to perform a final wraparound operation after the checksum calculation is completed in an embodiment. When the checksum accelerator engine 530-3 completes the generation of the checksum, the checksum accelerator engine 530-3 outputs the checksum, for example, by providing the checksum back to the PPN 502 or by writing the checksum to a storage location indicated by the PPN 502. In an embodiment, the PPN 502 is configured to provide the checksum accelerator engine 530-3 with an indicator (e.g., a destination pointer) of the memory location (e.g., in a group register file) to which the calculated checksum will be written. For example, in an embodiment, the PPN 502 is configured to include the indicator in one or more trigger instructions that are used to pass each segment to the checksum accelerator engine 530-3. In an embodiment, when the checksum accelerator engine 530-3 completes the checksum calculation, the PPN 502 writes the checksum to the indicated storage location, thereby placing the calculated checksum into the appropriate checksum field in the packet header.

[0073] In some embodiments, in at least some cases, the checksum accelerator engine 530-3 is configured to negate the checksum before outputting the checksum. For example, in an embodiment, the checksum accelerator engine 530-3 is configured to negate the calculated checksum when generating the checksum based on the IP header or, in at least some cases, based on the UDP header. In an embodiment, the checksum accelerator engine 530-3 is configured to determine whether to negate the calculated checksum based on instructions included in (e.g., encoded as) one or more trigger instructions, which are used to pass each segment to the checksum accelerator engine 530-3. For example, in an embodiment, the PPN 502 is configured to encode the trigger instruction as a "load new checksum" instruction to indicate that the calculated checksum does not need to be negated, or to encode the trigger instruction as a "load old checksum" instruction to indicate that the calculated checksum needs to be negated. In some embodiments and / or scenarios, the checksum accelerator engine 530-3 additionally or alternatively determines whether to negate the calculated checksum based on the value of the calculated checksum. For example, in an embodiment, for a checksum calculated based on a UDP header, the checksum accelerator engine 530 - 3 is configured to negate the calculated checksum if the value of the calculated checksum is 0xFFF.

[0074] Figure 6 is a block diagram of an example packet processing node 600 included in a header change processor according to an embodiment. In an embodiment, the packet processing node 600 corresponds to Figure 5 The packet processing node 502 of the programmable header change processor 500 is shown in FIG. 5 , and for illustration purposes, the packet processing node is in Figure 5 However, in other embodiments, the memory access system 600 is used in conjunction with the programmable header change processor 500. Figure 5 Another suitable processor device other than the programmable header change processor 500 may be used.

[0075] The packet processing node 600 includes a processor 601, a temporary memory (e.g., data RAM) 602, and a packet register file 603. According to an embodiment, the processor 601 is generally configured to implement a processing thread obtained from the memory 504 to process the packet header provided to the processing node 600. In an embodiment, the processor 601 is a small general-purpose CPU or another suitable processor configured to execute computer-readable instructions stored in the memory 504. The packet processing node 600 further includes a plurality of accelerator engines 604 and a packet register file access system 605. In an embodiment, the accelerator engine 604 corresponds to the accelerator engine 530. In another embodiment, the accelerator engine 604 additionally or alternatively includes an accelerator engine different from the accelerator engine 530. The packet register file access system 605 allows the processor 601 to trigger the accelerator engine 604 using a native CPU instruction (such as a native CPU read / write instruction), and provides regular access to the packet register file 603 for read / write operations unrelated to the accelerator engine 604.

[0076] The packet register file 604 is configured to store packet information provided by the distributor 508 to the packet processing node 600, such as at least a portion of a packet header of a packet, a descriptor corresponding to the packet, and a packet header received by the input processor 200 ( Figure 2 ) metadata generated for the packet, etc. The packet register file 603 is configured to also store various data generated during the implementation of the processing thread for the packet. In an embodiment, the packet register file 603 is additionally configured to store data generated by the accelerator engine 604, such as a portion of a packet header processed by the accelerator engine 604. In an embodiment, the packet register file 603 includes, for example, a register array and / or a multi-port random access memory (RAM). In other embodiments, the packet register file 603 is implemented in other suitable ways.

[0077] In an embodiment, the grouped register file access system 605 includes an input circuit 610 and an instruction decoder 614. In operation, an instruction 611 issued by the processor 601 is provided to the input circuit 610. In an embodiment, the instruction 611 includes a read instruction or a write instruction. In an embodiment, the read instruction or the write instruction is encoded as an accelerator engine instruction in some cases, and is encoded as a conventional read instruction or write instruction in other cases. For example, in an embodiment, the processor 601 is configured to encode the read instruction as an accelerator trigger instruction to trigger the accelerator engine 604 to perform an operation. As another example, the processor 601 is configured to encode the write instruction as an accelerator write instruction to dynamically write the accelerator engine operand data to the grouped register file 603 before triggering the accelerator engine 604 to perform an operation. In other embodiments, the instruction 611 includes instructions of a suitable type other than a write / read instruction encoded as an accelerator instruction.

[0078] Input circuitry 610 includes circuitry configured to perform hazard resolution to address situations in which a read or write instruction is provided to memory access system 600 concurrently (e.g., in the same clock cycle) with another read or write instruction, or while memory access system 600 is busy processing a previously issued read or write instruction. In an embodiment, input circuitry 602 includes a buffer (not shown) that temporarily buffers one or more instructions until memory access system 600 is able to process the one or more instructions.

[0079] In an embodiment, input circuit 610 writes instruction 611 to temporary storage memory 602, and instruction decoder 614 decodes the instruction written to temporary storage memory 602. In an embodiment, instruction decoder 614 decodes instruction 611 based on a memory map used by processor 601, wherein according to an embodiment, the memory map includes a map of both conventional read / write instructions and read / write instructions encoded as accelerator instructions. Figure 7700 is a block diagram of an example memory map 700 used by a processor 601 according to an embodiment. In an embodiment, the memory map 700 includes an accelerator instruction map 702 that maps instructions addressed to addresses in a first address range to accelerator instructions. Thus, for example, according to the memory map 700 in the illustrated embodiment, read / write instructions in an address range of 0000 1000 to 0000 1FFF are mapped to accelerator instructions. In an embodiment, the memory map 700 also includes a grouped register file map 704 that maps instructions addressed to addresses in a second address range to conventional grouped register file read / write instructions. For example, according to the memory map 700 in the illustrated embodiment, read / write instructions in an address range of 0000 2000 to 0000 23FF are mapped to conventional grouped register file instructions.

[0080] Reference again Figure 6 and Figure 7 In an embodiment, when the address of instruction 611 is in the address range mapped to the accelerator instruction by the memory map 700, the instruction decoder 614 decodes instruction 611 into an accelerator instruction, such as a trigger instruction or an accelerator write instruction. In an embodiment, the accelerator instruction 611 is a 32-bit processor instruction, and for exemplary purposes, the accelerator trigger instruction 611 is described in the context of a 32-bit processor instruction. However, in other embodiments, other suitable processor instructions (e.g., 16-bit instructions, 64-bit instructions) are utilized. In an embodiment, bits [31:26] of the accelerator instruction are encoded to indicate the type of operation requested by the accelerator instruction, and accordingly indicate the type of accelerator engine being triggered by the instruction. As an example, bits [31:26] of the accelerator instruction 611 are encoded to indicate that the accelerator instruction 611 is one of the following: i) a byte copy instruction requesting a byte field copy operation, ii) a load new checksum instruction requesting a new checksum load operation, iii) a load old checksum instruction requesting an old checksum load operation, iv) a bit field copy instruction requesting a bit field copy operation, v) a bit field addition instruction requesting a bit field addition operation, vi) a bit field subtraction instruction requesting a bit field subtraction operation, etc. In an embodiment, the remaining bits [25:0] of the accelerator instruction 611 are encoded to indicate the location of the source and / or destination header fields, descriptor fields, or configuration registers in the group register file 603. According to some embodiments, example encodings of instructions are described below with reference to Figure 8A-B Described in more detail.

[0081] In an embodiment, the instruction decoder 614 determines whether the instruction 611 is mapped to an accelerator instruction or to a conventional read / write instruction. In an embodiment, if the instruction 611 is mapped to an accelerator instruction, the instruction decoder 614 decodes the instruction as an accelerator trigger instruction or an accelerator write instruction, and extracts an indication of the relevant source / destination location of the source / destination field of the corresponding instruction in the grouped register file 603. In an embodiment, the accelerator trigger instruction decoded by the instruction decoder 604 and the conventional CPU read instruction issued by the processor 601 are provided to the connection (junction) 620. Similarly, the accelerator write instruction decoded by the instruction decoder 604 and the conventional write instruction issued by the processor 601 are provided to the connection 630. In an embodiment, in order to balance the time between issuing an accelerator instruction and the time when the corresponding decoded accelerator instruction is provided to connection 620 / 630, and the time between issuing a conventional CPU read instruction and the time when the conventional CPU instruction is provided to connection 620 / 630, the decoded accelerator instruction and / or the conventional CPU instruction are transmitted via one or more delay lines (such as Figure 6 Delay lines 618 / 628 in are provided to connections 620 / 630.

[0082] The decoded accelerator trigger instruction controls the multiplexer 622 to select the appropriate operand data for the execution of the instruction. In an embodiment, the multiplexer 611 selects between the operand data read from the grouped register file 603 and the operand data obtained from the accelerator engine 604, thereby allowing the data generated by the accelerator engine 604 to be directly used in the previously triggered operation for the execution of the current accelerator trigger instruction in an embodiment. In an embodiment, when the grouped register file 603 contains the destination of the executed operation, the data generated by the accelerator engine 604 is also written to the grouped register file 603, as indicated by the accelerator trigger instruction 611. Similarly, in an embodiment, the data requested to be written to the grouped register file 603 by the conventional CPU write instruction is written to the grouped register file 603. In addition, in an embodiment, the data read from the grouped processor file 603 in response to the conventional CPU read instruction is directly provided to the processor 601.

[0083] Figure 8A-B 6 is an illustration of several example accelerator instructions corresponding to instructions 611 issued by processor 601 , according to an embodiment. Fig. 8A is a schematic diagram of an example byte field operation instruction 800 according to an embodiment. Fig. 8A An example bit allocation used in byte field operation instruction 800 is shown. Fig. 8A Different suitable bit allocations than those shown in FIG. 5 are utilized.

[0084] In an embodiment, bits [31:26] of instruction 800 are encoded to indicate the type of byte field operation triggered by instruction 800. For example, in various embodiments, a first value (e.g., 000000) of bits [31:26] of instruction 800 indicates that a byte field copy operation is triggered, a second value (e.g., 000001) of bits [31:26] of instruction 800 indicates that a checksum load operation is triggered, etc. In an embodiment, in some cases, bits [25:21] of instruction 800 are encoded to indicate a subtype of a byte field operation. For example, in an embodiment, when bits [31:26] of instruction 800 are set to indicate a checksum load operation, bits [31:26] of instruction 800 are set to indicate whether instruction 800 is a load new checksum instruction for loading a newly calculated checksum into a packet header checksum field, or a load old checksum instruction for loading an old checksum into a packet header checksum field.

[0085] Continue to refer to Fig. 8A In an embodiment, bits [20:15] of instruction 800 are encoded to indicate the length of the destination / source field of the operation. In an embodiment, for example, bits [20:15] are set to a value corresponding to the length of the field minus one (length-1). In an embodiment, bits [15:8] of instruction 800 are encoded to indicate the location of the destination field to which the operation is to be applied. In an embodiment, bit 15 of instruction 800 is encoded to indicate whether the destination field of the operation is a packet header field or a non-packet header field, such as a packet descriptor field or other packet register field. In addition, in an embodiment, bits [14:8] of instruction 800 are encoded to indicate, according to the indication encoded in bit 15, the index of the first byte of the source field in the packet header in the packet register file 603, the index of the first byte of the source field in the packet descriptor in the packet register file 603, or the index of the first byte in the configuration register in the packet register file 603. In an embodiment, bits [7:0] of instruction 800 are encoded to indicate the location of the source field from which the source data of the operation is to be obtained. In an embodiment, bit 7 of instruction 800 is encoded to indicate whether the source field of the operation is a packet header field or a non-packet header field, such as a packet descriptor field or other packet register field. Additionally, in an embodiment, bits [6:0] of instruction 800 are encoded to indicate: an index to the first byte of a source field in a packet header in packet register file 603, an index to the first byte of a source field in a packet descriptor in packet register file 603, or an index to the first byte in a configuration register in packet register file 603, depending on the indication encoded in bit 7.

[0086] Figure 8B is a schematic diagram of an example bit field operation instruction 850 according to an embodiment. Figure 8B 850. Figure 8B Different suitable bit allocations than those shown in are utilized. In an embodiment, bits [31:26] of instruction 850 are encoded to indicate the type of bit field operation triggered by instruction 850. For example, in various embodiments, a first value (e.g., 000001) of bits [31:26] of instruction 850 indicates that a byte field copy operation is triggered, a second value (e.g., 000010) of bits [31:26] of instruction 850 indicates that a bit field addition operation is triggered, a third value (e.g., 000011) of bits [31:26] of instruction 850 indicates that a bit field subtraction operation is triggered, etc. In an embodiment, bits [25:23] of instruction 850 are encoded to indicate the initial position of a set of destination bits of the operation, and bits [25:23] of instruction 850 are encoded to indicate the initial position of a set of source bits of the operation. In an embodiment, bits [19:16] are encoded to indicate the length (e.g., number of bits) of a set of destination bits and source bits of the operation.

[0087] Continue to refer to Figure 8B In an embodiment, bits [15:0] of instruction 850 are encoded to indicate the byte position of a destination / source field, which includes a set of bits indicated by bits [25:16]. In an embodiment, bit 15 of instruction 850 is encoded to indicate whether the destination field of the operation is a packet header field or a non-packet header field, such as a packet descriptor field or other packet register field. In addition, in an embodiment, bits [14:8] of instruction 850 are encoded to indicate: the index of the first byte of the source / destination field in the packet header in packet register file 603, the index of the first byte of the source / destination field in the packet descriptor in packet register file 603, or the index of the first byte in the configuration register in packet register file 603, according to the indication encoded in bit 15. Similarly, in an embodiment, bits [7:0] of instruction 850 are encoded to indicate the location of the source field from which the source data of the operation is to be obtained. In an embodiment, bit 7 of instruction 850 is encoded to indicate whether the source field of the operation is a packet header field or a non-packet header field, such as a packet descriptor field or other packet register field. Additionally, in an embodiment, bits [6:0] of instruction 850 are encoded to indicate: an index to the first byte of a source field in a packet header in packet register file 603, an index to the first byte of a source field in a packet descriptor in packet register file 603, or an index to the first byte in a configuration register in packet register file 603, depending on the indication encoded in bit 7.

[0088] Fig. 9 is a flow chart illustrating an example method 900 for processing packets in a network device according to an embodiment. In an embodiment, the network device 100 implements the method 900 to process packets received by the network device 100. Therefore, for purposes of explanation only, the method 900 is described with reference to the network device 100. In other embodiments, the method 900 is implemented by another suitable network device.

[0089] At block 902, a packet received via a port of a network device is received by a packet processor of the network device. In an embodiment, the packet received at block 902 includes a packet header and a payload. In an embodiment, the packet is received by Figure 1 In another embodiment, the packet is received by the packet processor 104 of the network device 100. Figure 1 The network device 100 may be configured to receive packets from a suitable packet processor different from the receiving processor 104 of the network device 100 and / or ... Figure 1 The network device 100 receives packets from different network device processors.

[0090] At block 904, at least one egress interface via which the packet is transmitted by the network device is determined. Figure 1 The forwarding engine 106 of the packet processor 104 determines at least one egress interface via which the packet is transmitted. In another embodiment, another suitable device (not the forwarding engine 106) determines at least one egress interface via which the packet is transmitted.

[0091] At block 906, at least one packet header of the packet is provided to a programmable header modification engine, the programmable header modification engine comprising: i) a hardware input processor implemented in hardware, and ii) a programmable header modification processor coupled to a program memory and configured to execute computer readable instructions stored in the program memory to perform one or more header modification operations on the received packet. In an embodiment, at least the packet header is provided to Figure 1 The programmable header alteration engine 110 of the packet processor 104 of the embodiment of the present invention is provided to the programmable header alteration engine 110. In this embodiment, the hardware input processor of the programmable header alteration engine corresponds to the input processor 118 of the programmable header alteration engine 110, and the programmable header alteration processor of the header alteration engine corresponds to the programmable header alteration processor 112. In other embodiments, at least the packet header is provided to a programmable header alteration engine different from the programmable header alteration engine 110.

[0092] At block 908, a determination is made as to whether the packet header is to be provided to a processing path coupled to the programmable header alteration processor or is to be diverted to a bypass path that bypasses the programmable header alteration processor. In an embodiment, a hardware input processor of the programmable header alteration engine determines whether the packet header is to be provided to a processing path coupled to the programmable header alteration processor or is to be diverted to a bypass path that bypasses the programmable header alteration processor. In an embodiment, Figure 2 The bypass decision engine 206 of the input processor 200 determines whether the packet will be provided to the programmable header change processor via the processing path, or will be transferred to a bypass path that bypasses the header change processor. In an embodiment, Figure 3 The method 300 of is implemented to determine whether the packet will be provided to the programmable header change processor via the processing path, or will be transferred to a bypass path that bypasses the header change processor. In other embodiments, the determination of block 908 is performed in other suitable ways.

[0093] At block 910, the packet header is provided to the processing path or the bypass path based on the determination made at block 909 as to whether the packet header is to be provided to the processing path or is to be diverted to the bypass path. In an embodiment, a hardware input processor of the programmable header alteration engine provides the packet header to the processing path or the bypass path based on the determination made at block 909 as to whether the packet header is to be provided to the processing path or is to be diverted to the bypass path.

[0094] At block 912, the packet header is selectively: i) processed by the programmable header modification processor when the packet header is provided to the processing path, or ii) not processed by the programmable header modification processor when the packet header is provided to the bypass path. In an embodiment, at block 912, Figure 1 A programmable header change processor 112 or Figure 5 The programmable header change processor 500 selectively processes or does not process the packet header. In another embodiment, at block 912, another suitable programmable header change processor selectively processes or does not process the packet header.

[0095] In general, because method 900 allows packets to dynamically bypass a header change processor, in an embodiment, method 900 allows packets that may not require header changes by a programmable header change processor to quickly pass through the programmable header change engine. For example, in an embodiment, certain packet flows and / or packet types that do not require header changes by a programmable header change processor are allowed to quickly pass through the programmable header change engine. In some embodiments, during times when congestion occurs in the header change processor, certain packets and / or packet flows are allowed to bypass the header change processor. In at least some embodiments, allowing some packets to dynamically bypass the programmable header change processor increases the processing capacity available to process packets that require header changes by the programmable header change processor, compared to systems that do not utilize dynamic bypass of the header change processor.

[0096] At block 914 , the packet having the packet header that was selectively processed or not processed at block 910 is transmitted via at least one egress interface of the network device determined at block 904 .

[0097] Fig.10 is a flow chart illustrating an example method 1000 for processing packets in a network device according to another embodiment. In an embodiment, the network device 100 implements the method 1000 to process packets received by the network device 100. Therefore, for purposes of explanation only, the method 1000 is described with reference to the network device 100. In other embodiments, the method 1000 is implemented by another suitable network device.

[0098] At block 1002, a packet received via a port of a network device is received by a packet processor of the network device. In an embodiment, the packet received at block 902 includes a packet header and a payload. In an embodiment, the packet is received by Figure 1 In another embodiment, the packet is received by the packet processor 104 of the network device 100. Figure 1 The network device 100 may be configured to receive packets from a suitable packet processor different from the receiving processor 104 of the network device 100 and / or ... Figure 1 The network device 100 receives packets from different network device processors.

[0099] At block 1004, at least one egress interface via which the packet is transmitted by the network device is determined. Figure 1 The forwarding engine 106 of the packet processor 104 determines at least one egress interface via which the packet is transmitted. In another embodiment, another suitable device (not the forwarding engine 106) determines at least one egress interface via which the packet is transmitted.

[0100] At block 1006, a packet header of the packet is processed using a programmable header modification processor coupled to the program processor and configured to execute computer readable instructions stored in a program memory to perform one or more header modification operations on the received packet. Figure 1 In another embodiment, the packet header is processed by a programmable header change processor 112. Figure 1 In an embodiment, processing the packet header at block 1006 includes: triggering a hardware checksum accelerator engine to calculate a bit string corresponding to at least a portion of the packet header. In an embodiment, processing the packet header at block 1006 includes: triggering a hardware checksum accelerator engine to calculate a bit string corresponding to at least a portion of the packet header. Figure 5 In another embodiment, processing the packet header of block 1006 includes: triggering a packet different from Figure 5 The hardware checksum accelerator engine 530-3 of the embodiment triggers the hardware checksum accelerator engine including: i) dividing the bit string into a plurality of segments of the bit string, and ii) passing the plurality of segments of the bit string to the hardware checksum accelerator engine.

[0101] At block 1008, the checksum is incrementally calculated by the hardware checksum accelerator engine at least by incrementally summing corresponding segments of the plurality of segments of the bit string. In an embodiment, the incrementally summing corresponding segments of the plurality of segments of block 1008 includes: summing the plurality of segments at a plurality of summing stages. In an embodiment, the incrementally summing corresponding segments of the plurality of segments of block 1008 is performed according to the above combined Figure 5 In another embodiment, the incremental summing of the corresponding segments of the plurality of segments of block 1008 is performed in other suitable manners. In an embodiment, the incremental summing of the plurality of segments at a plurality of summing stages stores the result of the previous summing stage in an accumulator, the result of the previous summing stage corresponding to the sum of two or more segments of the plurality of segments passed to the hardware checksum accelerator engine, and in a subsequent summing stage, the result of the previous summing stage stored in the accumulator is summed with the subsequent segment of the plurality of segments passed to the hardware checksum accelerator engine.

[0102] In at least some embodiments, because corresponding segments of the bit string are serially passed to the hardware checksum accelerator engine in box 1006 and are used to incrementally calculate the checksum by the hardware checksum accelerator engine in box 1008, method 1000 allows a smaller hardware checksum accelerator engine (in terms of size, power consumption, etc.) to be used, especially when relatively long bit strings require checksum calculations, compared to a system in which the entire bit string is provided to the checksum engine and the checksum is calculated for the entire bit string in the same clock cycle.

[0103] At block 1010 , the packet having the modified packet header including the checksum calculated incrementally at block 1008 is transmitted via at least one egress interface of the network device determined at block 1004 .

[0104] In an embodiment, a method for processing a packet in a network device comprises: receiving, at a packet processor of the network device, a packet received by the network device from a network link; determining, using the packet processor, at least one egress interface via which the packet is transmitted by the network device; providing at least a packet header of the packet to a programmable header alteration engine of the packet processor, the programmable header alteration engine comprising: i) a hardware input processor implemented in hardware, and ii) a programmable header alteration processor coupled to a program memory, the programmable header alteration processor being configured to execute computer-readable instructions stored in the program memory to perform one or more header alteration operations on the received packet; determining, using the programmable header alteration engine, ... A hardware input processor of the change engine determines whether a packet header will be provided to a processing path coupled to a programmable header change processor or will be transferred to a bypass path that bypasses the programmable header change processor; based on the determination of whether the packet header will be provided to the processing path or will be transferred to the bypass path, the hardware input processor of the programmable header change engine provides the packet header to the processing path or the bypass path; selectively i) processes the packet header by the programmable header change processor when the packet header is provided to the processing path, and ii) does not process the packet header by the programmable header change processor when the packet header is provided to the bypass path; and transmits the packet via at least one egress interface of the network device using a network device.

[0105] In other embodiments, the method further includes one of the following features, or any suitable combination of two or more features.

[0106] The method also includes determining, using the packet processor, a packet flow to which the packet belongs.

[0107] The method also includes determining whether the packet header is to be provided to the processing path or to be diverted to the bypass path includes determining whether the packet header is to be provided to the processing path or to be diverted to the bypass path based at least in part on a packet flow to which the packet belongs.

[0108] Determining whether the packet header is to be provided to the processing path or to be diverted to the bypass path includes determining whether the packet header is to be provided to the processing path or to be diverted to the bypass path based on one or more statistical attributes associated with the packet.

[0109] Determining whether a packet header is to be provided to a processing path or to be diverted to a bypass path includes determining whether the packet header is to be provided to a processing path or to be diverted to a bypass path based at least in part on i) a congestion level of a programmable header change processor and ii) one or more congestion handling attributes associated with the packet.

[0110] The method also includes: when it is determined that the packet header is to be transferred to the bypass path, storing the packet header in parallel with the programmable header change processor in a unified buffer, the unified buffer being configured to temporarily store: i) packet headers of packets that bypass the programmable header change processor, and ii) at least multiple portions of packet headers that do not bypass the programmable header change processor, wherein the portions of the packet header are not required for processing by the programmable header change processor.

[0111] The method also includes: when it is determined that the packet header will be provided to the processing path: extracting one or more parts of the packet header to be provided to the programmable header change processor, generating a header change processor accessible header to include the one or more parts extracted from the packet header, separating the header change processor accessible header from the packet header, providing the header change processor accessible header instead of the packet header to the programmable header change processor, processing the header change processor accessible header using the programmable header change processor, and after processing the header change processor accessible header using the programmable header change processor, integrating the processed header change processor accessible header into the packet header.

[0112] The method also includes: generating metadata using a hardware input processor of a programmable header change engine to include at least an indicator of a processing thread stored in a program memory, which processing thread will be implemented to process the packet header by the programmable header change processor; and providing the metadata to the programmable header change processor together with the changed accessible header using the hardware input processor of the programmable header change engine.

[0113] Providing metadata together with a changed accessible header to a programmable header change processor includes: dividing the information including the metadata and the changed accessible header into multiple blocks, and serially passing corresponding blocks of the multiple blocks to the programmable header change processor, wherein an initial block of the multiple blocks passed to the programmable header change processor includes at least an indicator of a processing thread stored in a program memory, which processing thread will be implemented to process packets by the programmable header change processor.

[0114] The method also includes: before receiving the initial portion of the changed accessible header at the programmable header change processor, based on an indicator of a processing thread included in an initial block of the plurality of blocks, obtaining, with the programmable header change processor, from a program memory a set of computer readable instructions to be used to process the changed accessible header.

[0115] The programmable header change processor includes a plurality of processing nodes.

[0116] The method also includes: when it is determined that the packet header is to be provided to the processing path, providing at least a portion of the packet header to a processing node among a plurality of processing nodes for processing the packet header by the processing node, wherein the processing of the packet header by the processing node is performed in parallel with the processing of another packet header by another processing node among the plurality of processing nodes, the other packet header corresponding to another packet received by the network device.

[0117] Processing a packet header by a programmable header alteration processor includes executing a set of computer-readable instructions retrieved from a packet memory using the programmable header alteration processor, including, during execution of the set of computer-readable instructions, triggering one or more hardware accelerator engines to perform one or more specific processing operations relative to the packet header.

[0118] Triggering a hardware accelerator engine in one or more hardware accelerator engines includes: issuing a native central processing unit (CPU) instruction of a processing node of a programmable header change processor; and mapping the native CPU instruction to an accelerator trigger instruction based on an address indicated in the native CPU instruction to trigger the hardware accelerator engine.

[0119] In another embodiment, a network device includes a packet processor and a programmable header alteration engine, the packet processor being configured to: i) receive a packet from a network link, and ii) determine at least one egress interface via which the packet is transmitted by the network device, the programmable header alteration engine comprising: i) a hardware input processor implemented in hardware, and ii) a programmable header alteration processor coupled to a program memory, the programmable header alteration processor being configured to: execute computer-readable instructions stored in the program memory to perform one or more header alteration operations on the received packet. The hardware input processor is configured to: determine whether a packet header of the packet is to be provided to a processing path coupled to the programmable header alteration processor or is to be transferred to a bypass path that bypasses the programmable header alteration processor; and based on the determination as to whether the packet header is to be provided to the processing path or is to be transferred to the bypass path, provide the packet header to the processing path or the bypass path. The programmable header alteration processor is configured to selectively: i) process the packet header when the packet header is provided to the processing path, and ii) not process the packet header when the packet header is provided to the bypass path. The packet processor is also configured to cause the packet to be transmitted via at least one egress interface of the network device.

[0120] In other embodiments, the network device further includes one of the following features, or any suitable combination of two or more features.

[0121] The packet processor is also configured to determine a packet flow to which the packet belongs.

[0122] The hardware input processor is configured to determine whether a packet header is to be provided to a processing path or to be diverted to a bypass path based at least in part on a packet flow to which the packet belongs.

[0123] The hardware input processor is configured to determine whether a packet header is to be provided to a processing path or to be diverted to a bypass path based on one or more statistical attributes associated with the packet.

[0124] The hardware input processor is configured to determine whether a packet header is to be provided to a processing path or diverted to a bypass path based at least in part on i) a congestion level of the programmable header alteration processor and ii) one or more congestion handling attributes associated with the packet.

[0125] The hardware input processor is also configured to: when it is determined that the packet header is to be provided to the bypass path, store the packet header in parallel with the programmable header change processor in a unified buffer, the unified buffer being configured to temporarily store: i) packet headers of packets that bypass the programmable header change processor, and ii) at least portions of packet headers that do not bypass the programmable header change processor, wherein the portion of the packet header is not required for processing by the header change processor.

[0126] The hardware input processor is also configured to: when it is determined that a packet header will be provided to a processing path: extract one or more portions of the packet header to be provided to a programmable header change processor; generate a header change processor accessible header to include one or more portions extracted from the packet header, the header change processor accessible header separated from the packet header; and provide the header change processor accessible header instead of the packet header to the header change processor.

[0127] The hardware input processor is also configured to: generate metadata corresponding to the packet, the metadata comprising at least an indicator of a processing thread stored in a program memory, the processing thread to be implemented to process the packet header by a programmable header change processor; and provide the metadata to the header change processor together with the changed accessible header.

[0128] The hardware input processor is configured to: divide information including metadata and change-accessible headers into multiple blocks, and serially pass corresponding blocks of the multiple blocks to the programmable header change processor, wherein an initial block of the multiple blocks passed to the programmable header change processor includes an indicator of a processing thread stored in a program memory, which processing thread will be implemented to process the packet header by the programmable header change processor.

[0129] The programmable header change processor is configured to: before receiving the initial portion of the change accessible header at the programmable header change processor, based on an indicator of a processing thread included in an initial block of the plurality of blocks, obtain from the program memory a set of computer readable instructions to be used to process the change accessible header.

[0130] The programmable header change processor includes a plurality of processing nodes.

[0131] The hardware input processor is configured to: when it is determined that a packet header is to be provided to a processing path, provide at least a portion of the packet header to a processing node among a plurality of processing nodes for processing the packet header by the processing node, wherein the processing of the packet header by the processing node is performed in parallel with the processing of another packet header by another processing node among the plurality of processing nodes, the other packet header corresponding to another packet received by the network device.

[0132] The programmable header change processor is configured to: execute a set of computer-readable instructions obtained from a packet memory to process a packet header, and the programmable header change processor is configured to: trigger one or more hardware accelerator engines to perform one or more specific processing operations relative to the packet header during the execution of the set of computer-readable instructions, wherein the header change processor is configured to: trigger an accelerator engine in one or more accelerator engines at least by issuing a native CPU instruction of a processing node of the header change processor, wherein based on an address indicated in the native CPU instruction, the native CPU instruction is mapped to an accelerator trigger instruction to trigger the hardware accelerator engine.

[0133] In yet another embodiment, a method for processing packets in a network device comprises: receiving, at a packet processor of the network device, a packet received by the network device from a network link; determining, using the packet processor, at least one egress interface via which the packet is transmitted by the network device; processing a packet header of the packet using a programmable header change processor coupled to a program memory, the programmable header change processor being configured to execute computer-readable instructions stored in the program memory to perform one or more header change operations on the received packet, the processing comprising triggering a hardware checksum accelerator engine to calculate a checksum for a bit string corresponding to at least a portion of the packet header, wherein triggering the hardware checksum accelerator engine comprises: i) dividing the bit string into a plurality of segments of the bit string, and ii) passing the plurality of segments of the bit string to the hardware checksum accelerator engine; incrementally calculating a checksum using the hardware checksum accelerator at least by incrementally summing corresponding segments of the plurality of segments of the bit string passed to the hardware checksum accelerator engine; and transmitting the packet having the modified header including the checksum via at least one egress interface of the network device.

[0134] In other embodiments, the method further includes one of the following features, or any suitable combination of two or more features.

[0135] Triggering the hardware checksum accelerator engine includes: generating a corresponding trigger instruction using a programmable header change processor to pass a corresponding segment of the plurality of segments of the bit string to the hardware checksum accelerator engine; and providing the corresponding trigger instruction to the hardware checksum accelerator engine serially.

[0136] Triggering the hardware checksum accelerator engine includes: issuing one or more native central processing unit (CPU) instructions supported by a programmable header change processor, and mapping each of the one or more native CPU instructions to an accelerator trigger instruction based on an address indicated in the one or more native CPU instructions for triggering the hardware checksum accelerator engine.

[0137] Incrementally calculating the checksum includes: incrementally summing multiple segments in multiple summing stages using a hardware checksum accelerator engine, including: storing a result of a previous summing stage in an accumulator, the result of the previous summing stage corresponding to the sum of two or more segments of the multiple segments passed to the hardware checksum accelerator engine; and in a subsequent summing stage, summing the result of the previous summing stage stored in the accumulator with a subsequent segment of the multiple segments passed to the hardware checksum accelerator engine.

[0138] Incrementally computing the checksum also includes wrapping one or more carry bits generated in a previous summation stage back into the accumulator during the same clock cycle that the previous summation stage is executed by the hardware checksum accelerator engine.

[0139] The method also includes: determining, using the hardware checksum accelerator engine, whether a checksum is to be negated based on information provided to the hardware checksum accelerator engine by the programmable header change processor; and in response to determining that the checksum is to be negated, negating the checksum before outputting the checksum from the hardware checksum accelerator engine.

[0140] Triggering the hardware checksum accelerator engine to calculate a checksum for the bit string includes providing an indication to the hardware checksum accelerator engine of a memory location in the memory where the checksum is to be written.

[0141] The method also includes causing the checksum to be written to the indicated memory location in the memory using a hardware checksum accelerator engine.

[0142] Triggering a hardware checksum accelerator engine to calculate a checksum for a bit string includes: triggering a hardware checksum accelerator engine to calculate a checksum for a bit string corresponding to one of the following: i) an Internet Protocol (IP) header included in a packet header, ii) a User Datagram Protocol (UDP) header included in a packet header, or iii) a Generic UDP Encapsulation (GUE) header included in a packet header.

[0143] In yet another embodiment, a network device includes a packet processor and a programmable header alteration processor, the packet processor being configured to: i) receive a packet from a network link, the packet including a packet header and a payload, and ii) determine at least one egress interface via which the packet is to be transmitted by the network device, the programmable header alteration processor being coupled to a program memory, the programmable header alteration processor being configured to: execute computer-readable instructions stored in the program memory to perform one or more header alteration operations on a packet header of the received packet, the programmable header alteration processor being configured to: during processing of the packet header of the received packet, trigger a hardware checksum accelerator engine to calculate a checksum for a bit string corresponding to at least a portion of the packet header. The programmable header alteration processor is configured to: divide the bit string into a plurality of segments of the bit string, and pass the plurality of segments of the bit string to the hardware checksum accelerator engine. The hardware checksum accelerator engine is configured to: incrementally calculate a checksum by at least incrementally summing corresponding segments of the plurality of segments of the bit string passed to the hardware checksum accelerator engine. The packet processor is also configured to cause the packet with the modified header including the checksum to be transmitted via at least one egress interface of the network device.

[0144] In other embodiments, the network device further includes one of the following features, or any suitable combination of two or more features.

[0145] The programmable header alteration processor is configured to generate a corresponding trigger instruction to pass a corresponding segment of the plurality of segments of the bit string to the hardware checksum accelerator engine, and serially provide the corresponding trigger instruction to the hardware checksum accelerator engine.

[0146] The programmable header change processor is configured to trigger the hardware checksum accelerator engine at least by issuing one or more native CPU instructions supported by the programmable header change processor, wherein each of the one or more native CPU instructions is mapped to an accelerator trigger instruction based on an address indicated in the native CPU instruction to trigger the hardware checksum accelerator engine.

[0147] The hardware checksum accelerator engine is configured to incrementally compute a checksum by at least summing a plurality of segments of a plurality of summing stages.

[0148] The hardware checksum accelerator engine is configured to: store a result of a previous summation stage in an accumulator, the result of the previous summation stage corresponding to the sum of two or more segments of the plurality of segments passed to the hardware checksum accelerator engine, and in a subsequent summation stage, sum the result of the previous summation stage stored in the accumulator with a subsequent segment of the plurality of segments passed to the hardware checksum accelerator engine.

[0149] The hardware checksum accelerator engine is further configured to pack one or more carry bits generated in a previous summation stage back into the accumulator during a same clock cycle in which the previous summation stage is executed by the hardware checksum accelerator engine.

[0150] The hardware checksum accelerator engine is further configured to: determine whether the checksum is to be negated based on information provided to the hardware checksum accelerator engine by the programmable header alteration processor; and in response to determining that the checksum is to be negated, negate the checksum before outputting the checksum.

[0151] The programmable header alteration processor is further configured to provide an indication to the hardware checksum accelerator engine of a memory location in the memory where the checksum is to be written.

[0152] The hardware checksum accelerator engine is further configured to cause the checksum to be written to the indicated memory location in the memory.

[0153] The programmable header change processor is also configured to: trigger the hardware checksum accelerator engine to calculate a checksum corresponding to one of the following: i) an Internet Protocol (IP) header included in the packet header, ii) a User Datagram Protocol (UDP) header included in the packet header, or iii) a Generic UDP Encapsulation (GUE) header included in the packet header.

[0154] At least some of the various blocks, operations, and techniques described above may be implemented using hardware, a processor executing firmware instructions, a processor executing software instructions, or any combination thereof.

[0155] When implemented in hardware, the hardware may include one or more of discrete components, integrated circuits, application specific integrated circuits (ASICs), programmable logic devices (PLDs), and the like.

[0156] When implemented with a processor that executes software or firmware instructions, the software or firmware instructions may be stored in any computer-readable memory, such as on a disk, optical disk, or other storage medium, in RAM or ROM or flash memory, a processor, a hard drive, an optical drive, a tape drive, etc. The software or firmware instructions may include machine-readable instructions that, when executed by one or more processors, cause the one or more processors to perform various actions.

[0157] Although the present invention has been described with reference to specific examples, these specific examples are intended to be illustrative only and are not intended to limit the present invention, and the disclosed embodiments may be changed, added, and / or deleted without departing from the scope of the present invention. For example, one or more parts of the above methods or techniques may be performed in a different order (or concurrently) while still achieving the desired results.

Claims

1. A method for processing packets in a network device, the method comprising: receiving, at a packet processor of the network device, a packet received by the network device from a network link; determining, with the packet processor, at least one egress interface via which the packet is to be transmitted by the network device; providing at least a packet header of the packet to a programmable header alteration engine of the packet processor, the programmable header alteration engine comprising: i) a hardware input processor implemented in hardware; and ii) a programmable header alteration processor coupled to a program memory, the programmable header alteration processor being configured to execute computer readable instructions stored in the program memory to perform one or more header alteration operations on a received packet; determining, using the hardware input processor of the programmable header alteration engine, whether the packet header is to be provided to a processing path coupled to the programmable header alteration processor or to be diverted to a bypass path that bypasses the programmable header alteration processor; providing, with the hardware input processor of the programmable header alteration engine, the packet header to the processing path or the bypass path based on the determination that the packet header is to be provided to the processing path or is to be diverted to the bypass path; selectively i) processing the packet header by the programmable header alteration processor when the packet header is provided to the processing path; ii) not processing the packet header by the programmable header alteration processor when the packet header is provided to the bypass path; and The packet is transmitted using the network device via the at least one egress interface of the network device.

2. The method according to claim 1, wherein: The method further includes determining, using the packet processor, a packet flow to which the packet belongs, and Determining whether the packet header is to be provided to the processing path or to be diverted to the bypass path includes determining whether the packet header is to be provided to the processing path or to be diverted to the bypass path based at least in part on the packet flow to which the packet belongs.

3. The method of claim 2, wherein determining whether the packet header is to be provided to the processing path or is to be diverted to the bypass path comprises: Based on one or more statistical attributes associated with the packet, it is determined whether the packet header is to be provided to the processing path or to be diverted to the bypass path.

4. The method of claim 1 , wherein determining whether the packet header is to be provided to the processing path or is to be diverted to the bypass path comprises: A determination is made whether a packet header will be provided to the processing path or diverted to the bypass path based at least in part on: i) a congestion level of the programmable header alteration processor; and ii) one or more congestion handling attributes associated with the packet.

5. The method according to claim 1, further comprising: When it is determined that the packet header is to be diverted to the bypass path, storing the packet header in a unified buffer in parallel with the programmable header alteration processor, the unified buffer being configured to temporarily store i) packet headers of packets that bypass the programmable header alteration processor; and ii) at least a portion of a packet header that does not bypass the programmable header alteration processor, wherein the portion of the packet header does not need to be processed by the programmable header alteration processor.

6. The method according to claim 1, further comprising: When it is determined that the packet header is to be provided to the processing path, extracting one or more portions of the packet header to be provided to the programmable header alteration processor, generating a header alteration processor-accessible header to include the one or more portions extracted from the packet header, the header alteration processor-accessible header being separated from the packet header, providing the programmable header alteration processor with a header accessible to the header alteration processor other than the packet header, processing said header alteration processor accessible header using said programmable header alteration processor, and After processing the header alteration processor accessible header using the programmable header alteration processor, the processed header alteration processor accessible header is integrated into the packet header.

7. The method according to claim 6, further comprising: generating metadata with the hardware input processor of the programmable header alteration engine to include at least an indicator of a processing thread stored in the program memory, the processing thread to be implemented by the programmable header alteration processor to process the packet header, and The metadata and the header alteration processor-accessible headers are provided to the programmable header alteration processor using the hardware input processor of the programmable header alteration engine.

8. The method of claim 7, wherein providing the metadata and the header alteration processor accessible headers to the programmable header alteration processor comprises: dividing information including the metadata and the header accessible to the header change handler into a plurality of chunks, and Corresponding blocks among the plurality of blocks are transmitted serially to the programmable header change processor, wherein an initial block among the plurality of blocks transmitted to the programmable header change processor comprises at least: the indicator of the processing thread stored in the program memory, the processing thread to be implemented by the programmable header change processor to process the packet.

9. The method according to claim 8, further comprising: Prior to receiving an initial portion of the header change processor accessible header at the programmable header change processor, obtaining, using the programmable header change processor, a set of computer-readable instructions from the program memory to be used to process the header change processor accessible header based on the indicator of the processing thread, the indicator being included in the initial block of the plurality of blocks.

10. The method of claim 1, wherein: The programmable header change processor includes a plurality of processing nodes, and The method also includes: when it is determined that the packet header is to be provided to the processing path, providing at least a portion of the packet header to a processing node among the multiple processing nodes for processing the packet header by the processing node, wherein the processing of the packet header by the processing node is performed in parallel with the processing of another packet header by another processing node among the multiple processing nodes, and the other packet header corresponds to another packet received by the network device.

11. The method of claim 1 , wherein processing the packet header by the programmable header alteration processor comprises: Utilizing the programmable header change processor to execute a computer readable instruction set obtained from the packet memory, during the execution of the computer readable instruction set, triggering one or more hardware accelerator engines to perform one or more specific processing operations on the packet header, wherein triggering a hardware accelerator engine among the one or more hardware accelerator engines comprises: issuing instructions of a local central processing unit (CPU) of a processing node of the programmable header change processor, and Based on the address indicated in the native CPU instruction, the native CPU instruction is mapped to an acceleration trigger instruction to trigger the hardware accelerator engine.

12. The method according to claim 1, further comprising: receiving, at a packet processor of the network device, a packet received by the network device from a network link; determining, with the packet processor, at least one egress interface via which the packet is to be transmitted by the network device; processing a packet header of the packet using a programmable header alteration processor coupled to a program memory, the programmable header alteration processor being configured to execute computer-readable instructions stored in the program memory to perform one or more header alteration operations on the received packet, the processing comprising triggering a hardware checksum accelerator engine to calculate a checksum for a bit string corresponding to at least a portion of the packet header, wherein triggering the hardware checksum accelerator engine comprises: i) dividing the bit string into a plurality of segments of the bit string, and ii) transmitting the plurality of segments of the bit string to the hardware checksum accelerator engine; calculating, with the hardware checksum accelerator, the checksum incrementally at least by incrementally summing corresponding ones of the plurality of segments of the bit string transmitted to the hardware checksum accelerator engine; and The packet having a modified header including the checksum is transmitted via the at least one egress interface of the network device.

13. The method of claim 12, wherein triggering the hardware checksum accelerator engine comprises: generating, using the programmable header alteration processor, corresponding trigger instructions to transmit corresponding segments of the plurality of segments of the bit string to the hardware checksum accelerator engine, and The corresponding trigger instructions are provided serially to the hardware checksum accelerator engine.

14. The method of claim 12, wherein triggering the hardware checksum accelerator engine comprises: issuing one or more local central processing unit (CPU) instructions supported by the programmable header change processor, and Each of the one or more native CPU instructions is mapped to an accelerator trigger instruction for triggering the hardware checksum accelerator engine based on an address indicated in the one or more native CPU instructions.

15. The method of claim 12, wherein incrementally calculating the checksum comprises: Incrementally summing the plurality of segments in a plurality of summing stages using the hardware checksum accelerator engine comprises: storing a result of a previous summation stage in an accumulator, the result of the previous summation stage corresponding to a sum of two or more of the plurality of segments transmitted to the hardware checksum accelerator engine, and In a subsequent summation stage, the result of the previous summation stage stored in the accumulator is summed with a subsequent segment among the plurality of segments transmitted to the hardware checksum accelerator engine.

16. The method of claim 15, wherein incrementally calculating the checksum further comprises: One or more carry bits generated in the previous summation stage are packed back into the accumulator in the same clock cycle in which the previous summation stage is executed by the hardware checksum accelerator engine.

17. The method according to claim 12, further comprising: determining, using the hardware checksum accelerator engine, whether the checksum is to be negated based on information provided to the hardware checksum accelerator engine by the programmable header alteration processor, and In response to determining that the checksum is to be negated, the checksum is negated before outputting the checksum from the hardware checksum accelerator engine.

18. The method of claim 12, wherein: Triggering the hardware checksum accelerator engine to calculate the checksum for the bit string comprises: providing the hardware checksum accelerator engine with an indication of a memory location in a memory where the checksum is to be written, and The method further includes causing the checksum to be written to the indicated memory location in the memory using the hardware checksum accelerator engine.

19. The method of claim 12, wherein triggering the hardware checksum accelerator engine to calculate the checksum for the bit string comprises: The hardware checksum accelerator engine is triggered to calculate the checksum for a bit string corresponding to one of: i) an Internet Protocol (IP) header included in the packet header, ii) a User Datagram Protocol (UDP) header included in the packet header, or iii) a Generic UDP Encapsulation (GUE) header included in the packet header.

20. A network device comprising: a packet processor configured to: i) receive a packet from a network link, and ii) determine at least one egress interface via which the packet is to be transmitted by the network device; as well as A programmable header alteration engine comprising: i) a hardware input processor implemented in hardware, and ii) a programmable header alteration processor coupled to a program memory, the programmable header alteration processor being configured to execute computer readable instructions stored in the program memory to perform one or more header alteration operations on a received packet, wherein: The hardware input processor is configured to: determining whether a packet header of the packet is to be provided to a processing path coupled to the programmable header alteration processor or is to be diverted to a bypass path that bypasses the programmable header alteration processor, and providing the packet header to the processing path or the bypass path based on the determination that the packet header is to be provided to the processing path or is to be diverted to the bypass path, and The programmable header alteration processor is configured to selectively: i) process the packet header when the header is provided to the processing path, and ii) not process the packet header when the packet header is provided to the bypass path, and The packet processor is further configured to cause the packet to be transmitted via the at least one egress interface of the network device.

21. The network device according to claim 20, wherein: The packet processor is further configured to: determine a packet flow to which the packet belongs, and The hardware input processor is configured to determine whether the packet header is to be provided to the processing path or to be diverted to the bypass path based at least in part on the packet flow to which the packet belongs.

22. The network device of claim 20, wherein the hardware input processor is configured to determine whether the packet header is to be provided to the processing path or to be diverted to the bypass path based on one or more statistical attributes associated with the packet.

23. A network device according to claim 20, wherein the hardware input processor is configured to: determine whether the packet header will be provided to the processing path or will be transferred to the bypass path based at least in part on: i) a congestion level of the programmable header change processor; and ii) one or more congestion handling attributes associated with the packet.

24. The network device of claim 20, wherein the hardware input processor is further configured to: when determining that the packet header is to be provided to the bypass path, store the packet header in a unified buffer in parallel with the programmable header change processor, the unified buffer being configured to temporarily store: i) packet headers of packets that bypass the programmable header change processor, and ii) at least a portion of packet headers that do not bypass the programmable header change processor, wherein the portion of the packet header does not need to be processed by the header change processor.

25. The network device of claim 20, wherein the hardware input processor is further configured to: when determining that the packet header is to be provided to the processing path, extracting one or more portions of the packet header to be provided to the programmable header alteration processor, generating a header alteration processor-accessible header to include the one or more portions extracted from the packet header, the header alteration processor-accessible header being separated from the packet header, and The header alteration processor is provided with a header accessible to the header alteration processor other than the packet header.

26. The network device of claim 25, wherein the hardware input processor is further configured to: generating metadata corresponding to the packet, the metadata comprising at least an indicator of a processing thread stored in the program memory, the processing thread to be implemented by the programmable header alteration processor to process a packet header, and The metadata is provided to the header alteration processor along with the header alteration processor accessible header.

27. The network device of claim 26, wherein the hardware input processor is configured to: dividing information including the metadata and the header accessible to the header change handler into a plurality of chunks, and transmitting a corresponding block among the plurality of blocks serially to the programmable header alteration processor, wherein an initial block among the plurality of blocks transmitted to the programmable header alteration processor comprises: The indicator of the processing thread stored in the packet memory is to be implemented by the programmable header alteration processor to process the packet header.

28. A network device according to claim 27, wherein the programmable header change processor is configured to: before receiving the initial portion of the header change processor accessible header at the programmable header change processor, based on the indicator of the processing thread, obtain a computer-readable instruction set from the program memory to be used to process the header change processor accessible header, and the indicator is included in the initial block of the multiple blocks.

29. The network device according to claim 20, wherein: The programmable header change processor includes a plurality of processing nodes, and The hardware input processor is configured to: when it is determined that the packet header is to be provided to the processing path, provide at least a portion of the packet header to a processing node among the multiple processing nodes for processing the packet header by the processing node, wherein the processing of the packet header by the processing node is performed in parallel with the processing of another packet header by another processing node among the multiple processing nodes, and the other packet header corresponds to another packet received by the network device.

30. A network device according to claim 20, wherein the programmable header change processor is configured to execute a computer-readable instruction set obtained from the packet memory to process the packet header, and the programmable header change processor is configured to trigger one or more hardware accelerator engines to perform one or more specific processing operations on the packet header during the execution of the computer-readable instruction set, wherein the header change processor is configured to: trigger an accelerator engine among the one or more accelerator engines at least by issuing a native CPU instruction of a processing node of the header change processor, wherein the native CPU instruction is mapped to an accelerator trigger instruction based on an address indicated in the native CPU instruction to trigger the hardware accelerator engine.

31. The network device according to claim 20, further comprising: A packet processor configured to: i) receive a packet from a network link, the packet comprising a packet header and a payload; and ii) determining at least one egress interface via which the packet is to be transmitted by the network device; as well as a programmable header alteration processor coupled to a program memory, the programmable header alteration processor configured to execute computer-readable instructions stored in the program memory to perform one or more header alteration operations on a packet header of a received packet, the programmable header alteration processor configured to: during processing of a packet header of a received packet, trigger a hardware checksum accelerator engine to calculate a checksum for a bit string corresponding to at least a portion of the packet header, the programmable header alteration processor configured to: dividing the bit string into a plurality of segments of the bit string, and transmitting the plurality of segments of the bit string to the hardware checksum acceleration engine; in: The hardware checksum accelerator engine is configured to incrementally calculate the checksum at least by incrementally summing corresponding segments among the plurality of segments of the bit string transmitted to the hardware checksum accelerator engine; as well as The packet processor is further configured to cause the packet having a modified header including the checksum to be transmitted via the at least one egress interface of the network device.

32. The network device of claim 31 , wherein the programmable header alteration processor is configured to: generating a corresponding trigger instruction to transmit a corresponding segment of the plurality of segments of the bit string to the hardware checksum accelerator engine, and The corresponding trigger instructions are provided serially to the hardware checksum accelerator engine.

33. A network device according to claim 31, wherein the programmable header change processor is configured to: trigger the hardware checksum accelerator engine at least by issuing one or more native CPU instructions supported by the programmable header change processor, wherein based on an address indicated in the native CPU instruction, each of the one or more native CPU instructions is mapped to an accelerator trigger instruction for triggering the hardware checksum accelerator engine.

34. The network device of claim 31 , wherein the hardware checksum accelerator engine is configured to incrementally compute the checksum at least by summing the plurality of segments over a plurality of summing stages, the hardware checksum accelerator engine being configured to: storing a result of a previous summing stage in an accumulator, the result of the previous summing stage corresponding to a sum of two or more of the plurality of segments transmitted to the hardware checksum accelerator engine, and In a subsequent summation stage, the result of the previous summation stage stored in the accumulator is summed with a subsequent segment among the plurality of segments transmitted to the hardware checksum accelerator engine.

35. The network device of claim 34, wherein the hardware checksum accelerator engine is further configured to pack one or more carry bits generated in the previous summation stage back into the accumulator in the same clock cycle in which the previous summation stage is executed by the hardware checksum accelerator engine.

36. The network device of claim 31 , wherein the hardware checksum accelerator engine is further configured to: determining whether the checksum is to be negated based on information provided by the programmable header alteration processor to the hardware checksum accelerator engine, and In response to determining that the checksum is to be negated, the checksum is negated before outputting the checksum.

37. The network device of claim 31, wherein: The programmable header alteration processor is further configured to: provide to the hardware checksum accelerator engine an indication of a memory location in memory where the checksum is to be written, and The hardware checksum accelerator engine is further configured to cause the checksum to be written to the indicated memory location in the memory.

38. A network device according to claim 31, wherein the programmable header change processor is configured to trigger the hardware checksum accelerator engine to calculate the checksum for one of the following: i) an Internet Protocol (IP) header included in the packet header, ii) a User Datagram Protocol (UDP) header included in the packet header, or iii) a Generic UDP Encapsulation (GUE) header included in the packet header.