[P4-dev] Difference among p4c, p4c-bm2-ss, p4c-bmv2 ??

Rui Miguel rmiguel at lasige.di.fc.ul.pt
Wed Jun 14 10:36:02 EDT 2017

Hi! I'll give a brief answer to the best of my knowledge; others may be able to elaborate further. :)

p4c is short for p4compiler. p4c-bm2-ss is the part of the p4 compiler (p4c) that compiles for the behavioral model 2 (bm2), specifically for the simple_switch (ss) target.
Under your behavioral-model directory, there's a folder called "targets". Inside it, you will find several targets, one of which is simple_switch. If you look inside, you will find a file named main.cpp, hinting that this is the component that actually runs and gets stuff done. The remaining of behavioral model 2 is a C++ library that the targets use.

Now, there are two versions of the P4 language: P4-14 and P4-16. 
- p4c-bmv2 is the official compiler for P4-14.
- p4c is a new compiler that also compiles P4-16, while retaining the ability to compile P4-14 programs.

simple_nat.p4 is written in P4-14, so you managed to compile it using either one. ipv4_forward.p4 is written in P4-16, therefore you had no choice but to compile it using p4c-bm2-ss. 

Both P4 compilers produce a .json as output. This .json is fed to the simple_switch. So long as the simple_switch understands the.json file, it will run.

Happy programming,
~Rui Miguel
----------------original message-----------------
From: "Kentaro Ebisawa" ebiken.g at gmail.com 
To: "p4-dev" 
Date: Wed, 14 Jun 2017 19:44:19 +0900
> Hi,
> What's the difference among p4c, p4c-bm2-ss, p4c-bmv2 ??
> While trying examples under github.com/p4lang/tutorials , simple_nat.p4 
> was able to compile using p4c-bmv2, while ipv4_forward.p4 required 
> p4c-bm2-ss.
> I first thought p4c-bm2-ss is required to run with simple_siwtch, but 
> both *.json worked when I started simple_switch using them:
> p4c-bm2-ss -o ipv4_forward.json ipv4_forward.p4
> sudo simple_switch --log-console --dump-packet-data 64 -i 0 at vtap0 -i 
> 1 at vtap1 ipv4_forward.json
> p4c-bmv2 --json simple_nat.json simple_nat.p4
> sudo simple_switch --log-console --dump-packet-data 64 -i 0 at vtap0 -i 
> 1 at vtap1 simple_nat.json
> Thanks,
> -- 
> Kentaro Ebisawa ebiken.g at gmail.com 
> _______________________________________________
> P4-dev mailing list
> P4-dev at lists.p4.org 
> http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org

More information about the P4-dev mailing list