# A Programmable SRv6 Processor for SFC
## 3 Protocol-Independent Pipeline Design
### Programmable SR Forwarding for Network Slice
#### 3.4.1. SRv6 Mapping in Processor  
The SRv6 [28], namely SR+IPv6, adopts the existing IPv6 forwarding technology and realizes network programming through the flexible IPv6 extension header. To implement SR technology on the IPv6 forwarding plane, SRv6 adds an SRH extension header in the IPv6 route extension header, which specifies an explicit IPv6 path and stores IPv6 segment list information. During packet forwarding, the segments left and segment list fields jointly determine the IPv6 destination address (DA) information to guide packet forwarding paths and behaviors. In this paper, we have enabled SRv6 forwarding by extending the deparser module in the RMT pipeline to deparser plus. Figure 3 shows the mapping of the SRv6 packet forwarding process on the pipeline using the source node as an example. Ingress RMT is responsible for parsing the packet, extracting its flow ID, and writing in metadata, which indicates if it is a packet that needs to be inserted into the SRH, before sending it to the deparser plus module. In the deparser plus module, the metadata determines the type of message. If the packet is a source node SRv6 packet, the metadata searches for the action table based on the flow ID and packet type, obtains insert instructions, and configures the PDT. The instruction contains the insert opcode, offset, index of mapping table, length of inserted data, and packet length field offset. The PDT module obtains the SRH through the index of mapping table, invokes the action module to insert the SRH into the IPv6 packet through the offset and offset length in the insert instruction, and adds the corresponding length value to the payload length field in the IPv6 packet header. The egress RMT performs normal SRv6 packet processing, such as replacing the destination IP address, rewriting the segment left field, and replacing the MAC address. The egress RMT searches the forwarding table to obtain the output port and sends out the SRv6 packet. The P4 program is used to describe the specific processing behavior of processor to SRv6 packets, as shown in Algorithm 1. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Operation** & **Description** & **Format** \\ \hline insert & Insert data in the corresponding & \begin{tabular}{c} \{opcode, offset, mapping table index, \\ inserted data length, packet length \\ field offset\} \\ \end{tabular} \\ \hline delete & \begin{tabular}{c} Delete data in the corresponding \\ position of the packet header \\ \end{tabular} & \begin{tabular}{c} \{opcode, offset, deleted data length, \\ packet length field offset\} \\ \end{tabular} \\ \hline compress & \begin{tabular}{c} Compress the corresponding \\ fields in the packet header \\ \end{tabular} & \begin{tabular}{c} \{opcode, SID prefix, SID length, \\ packet length field offset\} \\ \end{tabular} \\ \hline decompress & \begin{tabular}{c} Decompress the corresponding \\ fields in the packet header \\ \end{tabular} & \begin{tabular}{c} \{opcode, uSID prefix, uSID length, \\ packet length field offset\} \\ \end{tabular} \\ \hline encapsulate & \begin{tabular}{c} Encapsulate header \\ \end{tabular} & \begin{tabular}{c} \{opcode, encapsulated info, offset of \\ altered field, altered field info, packet \\ length field offset\} \\ \end{tabular} \\ \hline decapsulate & \begin{tabular}{c} Decapsulate packet header \\ \end{tabular} & \
\begin{tabular}{c} \{opcode, offset of encapsulated info, \\ offset of altered field, altered field, \\ packet length field offset\} \\ \end{tabular} \\ \hline alter & Alter action table &
\begin{tabular}{c} \{opcode, action table index, \\ instruction length, altered instruction\} \\ \end{tabular} \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Deparser plus instruction definition.