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

Fix counters attribute name #639

Merged
merged 1 commit into from
Jun 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion backends/bmv2/bmv2stf.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,10 @@ def run(self):
return FAILURE
thriftPort = str(9090 + rand)
rv = SUCCESS

try:
os.remove("/tmp/bmv2-%d-notifications.ipc" % rand)
except OSError:
pass
try:
runswitch = [FindExe("behavioral-model", "simple_switch"),
"--log-file", self.switchLogFile, "--log-flush",
Expand Down Expand Up @@ -552,6 +555,10 @@ def run(self):
reportError("CLI process failed with exit code", cli.returncode)
rv = FAILURE
finally:
try:
os.remove("/tmp/bmv2-%d-notifications.ipc" % rand)
except OSError:
pass
concurrent.release(rand)
if self.options.verbose:
print("Execution completed")
Expand Down
7 changes: 5 additions & 2 deletions backends/bmv2/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,11 @@ ControlConverter::convertTable(const CFG::TableNode* node,
size = BMV2::TableAttributes::defaultTableSize;

result->emplace("max_size", size);
auto ctrs = table->properties->getProperty(BMV2::TableImplementation::directCounterName);
auto ctrs = table->properties->getProperty(BMV2::TableAttributes::countersName);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can just delete these from TableImplementation?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is the only change I am requesting: removal of the unused constants.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you suggesting replacing them with string constant literals? Or something else?

if (ctrs != nullptr) {
// The counters attribute should list the counters of the table, accessed in
// actions of the table. We should be checking that this attribute and the
// actions are consistent?
if (ctrs->value->is<IR::ExpressionValue>()) {
auto expr = ctrs->value->to<IR::ExpressionValue>()->expression;
if (expr->is<IR::ConstructorCallExpression>()) {
Expand Down Expand Up @@ -472,7 +475,7 @@ ControlConverter::convertTable(const CFG::TableNode* node,
}
result->emplace("support_timeout", sup_to);

auto dm = table->properties->getProperty(BMV2::TableAttributes::directMeterName);
auto dm = table->properties->getProperty(BMV2::TableAttributes::metersName);
if (dm != nullptr) {
if (dm->value->is<IR::ExpressionValue>()) {
auto expr = dm->value->to<IR::ExpressionValue>()->expression;
Expand Down
3 changes: 2 additions & 1 deletion backends/bmv2/helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ const cstring MatchImplementation::rangeMatchTypeName = "range";
const cstring TableAttributes::implementationName = "implementation";
const cstring TableAttributes::sizeName = "size";
const cstring TableAttributes::supportTimeoutName = "supportTimeout";
const cstring TableAttributes::directMeterName = "meters";
const cstring TableAttributes::countersName = "counters";
const cstring TableAttributes::metersName = "meters";
const unsigned TableAttributes::defaultTableSize = 1024;
const cstring V1ModelProperties::jsonMetadataParameterName = "standard_metadata";

Expand Down
3 changes: 2 additions & 1 deletion backends/bmv2/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class TableAttributes {
static const cstring sizeName;
static const cstring supportTimeoutName;
static const unsigned defaultTableSize;
static const cstring directMeterName;
static const cstring countersName;
static const cstring metersName;
};

class V1ModelProperties {
Expand Down
4 changes: 2 additions & 2 deletions control-plane/p4RuntimeSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ template <typename Kind> struct CounterlikeTraits;
template<> struct CounterlikeTraits<IR::Counter> {
static const cstring name() { return "counter"; }
static const cstring directPropertyName() {
return P4V1::V1Model::instance.tableAttributes.directCounter.name;
return P4V1::V1Model::instance.tableAttributes.counters.name;
}
static const cstring typeName() {
return P4V1::V1Model::instance.counter.name;
Expand All @@ -309,7 +309,7 @@ template<> struct CounterlikeTraits<IR::Counter> {
template<> struct CounterlikeTraits<IR::Meter> {
static const cstring name() { return "meter"; }
static const cstring directPropertyName() {
return P4V1::V1Model::instance.tableAttributes.directMeter.name;
return P4V1::V1Model::instance.tableAttributes.meters.name;
}
static const cstring typeName() {
return P4V1::V1Model::instance.meter.name;
Expand Down
4 changes: 2 additions & 2 deletions frontends/p4/fromv1.0/programStructure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ ProgramStructure::convertTable(const IR::V1Table* table, cstring newName,
auto propvalue = new IR::ExpressionValue(constructor);
auto annos = addNameAnnotation(ctr);
auto prop = new IR::Property(
IR::ID(v1model.tableAttributes.directCounter.Id()),
IR::ID(v1model.tableAttributes.counters.Id()),
annos, propvalue, false);
props->push_back(prop);
}
Expand All @@ -831,7 +831,7 @@ ProgramStructure::convertTable(const IR::V1Table* table, cstring newName,
auto meter = new IR::PathExpression(mtr->name);
auto propvalue = new IR::ExpressionValue(meter);
auto prop = new IR::Property(
IR::ID(v1model.tableAttributes.directMeter.Id()), propvalue, false);
IR::ID(v1model.tableAttributes.meters.Id()), propvalue, false);
props->push_back(prop);
}

Expand Down
8 changes: 4 additions & 4 deletions frontends/p4/fromv1.0/v1model.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,12 @@ struct Switch_Model : public ::Model::Elem {

struct TableAttributes_Model {
TableAttributes_Model() : tableImplementation("implementation"),
directCounter("counters"),
directMeter("meters"), size("size"),
counters("counters"),
meters("meters"), size("size"),
supportTimeout("support_timeout") {}
::Model::Elem tableImplementation;
::Model::Elem directCounter;
::Model::Elem directMeter;
::Model::Elem counters;
::Model::Elem meters;
::Model::Elem size;
::Model::Elem supportTimeout;
const unsigned defaultTableSize = 1024;
Expand Down