Query regarding P4 meter and ONOS

108 views
Skip to first unread message

Debobroto Das

unread,
Feb 1, 2020, 3:55:03 PM2/1/20
to P4 brigade
As far as I understand, only indirect meter are supported at this moment. Now assume we have 2 array of meters defined in data plane like following


#define METER1_SIZE 100
Meter<bit<7>>(METER1_SIZE, PSA_MeterType_t.BYTES) meter1Array;
Meter<bit<7>>(METER1_SIZE, PSA_MeterType_t.BYTES) meter2Array;



Now when we use the getAllMeters (http://api.onosproject.org/1.8.2/org/onosproject/net/meter/MeterService.html#getAllMeters--) -- we are supposed to get 200 meters. now my questions is how do we understand among these 200 meters which are from meter1Array and which are from meter2Array. 

Same question is also applicable for getMeter method (http://api.onosproject.org/1.8.2/org/onosproject/net/meter/MeterService.html#getMeter-org.onosproject.net.DeviceId-org.onosproject.net.meter.MeterId-). When we want to get a specific meter how do ww index them. For example we want to get the 5 th meter from meter1Array. what will be the meterId we have to pass as parameter to getMeter method?



Another slightly different topics, is there any full example available to understand, how to use the P4runtime controllers and client for read write direct meter and registers? 


Carmelo Cascone

unread,
Feb 3, 2020, 1:43:30 PM2/3/20
to Debobroto Das, P4 brigade
As of today (ONOS 2.3) support for P4Runtime meters is not complete. You can use methods exposed by the P4Runtime protocol modules, e.g. to read meter cell configurations from a given meter ID:

However, this has not been integrated yet with thee rest of the ONOS northbound, i.e. calls to MeterService for a P4Runtime device are not expected to work. You can stil use MeterService for OpenFlow devices, but not for P4Runtime ones.

If anyone is willing to contribute in this direction, I can provide some guidance.

Having said so, you should be able to retrieve the meter ID using Meter.meterCellId():

For P4Runtime devices, you should expect a MeterCellId of type PIPELINE_INDEPENDENT, which can be casted to PiMeterCellId. From there you can retrieve the meter ID:

And index:

Concerning method MeterService.getMeter(...), that one needs to be update to accept MeterCellId instead of MeterId.

— Carmelo


--
You received this message because you are subscribed to the Google Groups "P4 brigade" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brigade-p4+...@onosproject.org.
To view this discussion on the web visit https://groups.google.com/a/onosproject.org/d/msgid/brigade-p4/5ba9bd2c-3d44-4505-a4f0-44662080167b%40onosproject.org.

Debobroto Das

unread,
Feb 3, 2020, 3:41:48 PM2/3/20
to P4 brigade, debobrot...@gmail.com
I am deeply interested about meter controlling from onos. I will be waiting for your guidelines to this direction. I tried to study onos codebase related to meter and grpc. I was unable to understand them clearly. I was feeling lack of information about  where to start,  where to look for. 
To unsubscribe from this group and stop receiving emails from it, send an email to briga...@onosproject.org.

Debobroto Das

unread,
Feb 7, 2020, 11:22:44 AM2/7/20
to briga...@onosproject.org, debobrot...@gmail.com
Hi Carmelo, 

As per my understanding, to support p4 meter in ONOS, we need to support 2 things
a) Building P4runtime write request 
     i) Parsing the p4info file to get the relevant id's of P4 object in data plane -- I believe this is already done
     ii) Accessing p4runtime id's of relevant objects. Example: what is the id of a meter in pipeline   --- (https://github.com/p4lang/p4runtime/blob/master/proto/p4/config/v1/p4info.proto). I guess they are defined here. 
     iii) How to create the write request using the id and user provided data (data provided from control plane) -- (https://github.com/p4lang/p4runtime/blob/master/proto/p4/config/v1/p4info.proto) I guess we can send request to a p4runtime enabled device using formats defined                      here. am I right? 
b) Parsing P4runtime responses
Can you kindly give me some guideline on where I can find relevant classes and possibly in which portion of the code can be helpful to understand the things? 

Regards
Robin


On Monday, February 3, 2020 at 1:43:30 PM UTC-5, Carmelo Cascone wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to briga...@onosproject.org.

Carmelo Cascone

unread,
Feb 12, 2020, 2:36:37 PM2/12/20
to Debobroto Das, P4 brigade
Hi Debobroto,

