blob: 9d6e00fccf628a101aa7b4a0eceeb95973b02c21 [file] [log] [blame]
Carmelo Casconeca94bcf2017-10-27 14:16:59 -07001/*
2 * Copyright 2017-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef __WCMP__
18#define __WCMP__
19
20#include "headers.p4"
21#include "defines.p4"
22
23control wcmp_control(inout headers_t hdr,
24 inout local_metadata_t local_metadata,
25 inout standard_metadata_t standard_metadata) {
26
27 direct_counter(CounterType.packets_and_bytes) wcmp_table_counter;
28 action_selector(HashAlgorithm.crc16, 32w64, 32w16) wcmp_selector;
29
30 table wcmp_table {
31 support_timeout = false;
32 key = {
33 local_metadata.next_hop_id : exact;
34 hdr.ipv4.src_addr : selector;
35 hdr.ipv4.dst_addr : selector;
36 hdr.ipv4.protocol : selector;
37 local_metadata.l4_src_port : selector;
38 local_metadata.l4_dst_port : selector;
39 }
40 actions = {
41 set_egress_port(standard_metadata);
42 }
43 implementation = wcmp_selector;
44 counters = wcmp_table_counter;
45 }
46
47 apply {
48 if (local_metadata.next_hop_id != 0) {
49 wcmp_table.apply();
50 }
51 }
52}
53
54#endif