Sending packets to different priority queues and setting rates in BMv2

How can I send packets to different priority queues and set the rates for different queues in the latest version of BMv2? I am currently using the following P4 code to set the priority:

if(meter_idx==1){
            standard_metadata.priority = (bit<3>)7;
        }
         else if(meter_idx==2){
             if(meta.meter_tag==0){
                  standard_metadata.priority = (bit<3>)5;
             }
             else{
                  standard_metadata.priority = (bit<3>)3;                
             }
         }else{
            if(meta.meter_tag==0){
                  standard_metadata.priority = (bit<3>)2;
             }
             else{
                  standard_metadata.priority = (bit<3>)0;
             }
        } 

I am also using these switch control plane codes to set the rates for the different queues:

set_queue_rate 15 2 0
set_queue_rate 24 2 2
set_queue_rate 32 2 3
set_queue_rate 48 2 5
set_queue_rate 64 2 7

Can anyone provide guidance on how to properly send packets to different priority queues and set the rates for those queues in the latest version of BMv2?

With today’s BMv2 source code, it requires modifying it and recompiling simple_switch and/or simple_switch_grpc in order to enable more than one FIFO queue per output port. Without changing the source code, there is only one FIFO queue per output port. See this Github issue for the (small) source code changes required: Does simple_switch_grpc support priority queue ? · Issue #877 · p4lang/behavioral-model · GitHub

This later Github issue refers to that earlier one, and proposes making an enhancement to the BMv2 code that would (after those enhancements were made) allow users to enable multiple priority queues per output port via a command line option, but so far no one has volunteered to make those changes: Consider making it a command line option to enable priority queues · Issue #1065 · p4lang/behavioral-model · GitHub

1 Like

hello are there any alternatives to BMv2

There are real hardware devices, e.g. Xilinx FPGAs, Tofino switch ASICs, NICs from multiple vendors, etc.

There is a DPDK software switch, but its current implementation of PSA does not implement egress, nor the traffic manager, so if the reason you are looking for alternatives is to find one that implements multiple class of service FIFO queues per output port, then it will not help you with that, unless you implement them yourself or find someone willing to do it for you: p4c/backends/dpdk at main · p4lang/p4c (github.com)

1 Like

Thank you so much, @andyfingerhut, for taking the time to reply.

Also one more question, How can I increase Bmv2 performance? I have installed Bmv2 in a VM running Ubuntu 18.04.6 LTS

Please read this page on BMv2 performance: behavioral-model/performance.md at main · p4lang/behavioral-model · GitHub