Changing Simple Switch in BMv2

Hello everyone,

I want to change simple switch in BMv2 but I am confused with two codes. I have a simpleSwitch.cpp in p4c/backends/bmv2/simpleSwitch.cpp and I have simple_switch.cpp in behavioral-model/targets/simple_switch/simple_switch.cpp. Also, they are not the same. Please let me know I need to change which of them and why they are not the same.

Thank you in advance,
Mohsen

The one in p4c is part of the P4 compiler back end for the BMv2 target device. It is involved in determining what data should be written to the BMv2 JSON file that is output by the p4c compiler when BMv2 is the target device.

The code in the behavioral-model repo is for processing packets as they arrive to the BMv2 software switch, e.g. constructing lookup keys for tables, determining which if any entries matched, updating counters and/or meters, performing multicast replication of packets when your P4 program directs that this should be done, etc.

Some desired changes to BMv2 would require only the BMv2 back end in p4c. Some would require only changing the BMv2 code in the behavioral-model repo. Many require changes to both of those programs. It depends upon what changes you want.

1 Like