blob: 9b820e1866c8e1464fad71c578ef9dd791d573ee [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 __TABLE0__
18#define __TABLE0__
19
20#include "headers.p4"
21#include "defines.p4"
22
23control table0_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) table0_counter;
28
29 action set_next_hop_id(next_hop_id_t next_hop_id) {
30 local_metadata.next_hop_id = next_hop_id;
31 }
32
Keesjan Karsten23368892018-05-22 10:46:01 +000033 action send_to_cpu() {
34 standard_metadata.egress_spec = CPU_PORT;
35 }
36
37 action set_egress_port(port_t port) {
38 standard_metadata.egress_spec = port;
39 }
40
Carmelo Cascone9b607da2019-05-08 14:03:01 -070041 action drop() {
42 mark_to_drop(standard_metadata);
43 }
44
Carmelo Casconeca94bcf2017-10-27 14:16:59 -070045 table table0 {
46 key = {
47 standard_metadata.ingress_port : ternary;
48 hdr.ethernet.src_addr : ternary;
49 hdr.ethernet.dst_addr : ternary;
50 hdr.ethernet.ether_type : ternary;
51 hdr.ipv4.src_addr : ternary;
52 hdr.ipv4.dst_addr : ternary;
53 hdr.ipv4.protocol : ternary;
54 local_metadata.l4_src_port : ternary;
55 local_metadata.l4_dst_port : ternary;
56 }
57 actions = {
Keesjan Karsten23368892018-05-22 10:46:01 +000058 set_egress_port;
59 send_to_cpu;
60 set_next_hop_id;
Carmelo Cascone9b607da2019-05-08 14:03:01 -070061 drop;
Carmelo Casconeca94bcf2017-10-27 14:16:59 -070062 }
Carmelo Cascone9b607da2019-05-08 14:03:01 -070063 const default_action = drop();
Carmelo Casconeca94bcf2017-10-27 14:16:59 -070064 counters = table0_counter;
65 }
66
67 apply {
68 table0.apply();
69 }
70}
71
72#endif