Code Monkey home page Code Monkey logo

switch's Introduction

Switch

The switch repository contains the switch.p4 sample P4 program along with all the library repos to manipulate the switch using SAI, SwitchAPI and switchlink.

    +-----+   +-----+   +-----+   +-----+
    |App a|   |App j|   |App n|   |App z|
    |     |...|     |...|     |...|     |
    +-----+   +-----+   +-----+   +-----+
       |         |         |         |
       |         |    +----|         |
+------------+   |    |
| Switchlink |   |    |
|            |<-----------------------------+
+------------------+  |                     |
|     SAI          |  |                     |
|                  |  |                     |
+-----------------------+                   |
|      Switch API       |                   |
|                       |                   |
+-----------------------+---------+         |
|      Resource Mgmt. API         |         |
| (auto-gen. from switch.p4)      |         | Netlink events
+---------------------------------+         |
|        Soft Switch              |         |
|  (compiled from switch.p4)      |         |
+---------------------------------+         |
                                            |
                                            |
+----------------------------------------------------------------+
|                             Kernel                             |
|                                                                |
+----------------------------------------------------------------+

Directory Structure

p4src - P4 sources
switchsai - SAI library
switchapi - SwitchAPI
switchlink - Linux netlink listener
tests/ptf-tests - P4 dependent(PD), SAI and API tests
tests/of-tests - Openflow tests

Running switch in bmv2 without p4factory

You can now run switch.p4 in bmv2 without cloning p4factory. In order to do this you first need to install [bmv2] (https://github.com/p4lang/behavioral-model) and its compiler [p4c-bmv2] (https://github.com/p4lang/p4c-bm) on your system. Note that when running ./configure for bmv2, you need to provide the --with-pdfixed option, as switch requires the PD library. Additionally, if you plan on running the tests for switch.p4, please make sure you install [PTF] (https://github.com/p4lang/ptf) with sudo python setup.py install.

Once this is done, you can follow this steps:

 ./autogen.sh
 ./configure --with-bmv2 --with-switchsai
 make

The --with-switchsai flag will make sure that the compiled drivers include switchapi and switchsai. If you just need switchapi, replace the flag will --with-switchapi. Replace the flag with --with-switchlink if you need switchlink as well. If you omit these flags, the drivers will only include the PD.

Note that you should be using a fresh clone for this, not the switch submodule that comes with p4factory.

Make sure to look at the output of configure to spot any missing dependency.

Once everything has compiled, you can run the tests for switch.p4 (assuming you have installed [PTF] (https://github.com/p4lang/ptf). Please make sure that you have all the necessary veth pairs setup (you can use [tools/veth_setup.sh] (tools/veth_setup.sh)).

First, start the software switch with:

   sudo ./bmv2/run_bm.sh

Then, start the drivers with:

   sudo ./bmv2/run_drivers.sh

You can now run all the tests:

sudo ./bmv2/run_tests.sh  # for the PD tests
sudo ./bmv2/run_tests.sh --test-dir tests/ptf-tests/api-tests  # for the switchapi tests
sudo ./bmv2/run_tests.sh --test-dir tests/ptf-tests/sai-tests  # for the switchsai tests

switch's People

Contributors

antoninbas avatar cruzj avatar jiaxincao avatar jithinthomas avatar jklr avatar lguohan avatar

Watchers

 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.