Skip to content

Commit 2426e18

Browse files
[fmt] format all-over-the-place P4 code
1 parent 4a945a8 commit 2426e18

File tree

5 files changed

+3879
-3883
lines changed

5 files changed

+3879
-3883
lines changed

dpd/p4/constants.p4

Lines changed: 62 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -6,60 +6,60 @@ const bit<16> L2_ISOLATED_FLAG = 0x8000;
66
// NOTE: safe to include geneve ox_external_tag here as it is filled
77
// on nat_ingress, and nat_checksum is only computer on nat_ingress.
88
#define COMMON_FIELDS \
9-
meta.body_checksum, \
10-
hdr.inner_eth, \
11-
hdr.geneve, \
12-
hdr.geneve_opts.ox_external_tag, \
13-
hdr.udp.src_port, \
14-
hdr.udp.dst_port, \
15-
hdr.udp.hdr_length, \
16-
(bit<16>)hdr.ipv6.next_hdr, \
17-
hdr.ipv6.src_addr, \
18-
hdr.ipv6.dst_addr, \
19-
hdr.ipv6.payload_len
9+
meta.body_checksum, \
10+
hdr.inner_eth, \
11+
hdr.geneve, \
12+
hdr.geneve_opts.ox_external_tag, \
13+
hdr.udp.src_port, \
14+
hdr.udp.dst_port, \
15+
hdr.udp.hdr_length, \
16+
(bit<16>)hdr.ipv6.next_hdr, \
17+
hdr.ipv6.src_addr, \
18+
hdr.ipv6.dst_addr, \
19+
hdr.ipv6.payload_len
2020

2121
// Includes the final bit of the inner ipv4 pseudo-header and the inner ipv4
2222
// header
2323
#define IPV4_FIELDS \
24-
meta.l4_length, \
25-
hdr.inner_ipv4
24+
meta.l4_length, \
25+
hdr.inner_ipv4
2626

2727
// Includes the inner ipv6 header
2828
#define IPV6_FIELDS \
29-
hdr.inner_ipv6
29+
hdr.inner_ipv6
3030

3131
// TODO: these all need to be bigger. Early experimentation is showing that this
3232
// is going to need to come either through ATCAM/ALPM or code restructuring.
33-
const int IPV4_NAT_TABLE_SIZE = 1024; // nat routing table
34-
const int IPV6_NAT_TABLE_SIZE = 1024; // nat routing table
35-
const int IPV4_LPM_SIZE = 8192; // ipv4 forwarding table
36-
const int IPV6_LPM_SIZE = 1024; // ipv6 forwarding table
37-
const int IPV4_ARP_SIZE = 512; // arp cache
38-
const int IPV6_NEIGHBOR_SIZE = 512; // ipv6 neighbor cache
39-
const int SWITCH_IPV4_ADDRS_SIZE = 512; // ipv4 addrs assigned to our ports
40-
const int SWITCH_IPV6_ADDRS_SIZE = 512; // ipv6 addrs assigned to our ports
33+
const int IPV4_NAT_TABLE_SIZE = 1024; // nat routing table
34+
const int IPV6_NAT_TABLE_SIZE = 1024; // nat routing table
35+
const int IPV4_LPM_SIZE = 8192; // ipv4 forwarding table
36+
const int IPV6_LPM_SIZE = 1024; // ipv6 forwarding table
37+
const int IPV4_ARP_SIZE = 512; // arp cache
38+
const int IPV6_NEIGHBOR_SIZE = 512; // ipv6 neighbor cache
39+
const int SWITCH_IPV4_ADDRS_SIZE = 512; // ipv4 addrs assigned to our ports
40+
const int SWITCH_IPV6_ADDRS_SIZE = 512; // ipv6 addrs assigned to our ports
4141

42-
const int MULTICAST_TABLE_SIZE = 1024; // multicast routing table(s) for ip4/ip6 separately
43-
const int MULTICAST_NAT_TABLE_SIZE = 2048; // multicast NAT table (ipv4 + ipv6)
42+
const int MULTICAST_TABLE_SIZE = 1024; // multicast routing table(s) for ip4/ip6 separately
43+
const int MULTICAST_NAT_TABLE_SIZE = 2048; // multicast NAT table (ipv4 + ipv6)
4444

45-
const bit<8> SC_FWD_FROM_USERSPACE = 0x00;
46-
const bit<8> SC_FWD_TO_USERSPACE = 0x01;
47-
const bit<8> SC_ICMP_NEEDED = 0x02;
48-
const bit<8> SC_ARP_NEEDED = 0x03;
49-
const bit<8> SC_NEIGHBOR_NEEDED = 0x04;
50-
const bit<8> SC_INVALID = 0xff;
45+
const bit<8> SC_FWD_FROM_USERSPACE = 0x00;
46+
const bit<8> SC_FWD_TO_USERSPACE = 0x01;
47+
const bit<8> SC_ICMP_NEEDED = 0x02;
48+
const bit<8> SC_ARP_NEEDED = 0x03;
49+
const bit<8> SC_NEIGHBOR_NEEDED = 0x04;
50+
const bit<8> SC_INVALID = 0xff;
5151

