2019-07-10 07:07:17 +00:00
|
|
|
#ifndef NICO_EGRESS
|
|
|
|
#define NICO_EGRESS
|
|
|
|
|
2019-07-24 09:57:57 +00:00
|
|
|
#include "settings.p4"
|
|
|
|
|
2019-07-24 09:56:27 +00:00
|
|
|
/********************** EGRESS ACTIONS ***********************************/
|
2019-07-10 07:07:17 +00:00
|
|
|
|
2019-07-10 20:28:37 +00:00
|
|
|
action set_egress_port (port_t out_port) {
|
|
|
|
#ifndef _SUME_SWITCH_P4_
|
|
|
|
standard_metadata.egress_spec = out_port;
|
|
|
|
#else
|
|
|
|
sume_metadata.dst_port = out_port;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
action set_egress_port_and_mac (port_t out_port, mac_addr_t mac_addr) {
|
|
|
|
hdr.ethernet.dst_addr = mac_addr;
|
|
|
|
set_egress_port(out_port);
|
|
|
|
}
|
|
|
|
|
2019-07-24 09:56:27 +00:00
|
|
|
/********************** GENERAL ACTIONS ***********************************/
|
|
|
|
|
|
|
|
#ifndef _SUME_SWITCH_P4_
|
|
|
|
action controller_reply(task_t task) {
|
|
|
|
meta.task = task;
|
|
|
|
meta.ingress_port = standard_metadata.ingress_port;
|
|
|
|
clone3(CloneType.I2E, 100, meta);
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
action controller_reply(task_t task) {
|
|
|
|
meta.task = task;
|
|
|
|
meta.ingress_port = sume_metadata.src_port;
|
|
|
|
set_egress_port(4); /* port1 = 1, port2 = 2, port3=4 */
|
|
|
|
}
|
|
|
|
#endif /* _SUME_SWITCH_P4_ */
|
|
|
|
|
|
|
|
action controller_debug_table_id(table_t table_id) {
|
|
|
|
meta.table_id = table_id;
|
|
|
|
controller_reply(TASK_DEBUG);
|
|
|
|
}
|
|
|
|
|
|
|
|
action controller_debug() {
|
|
|
|
controller_reply(TASK_DEBUG);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/********************** ROUTING (egress definiton) TABLES ***********************************/
|
|
|
|
|
|
|
|
|
2019-07-10 20:28:37 +00:00
|
|
|
table v6_networks {
|
|
|
|
key = {
|
2019-07-24 20:38:55 +00:00
|
|
|
#ifndef _SUME_SWITCH_P4_
|
2019-07-10 20:28:37 +00:00
|
|
|
hdr.ipv6.dst_addr: lpm;
|
2019-07-24 20:38:55 +00:00
|
|
|
#else
|
|
|
|
hdr.ipv6.dst_addr: exact;
|
|
|
|
#endif
|
2019-07-10 07:07:17 +00:00
|
|
|
}
|
2019-07-10 20:28:37 +00:00
|
|
|
actions = {
|
|
|
|
set_egress_port;
|
|
|
|
set_egress_port_and_mac;
|
|
|
|
controller_debug;
|
|
|
|
controller_reply;
|
|
|
|
controller_debug_table_id;
|
|
|
|
NoAction;
|
|
|
|
}
|
|
|
|
size = ROUTING_TABLE_SIZE;
|
2019-07-10 07:07:17 +00:00
|
|
|
|
2019-07-24 20:52:23 +00:00
|
|
|
#ifndef _SUME_SWITCH_P4_
|
2019-07-10 20:28:37 +00:00
|
|
|
default_action = controller_debug_table_id(TABLE_V6_NETWORKS);
|
2019-07-24 20:52:23 +00:00
|
|
|
#else
|
|
|
|
default_action = controller_debug;
|
|
|
|
#endif
|
|
|
|
|
2019-07-10 20:28:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
table v4_networks {
|
|
|
|
key = {
|
2019-07-24 20:38:55 +00:00
|
|
|
#ifndef _SUME_SWITCH_P4_
|
2019-07-10 20:28:37 +00:00
|
|
|
hdr.ipv4.dst_addr: lpm;
|
2019-07-24 20:38:55 +00:00
|
|
|
#else
|
|
|
|
hdr.ipv4.dst_addr: exact;
|
|
|
|
#endif
|
2019-07-10 07:07:17 +00:00
|
|
|
}
|
2019-07-10 20:28:37 +00:00
|
|
|
actions = {
|
|
|
|
set_egress_port;
|
|
|
|
set_egress_port_and_mac;
|
|
|
|
controller_debug;
|
2019-07-28 10:16:48 +00:00
|
|
|
controller_reply;
|
2019-07-10 20:28:37 +00:00
|
|
|
controller_debug_table_id;
|
|
|
|
NoAction;
|
2019-07-10 07:07:17 +00:00
|
|
|
}
|
2019-07-10 20:28:37 +00:00
|
|
|
size = ROUTING_TABLE_SIZE;
|
2019-07-24 20:52:23 +00:00
|
|
|
|
|
|
|
#ifndef _SUME_SWITCH_P4_
|
2019-07-10 20:28:37 +00:00
|
|
|
default_action = controller_debug_table_id(TABLE_V4_NETWORKS);
|
2019-07-24 20:52:23 +00:00
|
|
|
#else
|
|
|
|
default_action = controller_debug;
|
|
|
|
#endif
|
2019-07-10 20:28:37 +00:00
|
|
|
}
|
2019-07-10 07:07:17 +00:00
|
|
|
#endif
|