[P4-dev] P4Runtime with bmv2 support

Antonin Bas antonin at barefootnetworks.com
Wed Jul 18 16:47:31 EDT 2018


1) I think the instructions in the simple_switch_grpc are pretty
comprehensive regarding how to install everything.

2) If you want to use P4Runtime, you probably want to use
simple_switch_grpc and not simple_switch.  You definitely *do not need to
compile PI with --with-bmv2*.

3) The fact that all Python packages are installed under a v1/ directory
has nothing to do with bmv1 vs bmv2. We decided to add the major semantic
version number to the P4Runtime Protobuf package path in accordance with
best practices for deploying cloud APIs. We are working on P4Runtime
v1.0.0, so the major version number is 1 and the Protobuf package therefore
includes v1.

4) You should be able to look at the tutorial code for directions on how to
use P4Runtime (of course you should probably also read the specification).
Apart from the package name (p4 -> p4.v1 and p4.config -> p4.config.v1),
things should be pretty much the same.

On Wed, Jul 18, 2018 at 5:16 AM, cs.lev <cs.lev at gmx.com> wrote:

> Regarding to developing own control-plane code, I used the latest
> version of PI (only grpc and protobufs are not up-to-dates as the
> installation instructions sticked to certain tags, e.g., 3.2), bmv2 and
> p4c.
>
> On the other hand, what I want is to control bmv2 softswitch via
> P4runtime (from a Python application if possible), so I guess I would
> need bmv2 support (without it, the python bindings will definitely be
> only for v1 (located under /usr/lib/...dist-packages/.../v1 as in my
> previous mail).
>
> Thus, I should compile PI with --with-bmv2 configuration, which
> requires nanosmg, thrift, etc.
> After doing so, and PI has found all libraries, I still find python
> bindings under directory /usr/local/lib/python2.7/dist-
> packages/p4/config/v1/.
>
> Maybe this version would be OK to control the bmv2, but if it is not
> the same (and working) version that the tutorial VM image has used,
> then is there any API documentation on how to build a Python-based
> P4runtime controller?
>
> Or is there any other tutorial in any kind of language showing examples
> of basic API calls to control the bmv2 with P4runtime?
>  - I have only found some youtube videos about ONOS and its p4runtime
> support but nothing else that would really help :S
>
> Thank you,
> cslev
>
>
> On Tue, 2018-07-17 at 10:09 -0700, Antonin Bas wrote:
> > If you want to use simple_switch_grpc, you need to follow the steps
> > in the README (https://github.com/p4lang/behavioral-model/tree/master
> > /targets/simple_switch_grpc) and install PI without bmv2 support (I
> > believe --without-bmv2 is the default actually so the flag could
> > simply be omitted).
> >
> > All of your problems seem to come from the fact that you want to use
> > the tutorials repo with the latest versions of PI & bmv2 & p4c. When
> > we release a new version of the tutorials, we use a "frozen" version
> > of the dependencies. So if you want to use the tutorials you have to
> > use the appropriate versions, as advertised here: https://github.com/
> > p4lang/tutorials/blob/master/vm/user-bootstrap.sh#L8
> > If you want to develop your own control-plane code, feel free to use
> > the latest version of PI & bmv2 & p4c as they should work fine
> > together, but don't expect the tutorial exercises to work with these.
> >
> > On Tue, Jul 17, 2018 at 8:21 AM, cs.lev <cs.lev at gmx.com> wrote:
> > > Dear all,
> > >
> > > I would like to have proper P4Runtime support on a bare-metal
> > > server, with all its python bindings to write my own controllers.
> > >
> > > I have run into the following issue during configuring and
> > > compiling related libraries.
> > >
> > > First of all, I found there is a cyclic dependency between bmv2 and
> > > PI (but correct me if I am wrong), as bmv2 can be compiled with PI
> > > support (--with-pi) which needs the PI libraries to be installed in
> > > order to compile afterwards the simple_switch_grpc binary.
> > > However, to support bmv2 in PI, during its installation, it
> > > requires bmv2 and its libraries.
> > >
> > > As a workaround, first I compiled PI without bmv2 support, then
> > > compiled bmv2 with PI support, and finally I recompiled PI with
> > > bmv2 support.
> > > Everything seemed to be OK, as compilation ended without errors and
> > > simple_switch_grpc could have been run.
> > >
> > > After trying to test (a modified version of the) p4runtime example
> > > (originally tailored to the mininet environment) from
> > > p4lang/tutorial,
> > > the python based controller has complained about missing modules.
> > > After a lot of googling, debugging, and comparing ENV variables of
> > > the p4tutorial’s VM and my bare metal installation, I have found
> > > that the libraries the python modules are looking for should be in
> > > /usr/local/lib/python2.7/dist-packages/p4/.
> > >
> > > However, the PI installation on the bare metal put all libraries
> > > into /usr/local/lib/python2.7/dist-packages/p4/v1,
> > > even though the configure parameter --with-bmv2 should have
> > > indicated to the compilation process to not put the corresponding
> > > libraries in such a subdirectory (v1).
> > >
> > > In the beginning, it seemed a good idea to do the following:
> > >
> > > $ cp /usr/local/lib/python2.7/dist-packages/p4/v1/*
> > > /usr/local/lib/python2.7/dist-packages/p4/
> > >
> > > $ cp  /usr/local/lib/python2.7/dist-packages/p4/config/v1/*
> > > /usr/local/lib/python2.7/dist-packages/p4/config/
> > > Then, the controller application was now complaining about missing
> > > modules.
> > > So, it indeed seemed to be a good workaround...
> > >
> > >
> > > BUT, (if you are still with me :)), the interesting parts started
> > > to show up.
> > > The controller could connect to the switch and even the
> > > readTableRules(p4info_helper,switch) function could have been
> > > called and returned without errors.
> > >
> > > At this point, I still believed that everything is working, however
> > > when I tried to insert flow rules into my switch, the controller
> > > raised the following error:
> > >   File "controller.py", line 86, in main
> > >     output_port='0')
> > >   File "controller.py", line 23, in addIPforwardRule
> > >     "port": 1,
> > >   File
> > > "/home/csikor/p4/p4_vlan/p4runtime_controller/p4runtime_lib/helper.
> > > py", line 173, in buildTableEntry
> > >     for match_field_name, value in match_fields.iteritems()
> > >   File
> > > "/home/csikor/p4/p4_vlan/p4runtime_controller/p4runtime_lib/helper.
> > > py", line 100, in get_match_field_pb
> > >     if match_type == p4info_pb2.MatchField.VALID:
> > > AttributeError: type object 'MatchField' has no attribute 'VALID'
> > >
> > >
> > > The rule inserting source code had no issues in the mininet
> > > environment, but for a comprehensive view I include the relevant
> > > part of it below:
> > > def addIPforwardRule(p4info_helper, sw):
> > > table_entry = p4info_helper.buildTableEntry(
> > > table_name="MyIngress.ipv4_lpm",
> > > match_fields={
> > > "hdr.ipv4.dstAddr": ("10.0.0.1", 32)
> > > },
> > > action_name="MyIngress.ipv4_forward",
> > > action_params={
> > > "port": 1
> > > })
> > > sw.WriteTableEntry(table_entry)
> > >
> > >
> > > Later on, I have found out that in contrast to other python
> > > modules, the p4info_pb2 library that I have used (copied from
> > > /usr/local/lib/python2.7/dist-packages/p4/config/v1) is not the
> > > same as it was in the p4lang/tutorial's VM's python modules, which
> > > of course is somewhat expected.
> > >
> > > In order to do a workaround again, as a last resort I have copied
> > > all the python libraries for P4runtime from the VM's
> > > /usr/local/lib/python2.7/dist-packages/p4/ directory to the same
> > > place at my bare metal server, but now I get a UNIMPLEMENTED error
> > > :)
> > >
> > >   File "controller.py", line 95, in
> > > main    s.SetForwardingPipelineConfig(p4info=p4info_helper.p4info,
> > > bmv2_json_file_path=bmv2_file_path)
> > >   File
> > > "/home/csikor/p4/p4_vlan/p4runtime_controller/p4runtime_lib/switch.
> > > py", line 45, in
> > > SetForwardingPipelineConfig    self.client_stub.SetForwardingPipeli
> > > neConfig(request)
> > >   File "/usr/local/lib/python2.7/dist-packages/grpc/_channel.py",
> > > line 492, in __call__    return _end_unary_response_blocking(state,
> > > call, False, deadline)
> > >   File "/usr/local/lib/python2.7/dist-packages/grpc/_channel.py",
> > > line 440, in _end_unary_response_blocking
> > >
> > >   raise _Rendezvous(state, None, None,
> > > deadline)grpc._channel._Rendezvous: <_Rendezvous of RPC that
> > > terminated with (StatusCode.UNIMPLEMENTED, )>
> > >
> > > I guess some of the installation steps should be revisited, but can
> > > someone explain me in which order and how should I proceed with the
> > > installation of the libraries to have the same environment as the
> > > VM has?
> > > Or what else can I do?
> > >
> > > Thank you for considering my request.
> > >
> > > BR,
> > > Levi
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > _______________________________________________
> > > P4-dev mailing list
> > > P4-dev at lists.p4.org
> > > http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org
> > >
> >
> >
> >
> > --
> > Antonin
>



-- 
Antonin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20180718/220de018/attachment.html>


More information about the P4-dev mailing list