[P4-dev] Resubmit Primitive and Instance_type in bmv2

Andy Fingerhut andy.fingerhut at gmail.com
Tue Sep 11 01:38:40 EDT 2018


I have not tried, but I wonder whether including all of standard_metadata
in your resubmit field list is causing the value of
standard_metadata.instance_type to be preserved from the original packet,
when it is 0 (NORMAL), and thus preventing the resubmitted packet from
having instance_type equal to 6?  You could try taking out
standard_metadata from the field list, and adding only the fields within
standard_metadata that you know you want to preserve, leaving out
instance_type.

I have a working P4_16 program that can do resubmit and recirculate
options, and use the instance_type field to distinguish in ingress
processing between packets from the ingress ports, vs. resubmitted, vs.
recirculated, that runs with recent versions of the open source p4c and
behavioral-model, so I think they are up to the task.

https://github.com/jafingerhut/p4-guide/tree/master/v1model-special-ops

Andy


On Sat, Aug 18, 2018 at 12:49 PM Yukinari He <yukinari.eed03 at g2.nctu.edu.tw>
wrote:

> Him Hermant,
>
>
>
> Thanks for the reply, I would give it a try later.
>
>
>
> Also, the below is the full program written in p4-14. Is there any logical
> error in my program?
>
>
>
> field_list resubmit_field {
>
>     standard_metadata;
>
>     intrinsic_metadata;
>
>     tmp;
>
> }
>
>
>
> action do_resubmit(){
>
>     modify_field(standard_metadata.ingress_port, 1);
>
>     resubmit(resubmit_field);
>
> }
>
> table resubmit_new_pkt{
>
>     actions {
>
>         do_resubmit;
>
>     }
>
> }
>
>
>
> action next_iteration(){
>
>     add_to_field(standard_metadata.ingress_port, 1);
>
>     resubmit(resubmit_field);
>
> }
>
> table start_next_iter{
>
>     actions {
>
>         next_iteration;
>
>     }
>
> }
>
> control ingress{
>
>     apply(read_port_num);
>
>     if(standard_metadata.instance_type == 6){
>
>         // to perform a loop: port 1 to tmp.port_num(writing in registers
> by RuntimeCmd)
>
>         if(standard_metadata.ingress_port <= tmp.port_num){
>
>             apply(get_best_hop_info);  //read something from registers
>
>             if(tmp.traffic >= tmp.best_hop_traffic){
>
>                 apply(best_hop_update); //write something to registers
>
>             }
>
>         }
>
>             if(standard_metadata.ingress_port < tmp.port_num)
>
>             apply(start_next_iter);
>
>     }
>
>     else{
>
>         apply(resubmit_new_pkt);  // new pkts, resubmit
>
>     }
>
> }
>
>
>
> Thanks,
>
> Yukinari
>
>
>
> *寄件者: *hemant at mnkcg.com
> *傳送時間: *2018年8月19日 上午 03:21
> *收件者: *'Yukinari He' <yukinari.eed03 at g2.nctu.edu.tw>; p4-dev at lists.p4.org
> *主旨: *RE: [P4-dev] Resubmit Primitive and Instance_type in bmv2
>
>
>
> You could use gdb and debug what happens to
> standard_metadata.instance_type
>
>
>
> Also, if the full P4 program can be shared, we could take a look.
>
>
>
> Thanks,
>
>
>
> Hemant
>
>
>
> *From:* P4-dev <p4-dev-bounces at lists.p4.org> *On Behalf Of *Yukinari He
> *Sent:* Saturday, August 18, 2018 12:27 PM
> *To:* p4-dev at lists.p4.org
> *Subject:* [P4-dev] Resubmit Primitive and Instance_type in bmv2
>
>
>
> Hi,
>
>
>
> I just complete a program with resubmit() as I’d like to deal with a
> loop-like behavior. I make *standatd_metadata.instance_type* as a field
> to check if a packet is resubmitted. However, I find that the condition
> which aims to check if the packet is resubmitted is never satisfied, so I’m
> not sure if the resubmit() is executed.
>
>
>
> Below is the pseudo-code of my program:
>
> Ingress{
>
>         // do something, Part A
>
>         If standard_metadata.instance_type == 6
>
>             If indicator < limit
>
>               // do something and resubmit again, Part B
>
>        Else if standard_metadata.instance_type != 6
>
>                 Resubmit()
>
> }
>
>
>
> I expect that when a packet comes, the switch should do something and
> resubmit it. The switch will then do Part A again and execute Part B as
> well for resubmitted packets until the termination condition comes true,
> but I find that the condition “*standard_metadata.instance_type == 6*” is
> never satisfied and the *instance_type* is always 0.
>
>
>
> Are there any mistakes I made?
>
>
>
> Thanks,
>
> Yukinari
>
>
> _______________________________________________
> P4-dev mailing list
> P4-dev at lists.p4.org
> http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20180910/4568918b/attachment-0001.html>


More information about the P4-dev mailing list