p4-dev@lists.p4.org

list for questions/discussion of p4 programs and tools

View all threads

print functionality in P4 for printing parse header and meta-data

SG
Sahil Gupta
Fri, Nov 20, 2020 4:55 PM

Hi all,
Anybody implemented some form of print functionality in the P4 language?
I want to print my application payload when it gets parsed. (either binary
or Hex representation)
Any other quick hack is also welcome.

Thanks
Sahil Gupta

Hi all, Anybody implemented some form of print functionality in the P4 language? I want to print my application payload when it gets parsed. (either binary or Hex representation) Any other quick hack is also welcome. Thanks Sahil Gupta
MB
Mihai Budiu
Fri, Nov 20, 2020 5:56 PM

If you run on an architecture that implements v1model.p4 there is a log_msg function which is there for this purpose. However, not all targets may support this function.

Mihai

From: P4-dev p4-dev-bounces@lists.p4.org On Behalf Of Sahil Gupta
Sent: Friday, November 20, 2020 8:56 AM
To: p4-dev p4-dev@lists.p4.org
Subject: [P4-dev] print functionality in P4 for printing parse header and meta-data

Hi all,
Anybody implemented some form of print functionality in the P4 language?
I want to print my application payload when it gets parsed. (either binary or Hex representation)
Any other quick hack is also welcome.
Thanks
Sahil Gupta

If you run on an architecture that implements v1model.p4 there is a log_msg function which is there for this purpose. However, not all targets may support this function. Mihai From: P4-dev <p4-dev-bounces@lists.p4.org> On Behalf Of Sahil Gupta Sent: Friday, November 20, 2020 8:56 AM To: p4-dev <p4-dev@lists.p4.org> Subject: [P4-dev] print functionality in P4 for printing parse header and meta-data Hi all, Anybody implemented some form of print functionality in the P4 language? I want to print my application payload when it gets parsed. (either binary or Hex representation) Any other quick hack is also welcome. Thanks Sahil Gupta
H
hemant@mnkcg.com
Fri, Nov 20, 2020 6:07 PM

If you look at p4c/p4include/v1model.p4, there is a log_msg() API.

Example use of the API exists in several P4 programs in
p4c/testdata/p4_16_samples/.  For one example, see issue2201-bmv2.p4.

Hemant

From: P4-dev p4-dev-bounces@lists.p4.org On Behalf Of Sahil Gupta
Sent: Friday, November 20, 2020 11:56 AM
To: p4-dev p4-dev@lists.p4.org
Subject: [P4-dev] print functionality in P4 for printing parse header and
meta-data

Hi all,

Anybody implemented some form of print functionality in the P4 language?

I want to print my application payload when it gets parsed. (either binary or
Hex representation)

Any other quick hack is also welcome.

Thanks

Sahil Gupta

If you look at p4c/p4include/v1model.p4, there is a log_msg() API. Example use of the API exists in several P4 programs in p4c/testdata/p4_16_samples/. For one example, see issue2201-bmv2.p4. Hemant From: P4-dev <p4-dev-bounces@lists.p4.org> On Behalf Of Sahil Gupta Sent: Friday, November 20, 2020 11:56 AM To: p4-dev <p4-dev@lists.p4.org> Subject: [P4-dev] print functionality in P4 for printing parse header and meta-data Hi all, Anybody implemented some form of print functionality in the P4 language? I want to print my application payload when it gets parsed. (either binary or Hex representation) Any other quick hack is also welcome. Thanks Sahil Gupta
SG
Sahil Gupta
Fri, Nov 20, 2020 6:35 PM

Thanks for this information.
I am also testing my program in behavioral models. So, hopefully, there
should not be a problem using log_msg()
Is there any p4 video or web tutorial online for the same?
I will check this p4c repository for more details if that serves the
purpose.

Thanks
Sahil Gupta

Thanks for this information. I am also testing my program in behavioral models. So, hopefully, there should not be a problem using log_msg() Is there any p4 video or web tutorial online for the same? I will check this p4c repository for more details if that serves the purpose. Thanks Sahil Gupta
MB
Mihai Budiu
Fri, Nov 20, 2020 6:37 PM

Here are the comments in v1model.p4.

/*

  • Log user defined messages
  • Example: log_msg("User defined message");
  • or log_msg("Value1 = {}, Value2 = {}",{value1, value2});
    */
    extern void log_msg(string msg);
    extern void log_msg<T>(string msg, in T data);

Mihai

