Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create dpdk specific pna.p4 and extend it #3658

Merged
merged 11 commits into from
Nov 11, 2022
Prev Previous commit
Next Next commit
Added comments in pna.p4 and psa.p4
  • Loading branch information
kamleshbhalui committed Nov 11, 2022
commit dab1b253ea9e56a24c17c0ac9a31a4648b142d59
23 changes: 18 additions & 5 deletions p4include/dpdk/pna.p4
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,11 @@ enum PNA_CounterType_t {
@noWarn("unused")
extern Counter<W, S> {
Counter(bit<32> n_counters, PNA_CounterType_t type);
// dpdk does not support this overload currently if used with
// BYTES counter type
void count(in S index);

// Dpdk support this overload and requires packet length
void count(in S index, in bit<32> pkt_len);
}
// END:Counter_extern
Expand All @@ -382,7 +386,10 @@ extern Counter<W, S> {
@noWarn("unused")
extern DirectCounter<W> {
DirectCounter(PNA_CounterType_t type);
// dpdk does not support this overload currently if used with
// BYTES counter type
void count();
// Dpdk support this overload and requires packet length
void count(in bit<32> pkt_len);
}
// END:DirectCounter_extern
Expand All @@ -403,21 +410,24 @@ enum PNA_MeterColor_t { RED, GREEN, YELLOW }

extern Meter<S> {
Meter(bit<32> n_meters, PNA_MeterType_t type);
// dpdk does not support below two execute overload, using it
// result in compilation failure and suggest using `dpdk_execute`

// Use this method call to perform a color aware meter update (see
// RFC 2698). The color of the packet before the method call was
// made is specified by the color parameter.
PNA_MeterColor_t execute(in S index, in PNA_MeterColor_t color);
// Use this method call to perform a color blind meter update (see
// RFC 2698). It may be implemented via a call to execute(index,
// MeterColor_t.GREEN), which has the same behavior.
PNA_MeterColor_t execute(in S index);

// Adding param `in bit<32> pkt_len` to execute (part of Meter extern)
// leads to overload resolution failure due to ambiguous candidates,
// as p4c do overload resolution based on number of parameter and does
// not consider types. To workaround this we introduced new method in
// Meter extern `dpdk_execute` which has extra param.
PNA_MeterColor_t dpdk_execute(in S index, in PNA_MeterColor_t color, in bit<32> pkt_len);

// Use this method call to perform a color blind meter update (see
// RFC 2698). It may be implemented via a call to execute(index,
// MeterColor_t.GREEN), which has the same behavior.
PNA_MeterColor_t execute(in S index);
PNA_MeterColor_t dpdk_execute(in S index, in bit<32> pkt_len);
}
// END:Meter_extern
Expand All @@ -426,8 +436,11 @@ extern Meter<S> {
extern DirectMeter {
DirectMeter(PNA_MeterType_t type);
// See the corresponding methods for extern Meter.
// dpdk does not support below two execute overload, using it
// result in compilation failure and suggest using `dpdk_execute`
PNA_MeterColor_t execute(in PNA_MeterColor_t color);
PNA_MeterColor_t execute();

PNA_MeterColor_t dpdk_execute(in PNA_MeterColor_t color, in bit<32> pkt_len);
PNA_MeterColor_t dpdk_execute(in bit<32> pkt_len);
}
Expand Down
29 changes: 20 additions & 9 deletions p4include/dpdk/psa.p4
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,10 @@ enum PSA_CounterType_t {
@noWarn("unused")
extern Counter<W, S> {
Counter(bit<32> n_counters, PSA_CounterType_t type);
// dpdk does not support this overload currently if used with
// BYTES counter type
void count(in S index);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does DPDK do when a PSA program calls the original count method that does not have a pkt_len parameter? Nothing? It would be good to have a comment here if it does anything other than what PSA defines.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And also for the corresponding method in the DirectCounter extern. And for Meter and DirectMeter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added the comments

// Dpdk support this overload and requires packet length
void count(in S index, in bit<32> pkt_len);

/*
Expand Down Expand Up @@ -629,9 +632,11 @@ extern Counter<W, S> {
@noWarn("unused")
extern DirectCounter<W> {
DirectCounter(PSA_CounterType_t type);
void count();
// dpdk does not support this overload currently if used with
// BYTES counter type
void count();
// Dpdk support this overload and requires packet length
void count(in bit<32> pkt_len);

/*
@ControlPlaneAPI
{
Expand Down Expand Up @@ -663,21 +668,24 @@ enum PSA_MeterColor_t { RED, GREEN, YELLOW }
extern Meter<S> {
Meter(bit<32> n_meters, PSA_MeterType_t type);

// dpdk does not support below two execute overload, using it
// result in compilation failure and suggest using `dpdk_execute`

// Use this method call to perform a color aware meter update (see
// RFC 2698). The color of the packet before the method call was
// made is specified by the color parameter.
PSA_MeterColor_t execute(in S index, in PSA_MeterColor_t color);
// Use this method call to perform a color blind meter update (see
// RFC 2698). It may be implemented via a call to execute(index,
// MeterColor_t.GREEN), which has the same behavior.
PSA_MeterColor_t execute(in S index);

// Adding param `in bit<32> pkt_len` to execute (part of Meter extern)
// leads to overload resolution failure due to ambiguous candidates,
// as p4c do overload resolution based on number of parameter and does
// not consider types. To workaround this we introduced new method in
// Meter extern `dpdk_execute` which has extra param.
PSA_MeterColor_t dpdk_execute(in S index, in PSA_MeterColor_t color, in bit<32> pkt_len);

// Use this method call to perform a color blind meter update (see
// RFC 2698). It may be implemented via a call to execute(index,
// MeterColor_t.GREEN), which has the same behavior.
PSA_MeterColor_t execute(in S index);
PSA_MeterColor_t dpdk_execute(in S index, in PSA_MeterColor_t color, in bit<32> pkt_len);
PSA_MeterColor_t dpdk_execute(in S index, in bit<32> pkt_len);

/*
Expand All @@ -695,9 +703,12 @@ extern Meter<S> {
extern DirectMeter {
DirectMeter(PSA_MeterType_t type);
// See the corresponding methods for extern Meter.
// dpdk does not support below two execute overload, using it
// result in compilation failure and suggest using `dpdk_execute`
PSA_MeterColor_t execute(in PSA_MeterColor_t color);
PSA_MeterColor_t dpdk_execute(in PSA_MeterColor_t color, in bit<32> pkt_len);
PSA_MeterColor_t execute();

PSA_MeterColor_t dpdk_execute(in PSA_MeterColor_t color, in bit<32> pkt_len);
PSA_MeterColor_t dpdk_execute(in bit<32> pkt_len);

/*
Expand Down