[P4-dev] Difference between `clone` and `clone3` in v1model

Rui Miguel rmiguel at lasige.di.fc.ul.pt
Wed Nov 1 06:55:46 EDT 2017


I never tried using the multicast groups, but recirculate is definitely a possibility! As for metadata, it should work similarly to clone3<T>().

~ Rui Miguel 

----------------original message-----------------
From: "Dingyuan Hu" h-dy at outlook.com 
To: "Rui Miguel" rmiguel at lasige.di.fc.ul.pt 
CC: "p4-dev lists.p4.org" 
Date: Mon, 30 Oct 2017 07:35:42 +0000
-------------------------------------------------
 
 
> Hi 
> I think I can let A and A' go through different port.
> 
> 1. Clone A, we get A'
> 2. Set egress_spec for A
> 3. Recirculate A' at the end of egress (I am not sure about how metadata is 
> handled).
> 4. In ingress, we can use `instance_type` to know A'.
> 5. Change egress_spec for A' now.
> 
> PS: Another way, instead of using clone & recirculate, we can use multicast group 
> in BMv2. 
> 
> -----Original Message-----
> From: P4-dev [mailto:p4-dev-bounces at lists.p4.org ] On Behalf Of Rui Miguel
> Sent: Saturday, 28 October 2017 9:13 PM
> To: p4-dev lists.p4.org 
> Subject: Re: [P4-dev] Difference between `clone` and `clone3` in v1model
> 
> Hi again!
> 
> Under this scheme, I don't believe you can simultaneously change egress_spec 
> and clone. Both A and A' must leave through the same outgoing port.
> 
> Depending on what your purposes are, you can also employ a cheat that affronts the 
> ingress/egress logic a little, which is to edit simple_switch.cpp to make the 
> switch submit the clone not to egress_port, but to egress_spec:
> 
> https://github.com/p4lang/behavioral-model/blob/master/targets/simpl
> e_switch/simple_switch.cpp#L502
> Thus, the packet arrives at egress, you set its egress_spec (which does nothing 
> for the original), then use clone().
> 
> 
> ~ Rui Miguel
> 
> ----------------original message-----------------
> From: "Dingyuan Hu" h-dy at outlook.com 
> To: "Rui Miguel" rmiguel at lasige.di.fc.ul.pt 
> CC: "p4-dev lists.p4.org" 
> Date: Fri, 27 Oct 2017 07:16:55 +0000
> -------------------------------------------------
> 
> 
>> Hi Rui,
>> 
>> Thanks for your reply. I have another question.
>> 
>> I have a Packet A, and I clone it in ingress. So, I can get A and A’ in egress.
>> How to set different `egress_spec` for A and A’ ?
>> P4 not allowed change `egress_spec` (and `egress_port`) in egress and I 
>> can’t 
>> change A’ because it is generated after ingress.
>> 
>> 
>> Thanks,
>> Dingyuan Hu
>> 
>> ---
>> On 27/10/2017, 06:02, "P4-dev on behalf of Rui Miguel" 
>> 
> 
>> wrote:
>> 
>> Hello Dingyuan!
>> 
>> I'm not entirely sure about all the informations below; others may confirm or 
>> 
>> correct my statements.
>> 
>> 
>> - "session" might be there to be interpreted by the control plane. In the case 
>> of 
>> BMv2 simple_switch, it does nothing else by default. Also, both variations 
>> of 
>> clone() call with session=0 do nothing (I believe session is added to 
>> standard_metadata.clone_spec, and simple_switch evaluates whether it 
>> needs 
>> to clone by performing the statement "if (clone_spec)", which yields 0, or 
>> false, in such case).
>> 
>> 
>> - clone3<T> is supposed to pass user-defined metadata to the cloned packet. 
>> You 
>> should call clone3<T>() and replace T by the type of the metadata type you 
>> defined. I.e., if your ingress pipeline is control IPipe(inout pkt_t pkt, 
>> inout 
>> MYMETA_t, ...), then you should call clone3<MYMETA_t>(...). When the clone 
>> 
>> enters ingress (or egress), it will preserve all the data in MYMETA_t from the 
>> 
>> original.
>> I don't know what happens if you try to pass another type.
>> 
>> 
>> - About the CloneType. At least one of the reasons is practical: BMv2 
>> simple_switch does not implement I2I or E2I, so there's no way it would work 
>> even 
>> if they were present in the enum definition. The P4-14 spec does define such 
>> primitives, but they are unsupported by simple_switch.
>> 
>> 
>> Just a final hint: remember clone(), clone3(), recirculate() and 
>> resubmit() do 
>> not have immediate effects; the magic only happens at the end of the pipeline 
>> (ingress or egress).
>> 
>> 
>> ~ Rui Miguel
>> 
>> 
>> 
> 
> 
> 
> _______________________________________________
> P4-dev mailing list
> P4-dev at lists.p4.org 
> http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org
> 

-- 







More information about the P4-dev mailing list