From: P4-dev p4-dev-bounces@lists.p4.org On Behalf Of Sahil Gupta
Sent: Friday, November 20, 2020 10:36 AM
To: hemant@mnkcg.com
Cc: p4-dev p4-dev@lists.p4.org
Subject: Re: [P4-dev] print functionality in P4 for printing parse header and meta-data

Thanks for this information.
I am also testing my program in behavioral models. So, hopefully, there should not be a problem using log_msg()
Is there any p4 video or web tutorial online for the same?
I will check this p4c repository for more details if that serves the purpose.
Thanks
Sahil Gupta

Here are the comments in v1model.p4. /* * Log user defined messages * Example: log_msg("User defined message"); * or log_msg("Value1 = {}, Value2 = {}",{value1, value2}); */ extern void log_msg(string msg); extern void log_msg<T>(string msg, in T data); Mihai From: P4-dev <p4-dev-bounces@lists.p4.org> On Behalf Of Sahil Gupta Sent: Friday, November 20, 2020 10:36 AM To: hemant@mnkcg.com Cc: p4-dev <p4-dev@lists.p4.org> Subject: Re: [P4-dev] print functionality in P4 for printing parse header and meta-data Thanks for this information. I am also testing my program in behavioral models. So, hopefully, there should not be a problem using log_msg() Is there any p4 video or web tutorial online for the same? I will check this p4c repository for more details if that serves the purpose. Thanks Sahil Gupta
SG
Sahil Gupta
Fri, Nov 20, 2020 6:37 PM

@hemant@mnkcg.com hemant@mnkcg.com
Where I can see the log msg? In Switch logs or there is separate process
need to run on different terminal?

On Fri, Nov 20, 2020 at 1:35 PM Sahil Gupta sg5414@g.rit.edu wrote:

Thanks for this information.
I am also testing my program in behavioral models. So, hopefully, there
should not be a problem using log_msg()
Is there any p4 video or web tutorial online for the same?
I will check this p4c repository for more details if that serves the
purpose.

Thanks
Sahil Gupta

@hemant@mnkcg.com <hemant@mnkcg.com> Where I can see the log msg? In Switch logs or there is separate process need to run on different terminal? On Fri, Nov 20, 2020 at 1:35 PM Sahil Gupta <sg5414@g.rit.edu> wrote: > Thanks for this information. > I am also testing my program in behavioral models. So, hopefully, there > should not be a problem using log_msg() > Is there any p4 video or web tutorial online for the same? > I will check this p4c repository for more details if that serves the > purpose. > > Thanks > Sahil Gupta > >
H
hemant@mnkcg.com
Fri, Nov 20, 2020 6:39 PM

2nd try because this first message didn’t make it to the p4-dev mailer.

Hemant

From: hemant@mnkcg.com hemant@mnkcg.com
Sent: Friday, November 20, 2020 1:08 PM
To: 'sg5414@rit.edu' sg5414@rit.edu; 'p4-dev@lists.p4.org' p4-dev@lists.p4.org
Subject: RE: [P4-dev] print functionality in P4 for printing parse header and meta-data

If you look at p4c/p4include/v1model.p4, there is a log_msg() API.

Example use of the API exists in several P4 programs in p4c/testdata/p4_16_samples/.  For one example, see issue2201-bmv2.p4.

Hemant

From: P4-dev <p4-dev-bounces@lists.p4.org mailto:p4-dev-bounces@lists.p4.org > On Behalf Of Sahil Gupta
Sent: Friday, November 20, 2020 11:56 AM
To: p4-dev <p4-dev@lists.p4.org mailto:p4-dev@lists.p4.org >
Subject: [P4-dev] print functionality in P4 for printing parse header and meta-data

Hi all,

Anybody implemented some form of print functionality in the P4 language?

I want to print my application payload when it gets parsed. (either binary or Hex representation)

Any other quick hack is also welcome.

Thanks

Sahil Gupta

2nd try because this first message didn’t make it to the p4-dev mailer. Hemant From: hemant@mnkcg.com <hemant@mnkcg.com> Sent: Friday, November 20, 2020 1:08 PM To: 'sg5414@rit.edu' <sg5414@rit.edu>; 'p4-dev@lists.p4.org' <p4-dev@lists.p4.org> Subject: RE: [P4-dev] print functionality in P4 for printing parse header and meta-data If you look at p4c/p4include/v1model.p4, there is a log_msg() API. Example use of the API exists in several P4 programs in p4c/testdata/p4_16_samples/. For one example, see issue2201-bmv2.p4. Hemant From: P4-dev <p4-dev-bounces@lists.p4.org <mailto:p4-dev-bounces@lists.p4.org> > On Behalf Of Sahil Gupta Sent: Friday, November 20, 2020 11:56 AM To: p4-dev <p4-dev@lists.p4.org <mailto:p4-dev@lists.p4.org> > Subject: [P4-dev] print functionality in P4 for printing parse header and meta-data Hi all, Anybody implemented some form of print functionality in the P4 language? I want to print my application payload when it gets parsed. (either binary or Hex representation) Any other quick hack is also welcome. Thanks Sahil Gupta
SG
Sahil Gupta
Fri, Nov 20, 2020 6:44 PM

