Skip to content

Commit

Permalink
Disable 'unused' warning for some psa.p4 externs (#3147)
Browse files Browse the repository at this point in the history
* Disable 'unused' warning for some psa.p4 externs

Signed-off-by: Mihai Budiu <mbudiu@vmware.com>

* Add noWarn annotation to dpdk/psa.p4

* Disable noWarn for some pna.p4 externs

Signed-off-by: Mihai Budiu <mbudiu@vmware.com>

* More changed reference files

* More reference files changed

Signed-off-by: Mihai Budiu <mbudiu@vmware.com>

* Trivial commit to check CI pipeline

* Modified reference outputs

* More reference files
  • Loading branch information
Mihai Budiu authored Mar 26, 2022
1 parent a33e0af commit 8b71871
Show file tree
Hide file tree
Showing 303 changed files with 153 additions and 1,782 deletions.
2 changes: 1 addition & 1 deletion frontends/p4/unusedDeclarations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ const IR::Node* RemoveUnusedDeclarations::preorder(IR::Parameter* param) {
const IR::Node* RemoveUnusedDeclarations::warnIfUnused(const IR::Node* node) {
if (!refMap->isUsed(getOriginal<IR::IDeclaration>()))
if (giveWarning(getOriginal()))
::warning(ErrorType::WARN_UNUSED, "'%1%' is unused", node);
warn(ErrorType::WARN_UNUSED, "'%1%' is unused", node);
return node;
}

Expand Down
10 changes: 6 additions & 4 deletions p4include/bmv2/psa.p4
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ match_kind {
/// This action does not change whether a clone or resubmit operation
/// will occur.

@noWarnUnused
@noWarn("unused")
action send_to_port(inout psa_ingress_output_metadata_t meta,
in PortId_t egress_port)
{
Expand All @@ -380,7 +380,7 @@ action send_to_port(inout psa_ingress_output_metadata_t meta,
/// This action does not change whether a clone or resubmit operation
/// will occur.

@noWarnUnused
@noWarn("unused")
action multicast(inout psa_ingress_output_metadata_t meta,
in MulticastGroup_t multicast_group)
{
Expand All @@ -396,7 +396,7 @@ action multicast(inout psa_ingress_output_metadata_t meta,
/// This action does not change whether a clone will occur. It will
/// prevent a packet from being resubmitted.

@noWarnUnused
@noWarn("unused")
action ingress_drop(inout psa_ingress_output_metadata_t meta)
{
meta.drop = true;
Expand All @@ -409,7 +409,7 @@ action ingress_drop(inout psa_ingress_output_metadata_t meta)

/// This action does not change whether a clone will occur.

@noWarnUnused
@noWarn("unused")
action egress_drop(inout psa_egress_output_metadata_t meta)
{
meta.drop = true;
Expand Down Expand Up @@ -543,6 +543,7 @@ enum PSA_CounterType_t {
/// Indirect counter with n_counters independent counter values, where
/// every counter value has a data plane size specified by type W.

@noWarn("unused")
extern Counter<W, S> {
Counter(bit<32> n_counters, PSA_CounterType_t type);
void count(in S index);
Expand Down Expand Up @@ -572,6 +573,7 @@ extern Counter<W, S> {
// END:Counter_extern

// BEGIN:DirectCounter_extern
@noWarn("unused")
extern DirectCounter<W> {
DirectCounter(PSA_CounterType_t type);
void count();
Expand Down
11 changes: 6 additions & 5 deletions p4include/dpdk/psa.p4
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ match_kind {
/// This action does not change whether a clone or resubmit operation
/// will occur.

@noWarnUnused
@noWarn("unused")
action send_to_port(inout psa_ingress_output_metadata_t meta,
in PortId_t egress_port)
{
Expand All @@ -368,7 +368,7 @@ action send_to_port(inout psa_ingress_output_metadata_t meta,
/// This action does not change whether a clone or resubmit operation
/// will occur.

@noWarnUnused
@noWarn("unused")
action multicast(inout psa_ingress_output_metadata_t meta,
in MulticastGroup_t multicast_group)
{
Expand All @@ -384,7 +384,7 @@ action multicast(inout psa_ingress_output_metadata_t meta,
/// This action does not change whether a clone will occur. It will
/// prevent a packet from being resubmitted.

@noWarnUnused
@noWarn("unused")
action ingress_drop(inout psa_ingress_output_metadata_t meta)
{
meta.drop = true;
Expand All @@ -397,7 +397,7 @@ action ingress_drop(inout psa_ingress_output_metadata_t meta)

/// This action does not change whether a clone will occur.

@noWarnUnused
@noWarn("unused")
action egress_drop(inout psa_egress_output_metadata_t meta)
{
meta.drop = true;
Expand Down Expand Up @@ -530,7 +530,7 @@ enum PSA_CounterType_t {
// BEGIN:Counter_extern
/// Indirect counter with n_counters independent counter values, where
/// every counter value has a data plane size specified by type W.

@noWarn("unused")
extern Counter<W, S> {
Counter(bit<32> n_counters, PSA_CounterType_t type);
void count(in S index, @optional in bit<32> increment);
Expand Down Expand Up @@ -560,6 +560,7 @@ extern Counter<W, S> {
// END:Counter_extern

// BEGIN:DirectCounter_extern
@noWarn("unused")
extern DirectCounter<W> {
DirectCounter(PSA_CounterType_t type);
void count();
Expand Down
12 changes: 7 additions & 5 deletions p4include/pna.p4
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ limitations under the License.
#ifndef __PNA_P4__
#define __PNA_P4__

#include<core.p4>
#include <core.p4>

/**
* P4-16 declaration of the Portable NIC Architecture
Expand Down Expand Up @@ -370,13 +370,15 @@ enum PNA_CounterType_t {
/// Indirect counter with n_counters independent counter values, where
/// every counter value has a data plane size specified by type W.

@noWarn("unused")
extern Counter<W, S> {
Counter(bit<32> n_counters, PNA_CounterType_t type);
void count(in S index);
}
// END:Counter_extern

// BEGIN:DirectCounter_extern
@noWarn("unused")
extern DirectCounter<W> {
DirectCounter(PNA_CounterType_t type);
void count();
Expand Down Expand Up @@ -670,14 +672,14 @@ control PreControlT<PH, PM>(
in pna_pre_input_metadata_t istd,
inout pna_pre_output_metadata_t ostd);

parser MainParserT<PM, MH, MM>(
parser MainParserT<MH, MM>(
packet_in pkt,
//in PM pre_user_meta,
out MH main_hdr,
inout MM main_user_meta,
in pna_main_parser_input_metadata_t istd);

control MainControlT<PM, MH, MM>(
control MainControlT<MH, MM>(
//in PM pre_user_meta,
inout MH main_hdr,
inout MM main_user_meta,
Expand All @@ -691,9 +693,9 @@ control MainDeparserT<MH, MM>(
in pna_main_output_metadata_t ostd);

package PNA_NIC<PH, PM, MH, MM>(
MainParserT<PM, MH, MM> main_parser,
MainParserT<MH, MM> main_parser,
PreControlT<PH, PM> pre_control,
MainControlT<PM, MH, MM> main_control,
MainControlT<MH, MM> main_control,
MainDeparserT<MH, MM> main_deparser);
// END:Programmable_blocks

Expand Down
4 changes: 2 additions & 2 deletions test/gtest/p4runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -991,8 +991,8 @@ TEST_F(P4Runtime, PSADigests) {
)"), CompilerOptions::FrontendVersion::P4_16, "psa");

ASSERT_TRUE(test);
// 2 warnings
EXPECT_EQ(2u, ::diagnosticCount());
// 0 warnings
EXPECT_EQ(0u, ::diagnosticCount());
const auto &typeInfo = test->p4Info->type_info();

// Verify that that the digest() instances match the ones we expect from the
Expand Down
4 changes: 2 additions & 2 deletions testdata/p4_16_errors_outputs/psa-meter2.p4-stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ psa-meter2.p4(57): [--Werror=type-error] error: cast
b.data = (bit<16>)meter0.execute(index, PSA_MeterColor_t.GREEN);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
---- Actual error:
psa.p4(601): Cannot unify type 'PSA_MeterColor_t' with type 'bit<16>'
psa.p4(603): Cannot unify type 'PSA_MeterColor_t' with type 'bit<16>'
enum PSA_MeterColor_t { RED, GREEN, YELLOW }
^^^^^^^^^^^^^^^^
---- Originating from:
psa.p4(601): Cannot cast from 'PSA_MeterColor_t' to 'bit<16>'
psa.p4(603): Cannot cast from 'PSA_MeterColor_t' to 'bit<16>'
enum PSA_MeterColor_t { RED, GREEN, YELLOW }
^^^^^^^^^^^^^^^^
Empty file modified testdata/p4_16_samples/issue1897-bmv2.p4
100755 → 100644
Empty file.
Empty file modified testdata/p4_16_samples/issue2126.p4
100755 → 100644
Empty file.
Empty file modified testdata/p4_16_samples/issue3091.p4
100755 → 100644
Empty file.
Empty file modified testdata/p4_16_samples/psa-top-level-assignments-bmv2.p4
100755 → 100644
Empty file.
Empty file modified testdata/p4_16_samples/psa-top-level-assignments-bmv2.stf
100755 → 100644
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ control ingress(inout headers_t hdr, inout metadata_t user_meta, in psa_ingress_
@name("ingress.a") bit<12> a_0;
@name("ingress.meta") psa_ingress_output_metadata_t meta_0;
@name("ingress.egress_port") PortId_t egress_port_0;
@noWarnUnused @name(".send_to_port") action send_to_port_0() {
@noWarn("unused") @name(".send_to_port") action send_to_port_0() {
meta_0 = ostd;
egress_port_0 = istd.ingress_port;
meta_0.drop = false;
Expand Down
2 changes: 1 addition & 1 deletion testdata/p4_16_samples_outputs/hash-extern-bmv2-midend.p4
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ struct tuple_0 {
}

control ingress(inout headers_t hdr, inout metadata_t user_meta, in psa_ingress_input_metadata_t istd, inout psa_ingress_output_metadata_t ostd) {
@noWarnUnused @name(".send_to_port") action send_to_port_0() {
@noWarn("unused") @name(".send_to_port") action send_to_port_0() {
ostd.drop = false;
ostd.multicast_group = 32w0;
ostd.egress_port = istd.ingress_port;
Expand Down
6 changes: 0 additions & 6 deletions testdata/p4_16_samples_outputs/hash-extern-bmv2.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,6 +0,0 @@
psa.p4(546): [--Wwarn=unused] warning: 'W' is unused
extern Counter<W, S> {
^
psa.p4(575): [--Wwarn=unused] warning: 'W' is unused
extern DirectCounter<W> {
^
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ actions {
id: 27646489
name: "send_to_port"
alias: "send_to_port"
annotations: "@noWarnUnused"
annotations: "@noWarn(\"unused\")"
}
}
type_info {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ parser IngressParserImpl(packet_in buffer, out headers hdr, inout metadata user_
control ingress(inout headers hdr, inout metadata user_meta, in psa_ingress_input_metadata_t istd, inout psa_ingress_output_metadata_t ostd) {
@name("ingress.meta") psa_ingress_output_metadata_t meta_0;
@name("ingress.egress_port") PortId_t egress_port_0;
@noWarnUnused @name(".send_to_port") action send_to_port_0() {
@noWarn("unused") @name(".send_to_port") action send_to_port_0() {
meta_0 = ostd;
egress_port_0 = istd.ingress_port;
meta_0.drop = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ parser IngressParserImpl(packet_in buffer, out headers hdr, inout metadata user_
}

control ingress(inout headers hdr, inout metadata user_meta, in psa_ingress_input_metadata_t istd, inout psa_ingress_output_metadata_t ostd) {
@noWarnUnused @name(".send_to_port") action send_to_port_0() {
@noWarn("unused") @name(".send_to_port") action send_to_port_0() {
ostd.drop = false;
ostd.multicast_group = 32w0;
ostd.egress_port = istd.ingress_port;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +0,0 @@
psa.p4(546): [--Wwarn=unused] warning: 'W' is unused
extern Counter<W, S> {
^
psa.p4(575): [--Wwarn=unused] warning: 'W' is unused
extern DirectCounter<W> {
^
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ actions {
id: 27646489
name: "send_to_port"
alias: "send_to_port"
annotations: "@noWarnUnused"
annotations: "@noWarn(\"unused\")"
}
}
type_info {
Expand Down
6 changes: 0 additions & 6 deletions testdata/p4_16_samples_outputs/issue1208-1.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,6 +0,0 @@
psa.p4(546): [--Wwarn=unused] warning: 'W' is unused
extern Counter<W, S> {
^
psa.p4(575): [--Wwarn=unused] warning: 'W' is unused
extern DirectCounter<W> {
^
12 changes: 0 additions & 12 deletions testdata/p4_16_samples_outputs/issue2900.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,12 +0,0 @@
pna.p4(373): [--Wwarn=unused] warning: 'W' is unused
extern Counter<W, S> {
^
pna.p4(380): [--Wwarn=unused] warning: 'W' is unused
extern DirectCounter<W> {
^
pna.p4(673): [--Wwarn=unused] warning: 'PM' is unused
parser MainParserT<PM, MH, MM>(
^^
pna.p4(680): [--Wwarn=unused] warning: 'PM' is unused
control MainControlT<PM, MH, MM>(
^^
6 changes: 0 additions & 6 deletions testdata/p4_16_samples_outputs/p4rt_digest_complex.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,6 +0,0 @@
psa.p4(546): [--Wwarn=unused] warning: 'W' is unused
extern Counter<W, S> {
^
psa.p4(575): [--Wwarn=unused] warning: 'W' is unused
extern DirectCounter<W> {
^
12 changes: 0 additions & 12 deletions testdata/p4_16_samples_outputs/pna-action-selector.p4-error
Original file line number Diff line number Diff line change
@@ -1,12 +0,0 @@
pna.p4(373): [--Wwarn=unused] warning: 'W' is unused
extern Counter<W, S> {
^
pna.p4(380): [--Wwarn=unused] warning: 'W' is unused
extern DirectCounter<W> {
^
pna.p4(673): [--Wwarn=unused] warning: 'PM' is unused
parser MainParserT<PM, MH, MM>(
^^
pna.p4(680): [--Wwarn=unused] warning: 'PM' is unused
control MainControlT<PM, MH, MM>(
^^
12 changes: 0 additions & 12 deletions testdata/p4_16_samples_outputs/pna-action-selector.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,12 +0,0 @@
pna.p4(373): [--Wwarn=unused] warning: 'W' is unused
extern Counter<W, S> {
^
pna.p4(380): [--Wwarn=unused] warning: 'W' is unused
extern DirectCounter<W> {
^
pna.p4(673): [--Wwarn=unused] warning: 'PM' is unused
parser MainParserT<PM, MH, MM>(
^^
pna.p4(680): [--Wwarn=unused] warning: 'PM' is unused
control MainControlT<PM, MH, MM>(
^^
12 changes: 0 additions & 12 deletions testdata/p4_16_samples_outputs/pna-add-on-miss.p4-error
Original file line number Diff line number Diff line change
@@ -1,12 +0,0 @@
pna.p4(373): [--Wwarn=unused] warning: 'W' is unused
extern Counter<W, S> {
^
pna.p4(380): [--Wwarn=unused] warning: 'W' is unused
extern DirectCounter<W> {
^
pna.p4(673): [--Wwarn=unused] warning: 'PM' is unused
parser MainParserT<PM, MH, MM>(
^^
pna.p4(680): [--Wwarn=unused] warning: 'PM' is unused
control MainControlT<PM, MH, MM>(
^^
12 changes: 0 additions & 12 deletions testdata/p4_16_samples_outputs/pna-add-on-miss.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,12 +0,0 @@
pna.p4(373): [--Wwarn=unused] warning: 'W' is unused
extern Counter<W, S> {
^
pna.p4(380): [--Wwarn=unused] warning: 'W' is unused
extern DirectCounter<W> {
^
pna.p4(673): [--Wwarn=unused] warning: 'PM' is unused
parser MainParserT<PM, MH, MM>(
^^
pna.p4(680): [--Wwarn=unused] warning: 'PM' is unused
control MainControlT<PM, MH, MM>(
^^
12 changes: 0 additions & 12 deletions testdata/p4_16_samples_outputs/pna-dpdk-parser-state-err.p4-error
Original file line number Diff line number Diff line change
@@ -1,12 +0,0 @@
pna.p4(373): [--Wwarn=unused] warning: 'W' is unused
extern Counter<W, S> {
^
pna.p4(380): [--Wwarn=unused] warning: 'W' is unused
extern DirectCounter<W> {
^
pna.p4(673): [--Wwarn=unused] warning: 'PM' is unused
parser MainParserT<PM, MH, MM>(
^^
pna.p4(680): [--Wwarn=unused] warning: 'PM' is unused
control MainControlT<PM, MH, MM>(
^^
12 changes: 0 additions & 12 deletions testdata/p4_16_samples_outputs/pna-dpdk-parser-state-err.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,12 +0,0 @@
pna.p4(373): [--Wwarn=unused] warning: 'W' is unused
extern Counter<W, S> {
^
pna.p4(380): [--Wwarn=unused] warning: 'W' is unused
extern DirectCounter<W> {
^
pna.p4(673): [--Wwarn=unused] warning: 'PM' is unused
parser MainParserT<PM, MH, MM>(
^^
pna.p4(680): [--Wwarn=unused] warning: 'PM' is unused
control MainControlT<PM, MH, MM>(
^^
Original file line number Diff line number Diff line change
@@ -1,12 +0,0 @@
pna.p4(373): [--Wwarn=unused] warning: 'W' is unused
extern Counter<W, S> {
^
pna.p4(380): [--Wwarn=unused] warning: 'W' is unused
extern DirectCounter<W> {
^
pna.p4(673): [--Wwarn=unused] warning: 'PM' is unused
parser MainParserT<PM, MH, MM>(
^^
pna.p4(680): [--Wwarn=unused] warning: 'PM' is unused
control MainControlT<PM, MH, MM>(
^^
Original file line number Diff line number Diff line change
@@ -1,12 +0,0 @@
pna.p4(373): [--Wwarn=unused] warning: 'W' is unused
extern Counter<W, S> {
^
pna.p4(380): [--Wwarn=unused] warning: 'W' is unused
extern DirectCounter<W> {
^
pna.p4(673): [--Wwarn=unused] warning: 'PM' is unused
parser MainParserT<PM, MH, MM>(
^^
pna.p4(680): [--Wwarn=unused] warning: 'PM' is unused
control MainControlT<PM, MH, MM>(
^^
Loading

0 comments on commit 8b71871

Please sign in to comment.