Fixed Parser
The framework provides a default hardware parser for common packet types and packet structures. When the protocols supported by the hardware parser meet user requirements, you can use the hdr_fix_parser provided in the hydra_parser.hdr architecture file instead of implementing a custom parser. In this case, parsing is executed by the hardware, which simplifies programming and enhances performance.
Hardware Parser
The default protocols supported by the hardware parser are as follows:
header_union l3_union_t {
ipv4_t ipv4;
ipv6_t ipv6;
}
header_union l4_union_t {
tcp_t tcp;
udp_t udp;
icmp_t icmp;
}
header_union tunnel_union_t {
vxlan_t vxlan;
geneve_t geneve;
nvgre_t nvgre;
}
struct hdr_fix_headers {
ethernet_t ethernet;
vlan_t vlan;
l3_union_t l3;
l4_union_t l4;
tunnel_union_t tunnel;
ethernet_t inner_ethernet;
vlan_t inner_vlan;
l3_union_t inner_l3;
l4_union_t inner_l4;
}
Scenario |
Packet Type |
Maximum Parsing Depth |
Remarks |
|---|---|---|---|
Non-tunneled packets |
TCP (TSO), UDP (UFO), ICMP |
L4 |
None |
IPv4, IPv6 |
L3 |
None |
|
Other |
L2 |
None |
|
Tunneled packets |
VXLAN, GENEVE |
The outer tunnel headers are fully parsed, while the inner tunnel layers are processed similarly to non-tunneled packet scenarios. |
Tunnels with more than two layers are not supported. |
IPIP, GRE |
Outer L3 |
None |
Example
- You can use hdr_fix_parser() as the parser component to instantiate the package. In this case, the hdr_fix_headers structure needs to be passed as an input parameter of control to enable the utilization of the parsing results within the control logic.
- You cannot customize the hdr_fix_headers structure or the hdr_fix_parser component. The compiler will check the structure and parser component accordingly.
The following is an example of using the fixed parser:
control MyPrePipe(in hdr_fix_headers hdr) {
/* body omitted*/
}
control MyPostPipe(in hdr_fix_headers hdr) {
/* body omitted*/
}
RX_OVS(
hdr_fix_parser(),
MyPrePipe(),
MyPostPipe()
) main;