-
Notifications
You must be signed in to change notification settings - Fork 0
/
pmSwitch_cache_request.p4
38 lines (35 loc) · 1.25 KB
/
pmSwitch_cache_request.p4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "xilinx_custom.p4"
#include "common_request.p4"
control PMSwitchCacheRequestProcessing(inout headers hdr,
inout PMswitch_metadata_t ctrl) {
action writePacket() {
ctrl.PMSwitchOPS = hdr.pmswitchhds.type;
ctrl.hashedAddress = hdr.pmswitchhds.PMAddress;
ctrl.ackCount = 0x01;
}
action readPacket(){
ctrl.PMSwitchOPS = hdr.pmswitchhds.type;
ctrl.hashedAddress = hdr.pmswitchhds.PMAddress;
ctrl.ackCount = 0x02;
}
action bypass() {
ctrl.PMSwitchOPS = PMSWITCH_OPCODE_NOOP;
ctrl.hashedAddress = INVALID_ADDR;
ctrl.ackCount = 0xFF;
}
apply {
// We still need to filter out the packet from the processor.
if (hdr.ipv4.isValid()&& hdr.udp.isValid() && hdr.pmswitchhds.isValid()){
if((hdr.pmswitchhds.type == PMSWITCH_OPCODE_PERSIST_NEED_ACK)){
writePacket();
}else if(hdr.pmswitchhds.type == PMSWITCH_OPCODE_BYPASS){
readPacket();
}else{
bypass();
}
}else{
bypass();
}
}
}
XilinxSwitch(PMSwitch_request_Parser(), PMSwitchCacheRequestProcessing(), PMSwitch_request_Deparser()) main;