Skip to content

Commit 9ffcc88

Browse files
Merge branch 'master' of github.com:azure/sonic-swss into lag-mem-add-err
Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
2 parents 89cbcbd + e03c677 commit 9ffcc88

File tree

12 files changed

+71
-245
lines changed

12 files changed

+71
-245
lines changed

.github/CODEOWNERS

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# This is a comment.
2+
# Each line is a file pattern followed by one or more owners.
3+
4+
# rules are explained here
5+
# https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners
6+
7+
# These owners will be the default owners for everything in
8+
# the repo. Unless a later match takes precedence,
9+
# @prsunny will be requested for review when someone opens
10+
# a pull request.
11+
* @prsunny

orchagent/flexcounterorch.cpp

Lines changed: 15 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ extern IntfsOrch *gIntfsOrch;
1818
extern BufferOrch *gBufferOrch;
1919

2020
#define BUFFER_POOL_WATERMARK_KEY "BUFFER_POOL_WATERMARK"
21-
#define PORT_KEY "PORT"
22-
#define PORT_BUFFER_DROP_KEY "PORT_BUFFER_DROP"
23-
#define QUEUE_KEY "QUEUE"
24-
#define PG_WATERMARK_KEY "PG_WATERMARK"
25-
#define RIF_KEY "RIF"
2621

2722
unordered_map<string, string> flexCounterGroupMap =
2823
{
@@ -107,31 +102,26 @@ void FlexCounterOrch::doTask(Consumer &consumer)
107102
// which is automatically satisfied upon the creation of the orch object that requires
108103
// the syncd flex counter polling service
109104
// This postponement is introduced by design to accelerate the initialization process
110-
if(gPortsOrch && (value == "enable"))
105+
//
106+
// generateQueueMap() is called as long as a field "FLEX_COUNTER_STATUS" event is heard,
107+
// regardless of whether the key is "QUEUE" or whether the value is "enable" or "disable"
108+
// This can be because generateQueueMap() installs a fundamental list of queue stats
109+
// that need to be polled. So my doubt here is if queue watermark stats shall be piggybacked
110+
// into the same function as they may not be counted as fundamental
111+
if(gPortsOrch)
111112
{
112-
if(key == PORT_KEY)
113-
{
114-
gPortsOrch->generatePortCounterMap();
115-
m_port_counter_enabled = true;
116-
}
117-
else if(key == PORT_BUFFER_DROP_KEY)
118-
{
119-
gPortsOrch->generatePortBufferDropCounterMap();
120-
m_port_buffer_drop_counter_enabled = true;
121-
}
122-
else if(key == QUEUE_KEY)
123-
{
124-
gPortsOrch->generateQueueMap();
125-
}
126-
else if(key == PG_WATERMARK_KEY)
127-
{
128-
gPortsOrch->generatePriorityGroupMap();
129-
}
113+
gPortsOrch->generateQueueMap();
114+
gPortsOrch->generatePriorityGroupMap();
130115
}
131-
if(gIntfsOrch && (key == RIF_KEY) && (value == "enable"))
116+
if(gPortsOrch)
117+
{
118+
gPortsOrch->generatePriorityGroupMap();
119+
}
120+
if(gIntfsOrch)
132121
{
133122
gIntfsOrch->generateInterfaceMap();
134123
}
124+
// Install COUNTER_ID_LIST/ATTR_ID_LIST only when hearing buffer pool watermark enable event
135125
if (gBufferOrch && (key == BUFFER_POOL_WATERMARK_KEY) && (value == "enable"))
136126
{
137127
gBufferOrch->generateBufferPoolWatermarkCounterIdList();
@@ -154,13 +144,3 @@ void FlexCounterOrch::doTask(Consumer &consumer)
154144
consumer.m_toSync.erase(it++);
155145
}
156146
}
157-
158-
bool FlexCounterOrch::getPortCountersState() const
159-
{
160-
return m_port_counter_enabled;
161-
}
162-
163-
bool FlexCounterOrch::getPortBufferDropCountersState() const
164-
{
165-
return m_port_buffer_drop_counter_enabled;
166-
}

