Skip to content

Commit 95377ac

Browse files
authored
Merge branch 'master' into chassis-everflow-pr
2 parents 1201f02 + 500e2e9 commit 95377ac

29 files changed

Lines changed: 1105 additions & 318 deletions

cfgmgr/buffer_pool_mellanox.lua

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ local state_db = "6"
77

88
local lossypg_reserved = 19 * 1024
99
local lossypg_reserved_400g = 37 * 1024
10+
-- Number of 400G ports
11+
local port_count_400g = 0
12+
-- Number of lossy PG on 400G ports
1013
local lossypg_400g = 0
1114

1215
local result = {}
@@ -56,8 +59,11 @@ local function iterate_all_items(all_items)
5659
end
5760
profiles[index][2] = profiles[index][2] + size
5861
local speed = redis.call('HGET', 'PORT_TABLE:'..port, 'speed')
59-
if speed == '400000' and profile == '[BUFFER_PROFILE_TABLE:ingress_lossy_profile]' then
60-
lossypg_400g = lossypg_400g + size
62+
if speed == '400000' then
63+
if profile == '[BUFFER_PROFILE_TABLE:ingress_lossy_profile]' then
64+
lossypg_400g = lossypg_400g + size
65+
end
66+
port_count_400g = port_count_400g + 1
6167
end
6268
end
6369
end
@@ -145,6 +151,10 @@ end
145151
local lossypg_extra_for_400g = (lossypg_reserved_400g - lossypg_reserved) * lossypg_400g
146152
accumulative_occupied_buffer = accumulative_occupied_buffer + lossypg_extra_for_400g
147153

154+
-- Accumulate sizes for management PGs
155+
local accumulative_management_pg = (total_port - port_count_400g) * lossypg_reserved + port_count_400g * lossypg_reserved_400g
156+
accumulative_occupied_buffer = accumulative_occupied_buffer + accumulative_management_pg
157+
148158
-- Accumulate sizes for egress mirror and management pool
149159
local accumulative_egress_mirror_overhead = total_port * egress_mirror_headroom
150160
accumulative_occupied_buffer = accumulative_occupied_buffer + accumulative_egress_mirror_overhead + mgmt_pool_size
@@ -228,8 +238,9 @@ table.insert(result, "debug:accumulative size:" .. accumulative_occupied_buffer)
228238
for i = 1, #statistics do
229239
table.insert(result, "debug:" .. statistics[i][1] .. ":" .. statistics[i][2] .. ":" .. statistics[i][3])
230240
end
231-
table.insert(result, "debug:extra_400g:" .. (lossypg_reserved_400g - lossypg_reserved) .. ":" .. lossypg_400g)
241+
table.insert(result, "debug:extra_400g:" .. (lossypg_reserved_400g - lossypg_reserved) .. ":" .. lossypg_400g .. ":" .. port_count_400g)
232242
table.insert(result, "debug:mgmt_pool:" .. mgmt_pool_size)
243+
table.insert(result, "debug:accumulative_mgmt_pg:" .. accumulative_management_pg)
233244
table.insert(result, "debug:egress_mirror:" .. accumulative_egress_mirror_overhead)
234245
table.insert(result, "debug:shp_enabled:" .. tostring(shp_enabled))
235246
table.insert(result, "debug:shp_size:" .. shp_size)

cfgmgr/intfmgr.cpp

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ IntfMgr::IntfMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, c
4444
{
4545
//Build the interface list to be replayed to Kernel
4646
buildIntfReplayList();
47+
if (m_pendingReplayIntfList.empty())
48+
{
49+
setWarmReplayDoneState();
50+
}
4751
}
4852
}
4953

@@ -191,16 +195,25 @@ void IntfMgr::buildIntfReplayList(void)
191195

