Upgrade to Pro — share decks privately, control downloads, hide ads and more …

p4alu: Arithmetic Logic Unit in P4

ebiken
November 29, 2017

p4alu: Arithmetic Logic Unit in P4

Example of how to code and run P4 program simulating ALU.
Presented at Software Router BoF @ IW2017 Japan

GitHub: https://github.com/ebiken/p4sandbox/tree/master/p4alu

This was originally uploaded to slideshare_com and moved here on Nov, 2022.

The original idea of implementing ALU on P4 was presented by many others before this slide. Sorry that I do not remember the exact presentation I was inspired from, but wanted to note this is not the first slide/code to share this idea. (it's most likely one of "P4 Language Consortium" event / preson)

Also, more sophisticated code exists as tutorial / exercises.
https://github.com/p4lang/tutorials/tree/master/exercises/calc

ebiken

November 29, 2017
Tweet

More Decks by ebiken

Other Decks in Technology

Transcript

  1. ~ p4alu ~ Arithmetic Logic Unit in P4 Kentaro Ebisawa

    | Ponto Networks, Inc. [email protected] Twitter: @ebiken p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 1
  2. • “p4alu” is an P4 program who would parse UDP

    packet with payload in "p4alu header format" and apply calculation. • This program is tested using BMv2 simple_switch P4 target. • Source Code on GitHub • https://github.com/ebiken/p4sandbox/tree/master/p4alu • Generic P4 information in Japanese (日本語) • How to Run P4 Behavior Model v2 (JAPANESE) • https://www.slideshare.net/kentaroebisawa/how-to-run-p4-bmv2 p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 2 p4alu
  3. p4alu ... Arithmetic Logic Unit in P4 | Software Router

    BoF @ IW2017 Japan | 2017/11/29 3 ALU Integer Operand Integer Operand Integer Result opCode op1 op2 result
  4. p4alu ... Arithmetic Logic Unit in P4 | Software Router

    BoF @ IW2017 Japan | 2017/11/29 4 p4alu header format Integer Operand Integer Operand Integer Result opCode op1 op2 result
  5. p4alu ... Arithmetic Logic Unit in P4 | Software Router

    BoF @ IW2017 Japan | 2017/11/29 5 P4 parser
  6. p4alu ... Arithmetic Logic Unit in P4 | Software Router

    BoF @ IW2017 Japan | 2017/11/29 6 P4 action
  7. p4alu ... Arithmetic Logic Unit in P4 | Software Router

    BoF @ IW2017 Japan | 2017/11/29 7 P4 table & control
  8. p4alu ... Arithmetic Logic Unit in P4 | Software Router

    BoF @ IW2017 Japan | 2017/11/29 8 Setup netns based hosts BMv2 running p4alu
  9. p4alu ... Arithmetic Logic Unit in P4 | Software Router

    BoF @ IW2017 Japan | 2017/11/29 9 Compile and Run on BMv2
  10. p4alu ... Arithmetic Logic Unit in P4 | Software Router

    BoF @ IW2017 Japan | 2017/11/29 10 Configure Tables via runtime_CLI Forward Packet from/to port#0 <-> port#1 Apply action based on opCode • opCode: 1 => p4alu_add • opCode: 2 => p4alu_sub BMv2 Runtime CLI command format
  11. p4alu ... Arithmetic Logic Unit in P4 | Software Router

    BoF @ IW2017 Japan | 2017/11/29 11 Packet Format (sending from host0) • opCode: 0x01 => p4alu_add • opCode: 0x02 => p4alu_sub
  12. CuiShark by @slankdev | https://github.com/slankdev/cuishark p4alu ... Arithmetic Logic Unit

    in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 12 packets after going through p4alu op1 opCode op2 result
  13. CuiShark by @slankdev | https://github.com/slankdev/cuishark p4alu ... Arithmetic Logic Unit

    in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 13 packets after going through p4alu op1 opCode op2 result