orchagent/flexcounterorch.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,10 @@ class FlexCounterOrch: public Orch
1515
void doTask(Consumer &consumer);
1616
FlexCounterOrch(swss::DBConnector *db, std::vector<std::string> &tableNames);
1717
virtual ~FlexCounterOrch(void);
18-
bool getPortCountersState() const;
19-
bool getPortBufferDropCountersState() const;
2018

2119
private:
2220
std::shared_ptr<swss::DBConnector> m_flexCounterDb = nullptr;
2321
std::shared_ptr<swss::ProducerTable> m_flexCounterGroupTable = nullptr;
24-
bool m_port_counter_enabled = false;
25-
bool m_port_buffer_drop_counter_enabled = false;
2622
};
2723

2824
#endif

orchagent/macsecorch.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,14 @@ class MACsecOrchContext
231231
{
232232
return nullptr;
233233
}
234-
m_port_id = std::make_unique<sai_object_id_t>(port->m_port_id);
235-
// TODO: If the MACsec was enabled at the gearbox, should use line port id as the port id.
234+
if (port->m_line_side_id != SAI_NULL_OBJECT_ID)
235+
{
236+
m_port_id = std::make_unique<sai_object_id_t>(port->m_line_side_id);
237+
}
238+
else
239+
{
240+
m_port_id = std::make_unique<sai_object_id_t>(port->m_port_id);
241+
}
236242
}
237243
return m_port_id.get();
238244
}
@@ -241,12 +247,22 @@ class MACsecOrchContext
241247
{
242248
if (m_switch_id == nullptr)
243249
{
244-
if (gSwitchId == SAI_NULL_OBJECT_ID)
250+
auto port = get_port();
251+
sai_object_id_t switchId;
252+
if (port == nullptr || port->m_switch_id == SAI_NULL_OBJECT_ID)
253+
{
254+
switchId = gSwitchId;
255+
}
256+
else
257+
{
258+
switchId = port->m_switch_id;
259+
}
260+
if (switchId == SAI_NULL_OBJECT_ID)
245261
{
246262
SWSS_LOG_ERROR("Switch ID cannot be found");
247263
return nullptr;
248264
}
249-
m_switch_id = std::make_unique<sai_object_id_t>(gSwitchId);
265+
m_switch_id = std::make_unique<sai_object_id_t>(switchId);
250266
}
251267
return m_switch_id.get();
252268
}

orchagent/nexthopgroupkey.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class NextHopGroupKey
3333

3434
NextHopGroupKey(const std::string &nexthops, const std::string &weights)
3535
{
36+
m_overlay_nexthops = false;
3637
std::vector<std::string> nhv = tokenize(nexthops, NHG_DELIMITER);
3738
std::vector<std::string> wtv = tokenize(weights, NHG_DELIMITER);
3839
for (uint32_t i = 0; i < nhv.size(); i++)

orchagent/orchdaemon.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,7 @@ bool OrchDaemon::init()
352352
CFG_FLEX_COUNTER_TABLE_NAME
353353
};
354354

355-
auto* flexCounterOrch = new FlexCounterOrch(m_configDb, flex_counter_tables);
356-
m_orchList.push_back(flexCounterOrch);
357-
358-
gDirectory.set(flexCounterOrch);
359-
gDirectory.set(gPortsOrch);
355+
m_orchList.push_back(new FlexCounterOrch(m_configDb, flex_counter_tables));
360356

361357
vector<string> pfc_wd_tables = {
362358
CFG_PFC_WD_TABLE_NAME

orchagent/port.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ class Port
162162
SystemPortInfo m_system_port_info;
163163
SystemLagInfo m_system_lag_info;
164164

165+
sai_object_id_t m_switch_id = 0;
166+
sai_object_id_t m_line_side_id = 0;
167+
165168
bool m_fec_cfg = false;
166169
bool m_an_cfg = false;
167170
};

