-
-
Save rafaelsilvag/727507e96849af3de7ad10082c7d7f86 to your computer and use it in GitHub Desktop.
add PolKA to RARE/Freertr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -Nur '--exclude=.git' misc/rare/p4src/bf_router.p4 rare/p4src/bf_router.p4 | |
--- misc/rare/p4src/bf_router.p4 2021-04-02 15:34:31.941853914 -0300 | |
+++ rare/p4src/bf_router.p4 2021-03-24 10:44:37.019907672 -0300 | |
@@ -27,6 +27,7 @@ | |
#include "include/cst_ip_protocol.p4" | |
#include "include/hdr_cpu.p4" | |
#include "include/hdr_bier.p4" | |
+#include "include/hdr_polka.p4" | |
#include "include/hdr_internal.p4" | |
#include "include/hdr_ethernet.p4" | |
#include "include/hdr_arp.p4" | |
@@ -66,6 +67,7 @@ | |
#include "include/ig_ctl_vrf.p4" | |
#include "include/ig_ctl_bridge.p4" | |
#include "include/ig_ctl_mpls.p4" | |
+#include "include/ig_ctl_polka.p4" | |
#include "include/ig_ctl_ipv4.p4" | |
#include "include/ig_ctl_ipv6.p4" | |
#include "include/ig_ctl_ipv4b.p4" | |
diff -Nur '--exclude=.git' misc/rare/p4src/include/cst_ethertype.p4 rare/p4src/include/cst_ethertype.p4 | |
--- misc/rare/p4src/include/cst_ethertype.p4 2021-04-02 15:34:31.941853914 -0300 | |
+++ rare/p4src/include/cst_ethertype.p4 2021-03-26 14:36:06.219252944 -0300 | |
@@ -32,6 +32,7 @@ | |
const bit<16> ETHERTYPE_PPPOE_DATA = 0x8864; | |
const bit<16> ETHERTYPE_ROUTEDMAC = 0x6558; | |
const bit<16> ETHERTYPE_ROUTEDMAC_INT = 0x6559; | |
+const bit<16> ETHERTYPE_POLKA = 0x1234; | |
const bit<16> PPPTYPE_IPV4 = 0x0021; | |
const bit<16> PPPTYPE_IPV6 = 0x0057; | |
diff -Nur '--exclude=.git' misc/rare/p4src/include/cst_table_size.p4 rare/p4src/include/cst_table_size.p4 | |
--- misc/rare/p4src/include/cst_table_size.p4 2021-04-02 15:34:31.941853914 -0300 | |
+++ rare/p4src/include/cst_table_size.p4 2021-03-24 10:44:37.019907672 -0300 | |
@@ -40,6 +40,7 @@ | |
#define MAC_TABLE_SIZE 512 | |
#define BUNDLE_TABLE_SIZE 512 | |
#define VLAN_TABLE_SIZE 512 | |
+#define POLKA_CONF_TABLE_SIZE 32 | |
#define NEXTHOP_TABLE_SIZE 1024 | |
#define PPPOE_TABLE_SIZE 512 | |
diff -Nur '--exclude=.git' misc/rare/p4src/include/def_types.p4 rare/p4src/include/def_types.p4 | |
--- misc/rare/p4src/include/def_types.p4 2021-04-02 15:34:31.941853914 -0300 | |
+++ rare/p4src/include/def_types.p4 2021-03-24 10:44:37.023907545 -0300 | |
@@ -32,6 +32,8 @@ | |
//typedef bit<9> PortId_t; | |
typedef bit<16> NextHopId_t; | |
typedef bit<10> SubIntId_t; | |
+typedef bit<16> nodeid_t; | |
+typedef bit<128> routeid_t; | |
#define MAX_PORT 1023 | |
diff -Nur '--exclude=.git' misc/rare/p4src/include/hdr_ig_headers.p4 rare/p4src/include/hdr_ig_headers.p4 | |
--- misc/rare/p4src/include/hdr_ig_headers.p4 2021-04-02 15:34:31.945853886 -0300 | |
+++ rare/p4src/include/hdr_ig_headers.p4 2021-03-24 10:44:37.023907545 -0300 | |
@@ -54,6 +54,9 @@ | |
bier_t bier; | |
#endif | |
#endif | |
+#ifdef HAVE_POLKA | |
+ polka_t polka; | |
+#endif | |
ethernet_t eth2; | |
arp_t arp; | |
llc_t llc; | |
diff -Nur '--exclude=.git' misc/rare/p4src/include/hdr_polka.p4 rare/p4src/include/hdr_polka.p4 | |
--- misc/rare/p4src/include/hdr_polka.p4 1969-12-31 21:00:00.000000000 -0300 | |
+++ rare/p4src/include/hdr_polka.p4 2021-03-24 11:07:32.971176310 -0300 | |
@@ -0,0 +1,27 @@ | |
+/* | |
+ * Copyright 2021-present Universidade Federal do Espirito Santo (UFES) and | |
+ * Instituto Federal do Espirito Santo (IFES) | |
+ * | |
+ * Licensed under the Apache License, Version 2.0 (the "License"); | |
+ * you may not use this file except in compliance with the License. | |
+ * You may obtain a copy of the License at | |
+ * | |
+ * http://www.apache.org/licenses/LICENSE-2.0 | |
+ * | |
+ * Unless required by applicable law or agreed to in writing, software | |
+ * distributed under the License is distributed On an "AS IS" BASIS, | |
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
+ * See the License for the specific language governing permissions and | |
+ * limitations under the License. | |
+ */ | |
+ | |
+#ifndef _POLKA_P4_ | |
+#define _POLKA_P4_ | |
+ | |
+header polka_t { | |
+ bit<16> version; | |
+ bit<16> proto; | |
+ routeid_t routeid; | |
+} | |
+ | |
+#endif // _POLKA_P4_ | |
diff -Nur '--exclude=.git' misc/rare/p4src/include/ig_ctl.p4 rare/p4src/include/ig_ctl.p4 | |
--- misc/rare/p4src/include/ig_ctl.p4 2021-04-02 15:34:31.945853886 -0300 | |
+++ rare/p4src/include/ig_ctl.p4 2021-03-24 10:44:37.023907545 -0300 | |
@@ -69,6 +69,9 @@ | |
#ifdef HAVE_INACL | |
IngressControlAclIn() ig_ctl_acl_in; | |
#endif | |
+#ifdef HAVE_POLKA | |
+ IngressControlPolKA() ig_ctl_polka; | |
+#endif | |
IngressControlVlanIn()ig_ctl_vlan_in; | |
IngressControlVRF()ig_ctl_vrf; | |
#ifdef HAVE_NAT | |
@@ -133,6 +136,11 @@ | |
#ifdef HAVE_MPLS | |
ig_ctl_mpls.apply(hdr, ig_md, ig_intr_md, ig_dprsr_md, ig_tm_md); | |
#endif | |
+#ifdef HAVE_POLKA | |
+ if (ig_md.polka_valid == 1){ | |
+ ig_ctl_polka.apply(hdr, ig_md, ig_intr_md, ig_dprsr_md, ig_tm_md); | |
+ } | |
+#endif | |
#ifdef HAVE_FLOWSPEC | |
ig_ctl_flowspec.apply(hdr, ig_md, ig_intr_md, ig_dprsr_md, ig_tm_md); | |
#endif | |
diff -Nur '--exclude=.git' misc/rare/p4src/include/ig_ctl_polka.p4 rare/p4src/include/ig_ctl_polka.p4 | |
--- misc/rare/p4src/include/ig_ctl_polka.p4 1969-12-31 21:00:00.000000000 -0300 | |
+++ rare/p4src/include/ig_ctl_polka.p4 2021-04-02 15:37:02.804869221 -0300 | |
@@ -0,0 +1,128 @@ | |
+/* | |
+ * Copyright 2019-present Universidade Federal do Espirito Santo (UFES) and | |
+ * Instituto Federal do Espirito Santo (IFES) | |
+ * | |
+ * Licensed under the Apache License, Version 2.0 (the "License"); | |
+ * you may not use this file except in compliance with the License. | |
+ * You may obtain a copy of the License at | |
+ * | |
+ * http://www.apache.org/licenses/LICENSE-2.0 | |
+ * | |
+ * Unless required by applicable law or agreed to in writing, software | |
+ * distributed under the License is distributed On an "AS IS" BASIS, | |
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
+ * See the License for the specific language governing permissions and | |
+ * limitations under the License. | |
+ */ | |
+ | |
+#ifndef _IG_CTL_POLKA_P4_ | |
+#define _IG_CTL_POLKA_P4_ | |
+ | |
+control calc_polka( | |
+ inout headers hdr, | |
+ inout ingress_metadata_t ig_md)(nodeid_t coeff) | |
+{ | |
+ CRCPolynomial<bit<16>>( | |
+ coeff = coeff, | |
+ reversed = false, | |
+ msb = false, | |
+ extended = false, | |
+ init = 16w0x0000, | |
+ xor = 16w0x0000) poly; | |
+ Hash<bit<16>>(HashAlgorithm_t.CUSTOM, poly) hash_polka; | |
+ | |
+ action do_polka_nhop() { | |
+ bit<16> nbase=0; | |
+ bit<64> ncount=4294967296*2; | |
+ bit<16> nresult; | |
+ bit<16> nport; | |
+ // gets the routeId | |
+ routeid_t routeid = ig_md.polka_routeid; | |
+ routeid_t ndata = routeid >> 16; | |
+ | |
+ bit<16> dif = (bit<16>) (routeid ^ (ndata << 16)); | |
+ nresult = hash_polka.get((routeid_t) ndata); | |
+ | |
+ nport = nresult ^ dif; | |
+ ig_md.polka_portid = (SubIntId_t) nport; | |
+ } | |
+ | |
+ apply { | |
+ do_polka_nhop(); | |
+ } | |
+} | |
+ | |
+control IngressControlPolKA( | |
+ inout headers hdr, | |
+ inout ingress_metadata_t ig_md, | |
+ in ingress_intrinsic_metadata_t ig_intr_md, | |
+ inout ingress_intrinsic_metadata_for_deparser_t ig_dprsr_md, | |
+ inout ingress_intrinsic_metadata_for_tm_t ig_tm_md) | |
+{ | |
+ /* NodeID from 1 to 10 */ | |
+ calc_polka(coeff=16w0x002b) do_polka_1; | |
+ calc_polka(coeff=16w0x002d) do_polka_2; | |
+ calc_polka(coeff=16w0x0039) do_polka_3; | |
+ calc_polka(coeff=16w0x003f) do_polka_4; | |
+ calc_polka(coeff=16w0x0047) do_polka_5; | |
+ calc_polka(coeff=16w0x0053) do_polka_6; | |
+ calc_polka(coeff=16w0x008d) do_polka_7; | |
+ calc_polka(coeff=16w0x00bd) do_polka_8; | |
+ calc_polka(coeff=16w0x00d7) do_polka_9; | |
+ calc_polka(coeff=16w0x00f5) do_polka_10; | |
+ /* End NodeID */ | |
+ | |
+ action act_drop() { | |
+ ig_dprsr_md.drop_ctl = 1; | |
+ } | |
+ | |
+ action get_nodeid(nodeid_t nodeid) { | |
+ ig_md.polka_nodeid = (nodeid_t) nodeid; | |
+ ig_md.polka_nodeid_valid = 1; | |
+ } | |
+ | |
+ table tbl_polka_conf { | |
+ key = { | |
+ ig_md.polka_req_conf: | |
+ exact; | |
+ } | |
+ actions = { | |
+ get_nodeid; | |
+ } | |
+ size = POLKA_CONF_TABLE_SIZE; | |
+ } | |
+ | |
+ apply { | |
+ // Request nodeID | |
+ ig_md.polka_req_conf = 1; | |
+ if (tbl_polka_conf.apply().hit){ | |
+ if (ig_md.polka_nodeid_valid == 1){ | |
+ // calculate portID | |
+ if (ig_md.polka_nodeid == 1) | |
+ do_polka_1.apply(hdr, ig_md); | |
+ else if (ig_md.polka_nodeid == 2) | |
+ do_polka_2.apply(hdr, ig_md); | |
+ else if (ig_md.polka_nodeid == 3) | |
+ do_polka_3.apply(hdr, ig_md); | |
+ else if (ig_md.polka_nodeid == 4) | |
+ do_polka_4.apply(hdr, ig_md); | |
+ else if (ig_md.polka_nodeid == 5) | |
+ do_polka_5.apply(hdr, ig_md); | |
+ else if (ig_md.polka_nodeid == 6) | |
+ do_polka_6.apply(hdr, ig_md); | |
+ else if (ig_md.polka_nodeid == 7) | |
+ do_polka_7.apply(hdr, ig_md); | |
+ else if (ig_md.polka_nodeid == 8) | |
+ do_polka_8.apply(hdr, ig_md); | |
+ else if (ig_md.polka_nodeid == 9) | |
+ do_polka_9.apply(hdr, ig_md); | |
+ else if (ig_md.polka_nodeid == 10) | |
+ do_polka_10.apply(hdr, ig_md); | |
+ else | |
+ act_drop(); | |
+ } | |
+ } | |
+ } | |
+} | |
+ | |
+#endif // _IG_CTL_POLKA_P4_ | |
diff -Nur '--exclude=.git' misc/rare/p4src/include/ig_prs_clr.p4 rare/p4src/include/ig_prs_clr.p4 | |
--- misc/rare/p4src/include/ig_prs_clr.p4 2021-04-02 15:34:31.945853886 -0300 | |
+++ rare/p4src/include/ig_prs_clr.p4 2021-03-24 12:25:03.676476640 -0300 | |
@@ -61,6 +61,13 @@ | |
ig_md.mpls0_valid = 0; | |
ig_md.mpls1_valid = 0; | |
#endif | |
+ig_md.polka_valid = 0; | |
+ig_md.polka_nodeid_valid = 0; | |
+ig_md.polka_nodeid = 0; | |
+ig_md.polka_version = 0; | |
+ig_md.polka_req_conf = 0; | |
+ig_md.polka_routeid = 0; | |
+ig_md.polka_portid = 0; | |
ig_md.arp_valid = 0; | |
ig_md.ipv4_valid = 0; | |
ig_md.ipv6_valid = 0; | |
diff -Nur '--exclude=.git' misc/rare/p4src/include/ig_prs_hdr.p4 rare/p4src/include/ig_prs_hdr.p4 | |
--- misc/rare/p4src/include/ig_prs_hdr.p4 2021-04-02 15:34:31.945853886 -0300 | |
+++ rare/p4src/include/ig_prs_hdr.p4 2021-03-24 10:44:37.023907545 -0300 | |
@@ -29,6 +29,10 @@ | |
ETHERTYPE_ROUTEDMAC: | |
prs_eth6; | |
#endif | |
+#ifdef HAVE_POLKA | |
+ETHERTYPE_POLKA: | |
+ prs_polka; | |
+#endif | |
ETHERTYPE_ARP: | |
prs_arp; | |
ETHERTYPE_LACP: | |
@@ -67,6 +71,10 @@ | |
ETHERTYPE_ROUTEDMAC: | |
prs_eth6; | |
#endif | |
+#ifdef HAVE_POLKA | |
+ETHERTYPE_POLKA: | |
+ prs_polka; | |
+#endif | |
ETHERTYPE_ARP: | |
prs_arp; | |
ETHERTYPE_LACP: | |
@@ -182,6 +190,50 @@ | |
#endif | |
#endif | |
+#ifdef HAVE_POLKA | |
+state prs_polka { | |
+ pkt.extract(hdr.polka); | |
+ // begin - to get version and the routeId from the PolKA header | |
+ ig_md.polka_valid = 1; | |
+ ig_md.polka_version = hdr.polka.version; | |
+ ig_md.polka_routeid = hdr.polka.routeid; | |
+ // end | |
+ transition select(hdr.polka.proto) { | |
+0 &&& 0xfe00: | |
+ prs_llc; /* LLC SAP frame */ | |
+0 &&& 0xfa00: | |
+ prs_llc; /* LLC SAP frame */ | |
+#ifdef HAVE_PPPOE | |
+ETHERTYPE_PPPOE_CTRL : | |
+ prs_pppoeCtrl; | |
+ETHERTYPE_PPPOE_DATA : | |
+ prs_pppoeData; | |
+#endif | |
+#ifdef HAVE_MPLS | |
+ETHERTYPE_MPLS_UCAST: | |
+ prs_mpls0; | |
+#endif | |
+ETHERTYPE_IPV4: | |
+ prs_ipv4; | |
+ETHERTYPE_IPV6: | |
+ prs_ipv6; | |
+#ifdef HAVE_TAP | |
+ETHERTYPE_ROUTEDMAC_INT: | |
+ prs_eth2; | |
+ETHERTYPE_ROUTEDMAC: | |
+ prs_eth6; | |
+#endif | |
+ETHERTYPE_ARP: | |
+ prs_arp; | |
+ETHERTYPE_LACP: | |
+ prs_control; | |
+ETHERTYPE_LLDP: | |
+ prs_control; | |
+ default: | |
+ accept; | |
+ } | |
+} | |
+#endif | |
state prs_eth2 { | |
pkt.extract(hdr.eth2); | |
diff -Nur '--exclude=.git' misc/rare/p4src/include/mtd_ig_metadata.p4 rare/p4src/include/mtd_ig_metadata.p4 | |
--- misc/rare/p4src/include/mtd_ig_metadata.p4 2021-04-02 15:34:31.945853886 -0300 | |
+++ rare/p4src/include/mtd_ig_metadata.p4 2021-03-24 12:24:48.508522321 -0300 | |
@@ -57,6 +57,13 @@ | |
bit <1> srv_remove; | |
bit <1> saw_rsvp; | |
bit <1> bier_remove; | |
+ bit <1> polka_valid; | |
+ bit <1> polka_nodeid_valid; | |
+ nodeid_t polka_nodeid; | |
+ bit <16> polka_version; | |
+ bit <4> polka_req_conf; | |
+ routeid_t polka_routeid; | |
+ SubIntId_t polka_portid; | |
bit <1> mpls0_remove; | |
bit <1> mpls1_remove; | |
#ifdef NEED_REPLICA | |
diff -Nur '--exclude=.git' misc/rare/REFERENCE-LAB-MODEL/p4src/bf_router.p4 rare/REFERENCE-LAB-MODEL/p4src/bf_router.p4 | |
--- misc/rare/REFERENCE-LAB-MODEL/p4src/bf_router.p4 2021-04-02 15:34:31.941853914 -0300 | |
+++ rare/REFERENCE-LAB-MODEL/p4src/bf_router.p4 2021-03-24 10:44:37.019907672 -0300 | |
@@ -27,6 +27,7 @@ | |
#include "include/cst_ip_protocol.p4" | |
#include "include/hdr_cpu.p4" | |
#include "include/hdr_bier.p4" | |
+#include "include/hdr_polka.p4" | |
#include "include/hdr_internal.p4" | |
#include "include/hdr_ethernet.p4" | |
#include "include/hdr_arp.p4" | |
@@ -66,6 +67,7 @@ | |
#include "include/ig_ctl_vrf.p4" | |
#include "include/ig_ctl_bridge.p4" | |
#include "include/ig_ctl_mpls.p4" | |
+#include "include/ig_ctl_polka.p4" | |
#include "include/ig_ctl_ipv4.p4" | |
#include "include/ig_ctl_ipv6.p4" | |
#include "include/ig_ctl_ipv4b.p4" | |
diff -Nur '--exclude=.git' misc/rare/REFERENCE-LAB-MODEL/p4src/include/cst_ethertype.p4 rare/REFERENCE-LAB-MODEL/p4src/include/cst_ethertype.p4 | |
--- misc/rare/REFERENCE-LAB-MODEL/p4src/include/cst_ethertype.p4 2021-04-02 15:34:31.941853914 -0300 | |
+++ rare/REFERENCE-LAB-MODEL/p4src/include/cst_ethertype.p4 2021-03-26 14:36:06.219252944 -0300 | |
@@ -32,6 +32,7 @@ | |
const bit<16> ETHERTYPE_PPPOE_DATA = 0x8864; | |
const bit<16> ETHERTYPE_ROUTEDMAC = 0x6558; | |
const bit<16> ETHERTYPE_ROUTEDMAC_INT = 0x6559; | |
+const bit<16> ETHERTYPE_POLKA = 0x1234; | |
const bit<16> PPPTYPE_IPV4 = 0x0021; | |
const bit<16> PPPTYPE_IPV6 = 0x0057; | |
diff -Nur '--exclude=.git' misc/rare/REFERENCE-LAB-MODEL/p4src/include/cst_table_size.p4 rare/REFERENCE-LAB-MODEL/p4src/include/cst_table_size.p4 | |
--- misc/rare/REFERENCE-LAB-MODEL/p4src/include/cst_table_size.p4 2021-04-02 15:34:31.941853914 -0300 | |
+++ rare/REFERENCE-LAB-MODEL/p4src/include/cst_table_size.p4 2021-03-24 10:44:37.019907672 -0300 | |
@@ -40,6 +40,7 @@ | |
#define MAC_TABLE_SIZE 512 | |
#define BUNDLE_TABLE_SIZE 512 | |
#define VLAN_TABLE_SIZE 512 | |
+#define POLKA_CONF_TABLE_SIZE 32 | |
#define NEXTHOP_TABLE_SIZE 1024 | |
#define PPPOE_TABLE_SIZE 512 | |
diff -Nur '--exclude=.git' misc/rare/REFERENCE-LAB-MODEL/p4src/include/def_types.p4 rare/REFERENCE-LAB-MODEL/p4src/include/def_types.p4 | |
--- misc/rare/REFERENCE-LAB-MODEL/p4src/include/def_types.p4 2021-04-02 15:34:31.941853914 -0300 | |
+++ rare/REFERENCE-LAB-MODEL/p4src/include/def_types.p4 2021-03-24 10:44:37.023907545 -0300 | |
@@ -32,6 +32,8 @@ | |
//typedef bit<9> PortId_t; | |
typedef bit<16> NextHopId_t; | |
typedef bit<10> SubIntId_t; | |
+typedef bit<16> nodeid_t; | |
+typedef bit<128> routeid_t; | |
#define MAX_PORT 1023 | |
diff -Nur '--exclude=.git' misc/rare/REFERENCE-LAB-MODEL/p4src/include/hdr_ig_headers.p4 rare/REFERENCE-LAB-MODEL/p4src/include/hdr_ig_headers.p4 | |
--- misc/rare/REFERENCE-LAB-MODEL/p4src/include/hdr_ig_headers.p4 2021-04-02 15:34:31.945853886 -0300 | |
+++ rare/REFERENCE-LAB-MODEL/p4src/include/hdr_ig_headers.p4 2021-03-24 10:44:37.023907545 -0300 | |
@@ -54,6 +54,9 @@ | |
bier_t bier; | |
#endif | |
#endif | |
+#ifdef HAVE_POLKA | |
+ polka_t polka; | |
+#endif | |
ethernet_t eth2; | |
arp_t arp; | |
llc_t llc; | |
diff -Nur '--exclude=.git' misc/rare/REFERENCE-LAB-MODEL/p4src/include/hdr_polka.p4 rare/REFERENCE-LAB-MODEL/p4src/include/hdr_polka.p4 | |
--- misc/rare/REFERENCE-LAB-MODEL/p4src/include/hdr_polka.p4 1969-12-31 21:00:00.000000000 -0300 | |
+++ rare/REFERENCE-LAB-MODEL/p4src/include/hdr_polka.p4 2021-03-24 11:07:32.971176310 -0300 | |
@@ -0,0 +1,27 @@ | |
+/* | |
+ * Copyright 2021-present Universidade Federal do Espirito Santo (UFES) and | |
+ * Instituto Federal do Espirito Santo (IFES) | |
+ * | |
+ * Licensed under the Apache License, Version 2.0 (the "License"); | |
+ * you may not use this file except in compliance with the License. | |
+ * You may obtain a copy of the License at | |
+ * | |
+ * http://www.apache.org/licenses/LICENSE-2.0 | |
+ * | |
+ * Unless required by applicable law or agreed to in writing, software | |
+ * distributed under the License is distributed On an "AS IS" BASIS, | |
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
+ * See the License for the specific language governing permissions and | |
+ * limitations under the License. | |
+ */ | |
+ | |
+#ifndef _POLKA_P4_ | |
+#define _POLKA_P4_ | |
+ | |
+header polka_t { | |
+ bit<16> version; | |
+ bit<16> proto; | |
+ routeid_t routeid; | |
+} | |
+ | |
+#endif // _POLKA_P4_ | |
diff -Nur '--exclude=.git' misc/rare/REFERENCE-LAB-MODEL/p4src/include/ig_ctl.p4 rare/REFERENCE-LAB-MODEL/p4src/include/ig_ctl.p4 | |
--- misc/rare/REFERENCE-LAB-MODEL/p4src/include/ig_ctl.p4 2021-04-02 15:34:31.945853886 -0300 | |
+++ rare/REFERENCE-LAB-MODEL/p4src/include/ig_ctl.p4 2021-03-24 10:44:37.023907545 -0300 | |
@@ -69,6 +69,9 @@ | |
#ifdef HAVE_INACL | |
IngressControlAclIn() ig_ctl_acl_in; | |
#endif | |
+#ifdef HAVE_POLKA | |
+ IngressControlPolKA() ig_ctl_polka; | |
+#endif | |
IngressControlVlanIn()ig_ctl_vlan_in; | |
IngressControlVRF()ig_ctl_vrf; | |
#ifdef HAVE_NAT | |
@@ -133,6 +136,11 @@ | |
#ifdef HAVE_MPLS | |
ig_ctl_mpls.apply(hdr, ig_md, ig_intr_md, ig_dprsr_md, ig_tm_md); | |
#endif | |
+#ifdef HAVE_POLKA | |
+ if (ig_md.polka_valid == 1){ | |
+ ig_ctl_polka.apply(hdr, ig_md, ig_intr_md, ig_dprsr_md, ig_tm_md); | |
+ } | |
+#endif | |
#ifdef HAVE_FLOWSPEC | |
ig_ctl_flowspec.apply(hdr, ig_md, ig_intr_md, ig_dprsr_md, ig_tm_md); | |
#endif | |
diff -Nur '--exclude=.git' misc/rare/REFERENCE-LAB-MODEL/p4src/include/ig_ctl_polka.p4 rare/REFERENCE-LAB-MODEL/p4src/include/ig_ctl_polka.p4 | |
--- misc/rare/REFERENCE-LAB-MODEL/p4src/include/ig_ctl_polka.p4 1969-12-31 21:00:00.000000000 -0300 | |
+++ rare/REFERENCE-LAB-MODEL/p4src/include/ig_ctl_polka.p4 2021-04-02 15:37:02.804869221 -0300 | |
@@ -0,0 +1,128 @@ | |
+/* | |
+ * Copyright 2019-present Universidade Federal do Espirito Santo (UFES) and | |
+ * Instituto Federal do Espirito Santo (IFES) | |
+ * | |
+ * Licensed under the Apache License, Version 2.0 (the "License"); | |
+ * you may not use this file except in compliance with the License. | |
+ * You may obtain a copy of the License at | |
+ * | |
+ * http://www.apache.org/licenses/LICENSE-2.0 | |
+ * | |
+ * Unless required by applicable law or agreed to in writing, software | |
+ * distributed under the License is distributed On an "AS IS" BASIS, | |
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
+ * See the License for the specific language governing permissions and | |
+ * limitations under the License. | |
+ */ | |
+ | |
+#ifndef _IG_CTL_POLKA_P4_ | |
+#define _IG_CTL_POLKA_P4_ | |
+ | |
+control calc_polka( | |
+ inout headers hdr, | |
+ inout ingress_metadata_t ig_md)(nodeid_t coeff) | |
+{ | |
+ CRCPolynomial<bit<16>>( | |
+ coeff = coeff, | |
+ reversed = false, | |
+ msb = false, | |
+ extended = false, | |
+ init = 16w0x0000, | |
+ xor = 16w0x0000) poly; | |
+ Hash<bit<16>>(HashAlgorithm_t.CUSTOM, poly) hash_polka; | |
+ | |
+ action do_polka_nhop() { | |
+ bit<16> nbase=0; | |
+ bit<64> ncount=4294967296*2; | |
+ bit<16> nresult; | |
+ bit<16> nport; | |
+ // gets the routeId | |
+ routeid_t routeid = ig_md.polka_routeid; | |
+ routeid_t ndata = routeid >> 16; | |
+ | |
+ bit<16> dif = (bit<16>) (routeid ^ (ndata << 16)); | |
+ nresult = hash_polka.get((routeid_t) ndata); | |
+ | |
+ nport = nresult ^ dif; | |
+ ig_md.polka_portid = (SubIntId_t) nport; | |
+ } | |
+ | |
+ apply { | |
+ do_polka_nhop(); | |
+ } | |
+} | |
+ | |
+control IngressControlPolKA( | |
+ inout headers hdr, | |
+ inout ingress_metadata_t ig_md, | |
+ in ingress_intrinsic_metadata_t ig_intr_md, | |
+ inout ingress_intrinsic_metadata_for_deparser_t ig_dprsr_md, | |
+ inout ingress_intrinsic_metadata_for_tm_t ig_tm_md) | |
+{ | |
+ /* NodeID from 1 to 10 */ | |
+ calc_polka(coeff=16w0x002b) do_polka_1; | |
+ calc_polka(coeff=16w0x002d) do_polka_2; | |
+ calc_polka(coeff=16w0x0039) do_polka_3; | |
+ calc_polka(coeff=16w0x003f) do_polka_4; | |
+ calc_polka(coeff=16w0x0047) do_polka_5; | |
+ calc_polka(coeff=16w0x0053) do_polka_6; | |
+ calc_polka(coeff=16w0x008d) do_polka_7; | |
+ calc_polka(coeff=16w0x00bd) do_polka_8; | |
+ calc_polka(coeff=16w0x00d7) do_polka_9; | |
+ calc_polka(coeff=16w0x00f5) do_polka_10; | |
+ /* End NodeID */ | |
+ | |
+ action act_drop() { | |
+ ig_dprsr_md.drop_ctl = 1; | |
+ } | |
+ | |
+ action get_nodeid(nodeid_t nodeid) { | |
+ ig_md.polka_nodeid = (nodeid_t) nodeid; | |
+ ig_md.polka_nodeid_valid = 1; | |
+ } | |
+ | |
+ table tbl_polka_conf { | |
+ key = { | |
+ ig_md.polka_req_conf: | |
+ exact; | |
+ } | |
+ actions = { | |
+ get_nodeid; | |
+ } | |
+ size = POLKA_CONF_TABLE_SIZE; | |
+ } | |
+ | |
+ apply { | |
+ // Request nodeID | |
+ ig_md.polka_req_conf = 1; | |
+ if (tbl_polka_conf.apply().hit){ | |
+ if (ig_md.polka_nodeid_valid == 1){ | |
+ // calculate portID | |
+ if (ig_md.polka_nodeid == 1) | |
+ do_polka_1.apply(hdr, ig_md); | |
+ else if (ig_md.polka_nodeid == 2) | |
+ do_polka_2.apply(hdr, ig_md); | |
+ else if (ig_md.polka_nodeid == 3) | |
+ do_polka_3.apply(hdr, ig_md); | |
+ else if (ig_md.polka_nodeid == 4) | |
+ do_polka_4.apply(hdr, ig_md); | |
+ else if (ig_md.polka_nodeid == 5) | |
+ do_polka_5.apply(hdr, ig_md); | |
+ else if (ig_md.polka_nodeid == 6) | |
+ do_polka_6.apply(hdr, ig_md); | |
+ else if (ig_md.polka_nodeid == 7) | |
+ do_polka_7.apply(hdr, ig_md); | |
+ else if (ig_md.polka_nodeid == 8) | |
+ do_polka_8.apply(hdr, ig_md); | |
+ else if (ig_md.polka_nodeid == 9) | |
+ do_polka_9.apply(hdr, ig_md); | |
+ else if (ig_md.polka_nodeid == 10) | |
+ do_polka_10.apply(hdr, ig_md); | |
+ else | |
+ act_drop(); | |
+ } | |
+ } | |
+ } | |
+} | |
+ | |
+#endif // _IG_CTL_POLKA_P4_ | |
diff -Nur '--exclude=.git' misc/rare/REFERENCE-LAB-MODEL/p4src/include/ig_prs_clr.p4 rare/REFERENCE-LAB-MODEL/p4src/include/ig_prs_clr.p4 | |
--- misc/rare/REFERENCE-LAB-MODEL/p4src/include/ig_prs_clr.p4 2021-04-02 15:34:31.945853886 -0300 | |
+++ rare/REFERENCE-LAB-MODEL/p4src/include/ig_prs_clr.p4 2021-03-24 12:25:03.676476640 -0300 | |
@@ -61,6 +61,13 @@ | |
ig_md.mpls0_valid = 0; | |
ig_md.mpls1_valid = 0; | |
#endif | |
+ig_md.polka_valid = 0; | |
+ig_md.polka_nodeid_valid = 0; | |
+ig_md.polka_nodeid = 0; | |
+ig_md.polka_version = 0; | |
+ig_md.polka_req_conf = 0; | |
+ig_md.polka_routeid = 0; | |
+ig_md.polka_portid = 0; | |
ig_md.arp_valid = 0; | |
ig_md.ipv4_valid = 0; | |
ig_md.ipv6_valid = 0; | |
diff -Nur '--exclude=.git' misc/rare/REFERENCE-LAB-MODEL/p4src/include/ig_prs_hdr.p4 rare/REFERENCE-LAB-MODEL/p4src/include/ig_prs_hdr.p4 | |
--- misc/rare/REFERENCE-LAB-MODEL/p4src/include/ig_prs_hdr.p4 2021-04-02 15:34:31.945853886 -0300 | |
+++ rare/REFERENCE-LAB-MODEL/p4src/include/ig_prs_hdr.p4 2021-03-24 10:44:37.023907545 -0300 | |
@@ -29,6 +29,10 @@ | |
ETHERTYPE_ROUTEDMAC: | |
prs_eth6; | |
#endif | |
+#ifdef HAVE_POLKA | |
+ETHERTYPE_POLKA: | |
+ prs_polka; | |
+#endif | |
ETHERTYPE_ARP: | |
prs_arp; | |
ETHERTYPE_LACP: | |
@@ -67,6 +71,10 @@ | |
ETHERTYPE_ROUTEDMAC: | |
prs_eth6; | |
#endif | |
+#ifdef HAVE_POLKA | |
+ETHERTYPE_POLKA: | |
+ prs_polka; | |
+#endif | |
ETHERTYPE_ARP: | |
prs_arp; | |
ETHERTYPE_LACP: | |
@@ -182,6 +190,50 @@ | |
#endif | |
#endif | |
+#ifdef HAVE_POLKA | |
+state prs_polka { | |
+ pkt.extract(hdr.polka); | |
+ // begin - to get version and the routeId from the PolKA header | |
+ ig_md.polka_valid = 1; | |
+ ig_md.polka_version = hdr.polka.version; | |
+ ig_md.polka_routeid = hdr.polka.routeid; | |
+ // end | |
+ transition select(hdr.polka.proto) { | |
+0 &&& 0xfe00: | |
+ prs_llc; /* LLC SAP frame */ | |
+0 &&& 0xfa00: | |
+ prs_llc; /* LLC SAP frame */ | |
+#ifdef HAVE_PPPOE | |
+ETHERTYPE_PPPOE_CTRL : | |
+ prs_pppoeCtrl; | |
+ETHERTYPE_PPPOE_DATA : | |
+ prs_pppoeData; | |
+#endif | |
+#ifdef HAVE_MPLS | |
+ETHERTYPE_MPLS_UCAST: | |
+ prs_mpls0; | |
+#endif | |
+ETHERTYPE_IPV4: | |
+ prs_ipv4; | |
+ETHERTYPE_IPV6: | |
+ prs_ipv6; | |
+#ifdef HAVE_TAP | |
+ETHERTYPE_ROUTEDMAC_INT: | |
+ prs_eth2; | |
+ETHERTYPE_ROUTEDMAC: | |
+ prs_eth6; | |
+#endif | |
+ETHERTYPE_ARP: | |
+ prs_arp; | |
+ETHERTYPE_LACP: | |
+ prs_control; | |
+ETHERTYPE_LLDP: | |
+ prs_control; | |
+ default: | |
+ accept; | |
+ } | |
+} | |
+#endif | |
state prs_eth2 { | |
pkt.extract(hdr.eth2); | |
diff -Nur '--exclude=.git' misc/rare/REFERENCE-LAB-MODEL/p4src/include/mtd_ig_metadata.p4 rare/REFERENCE-LAB-MODEL/p4src/include/mtd_ig_metadata.p4 | |
--- misc/rare/REFERENCE-LAB-MODEL/p4src/include/mtd_ig_metadata.p4 2021-04-02 15:34:31.945853886 -0300 | |
+++ rare/REFERENCE-LAB-MODEL/p4src/include/mtd_ig_metadata.p4 2021-03-24 12:24:48.508522321 -0300 | |
@@ -57,6 +57,13 @@ | |
bit <1> srv_remove; | |
bit <1> saw_rsvp; | |
bit <1> bier_remove; | |
+ bit <1> polka_valid; | |
+ bit <1> polka_nodeid_valid; | |
+ nodeid_t polka_nodeid; | |
+ bit <16> polka_version; | |
+ bit <4> polka_req_conf; | |
+ routeid_t polka_routeid; | |
+ SubIntId_t polka_portid; | |
bit <1> mpls0_remove; | |
bit <1> mpls1_remove; | |
#ifdef NEED_REPLICA |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment