bmv2
Designing your own switch target with bmv2
|
Go to the source code of this file.
Classes | |
class | bm::ExternSafeAccess |
Provides safe access to an extern instance for control plane calls. More... | |
class | bm::Context |
A Context instance is essentially a switch within a Switch instance. That just gave you a headache, right? :) Let's picture a simple example: a hardware P4-programmable switch, with a parser, a match-action pipeline and a deparser. Now let's make the picture a little bit more complex and let's say that our hardware switch can actually be split into 2 parts, each of which can be programmed with a different P4 program. So our switch essentially has parser1, pipeline1 and deparser1 which can be programmed by prog1.p4, and parser2, pipeline2 and deparser2 which can be programmed by prog2.p4. Maybe prog1.p4 only handles IPv4 packets, while prog2.p4 only handles IPv6 packets. This is what the Context class is trying to capture: different entities within the same switch, which can be programmed with their own P4 objects. Each context even has its own learning engine and can have its own packet replication engine, so they are very much independent.
We can remark that the same could be achieved by instantiating several 1-context Switch and doing some tweaking. However, we believe that contexts are slightly more general and slightly more convenient to use. They are also totally optional. When creating your target switch class, you can inherit from Switch instead of SwitchWContexts, and your switch will only have one context.
IMPORTANT: Context support has not yet been added to the bmv2 compiler. While you can already implemet multi-contexts target switches, they will all have to be programmed with the same P4 logic. We are planning to add support soon.