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