192196
m_cfgLoopbackIntfTable.getKeys(intfList);
193197
std::copy( intfList.begin(), intfList.end(), std::inserter( m_pendingReplayIntfList, m_pendingReplayIntfList.end() ) );
194-
198+
195199
m_cfgVlanIntfTable.getKeys(intfList);
196200
std::copy( intfList.begin(), intfList.end(), std::inserter( m_pendingReplayIntfList, m_pendingReplayIntfList.end() ) );
197-
201+
198202
m_cfgLagIntfTable.getKeys(intfList);
199203
std::copy( intfList.begin(), intfList.end(), std::inserter( m_pendingReplayIntfList, m_pendingReplayIntfList.end() ) );
200204

201205
SWSS_LOG_INFO("Found %d Total Intfs to be replayed", (int)m_pendingReplayIntfList.size() );
202206
}
203207

208+
void IntfMgr::setWarmReplayDoneState()
209+
{
210+
m_replayDone = true;
211+
WarmStart::setWarmStartState("intfmgrd", WarmStart::REPLAYED);
212+
// There is no operation to be performed for intfmgr reconcillation
213+
// Hence mark it reconciled right away
214+
WarmStart::setWarmStartState("intfmgrd", WarmStart::RECONCILED);
215+
}
216+
204217
bool IntfMgr::isIntfCreated(const string &alias)
205218
{
206219
vector<FieldValueTuple> temp;
@@ -705,7 +718,6 @@ bool IntfMgr::doIntfAddrTask(const vector<string>& keys,
705718
void IntfMgr::doTask(Consumer &consumer)
706719
{
707720
SWSS_LOG_ENTER();
708-
static bool replayDone = false;
709721

710722
string table_name = consumer.getTableName();
711723

@@ -761,13 +773,9 @@ void IntfMgr::doTask(Consumer &consumer)
761773

762774
it = consumer.m_toSync.erase(it);
763775
}
764-
765-
if (!replayDone && WarmStart::isWarmStart() && m_pendingReplayIntfList.empty() )
776+
777+
if (!m_replayDone && WarmStart::isWarmStart() && m_pendingReplayIntfList.empty() )
766778
{
767-
replayDone = true;
768-
WarmStart::setWarmStartState("intfmgrd", WarmStart::REPLAYED);
769-
// There is no operation to be performed for intfmgr reconcillation
770-
// Hence mark it reconciled right away
771-
WarmStart::setWarmStartState("intfmgrd", WarmStart::RECONCILED);
779+
setWarmReplayDoneState();
772780
}
773781
}

cfgmgr/intfmgr.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class IntfMgr : public Orch
3939
bool isIntfChangeVrf(const std::string &alias, const std::string &vrfName);
4040
int getIntfIpCount(const std::string &alias);
4141
void buildIntfReplayList(void);
42+
void setWarmReplayDoneState();
4243

4344
void addLoopbackIntf(const std::string &alias);
4445
void delLoopbackIntf(const std::string &alias);
@@ -53,6 +54,8 @@ class IntfMgr : public Orch
5354

5455
bool setIntfProxyArp(const std::string &alias, const std::string &proxy_arp);
5556
bool setIntfGratArp(const std::string &alias, const std::string &grat_arp);
57+
58+
bool m_replayDone {false};
5659
};
5760

5861
}

cfgmgr/nbrmgr.cpp

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,8 @@ void NbrMgr::doStateSystemNeighTask(Consumer &consumer)
348348
//Get the name of the device on which the neigh and route are
349349
//going to be programmed.
350350
string nbr_odev;
351-
if(!getVoqInbandInterfaceName(nbr_odev))
351+
string ibif_type;
352+
if(!getVoqInbandInterfaceName(nbr_odev, ibif_type))
352353
{
353354
//The inband interface is not available yet
354355
return;
@@ -380,16 +381,19 @@ void NbrMgr::doStateSystemNeighTask(Consumer &consumer)
380381
mac_address = MacAddress(fvValue(*i));
381382
}
382383

