Re: [RFC] ethdev: support metadata as flow rule criteria
From: Ferruh Yigit <hidden>
Date: 2018-08-23 15:34:52
On 8/13/2018 9:03 AM, Dekel Peled wrote:
Adding relevant maintainers.quoted
-----Original Message----- From: Dekel Peled [mailto:dekelp@mellanox.com] Sent: Monday, August 13, 2018 10:47 AM To: dev@dpdk.org Cc: Ori Kam <redacted>; Shahaf Shuler [off-list ref] Subject: [RFC] ethdev: support metadata as flow rule criteria Current implementation of rte_flow allows match pattern of flow rule, based on packet data or header fields. This limits the application use of match patterns. For example, consider a vswitch application which controls a set of VMs, connected with virtio, in a fabric with overlay of VXLAN. Several VMs can have the same inner tuple, while the outer tuple is different and controlled by the vswitch (encap action). For the vswtich to be able to offload the rule to the NIC, it must use a unique match criteria, independent from the inner tuple, to perform the encap action. This RFC adds support for additional metadata to use as match pattern. The metadata is an opaque item, fully controlled by the application. The use of metadata is relevant for egress rules only. It can be set in the flow rule using the RTE_FLOW_ITEM_META. Application should set the packet metdata in the mbuf->metadata field, and set the PKT_TX_METADATA flag in the mbuf->ol_flags. The NIC will use the packet metadata as match criteria for relevant flow rules. For example, to do an encap action depending on the VM id, the application needs to configure 'match on metadata' rte_flow rule with VM id as metadata, along with desired encap action. When preparing an egress data packet, application will set VM id data in mbuf metadata field and set PKT_TX_METADATA flag. PMD will send data packets to NIC, with VM id as metadata. Egress flow on NIC will match metadata as done with other criteria. Upon match on metadata (VM id) the appropriate encap action will be performed. This RFC introduces metadata item type for rte_flow RTE_FLOW_ITEM_META, along with corresponding struct rte_flow_item_meta and ol_flag PKT_TX_METADATA. It also enhances struct rte_mbuf with new data item, uint64_t metadata. Comments are welcome. Signed-off-by: Dekel Peled <redacted>
Why not use mbuf->udata64 but add a new field? In your sample, the information that "metadata" contains the VM id needs to be implemented into PMD so that it can program HW accordingly, this is not flexible. What if app needs to provide another custom id, how PMD can know if provided metadata is VM id or custom id? Won't be better to provide an id_type and id_value, PMD can be implemented to behave different for id_type and use the id_value in the context of that type?