Git Product home page Git Product logo

p4-hlir's Introduction

p4-hlir

Dependencies:
The following are required to run p4-validate and p4-graphs:

  • the Python yaml package
  • the Python ply package
  • the dot tool

ply will be installed automatically by setup.py when installing p4-hlir.

On Ubuntu, the following packages can be installed with apt-get to satisfy the remaining dependencies:

  • python-yaml
  • graphviz

To install:
sudo python setup.py install

To run validate tool:
p4-validate <path_to_p4_program>

To open a Python shell with an HLIR instance accessible:
p4-shell <path_to_p4_program>

To build the HLIR and access its objects:
from p4_hlir.main import HLIR
h = HLIR(<path_to_p4_program>)
h.build()

You can then access the different P4 top level objects using these Python OrderedDict's:
h.p4_actions
h.p4_control_flows
h.p4_headers
h.p4_header_instances
h.p4_fields
h.p4_field_lists
h.p4_field_list_calculations
h.p4_parser_exceptions
h.p4_parse_value_sets
h.p4_parse_states
h.p4_counters
h.p4_meters
h.p4_registers
h.p4_nodes
h.p4_tables
h.p4_action_profiles
h.p4_action_selectors
h.p4_conditional_nodes

The ingress entry points are stored in a dictionary:
h.p4_ingress_ptr

The egress entry point is:
h.p4_egress_ptr

To access the P4 types you can use the following import:
import p4_hlir.hlir.p4 as p4

Getting the graphs

To get the table graph or parse graph for a P4 program, use:
p4-graphs <path_to_p4_program>

Compiling to EBPF

There are multiple back-ends that can consume the HLIR P4 program representation. A compiler back-end which compiles programs expressed in a restricted subset of P4 into eBPF programs that can be run in the Linux kernel can be found at https://github.com/iovisor/bcc/tree/master/src/cc/frontends/p4

p4-hlir's People

Contributors

antoninbas avatar signorello avatar naclomi avatar mbudiu-bfn avatar peng-zhao avatar advaitdixit avatar freakypenguin avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.