orchagent/portsorch.cpp

Lines changed: 17 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,9 @@ static char* hostif_vlan_tag[] = {
284284
PortsOrch::PortsOrch(DBConnector *db, DBConnector *stateDb, vector<table_name_with_pri_t> &tableNames, DBConnector *chassisAppDb) :
285285
Orch(db, tableNames),
286286
m_portStateTable(stateDb, STATE_PORT_TABLE_NAME),
287-
port_stat_manager(PORT_STAT_COUNTER_FLEX_COUNTER_GROUP, StatsMode::READ, PORT_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS, false),
288-
port_buffer_drop_stat_manager(PORT_BUFFER_DROP_STAT_FLEX_COUNTER_GROUP, StatsMode::READ, PORT_BUFFER_DROP_STAT_POLLING_INTERVAL_MS, false),
289-
queue_stat_manager(QUEUE_STAT_COUNTER_FLEX_COUNTER_GROUP, StatsMode::READ, QUEUE_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS, false)
287+
port_stat_manager(PORT_STAT_COUNTER_FLEX_COUNTER_GROUP, StatsMode::READ, PORT_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS, true),
288+
port_buffer_drop_stat_manager(PORT_BUFFER_DROP_STAT_FLEX_COUNTER_GROUP, StatsMode::READ, PORT_BUFFER_DROP_STAT_POLLING_INTERVAL_MS, true),
289+
queue_stat_manager(QUEUE_STAT_COUNTER_FLEX_COUNTER_GROUP, StatsMode::READ, QUEUE_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS, true)
290290
{
291291
SWSS_LOG_ENTER();
292292

@@ -2273,21 +2273,19 @@ bool PortsOrch::initPort(const string &alias, const string &role, const int inde
22732273
vector<FieldValueTuple> fields;
22742274
fields.push_back(tuple);
22752275
m_counterTable->set("", fields);
2276-
22772276
// Install a flex counter for this port to track stats
2278-
auto flex_counters_orch = gDirectory.get<FlexCounterOrch*>();
2279-
/* Delay installing the counters if they are yet enabled
2280-
If they are enabled, install the counters immediately */
2281-
if (flex_counters_orch->getPortCountersState())
2277+
std::unordered_set<std::string> counter_stats;
2278+
for (const auto& it: port_stat_ids)
22822279
{
2283-
auto port_counter_stats = generateCounterStats(PORT_STAT_COUNTER_FLEX_COUNTER_GROUP);
2284-
port_stat_manager.setCounterIdList(p.m_port_id, CounterType::PORT, port_counter_stats);
2280+
counter_stats.emplace(sai_serialize_port_stat(it));
22852281
}
2286-
if (flex_counters_orch->getPortBufferDropCountersState())
2282+
port_stat_manager.setCounterIdList(p.m_port_id, CounterType::PORT, counter_stats);
2283+
std::unordered_set<std::string> port_buffer_drop_stats;
2284+
for (const auto& it: port_buffer_drop_stat_ids)
22872285
{
2288-
auto port_buffer_drop_stats = generateCounterStats(PORT_BUFFER_DROP_STAT_FLEX_COUNTER_GROUP);
2289-
port_buffer_drop_stat_manager.setCounterIdList(p.m_port_id, CounterType::PORT, port_buffer_drop_stats);
2286+
port_buffer_drop_stats.emplace(sai_serialize_port_stat(it));
22902287
}
2288+
port_buffer_drop_stat_manager.setCounterIdList(p.m_port_id, CounterType::PORT, port_buffer_drop_stats);
22912289

22922290
PortUpdate update = { p, true };
22932291
notify(SUBJECT_TYPE_PORT_CHANGE, static_cast<void *>(&update));
@@ -2320,11 +2318,8 @@ void PortsOrch::deInitPort(string alias, sai_object_id_t port_id)
23202318
p.m_port_id = port_id;
23212319

23222320
/* remove port from flex_counter_table for updating counters */
2323-
auto flex_counters_orch = gDirectory.get<FlexCounterOrch*>();
2324-
if ((flex_counters_orch->getPortCountersState()))
2325-
{
2326-
port_stat_manager.clearCounterIdList(p.m_port_id);
2327-
}
2321+
port_stat_manager.clearCounterIdList(p.m_port_id);
2322+
23282323
/* remove port name map from counter table */
23292324
m_counter_db->hdel(COUNTERS_PORT_NAME_MAP, alias);
23302325

@@ -5084,42 +5079,6 @@ void PortsOrch::generatePriorityGroupMapPerPort(const Port& port)
50845079
CounterCheckOrch::getInstance().addPort(port);
50855080
}
50865081

5087-
void PortsOrch::generatePortCounterMap()
5088-
{
5089-
if (m_isPortCounterMapGenerated)
5090-
{
5091-
return;
5092-
}
5093-
5094-
auto port_counter_stats = generateCounterStats(PORT_STAT_COUNTER_FLEX_COUNTER_GROUP);
5095-
for (const auto& it: m_portList)
5096-
{
5097-
if (it.first == "CPU")
5098-
{
5099-
continue;
5100-
}
5101-
port_stat_manager.setCounterIdList(it.second.m_port_id, CounterType::PORT, port_counter_stats);
5102-
}
5103-
5104-
m_isPortCounterMapGenerated = true;
5105-
}
5106-
5107-
void PortsOrch::generatePortBufferDropCounterMap()
5108-
{
5109-
if (m_isPortBufferDropCounterMapGenerated)
5110-
{
5111-
return;
5112-
}
5113-
5114-
auto port_buffer_drop_stats = generateCounterStats(PORT_BUFFER_DROP_STAT_FLEX_COUNTER_GROUP);
5115-
for (const auto& it: m_portList)
5116-
{
5117-
port_buffer_drop_stat_manager.setCounterIdList(it.second.m_port_id, CounterType::PORT, port_buffer_drop_stats);
5118-
}
5119-
5120-
m_isPortBufferDropCounterMapGenerated = true;
5121-
}
5122-
51235082
void PortsOrch::doTask(NotificationConsumer &consumer)
51245083
{
51255084
SWSS_LOG_ENTER();
@@ -5698,6 +5657,9 @@ bool PortsOrch::initGearboxPort(Port &port)
56985657

56995658
sai_deserialize_object_id(phyOidStr, phyOid);
57005659

5660+
SWSS_LOG_NOTICE("BOX: Gearbox port %s assigned phyOid 0x%" PRIx64, port.m_alias.c_str(), phyOid);
5661+
port.m_switch_id = phyOid;
5662+
57015663
/* Create SYSTEM-SIDE port */
57025664
attrs.clear();
57035665

@@ -5863,6 +5825,7 @@ bool PortsOrch::initGearboxPort(Port &port)
58635825

58645826
SWSS_LOG_NOTICE("BOX: Connected Gearbox ports; system-side:0x%" PRIx64 " to line-side:0x%" PRIx64, systemPort, linePort);
58655827
m_gearboxPortListLaneMap[port.m_port_id] = make_tuple(systemPort, linePort);
5828+
port.m_line_side_id = linePort;
58665829
}
58675830
}
58685831

@@ -6276,23 +6239,3 @@ void PortsOrch::voqSyncDelLagMember(Port &lag, Port &port)
62766239
string key = lag.m_system_lag_info.alias + ":" + port.m_system_port_info.alias;
62776240
m_tableVoqSystemLagMemberTable->del(key);
62786241
}
6279-
6280-
std::unordered_set<std::string> PortsOrch::generateCounterStats(const string& type)
6281-
{
6282-
std::unordered_set<std::string> counter_stats;
6283-
if (type == PORT_STAT_COUNTER_FLEX_COUNTER_GROUP)
6284-
{
6285-
for (const auto& it: port_stat_ids)
6286-
{
6287-
counter_stats.emplace(sai_serialize_port_stat(it));
6288-
}
6289-
}
6290-
else if (type == PORT_BUFFER_DROP_STAT_FLEX_COUNTER_GROUP)
6291-
{
6292-
for (const auto& it: port_buffer_drop_stat_ids)
6293-
{
6294-
counter_stats.emplace(sai_serialize_port_stat(it));
6295-
}
6296-
}
6297-
return counter_stats;
6298-
}