383-
if (!isIntfStateOk(nbr_odev))
384+
if (ibif_type == "port" && !isIntfOperUp(nbr_odev))
384385
{
385-
SWSS_LOG_DEBUG("Interface %s is not ready, skipping system neigh %s'", nbr_odev.c_str(), kfvKey(t).c_str());
386+
SWSS_LOG_DEBUG("Device %s is not oper up, skipping system neigh %s'", nbr_odev.c_str(), kfvKey(t).c_str());
386387
it++;
387388
continue;
388389
}
389390

390391
if (!addKernelNeigh(nbr_odev, ip_address, mac_address))
391392
{
392393
SWSS_LOG_ERROR("Neigh entry add on dev %s failed for '%s'", nbr_odev.c_str(), kfvKey(t).c_str());
394+
// Delete neigh to take care of deletion of exiting nbr for mac change. This makes sure that
395+
// re-try will be successful and route addtion (below) will be attempted and be successful
396+
delKernelNeigh(nbr_odev, ip_address);
393397
it++;
394398
continue;
395399
}
@@ -402,6 +406,8 @@ void NbrMgr::doStateSystemNeighTask(Consumer &consumer)
402406
{
403407
SWSS_LOG_ERROR("Route entry add on dev %s failed for '%s'", nbr_odev.c_str(), kfvKey(t).c_str());
404408
delKernelNeigh(nbr_odev, ip_address);
409+
// Delete route to take care of deletion of exiting route of nbr for mac change.
410+
delKernelRoute(ip_address);
405411
it++;
406412
continue;
407413
}
@@ -437,9 +443,24 @@ void NbrMgr::doStateSystemNeighTask(Consumer &consumer)
437443
}
438444
}
439445

440-
bool NbrMgr::getVoqInbandInterfaceName(string &ibif)
446+
bool NbrMgr::isIntfOperUp(const string &alias)
441447
{
448+
string oper;
449+
450+
if (m_statePortTable.hget(alias, "netdev_oper_status", oper))
451+
{
452+
if (oper == "up")
453+
{
454+
SWSS_LOG_DEBUG("NetDev %s is oper up", alias.c_str());
455+
return true;
456+
}
457+
}
442458

459+
return false;
460+
}
461+
462+
bool NbrMgr::getVoqInbandInterfaceName(string &ibif, string &type)
463+
{
443464
vector<string> keys;
444465
m_cfgVoqInbandInterfaceTable->getKeys(keys);
445466

@@ -448,9 +469,21 @@ bool NbrMgr::getVoqInbandInterfaceName(string &ibif)
448469
SWSS_LOG_NOTICE("Voq Inband interface is not configured!");
449470
return false;
450471
}
451-
//key:"alias" = inband interface name
472+
473+
// key:"alias" = inband interface name
474+
452475
vector<string> if_keys = tokenize(keys[0], config_db_key_delimiter);
476+
453477
ibif = if_keys[0];
478+
479+
// Get the type of the inband interface
480+
481+
if (!m_cfgVoqInbandInterfaceTable->hget(ibif, "inband_type", type))
482+
{
483+
SWSS_LOG_ERROR("Getting Voq Inband interface type failed for %s", ibif.c_str());
484+
return false;
485+
}
486+
454487
return true;
455488
}
456489

cfgmgr/nbrmgr.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ class NbrMgr : public Orch
3232
void doSetNeighTask(Consumer &consumer);
3333
void doTask(Consumer &consumer);
3434
void doStateSystemNeighTask(Consumer &consumer);
35-
bool getVoqInbandInterfaceName(string &nbr_odev);
35+
bool getVoqInbandInterfaceName(string &nbr_odev, string &ibiftype);
3636
bool addKernelRoute(string odev, IpAddress ip_addr);
3737
bool delKernelRoute(IpAddress ip_addr);
3838
bool addKernelNeigh(string odev, IpAddress ip_addr, MacAddress mac_addr);
3939
bool delKernelNeigh(string odev, IpAddress ip_addr);
40+
bool isIntfOperUp(const std::string &alias);
4041
unique_ptr<Table> m_cfgVoqInbandInterfaceTable;
4142

4243
Table m_statePortTable, m_stateLagTable, m_stateVlanTable, m_stateIntfTable, m_stateNeighRestoreTable;