5252
/* Flags used for per-packet-type counters */
53-
const bit<10> PKT_ETHER = 0x200;
54-
const bit<10> PKT_LLDP = 0x100;
55-
const bit<10> PKT_VLAN = 0x080;
56-
const bit<10> PKT_SIDECAR = 0x040;
57-
const bit<10> PKT_ICMP = 0x020;
58-
const bit<10> PKT_IPV4 = 0x010;
59-
const bit<10> PKT_IPV6 = 0x008;
60-
const bit<10> PKT_UDP = 0x004;
61-
const bit<10> PKT_TCP = 0x002;
62-
const bit<10> PKT_ARP = 0x001;
53+
const bit<10> PKT_ETHER = 0x200;
54+
const bit<10> PKT_LLDP = 0x100;
55+
const bit<10> PKT_VLAN = 0x080;
56+
const bit<10> PKT_SIDECAR = 0x040;
57+
const bit<10> PKT_ICMP = 0x020;
58+
const bit<10> PKT_IPV4 = 0x010;
59+
const bit<10> PKT_IPV6 = 0x008;
60+
const bit<10> PKT_UDP = 0x004;
61+
const bit<10> PKT_TCP = 0x002;
62+
const bit<10> PKT_ARP = 0x001;
6363

6464
/* Indexes into the service_ctr table */
6565
const bit<8> SVC_COUNTER_FW_TO_USER = 0;
@@ -70,26 +70,25 @@ const bit<8> SVC_COUNTER_BAD_PING = 4;
7070
const bit<32> SVC_COUNTER_MAX = 5;
7171

7272
/* Reasons a packet may be dropped by the p4 pipeline */
73-
const bit<8> DROP_IPV4_SWITCH_ADDR_MISS = 0x01;
74-
const bit<8> DROP_IPV6_SWITCH_ADDR_MISS = 0x02;
75-
const bit<8> DROP_BAD_PING = 0x03;
76-
const bit<8> DROP_NAT_HEADER_ERROR = 0x04;
77-
const bit<8> DROP_ARP_NULL = 0x05;
78-
const bit<8> DROP_ARP_MISS
79-
= 0x06;
80-
const bit<8> DROP_NDP_NULL = 0x07;
81-
const bit<8> DROP_NDP_MISS = 0x08;
82-
const bit<8> DROP_MULTICAST_TO_LOCAL_INTERFACE = 0x09;
83-
const bit<8> DROP_IPV4_CHECKSUM_ERR = 0x0A;
84-
const bit<8> DROP_IPV4_TTL_INVALID = 0x0B;
85-
const bit<8> DROP_IPV4_TTL_EXCEEDED = 0x0C;
86-
const bit<8> DROP_IPV6_TTL_INVALID = 0x0D;
87-
const bit<8> DROP_IPV6_TTL_EXCEEDED = 0x0E;
88-
const bit<8> DROP_IPV4_UNROUTEABLE = 0x0F;
89-
const bit<8> DROP_IPV6_UNROUTEABLE = 0x10;
90-
const bit<8> DROP_NAT_INGRESS_MISS = 0x11;
91-
const bit<8> DROP_MULTICAST_NO_GROUP = 0x12;
92-
const bit<8> DROP_MULTICAST_INVALID_MAC = 0x13;
93-
const bit<8> DROP_MULTICAST_CPU_COPY = 0x14;
94-
const bit<8> DROP_MULTICAST_SOURCE_FILTERED = 0x15;
95-
const bit<32> DROP_REASON_MAX = 0x16;
73+
const bit<8> DROP_IPV4_SWITCH_ADDR_MISS = 0x01;
74+
const bit<8> DROP_IPV6_SWITCH_ADDR_MISS = 0x02;
75+
const bit<8> DROP_BAD_PING = 0x03;
76+
const bit<8> DROP_NAT_HEADER_ERROR = 0x04;
77+
const bit<8> DROP_ARP_NULL = 0x05;
78+
const bit<8> DROP_ARP_MISS = 0x06;
79+
const bit<8> DROP_NDP_NULL = 0x07;
80+
const bit<8> DROP_NDP_MISS = 0x08;
81+
const bit<8> DROP_MULTICAST_TO_LOCAL_INTERFACE = 0x09;
82+
const bit<8> DROP_IPV4_CHECKSUM_ERR = 0x0A;
83+
const bit<8> DROP_IPV4_TTL_INVALID = 0x0B;
84+
const bit<8> DROP_IPV4_TTL_EXCEEDED = 0x0C;
85+
const bit<8> DROP_IPV6_TTL_INVALID = 0x0D;
86+
const bit<8> DROP_IPV6_TTL_EXCEEDED = 0x0E;
87+
const bit<8> DROP_IPV4_UNROUTEABLE = 0x0F;
88+
const bit<8> DROP_IPV6_UNROUTEABLE = 0x10;
89+
const bit<8> DROP_NAT_INGRESS_MISS = 0x11;
90+
const bit<8> DROP_MULTICAST_NO_GROUP = 0x12;
91+
const bit<8> DROP_MULTICAST_INVALID_MAC = 0x13;
92+
const bit<8> DROP_MULTICAST_CPU_COPY = 0x14;
93+
const bit<8> DROP_MULTICAST_SOURCE_FILTERED = 0x15;
94+
const bit<32> DROP_REASON_MAX = 0x16;

0 commit comments

Comments
 (0)