orchagent/portsorch.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include "gearboxutils.h"
1414
#include "saihelper.h"
1515
#include "lagid.h"
16-
#include "flexcounterorch.h"
1716

1817

1918
#define FCS_LEN 4
@@ -126,8 +125,6 @@ class PortsOrch : public Orch, public Subject
126125

127126
void generateQueueMap();
128127
void generatePriorityGroupMap();
129-
void generatePortCounterMap();
130-
void generatePortBufferDropCounterMap();
131128

132129
void refreshPortStatus();
133130
bool removeAclTableGroup(const Port &p);
@@ -293,9 +290,6 @@ class PortsOrch : public Orch, public Subject
293290
bool m_isPriorityGroupMapGenerated = false;
294291
void generatePriorityGroupMapPerPort(const Port& port);
295292

296-
bool m_isPortCounterMapGenerated = false;
297-
bool m_isPortBufferDropCounterMapGenerated = false;
298-
299293
bool setPortAutoNeg(sai_object_id_t id, int an);
300294
bool setPortFecMode(sai_object_id_t id, int fec);
301295
bool setPortInterfaceType(sai_object_id_t id, sai_port_interface_type_t interface_type);
@@ -339,8 +333,6 @@ class PortsOrch : public Orch, public Subject
339333
void voqSyncDelLagMember(Port &lag, Port &port);
340334
unique_ptr<LagIdAllocator> m_lagIdAllocator;
341335