cfgmgr/tunnelmgr.cpp

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,43 @@ static int cmdIpTunnelRouteAdd(const std::string& pfx, std::string & res)
6464
// ip route add/replace {{ip prefix}} dev {{tunnel intf}}
6565
// Replace route if route already exists
6666
ostringstream cmd;
67-
cmd << IP_CMD " route replace "
68-
<< shellquote(pfx)
69-
<< " dev "
70-
<< TUNIF;
67+
if (IpPrefix(pfx).isV4())
68+
{
69+
cmd << IP_CMD " route replace "
70+
<< shellquote(pfx)
71+
<< " dev "
72+
<< TUNIF;
73+
}
74+
else
75+
{
76+
cmd << IP_CMD " -6 route replace "
77+
<< shellquote(pfx)
78+
<< " dev "
79+
<< TUNIF;
80+
}
81+
7182
return swss::exec(cmd.str(), res);
7283
}
7384

7485
static int cmdIpTunnelRouteDel(const std::string& pfx, std::string & res)
7586
{
7687
// ip route del {{ip prefix}} dev {{tunnel intf}}
7788
ostringstream cmd;
78-
cmd << IP_CMD " route del "
79-
<< shellquote(pfx)
80-
<< " dev "
81-
<< TUNIF;
89+
if (IpPrefix(pfx).isV4())
90+
{
91+
cmd << IP_CMD " route del "
92+
<< shellquote(pfx)
93+
<< " dev "
94+
<< TUNIF;
95+
}
96+
else
97+
{
98+
cmd << IP_CMD " -6 route del "
99+
<< shellquote(pfx)
100+
<< " dev "
101+
<< TUNIF;
102+
}
103+
82104
return swss::exec(cmd.str(), res);
83105
}
84106

cfgmgr/vlanmgr.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ void VlanMgr::doVlanTask(Consumer &consumer)
306306
string admin_status;
307307
string mtu = DEFAULT_MTU_STR;
308308
string mac = gMacAddress.to_string();
309+
string hostif_name = "";
309310
vector<FieldValueTuple> fvVector;
310311
string members;
311312

@@ -362,6 +363,10 @@ void VlanMgr::doVlanTask(Consumer &consumer)
362363
mac = fvValue(i);
363364
setHostVlanMac(vlan_id, mac);
364365
}
366+
else if (fvField(i) == "hostif_name")
367+
{
368+
hostif_name = fvValue(i);
369+
}
365370
}
366371
/* fvVector should not be empty */
367372
if (fvVector.empty())
@@ -376,6 +381,9 @@ void VlanMgr::doVlanTask(Consumer &consumer)
376381
FieldValueTuple mc("mac", mac);
377382
fvVector.push_back(mc);
378383

384+
FieldValueTuple hostif_name_fvt("hostif_name", hostif_name);
385+
fvVector.push_back(hostif_name_fvt);
386+
379387
m_appVlanTableProducer.set(key, fvVector);
380388
m_vlans.insert(key);
381389

orchagent/crmorch.cpp

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -442,24 +442,24 @@ void CrmOrch::getResAvailableCounters()
442442
continue;
443443
}
444444

