Skip to content
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
20 changes: 17 additions & 3 deletions orchagent/flex_counter/flex_counter_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,28 @@ FlexCounterManager::FlexCounterManager(
const uint polling_interval,
const bool enabled,
FieldValueTuple fv_plugin) :
FlexCounterManager("FLEX_COUNTER_DB", group_name, stats_mode,
polling_interval, enabled, fv_plugin)
{
}

FlexCounterManager::FlexCounterManager(
const string& db_name,
const string& group_name,
const StatsMode stats_mode,
const uint polling_interval,
const bool enabled,
FieldValueTuple fv_plugin) :
group_name(group_name),
stats_mode(stats_mode),
polling_interval(polling_interval),
enabled(enabled),
fv_plugin(fv_plugin),
flex_counter_db(new DBConnector("FLEX_COUNTER_DB", 0)),
flex_counter_group_table(new ProducerTable(flex_counter_db.get(), FLEX_COUNTER_GROUP_TABLE)),
flex_counter_table(new ProducerTable(flex_counter_db.get(), FLEX_COUNTER_TABLE))
flex_counter_db(new DBConnector(db_name, 0)),
flex_counter_group_table(new ProducerTable(flex_counter_db.get(),
FLEX_COUNTER_GROUP_TABLE)),
flex_counter_table(new ProducerTable(flex_counter_db.get(),
FLEX_COUNTER_TABLE))
{
SWSS_LOG_ENTER();

Expand Down
8 changes: 8 additions & 0 deletions orchagent/flex_counter/flex_counter_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ class FlexCounterManager
FlexCounterManager()
{}

FlexCounterManager(
const std::string& db_name,
const std::string& group_name,
const StatsMode stats_mode,
const uint polling_interval,
const bool enabled,
swss::FieldValueTuple fv_plugin = std::make_pair("",""));

FlexCounterManager(const FlexCounterManager&) = delete;
FlexCounterManager& operator=(const FlexCounterManager&) = delete;
virtual ~FlexCounterManager();
Expand Down
6 changes: 6 additions & 0 deletions orchagent/flexcounterorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@ void FlexCounterOrch::doTask(Consumer &consumer)
vector<FieldValueTuple> fieldValues;
fieldValues.emplace_back(FLEX_COUNTER_STATUS_FIELD, value);
m_flexCounterGroupTable->set(flexCounterGroupMap[key], fieldValues);

// Update FLEX_COUNTER_STATUS for gearbox port
if (key == PORT_KEY && gPortsOrch && gPortsOrch->isGearboxEnabled())
{
gPortsOrch->setGearboxFlexCounterStatus(value == "enable");
}
}
else if(field == FLEX_COUNTER_DELAY_STATUS_FIELD)
{
Expand Down
60 changes: 49 additions & 11 deletions orchagent/macsecorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,21 @@ MACsecOrch::MACsecOrch(
StatsMode::READ,
MACSEC_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS, true),
m_macsec_flow_stat_manager(
COUNTERS_MACSEC_FLOW_GROUP,
StatsMode::READ,
MACSEC_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS, true),
m_gb_macsec_sa_attr_manager(
"GB_FLEX_COUNTER_DB",
COUNTERS_MACSEC_SA_ATTR_GROUP,
StatsMode::READ,
MACSEC_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS, true),
m_gb_macsec_sa_stat_manager(
"GB_FLEX_COUNTER_DB",
COUNTERS_MACSEC_SA_GROUP,
StatsMode::READ,
MACSEC_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS, true),
m_gb_macsec_flow_stat_manager(
"GB_FLEX_COUNTER_DB",
COUNTERS_MACSEC_FLOW_GROUP,
StatsMode::READ,
MACSEC_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS, true)
Expand Down Expand Up @@ -2122,17 +2137,17 @@ task_process_status MACsecOrch::createMACsecSA(
sc->m_sa_ids.erase(an);
});