342-
std::unordered_set<std::string> generateCounterStats(const string& type);
343-
344336
};
345337
#endif /* SWSS_PORTSORCH_H */
346338

orchagent/routeorch.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,7 +1906,7 @@ bool RouteOrch::removeRoute(RouteBulkContext& ctx)
19061906
auto& object_statuses = ctx.object_statuses;
19071907

19081908
// set to blackhole for default route
1909-
if (ipPrefix.isDefaultRoute())
1909+
if (ipPrefix.isDefaultRoute() && vrf_id == gVirtualRouterId)
19101910
{
19111911
sai_attribute_t attr;
19121912
attr.id = SAI_ROUTE_ENTRY_ATTR_PACKET_ACTION;
@@ -1950,7 +1950,7 @@ bool RouteOrch::removeRoutePost(const RouteBulkContext& ctx)
19501950
auto it_status = object_statuses.begin();
19511951

19521952
// set to blackhole for default route
1953-
if (ipPrefix.isDefaultRoute())
1953+
if (ipPrefix.isDefaultRoute() && vrf_id == gVirtualRouterId)
19541954
{
19551955
sai_status_t status = *it_status++;
19561956
if (status != SAI_STATUS_SUCCESS)
@@ -2030,7 +2030,7 @@ bool RouteOrch::removeRoutePost(const RouteBulkContext& ctx)
20302030
SWSS_LOG_INFO("Remove route %s with next hop(s) %s",
20312031
ipPrefix.to_string().c_str(), it_route->second.to_string().c_str());
20322032

2033-
if (ipPrefix.isDefaultRoute())
2033+
if (ipPrefix.isDefaultRoute() && vrf_id == gVirtualRouterId)
20342034
{
20352035
it_route_table->second[ipPrefix] = NextHopGroupKey();
20362036

0 commit comments

Comments
 (0)