445-
sai_attribute_t attr;
446-
attr.id = crmResSaiAvailAttrMap.at(res.first);
447-
448-
switch (attr.id)
445+
switch (res.first)
449446
{
450-
case SAI_SWITCH_ATTR_AVAILABLE_IPV4_ROUTE_ENTRY:
451-
case SAI_SWITCH_ATTR_AVAILABLE_IPV6_ROUTE_ENTRY:
452-
case SAI_SWITCH_ATTR_AVAILABLE_IPV4_NEXTHOP_ENTRY:
453-
case SAI_SWITCH_ATTR_AVAILABLE_IPV6_NEXTHOP_ENTRY:
454-
case SAI_SWITCH_ATTR_AVAILABLE_IPV4_NEIGHBOR_ENTRY:
455-
case SAI_SWITCH_ATTR_AVAILABLE_IPV6_NEIGHBOR_ENTRY:
456-
case SAI_SWITCH_ATTR_AVAILABLE_NEXT_HOP_GROUP_MEMBER_ENTRY:
457-
case SAI_SWITCH_ATTR_AVAILABLE_NEXT_HOP_GROUP_ENTRY:
458-
case SAI_SWITCH_ATTR_AVAILABLE_FDB_ENTRY:
459-
case SAI_SWITCH_ATTR_AVAILABLE_IPMC_ENTRY:
460-
case SAI_SWITCH_ATTR_AVAILABLE_SNAT_ENTRY:
461-
case SAI_SWITCH_ATTR_AVAILABLE_DNAT_ENTRY:
447+
case CrmResourceType::CRM_IPV4_ROUTE:
448+
case CrmResourceType::CRM_IPV6_ROUTE:
449+
case CrmResourceType::CRM_IPV4_NEXTHOP:
450+
case CrmResourceType::CRM_IPV6_NEXTHOP:
451+
case CrmResourceType::CRM_IPV4_NEIGHBOR:
452+
case CrmResourceType::CRM_IPV6_NEIGHBOR:
453+
case CrmResourceType::CRM_NEXTHOP_GROUP_MEMBER:
454+
case CrmResourceType::CRM_NEXTHOP_GROUP:
455+
case CrmResourceType::CRM_FDB_ENTRY:
456+
case CrmResourceType::CRM_IPMC_ENTRY:
457+
case CrmResourceType::CRM_SNAT_ENTRY:
458+
case CrmResourceType::CRM_DNAT_ENTRY:
462459
{
460+
sai_attribute_t attr;
461+
attr.id = crmResSaiAvailAttrMap.at(res.first);
462+
463463
sai_status_t status = sai_switch_api->get_switch_attribute(gSwitchId, 1, &attr);
464464
if (status != SAI_STATUS_SUCCESS)
465465
{
@@ -482,9 +482,12 @@ void CrmOrch::getResAvailableCounters()
482482
break;
483483
}
484484

485-
case SAI_SWITCH_ATTR_AVAILABLE_ACL_TABLE:
486-
case SAI_SWITCH_ATTR_AVAILABLE_ACL_TABLE_GROUP:
485+
case CrmResourceType::CRM_ACL_TABLE:
486+
case CrmResourceType::CRM_ACL_GROUP:
487487
{
488+
sai_attribute_t attr;
489+
attr.id = crmResSaiAvailAttrMap.at(res.first);
490+
488491
vector<sai_acl_resource_t> resources(CRM_ACL_RESOURCE_COUNT);
489492

490493
attr.value.aclresource.count = CRM_ACL_RESOURCE_COUNT;
@@ -512,9 +515,12 @@ void CrmOrch::getResAvailableCounters()
512515
break;
513516
}
514517

515-
case SAI_ACL_TABLE_ATTR_AVAILABLE_ACL_ENTRY:
516-
case SAI_ACL_TABLE_ATTR_AVAILABLE_ACL_COUNTER:
518+
case CrmResourceType::CRM_ACL_ENTRY:
519+
case CrmResourceType::CRM_ACL_COUNTER:
517520
{
521+
sai_attribute_t attr;
522+
attr.id = crmResSaiAvailAttrMap.at(res.first);
523+
518524
for (auto &cnt : res.second.countersMap)
519525
{
520526
sai_status_t status = sai_acl_api->get_acl_table_attribute(cnt.second.id, 1, &attr);
@@ -531,7 +537,7 @@ void CrmOrch::getResAvailableCounters()
531537
}
532538

533539
default:
534-
SWSS_LOG_ERROR("Failed to get CRM attribute %u. Unknown attribute.\n", attr.id);
540+
SWSS_LOG_ERROR("Failed to get CRM resource type %u. Unknown resource type.\n", (uint32_t)res.first);
535541
return;
536542
}
537543
}

0 commit comments

Comments
 (0)