Run multiple p4 programs on different P4 switches using bmv2

Hi, I was told to run multiple p4 programs using bmv2, say we define switch A and switch B, and want to execute A.p4 on switch A and B.p4 on switch B. But Iā€™m not quite sure if this can be done using bmv2. If this is possible, how can I do it?
Thanks a lot for any reply :smile:

Each bmv2 switch is a separate user space process, started via executing the command simple_switch_grpc with the desired command line options.

If you use the P4Runtime API, you can write one or more separate programs that act as P4Runtime API clients, connect using a TCP connection to a TCP port on which the simple_switch_grpc processes are listening for incoming connections (by default, TCP port 9559, unless you give a command line option that changes this default), and then send P4Runtime API messages over that socket to request that the switch perform various operations.

One of those operations, typically one of the first you do after making such a connection, is called SetForwardingPipelineConfig, which takes several parameters, one of which is the output of compiling a P4 program to be loaded into the switch. Your control program(s) could choose to give a different compiled P4 program to each of the simple_switch_grpc processes, or the same one ā€“ it is up to you to decide.

1 Like

If you want an example of doing these steps using a single simple_switch_grpc process, and a single client program written in Python, before you later advance to doing so with multiple simple_switch_grpc processes, one place you can start is here:

Thank you for your detailed explanation! This helped me a lot:)