Giter VIP home page Giter VIP logo

Comments (5)

ederollora avatar ederollora commented on August 16, 2024

It seems that:

  • you might not have declared the cpu_in header, missing declaration:
     struct headers_t {
         ( . . . )
         cpu_in_t cpu_in;
     }
    
  • or, that you probably have to refer to it as hdr.cpu_in.ingress
  • or, if this is a variable, you might have also not declared it: bit<n> cpu_in;

Regards,

from ngsdn-tutorial.

ederollora avatar ederollora commented on August 16, 2024

Hi,

My recommendation is that your first complete the P4 tutorial: https://github.com/p4lang/tutorials/. You will most likely feel lost in most exercises of NG SDN repo without having a basic understanding of P4. That tutorial will get you up to date in the language to some extent.

In terms of your problem, I was just writing some general code, so my examples will probably not work by just copy pasting it. In your case, the header is already declared (as per your link exercise). So do not modify this line:

struct parsed_headers_t {
    ...
    cpu_in_header_t cpu_in;
    ...
}

According to the exercise and your error I guess what you are trying to do is complete this part of the exercise:

if (standard_metadata.egress_port == CPU_PORT) {
    // *** TODO EXERCISE 4
    // Implement logic such that if the packet is to be forwarded to the
    // CPU port, e.g., if in ingress we matched on the ACL table with
    // action send/clone_to_cpu...
    // 1. Set cpu_in header as valid
    // 2. Set the cpu_in.ingress_port field to the original packet's
    //    ingress port (standard_metadata.ingress_port).
}

In this case you need to:

  1. use setValid() to set the cpu_in header valid.

image
(info: https://p4.org/p4-spec/docs/P4-16-v1.2.1.html#sec-ops-on-hdrs)

  1. Assign the ingress_port field the packet's ingress port (which is stored in standard_metadata as ingress_port, i.e. standard_metadata.ingress_port) to cpu_in's ingress_port field. That is: hdr.cpu_in.ingress_port equals standard_metadata.ingress_port;

To refer to the cpu_in header be sure you refer to it as hdr.cpu_in always, else making it valid and assigning a value to its ingress_port field will be wrong. I still recommend you to do the aforementioned P4 tutorial. I am letting you complete the exercise but if you need further help on the exact code let us know.

Regards,

from ngsdn-tutorial.

ederollora avatar ederollora commented on August 16, 2024

Hi,

Ok so let me explain some parts.

This part seems wrong for several reasons:

if (cpu_in.ingress_port.egress_port == 255) {

The original code wrote this line instead, and it should stay in the same way (AFAIK):

if (standard_metadata.egress_port == CPU_PORT) {
}

The errors also refers to the fact that cpu_in should be written hdr.cpu_in instead. Finally, ingress_port is a field in the cpu_in header but egress_port is not, so a reference like cpu_in.ingress_port.egress_port is wrong.

You should write something like:

if (standard_metadata.egress_port == CPU_PORT) { 
    hdr.cpu_in.setValid();
    hdr.cpu_in.ingress_port = standard_metadata.ingress_port;
    hdr.cpu_in._pad = 0;
}

This piece of code is trying express this: "So... if the output port that we defined in the Ingress part of the pipeline is the actual CPU port (so we are sending this packet to the controller), then we have to first make cpu_in header valid because we need to prepend it to the packet. In this way, the controller can know the ingress_port from which it came from."

Once again, I really encourage you to first complete the P4 tutorial from the link I sent in my previous message. I imagine it is difficult to understand some of the suggestions I make here.

If you need help to understand any exercises from the P4 tutorial you can preferably write to the P4 Slack or the p4-dev mailing list but you can write to me if you want to.

Regards,

from ngsdn-tutorial.

ederollora avatar ederollora commented on August 16, 2024

Hi

For clarity, I will try to point out some errors I see from your last message:

  1. if (hdr.cpu_out.setValid()) { should be if (hdr.cpu_out.isValid()) {. setValid makes a header valid (so it can be deparsed and put into the wire) and isValid() is letting you know if the header is valid or not.

2 and 3) Second error "Field cpu_in is not a member of structure header cpu_in_header_t" is confusing. You should have both defined and declared the cpu_in header. The following structures should be in your program:

@controller_header("packet_in")
header cpu_in_header_t {
    port_num_t  ingress_port;
    bit<7>      _pad;
}

and

struct parsed_headers_t {
    cpu_out_header_t cpu_out;
    cpu_in_header_t cpu_in;
   // more headers
}
  1. The rest of the errors are difficult to clarify with the original code (you can attach a file in next messages you post, so we can debug it. It looks like, maybe, you might have not closed some structures or control blocks.

Don't worry about the time. I think you can come to anyone on the ONOS or P4 community and everyone will try to help as long as they have free time. I definitely think that the P4 tutorials will bring you the knowledge you need before you face the NG-SDN tutorials. It will be of much help.

Let us know if you need more help. You can close the issues if you want to.

Cheers,

from ngsdn-tutorial.

santorsula avatar santorsula commented on August 16, 2024

OK.

from ngsdn-tutorial.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.