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

[pfcwdorch]: Add alert mode #342

Merged
merged 1 commit into from
Oct 12, 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
2 changes: 1 addition & 1 deletion orchagent/pfcactionhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class PfcWdActionHandler
public:
PfcWdActionHandler(sai_object_id_t port, sai_object_id_t queue,
uint8_t queueId, shared_ptr<Table> countersTable);
virtual ~PfcWdActionHandler(void) = 0;
virtual ~PfcWdActionHandler(void);

inline sai_object_id_t getPort(void)
{
Expand Down
9 changes: 9 additions & 0 deletions orchagent/pfcwdorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ PfcWdAction PfcWdOrch<DropHandler, ForwardHandler>::deserializeAction(const stri
{
{ "forward", PfcWdAction::PFC_WD_ACTION_FORWARD },
{ "drop", PfcWdAction::PFC_WD_ACTION_DROP },
{ "alert", PfcWdAction::PFC_WD_ACTION_ALERT },
Copy link
Contributor

Choose a reason for hiding this comment

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

is it better to move this const into the header file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is not intended to be used by anyone else. Enum is in header.

Copy link
Contributor

Choose a reason for hiding this comment

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

then a const static is better? do you know if the compiler will optimize here to only initialize the variable once?

Copy link
Contributor

@qiluo-msft qiluo-msft Oct 12, 2017

Choose a reason for hiding this comment

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

const static will be better here. Move out of this function, and make it a cpp global is even better.

There are several cost here:

  1. time cost: each function call will call the instructor once
  2. space cost: each template instantiate will create a local map instance

Copy link
Contributor

Choose a reason for hiding this comment

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

@qiluo-msft thanks for the explanation.

};

if (actionMap.find(key) == actionMap.end())
Expand Down Expand Up @@ -445,6 +446,14 @@ void PfcWdSwOrch<DropHandler, ForwardHandler>::handleWdNotification(swss::Notifi
entry->second.index,
PfcWdOrch<DropHandler, ForwardHandler>::getCountersTable());
}
else if (entry->second.action == PfcWdAction::PFC_WD_ACTION_ALERT)
{
entry->second.handler = make_shared<PfcWdActionHandler>(
entry->second.portId,
entry->first,
entry->second.index,
PfcWdOrch<DropHandler, ForwardHandler>::getCountersTable());
}
else
{
throw runtime_error("Unknown PFC WD action");
Expand Down
1 change: 1 addition & 0 deletions orchagent/pfcwdorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ enum class PfcWdAction
PFC_WD_ACTION_UNKNOWN,
PFC_WD_ACTION_FORWARD,
PFC_WD_ACTION_DROP,
PFC_WD_ACTION_ALERT,
};

template <typename DropHandler, typename ForwardHandler>
Expand Down