This presentation is a good starting point to get a basic understanding of how P4Runtime and protocol-independence are supported in ONOS. I suggest you take a look before starting on this task.

Support for P4Runtime Meters should be somewhat equivalent to the way we support other P4Runtime entities, such as FlowRule/TableEntry. In the following, I will provide references to the relevant pieces to support FlowRule/TableEntry. You can use that as a guide to complete the implementation for meters. I say complete because most of the code is there, but integration with the northbound API (MeterService) doe not work yet. Not sure what is missing. It might be helpful to dig in previous threads:

## Northbound API

Apps that wants to install flow rules can call the FlowRuleService:

## Core Implementation

FlowRuleService is implemented by the FlowRuleManager:

FlowRuleManager calls the FlowRuleDriverProvider:

## P4Runtime Driver

FlowRuleDriverProvider calls the FlowRuleProgrammable behavior for the given target device, in our case, the P4RuntimeFlowRuleProgrammable:

P4RuntimeFlowRuleProgrammable calls the PiFlowRuleTranslator, required translate the pipeline-agnostic FlowRule into a (P4) pipeline-specific table entry. The translation logic is provided by PiFlowRuleTranslatorImpl:

## P4Runtime Protocol

Once translated, the P4RuntimeFlowRuleProgrammable uses the P4RuntimeClient to add the PiTableEntry to a P4Runtime write request:

The implementation of the P4Runtime client uses “codecs” to translate a PiTableEntry object into the corresponding P4Runtime protobuf message:

Finally, the message is sent to the switch.

## Support for meters 

Architecture to support meters should be equivalent to FlowRule. So, the implementation of the following classes should be similar:

FlowRuleService -> MeterService
FlowRuleManager -> MeterManager
FlowRuleDriverProvider -> MeterDriverProvider
P4RuntimeFlowRuleProgrammable -> P4RuntimeMeterProgrammable
Note: this behavior is currently disabled. To enable it, uncomment this line
PiFlowRuleTranslator -> PiMeterTranslatorImpl
TableEntryCodec -> MeterEntryCodec & DirectMeterEntryCodec

Please let me know if you have any further questions.

Thanks
Carmelo


On Feb 7, 2020, at 8:22 AM, Debobroto Das <debobrot...@gmail.com> wrote:

Hi Carmelo, 

As per my understanding, to support p4 meter in ONOS, we need to support 2 things
a) Building P4runtime write request 
     i) Parsing the p4info file to get the relevant id's of P4 object in data plane -- I believe this is already done
     ii) Accessing p4runtime id's of relevant objects. Example: what is the id of a meter in pipeline
     iii) How to create the write request using the id and user provided data (data provided from control plane)
To unsubscribe from this group and stop receiving emails from it, send an email to brigade-p4+...@onosproject.org.
To view this discussion on the web visit https://groups.google.com/a/onosproject.org/d/msgid/brigade-p4/34121241-ef6e-4be3-bb2e-ee9886c24f22%40onosproject.org.

Debobroto Das

unread,
Feb 13, 2020, 11:59:43 AM2/13/20
to Carmelo Cascone, P4 brigade
Hi Carmelo,

Thanks a lot for the guidance. I was almost in the right track except the translation part. That helped me a lot. 

I have started working on the indirect meters. There are 2 scenarios.

Case 1) According to this (https://github.com/p4lang/p4runtime/blob/master/proto/p4/v1/p4runtime.proto  line 314) . If the index is unset then the switch should return all the meter information. To test this I have sent a request with the index unset. But I always get only one response. Though there are more than 1 indirect meter in the switch. I have attached the log here. Interestingly I also get an error message "Error while performing READ on device:ss0: UNKNOWN: Error when reading meter spec from target"

Checking status for indirect Meter: IngressPipeImpl.my_meter_indirect2 of device device:ss0
11:43:30.898 INFO  [ReadRequestImpl] Added entity to grpc request is meter_entry {
  meter_id: 335593720
}
11:43:30.899 INFO  [ReadRequestImpl] Sending read request to device:ss0 for 1 entities...
11:43:30.902 WARN  [P4RuntimeClientImpl] Error while performing READ on device:ss0: UNKNOWN: Error when reading meter spec from target
11:43:30.903 INFO  [P4RuntimeMeterProgrammable] Resposnse for indirect meter:IngressPipeImpl.my_meter_indirect2for device device:ss0is 1
11:43:30.904 INFO  [P4RuntimeMeterProgrammable]  CellId isPiMeterCellConfig{cellId=IngressPipeImpl.my_meter_indirect2:0, meterBands=[PiMeterBand{rate=0, burst=0}, PiMeterBand{rate=0, burst=0}]}

 Case 2)  when we set the index in a meter request. We should get the reply for that specific meter cell . To test that I built meter request for each of the meter in an array. And send request for each one. But still I get only one response from the Device. I have attached the log here