I tried to use it but I am getting the following error.
I have used it to apply an ingress control block.

Message:
p4@p4:~/tutorials/exercises/HTTP_payload_detection$ make
mkdir -p build pcaps logs
p4c-bm2-ss --p4v 16 --p4runtime-files build/basic.p4.p4info.txt -o
build/basic.json basic.p4
basic.p4(171): [--Werror=not-found] error: log_msg: Not found declaration
log_msg("Value1 = {}, Value2 = {}",{hdr.http.Get, hdr.http.Host});
^^^^^^^
../../utils/Makefile:43: recipe for target 'basic.json' failed
make: *** [basic.json] Error 1
p4@p4:~/tutorials/exercises/HTTP_payload_detection$

I tried to use it but I am getting the following error. I have used it to apply an ingress control block. *Message*: p4@p4:~/tutorials/exercises/HTTP_payload_detection$ make mkdir -p build pcaps logs p4c-bm2-ss --p4v 16 --p4runtime-files build/basic.p4.p4info.txt -o build/basic.json basic.p4 basic.p4(171): [--Werror=not-found] error: log_msg: Not found declaration log_msg("Value1 = {}, Value2 = {}",{hdr.http.Get, hdr.http.Host}); ^^^^^^^ ../../utils/Makefile:43: recipe for target 'basic.json' failed make: *** [basic.json] Error 1 p4@p4:~/tutorials/exercises/HTTP_payload_detection$
MB
Mihai Budiu
Fri, Nov 20, 2020 6:48 PM

You are probably using an old version of the tools.
This was merged in the compiler source tree 14 months ago.

Mihai

From: P4-dev p4-dev-bounces@lists.p4.org On Behalf Of Sahil Gupta
Sent: Friday, November 20, 2020 10:45 AM
To: hemant@mnkcg.com
Cc: p4-dev p4-dev@lists.p4.org
Subject: Re: [P4-dev] FW: print functionality in P4 for printing parse header and meta-data

I tried to use it but I am getting the following error.
I have used it to apply an ingress control block.

Message:
p4@p4:~/tutorials/exercises/HTTP_payload_detection$ make
mkdir -p build pcaps logs
p4c-bm2-ss --p4v 16 --p4runtime-files build/basic.p4.p4info.txt -o build/basic.json basic.p4
basic.p4(171): [--Werror=not-found] error: log_msg: Not found declaration
log_msg("Value1 = {}, Value2 = {}",{hdr.http.Get, hdr.http.Host});
^^^^^^^
../../utils/Makefile:43: recipe for target 'basic.json' failed
make: *** [basic.json] Error 1
p4@p4:~/tutorials/exercises/HTTP_payload_detection$

You are probably using an old version of the tools. This was merged in the compiler source tree 14 months ago. Mihai From: P4-dev <p4-dev-bounces@lists.p4.org> On Behalf Of Sahil Gupta Sent: Friday, November 20, 2020 10:45 AM To: hemant@mnkcg.com Cc: p4-dev <p4-dev@lists.p4.org> Subject: Re: [P4-dev] FW: print functionality in P4 for printing parse header and meta-data I tried to use it but I am getting the following error. I have used it to apply an ingress control block. Message: p4@p4:~/tutorials/exercises/HTTP_payload_detection$ make mkdir -p build pcaps logs p4c-bm2-ss --p4v 16 --p4runtime-files build/basic.p4.p4info.txt -o build/basic.json basic.p4 basic.p4(171): [--Werror=not-found] error: log_msg: Not found declaration log_msg("Value1 = {}, Value2 = {}",{hdr.http.Get, hdr.http.Host}); ^^^^^^^ ../../utils/Makefile:43: recipe for target 'basic.json' failed make: *** [basic.json] Error 1 p4@p4:~/tutorials/exercises/HTTP_payload_detection$
SG
Sahil Gupta
Fri, Nov 20, 2020 6:51 PM

Can you point me to the latest VM image which contains all the latest tools
built in?

Can you point me to the latest VM image which contains all the latest tools built in?