installCounter(CounterType::MACSEC_SA_ATTR, direction, port_sci_an, sc->m_sa_ids[an], macsec_sa_attrs);
installCounter(ctx, CounterType::MACSEC_SA_ATTR, direction, port_sci_an, sc->m_sa_ids[an], macsec_sa_attrs);
std::vector<FieldValueTuple> fvVector;
fvVector.emplace_back("state", "ok");
if (direction == SAI_MACSEC_DIRECTION_EGRESS)
{
installCounter(CounterType::MACSEC_SA, direction, port_sci_an, sc->m_sa_ids[an], macsec_sa_egress_stats);
installCounter(ctx, CounterType::MACSEC_SA, direction, port_sci_an, sc->m_sa_ids[an], macsec_sa_egress_stats);
m_state_macsec_egress_sa.set(swss::join('|', port_name, sci, an), fvVector);
}
else
{
installCounter(CounterType::MACSEC_SA, direction, port_sci_an, sc->m_sa_ids[an], macsec_sa_ingress_stats);
installCounter(ctx, CounterType::MACSEC_SA, direction, port_sci_an, sc->m_sa_ids[an], macsec_sa_ingress_stats);
m_state_macsec_ingress_sa.set(swss::join('|', port_name, sci, an), fvVector);
}

Expand Down Expand Up @@ -2167,8 +2182,8 @@ task_process_status MACsecOrch::deleteMACsecSA(

auto result = task_success;

uninstallCounter(CounterType::MACSEC_SA_ATTR, direction, port_sci_an, ctx.get_macsec_sc()->m_sa_ids[an]);
uninstallCounter(CounterType::MACSEC_SA, direction, port_sci_an, ctx.get_macsec_sc()->m_sa_ids[an]);
uninstallCounter(ctx, CounterType::MACSEC_SA_ATTR, direction, port_sci_an, ctx.get_macsec_sc()->m_sa_ids[an]);
uninstallCounter(ctx, CounterType::MACSEC_SA, direction, port_sci_an, ctx.get_macsec_sc()->m_sa_ids[an]);
if (!deleteMACsecSA(ctx.get_macsec_sc()->m_sa_ids[an]))
{
SWSS_LOG_WARN("Cannot delete the MACsec SA %s.", port_sci_an.c_str());
Expand Down Expand Up @@ -2293,7 +2308,29 @@ bool MACsecOrch::deleteMACsecSA(sai_object_id_t sa_id)
return true;
}

FlexCounterManager& MACsecOrch::MACsecSaStatManager(MACsecOrchContext &ctx)
{
if (ctx.get_gearbox_phy() != nullptr)
return m_gb_macsec_sa_stat_manager;
return m_macsec_sa_stat_manager;
}

FlexCounterManager& MACsecOrch::MACsecSaAttrStatManager(MACsecOrchContext &ctx)
{
if (ctx.get_gearbox_phy() != nullptr)
return m_gb_macsec_sa_attr_manager;
return m_macsec_sa_attr_manager;
}

FlexCounterManager& MACsecOrch::MACsecFlowStatManager(MACsecOrchContext &ctx)
{
if (ctx.get_gearbox_phy() != nullptr)
return m_gb_macsec_flow_stat_manager;
return m_macsec_flow_stat_manager;
}

void MACsecOrch::installCounter(
MACsecOrchContext &ctx,
CounterType counter_type,
sai_macsec_direction_t direction,
const std::string &obj_name,
Expand All @@ -2312,12 +2349,12 @@ void MACsecOrch::installCounter(
switch(counter_type)
{
case CounterType::MACSEC_SA_ATTR:
m_macsec_sa_attr_manager.setCounterIdList(obj_id, counter_type, counter_stats);
MACsecSaAttrStatManager(ctx).setCounterIdList(obj_id, counter_type, counter_stats);
m_macsec_counters_map.set("", fields);
break;

case CounterType::MACSEC_SA:
m_macsec_sa_stat_manager.setCounterIdList(obj_id, counter_type, counter_stats);
MACsecSaStatManager(ctx).setCounterIdList(obj_id, counter_type, counter_stats);
if (direction == SAI_MACSEC_DIRECTION_EGRESS)
{
m_macsec_sa_tx_counters_map.set("", fields);
Expand All @@ -2329,7 +2366,7 @@ void MACsecOrch::installCounter(
break;

case CounterType::MACSEC_FLOW:
m_macsec_flow_stat_manager.setCounterIdList(obj_id, counter_type, counter_stats);
MACsecFlowStatManager(ctx).setCounterIdList(obj_id, counter_type, counter_stats);
break;

default:
Expand All @@ -2340,6 +2377,7 @@ void MACsecOrch::installCounter(
}

void MACsecOrch::uninstallCounter(
MACsecOrchContext &ctx,
CounterType counter_type,
sai_macsec_direction_t direction,
const std::string &obj_name,
Expand All @@ -2348,12 +2386,12 @@ void MACsecOrch::uninstallCounter(
switch(counter_type)
{
case CounterType::MACSEC_SA_ATTR:
m_macsec_sa_attr_manager.clearCounterIdList(obj_id);
MACsecSaAttrStatManager(ctx).clearCounterIdList(obj_id);
m_counter_db.hdel(COUNTERS_MACSEC_NAME_MAP, obj_name);
break;

case CounterType::MACSEC_SA:
m_macsec_sa_stat_manager.clearCounterIdList(obj_id);
MACsecSaStatManager(ctx).clearCounterIdList(obj_id);
if (direction == SAI_MACSEC_DIRECTION_EGRESS)
{
m_counter_db.hdel(COUNTERS_MACSEC_SA_TX_NAME_MAP, obj_name);
Expand All @@ -2365,7 +2403,7 @@ void MACsecOrch::uninstallCounter(
break;

case CounterType::MACSEC_FLOW:
m_macsec_flow_stat_manager.clearCounterIdList(obj_id);
MACsecFlowStatManager(ctx).clearCounterIdList(obj_id);
break;

default:
Expand Down
11 changes: 11 additions & 0 deletions orchagent/macsecorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ class MACsecOrch : public Orch
FlexCounterManager m_macsec_sa_stat_manager;
FlexCounterManager m_macsec_flow_stat_manager;

FlexCounterManager m_gb_macsec_sa_attr_manager;
FlexCounterManager m_gb_macsec_sa_stat_manager;
FlexCounterManager m_gb_macsec_flow_stat_manager;

struct MACsecACLTable
{
sai_object_id_t m_table_id;
Expand Down Expand Up @@ -209,17 +213,24 @@ class MACsecOrch : public Orch

/* Counter */
void installCounter(
MACsecOrchContext &ctx,
CounterType counter_type,
sai_macsec_direction_t direction,
const std::string &obj_name,
sai_object_id_t obj_id,
const std::vector<std::string> &stats);
void uninstallCounter(
MACsecOrchContext &ctx,
CounterType counter_type,
sai_macsec_direction_t direction,
const std::string &obj_name,
sai_object_id_t obj_id);

/* Flex Counter Manager */
FlexCounterManager& MACsecSaStatManager(MACsecOrchContext &ctx);
FlexCounterManager& MACsecSaAttrStatManager(MACsecOrchContext &ctx);
FlexCounterManager& MACsecFlowStatManager(MACsecOrchContext &ctx);

/* MACsec ACL */
bool initMACsecACLTable(
MACsecACLTable &acl_table,
Expand Down
1 change: 1 addition & 0 deletions orchagent/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ class Port
SystemLagInfo m_system_lag_info;

sai_object_id_t m_switch_id = 0;
sai_object_id_t m_system_side_id = 0;
sai_object_id_t m_line_side_id = 0;

bool m_fec_cfg = false;
Expand Down
Loading