The problem of using register

254 views
Skip to first unread message

bin NIU

unread,
Oct 26, 2018, 4:36:10 AM10/26/18
to open-nfp
Hello :
  Recently , I want to implement a p4 application using smartnic , in this application I want to choose one out of every 100 packets to modify and the others are send out normally.
  But I found I cant not to choose the packet to modify.
  The following is the code
  


header_type ethernet_t {
    fields {
        dstAddr : 48;
        srcAddr : 48;
        etherType : 16;
    }
}

header_type ipv4_t {
    fields {
        version : 4;
        ihl : 4;
        //diffserv : 8;
        dscp : 6;
        ecn : 2;
        totalLen : 16;
        identification : 16;
        flags : 3;
        fragOffset : 13;
        ttl : 8;
        protocol : 8;
        hdrChecksum : 16;
        srcAddr : 32;
        dstAddr: 32;
    }
}



parser start {
    return parse_ethernet;
}

/*
 * Ethernet
 */

#define ETHERTYPE_IPV4 0x0800

header ethernet_t ethernet;
header ipv4_t ipv4;
parser parse_ethernet {
    extract(ethernet);
    return select(latest.etherType) {
        ETHERTYPE_IPV4 : parse_ipv4;
        default : ingress;
    }
}



parser parse_ipv4 {
    extract(ipv4);
    //set_metadata(tcp_length_meta.tcpLength,latest.totalLen - 20);
    return ingress;

}
action do_forward(espec) {
    modify_field(standard_metadata.egress_spec, espec);
    
}

action do_drop() {
    drop();
}
table tbl_forward {
    reads {
        standard_metadata.ingress_port : exact;
        //ipv4.dstAddr                   : ternary;
    }
    actions {
        do_forward;
        do_drop;
    }
    size : 4;
}

@pragma netro reglocked register
register hh_reg {
    width : 32;
    instance_count : 1;
}
action load_count_act() {
    register_read(load.load,hh_reg,0);
    register_write(hh_reg,0,load.load + 1);   
}
action load_rewrite() {
    register_write(hh_reg,0,0);
}
table tbl_load_count_act {
    actions {
        load_count_act;
    }
    
}
table tbl_load_rewrite {
    actions {
        load_rewrite;
    }
}
action test_count() {
    modify_field(ipv4.srcAddr,0);
}
table tbl_test {
    actions {
        test_count;
    }
}
control ingress {
    apply(tbl_forward);
    
    
}
control egress {
    

    apply(tbl_load_count_act);
    if (load.load == 100) {
        apply(tbl_load_rewrite);
        apply(tbl_test);
    }



}

David George

unread,
Oct 29, 2018, 2:34:36 AM10/29/18
to bin NIU, open...@googlegroups.com
Hi

This is due to the flowcache - the devtools user guide has a blurb about this. The register change isn't effecting the cached lookups for the flow.

Regards,
David

bin NIU

unread,
Oct 31, 2018, 3:53:58 AM10/31/18
to open-nfp
Hi:
Thanks for your reply , and Is there any way to make the cache invalid periodically? 
Regards
Bin

在 2018年10月29日星期一 UTC+8下午2:34:36,David George写道:

Gerhard de Klerk

unread,
Nov 12, 2018, 9:24:25 AM11/12/18
to bin NIU, open...@googlegroups.com
Hi Bin, 

The flow cache should time out after a while, but you can disable the flowcache all together. 
This will reduce performance but should provide the functionality that you are looking for.

Best regards,
Gerhard

--
You received this message because you are subscribed to the Google Groups "open-nfp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to open-nfp+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/open-nfp/5a9683df-f896-4f69-9452-7d702495f66c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Abhishek Dixit

unread,
May 22, 2024, 6:42:13 AM5/22/24
to open-nfp
hey, can you please tell me which file to modify to disable the lookup cache? I don't use GUI.
Reply all
Reply to author
Forward
0 new messages