11:54:53.425 INFO  [ReadRequestImpl] Added mentity Request is :  meter_entry {
  meter_id: 335567108
  index {
    index: 16383
  }
}
11:54:53.425 INFO  [ReadRequestImpl] total entity added in the grpc req is 16384
11:54:53.425 INFO  [ReadRequestImpl] Sending read request to device:ss0 for 16384 entities...
11:54:53.454 WARN  [P4RuntimeClientImpl] Error while performing READ on device:ss0: UNKNOWN: Error when reading meter spec from target
11:54:53.454 INFO  [P4RuntimeMeterProgrammable] Resposnse for indirect meter:IngressPipeImpl.my_meter_indirectfor device device:ss0is 1
11:54:53.454 INFO  [P4RuntimeMeterProgrammable]  CellId isPiMeterCellConfig{cellId=IngressPipeImpl.my_meter_indirect:0, meterBands=[PiMeterBand{rate=0, burst=0}, PiMeterBand{rate=0, burst=0}]}

Interestingly, in both the case I get an error message " 11:54:53.454 WARN  [P4RuntimeClientImpl] Error while performing READ on device:ss0: UNKNOWN: Error when reading meter spec from target"
Is my grpc request encoding is wrong? 

Robin

Carmelo Cascone

unread,
Feb 14, 2020, 8:33:59 PM2/14/20
to Debobroto Das, P4 brigade
Hi Deboroto,

Have you checked the bmv2 logs? The message “Error when reading meter spec from target” usually signifies some internal bmv2 error. Also, I would make sure you run the most recent version of bmv2.

If you want to make sure your P4Runtime request is correct, I would double check the P4Runtime specification:

Finally, I suggest to double check that meters are instantiated correctly in your p4 program. You P4info should report the “size" of your indirect meter, please make sure it is greater than 1:

Hope it helps
Carmelo

Debobroto Das

unread,
Feb 15, 2020, 1:47:47 PM2/15/20
to Carmelo Cascone, P4 brigade
I have checked them. 
Example:
relevant content of the p4info file. The meter I am trying to read

meters {
  preamble {
    id: 335567108
    name: "IngressPipeImpl.my_meter_indirect"
    alias: "my_meter_indirect"
    doc {
      brief: "Brief descr for indirect meter"
      description: "Long description for indirect meter"
    }
  }
  spec {
    unit: PACKETS
  }
  size: 16384
}


The grpc request I am sending from ReadRequestImplementation is : (This is printed as log after the request building is completed and befire calling the submit)

onosproject.onos-protocols-p4runtime-ctl - 2.4.0.SNAPSHOT | Added mentity is meter_entry {
  meter_id: 335567108
  index {
    index: 13674
  }
}


And following is the content of the bmv2 switch log : (cat  /tmp/bmv2-p0l0-log) 
 

entities {
  meter_entry {
    meter_id: 335567108
    index {
      index: 16381
    }
  }
}


As far as my understanding, I have read the bmv2 proto sppecs. and built the content of rpc request accordingly.  If you see anything wrong please let me know. 
 

Debobroto Das

unread,
Feb 15, 2020, 1:50:27 PM2/15/20
to Carmelo Cascone, P4 brigade
Btw, The command I am using for starting the bmv2 switch is following.


 simple_switch_grpc @ 29061ss3 BMV2 cmd string is :simple_switch_grpc --device-id 1 -i 1@ss3-eth1 -i 2@ss3-eth2 -i 3@ss3-eth3 -i 4@ss3-eth4 --thrift-port 39871 -L debug --log-file /tmp/bmv2-ss3.log --log-flush   --no-p4 -- --cpu-port 255 --grpc-server-addr 127.0.0.1:62003

After ONOS starts I provide a netcfg and after that the switches correctly configured with the p4 program and they forward packets according to my p4 program perfectly.  
Reply all
Reply to author
Forward
0 new messages