Skip to content

Commit b368083

Browse files
ICMP HW offload : Hardware Prober and ICMP_ECHO_SESSION support
Co-authored-by: manamand <[email protected]>
1 parent 51f9c57 commit b368083

25 files changed

+1156
-972
lines changed

src/DbInterface.cpp

Lines changed: 61 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ void DbInterface::getPortCableType(std::shared_ptr<swss::DBConnector> configDbCo
819819
//
820820
// ---> processLinkFailureDetectionType(std::vector<swss::KeyOpFieldsValuesTuple> &entries);
821821
//
822-
// process Mux Cable Table enteries to get linkFailureDetectionType by defaut its software
822+
// process Mux Cable Table enteries to get linkFailureDetectionType by defaut its software
823823
//
824824
void DbInterface::processLinkFailureDetectionType(std::vector<swss::KeyOpFieldsValuesTuple> &entries)
825825
{
@@ -828,14 +828,13 @@ void DbInterface::processLinkFailureDetectionType(std::vector<swss::KeyOpFieldsV
828828
std::string operation = kfvOp(entry);
829829
std::vector<swss::FieldValueTuple> fieldValues = kfvFieldsValues(entry);
830830

831-
std::string field = "link_failure_detection_type";
831+
std::string field = "link_prober_mode";
832832
std::vector<swss::FieldValueTuple>::const_iterator cit = std::find_if(
833833
fieldValues.cbegin(),
834834
fieldValues.cend(),
835835
[&field] (const swss::FieldValueTuple &fv) {return fvField(fv) == field;}
836836
);
837837
std::string linkFailureDetectionType = (cit != fieldValues.cend() ? cit->second : "software");
838-
839838
MUXLOGDEBUG(boost::format("port: %s, %s = %s") % portName % field % linkFailureDetectionType);
840839

841840
mMuxManagerPtr->updateLinkFailureDetectionType(portName, linkFailureDetectionType);
@@ -849,7 +848,7 @@ void DbInterface::processLinkFailureDetectionType(std::vector<swss::KeyOpFieldsV
849848
//
850849
void DbInterface::getLinkFailureDetectionType(std::shared_ptr<swss::DBConnector> configDbConnector)
851850
{
852-
MUXLOGINFO("Reading link_failure_detection_type");
851+
MUXLOGINFO("Reading link_prober_mode");
853852
swss::Table configDbMuxCableTable(configDbConnector.get(), CFG_MUX_CABLE_TABLE_NAME);
854853
std::vector<swss::KeyOpFieldsValuesTuple> entries;
855854

@@ -1580,8 +1579,7 @@ void DbInterface::processTsaEnableNotification(std::deque<swss::KeyOpFieldsValue
15801579
//
15811580
void DbInterface::createIcmpEchoSession(std::string key, IcmpHwOffloadEntriesPtr entries)
15821581
{
1583-
MUXLOGDEBUG(key);
1584-
1582+
MUXLOGDEBUG(boost::format(" %s : ICMP session Being created " % key));
15851583
boost::asio::post(mStrand, boost::bind(
15861584
&DbInterface::handleIcmpEchoSession,
15871585
this,
@@ -1612,14 +1610,59 @@ void DbInterface::handleIcmpEchoSession(std::string key, IcmpHwOffloadEntries *e
16121610
delete entries;
16131611
}
16141612

1613+
void DbInterface::updateTxIntervalv4(std::string key, uint32_t tx_interval)
1614+
{
1615+
MUXLOGDEBUG(boost::format(" %s : Updating Tx Interval v4 " %key));
1616+
boost::asio::post(mStrand, boost::bind(
1617+
&DbInterface::handleUpdateTxIntervalv4,
1618+
this,
1619+
key,
1620+
tx_interval
1621+
));
1622+
}
1623+
1624+
void DbInterface::updateTxIntervalv6(std::string key, uint32_t tx_interval)
1625+
{
1626+
MUXLOGDEBUG(boost::format(" %s : Updating Tx Interval v6 " %key));
1627+
boost::asio::post(mStrand, boost::bind(
1628+
&DbInterface::handleUpdateTxIntervalv6,
1629+
this,
1630+
key,
1631+
tx_interval
1632+
));
1633+
}
1634+
1635+
void DbInterface::handleUpdateTxIntervalv4(std::string key, uint32_t tx_interval)
1636+
{
1637+
std::vector<swss::FieldValueTuple> fvs;
1638+
fvs.emplace_back("interval_v4", std::to_string(tx_interval));
1639+
mAppDbIcmpEchoSessionTablePtr->set(key, fvs);
1640+
}
1641+
1642+
void DbInterface::handleUpdateTxIntervalv6(std::string key, uint32_t tx_interval)
1643+
{
1644+
std::vector<swss::FieldValueTuple> fvs;
1645+
fvs.emplace_back("interval_v6", std::to_string(tx_interval));
1646+
mAppDbIcmpEchoSessionTablePtr->set(key, fvs);
1647+
}
1648+
16151649
//
16161650
// ---> deleteIcmpEchoSession(std::string key);
16171651
//
16181652
// handles deletion of a ICMP_ECHO_SESSION in APP_ICMP_ECHO_SESSION_TABLE
16191653
//
16201654
void DbInterface::deleteIcmpEchoSession(std::string key)
16211655
{
1622-
MUXLOGDEBUG(boost::format("APP_ICMP_ECHO_SESSION_TABLE::key: %s ") %
1656+
MUXLOGDEBUG(boost::format(" %s : ICMP session Being deleted" % key));
1657+
boost::asio::post(mStrand, boost::bind(
1658+
&DbInterface::handleDeleteIcmpEchoSession,
1659+
this,
1660+
key
1661+
));
1662+
}
1663+
1664+
void DbInterface::handleDeleteIcmpEchoSession(std::string key) {
1665+
MUXLOGDEBUG(boost::format("APP_ICMP_ECHO_SESSION_TABLE::key: %s ") %
16231666
key
16241667
);
16251668
mAppDbIcmpEchoSessionTablePtr->del(key);
@@ -1628,21 +1671,19 @@ void DbInterface::deleteIcmpEchoSession(std::string key)
16281671
//
16291672
// ---> extractIfnameAndSessionType(const std::string &key, std::string &ifname, std::string &sessionType);
16301673
//
1631-
// helper function to extract interface name and session_type from the key
1674+
// helper function to extract interface name and session_type from the key
16321675
//
16331676
void DbInterface::extractIfnameAndSessionType(const std::string &key, std::string &ifname, std::string &sessionType)
16341677
{
1635-
size_t firstColon = key.find(':');
1636-
size_t secondColon = key.find(':', firstColon + 1);
1637-
size_t thirdColon = key.find(':', secondColon + 1);
1638-
size_t fourthColon = key.find(':', thirdColon + 1);
1639-
1640-
if (firstColon != std::string::npos &&
1641-
secondColon != std::string::npos &&
1642-
thirdColon != std::string::npos &&
1643-
fourthColon != std::string::npos) {
1644-
ifname = key.substr(secondColon + 1, thirdColon - secondColon - 1);
1645-
sessionType = key.substr(fourthColon + 1);
1678+
size_t firstSep = key.find('|');
1679+
size_t secondSep = key.find('|', firstSep + 1);
1680+
size_t thirdSep = key.find('|', secondSep + 1);
1681+
1682+
if (firstSep != std::string::npos &&
1683+
secondSep != std::string::npos &&
1684+
thirdSep != std::string::npos) {
1685+
ifname = key.substr(firstSep + 1, secondSep - firstSep - 1);
1686+
sessionType = key.substr(thirdSep + 1);
16461687
} else {
16471688
std::cerr << "Unexpected format: " << key << std::endl;
16481689
}
@@ -1672,7 +1713,7 @@ void DbInterface::processIcmpEchoSessionStateNotification(std::deque<swss::KeyOp
16721713
const std::string field = cit->first;
16731714
const std::string value = cit->second;
16741715

1675-
MUXLOGDEBUG(boost::format("port: %s, f: %s, v: %s") %
1716+
MUXLOGINFO(boost::format("port: %s, f: %s, v: %s") %
16761717
port %
16771718
field %
16781719
value

src/DbInterface.h

Lines changed: 62 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,24 @@ class DbInterface
422422
*/
423423
void deleteIcmpEchoSession(std::string key);
424424

425+
/**
426+
*@method updateTxIntervalv4
427+
*
428+
*@brief update Tx v4 Interval
429+
*
430+
*@return handles update of interval_v4 field for ICMP_ECHO_SESSION in APP_ICMP_ECHO_SESSION_TABLE
431+
*/
432+
void updateTxIntervalv4(std::string key, uint32_t tx_interval);
433+
434+
/**
435+
*@method updateTxIntervalv4
436+
*
437+
*@brief update Tx v6 Interval
438+
*
439+
*@return handles update of interval_v6 field for ICMP_ECHO_SESSION in APP_ICMP_ECHO_SESSION_TABLE
440+
*/
441+
void updateTxIntervalv6(std::string key, uint32_t Rx_interval);
442+
425443
private:
426444
friend class test::MuxManagerTest;
427445

@@ -883,63 +901,90 @@ class DbInterface
883901

884902
/**
885903
* @method processTsaEnableNotification
886-
*
904+
*
887905
* @brief process Tsa Enable Notification
888-
*
906+
*
889907
* @return none
890908
*/
891909
void processTsaEnableNotification(std::deque<swss::KeyOpFieldsValuesTuple> &entries);
892910

893911
/**
894912
* @method handleIcmpEchoSessionStateNotification
895-
*
913+
*
896914
* @brief extract enteries from State_DB ICMP_ECHO_SESSION_TABLE and call processing function
897-
*
915+
*
898916
* @return none
899917
*/
900918
void handleIcmpEchoSessionStateNotification(swss::SubscriberStateTable &stateDbIcmpEchoSessionTable);
901919

902920
/**
903921
* @method handleIcmpEchoSession
904-
*
922+
*
905923
* @brief handles creation of a ICMP_ECHO_SESSION in APP_ICMP_ECHO_SESSION_TABLE
906-
*
924+
*
907925
* @return none
908926
*/
909927
void handleIcmpEchoSession(std::string key, IcmpHwOffloadEntries *entries);
910928

911929
/**
912-
* @method processIcmpEchoSessionStateNotification
913-
*
930+
* @method handleDeleteIcmpEchoSession
931+
*
932+
* @brief handles deletion of a ICMP_ECHO_SESSION in APP_ICMP_ECHO_SESSION_TABLE
933+
*
934+
* @return none
935+
*/
936+
void handleDeleteIcmpEchoSession(std::string key);
937+
938+
/**
939+
* @method handleUpdateTxIntervalv4
940+
*
941+
* @brief handles update of interval_v4 field for ICMP_ECHO_SESSION in APP_ICMP_ECHO_SESSION_TABLE
942+
*
943+
* @return none
944+
*/
945+
void handleUpdateTxIntervalv4(std::string key, uint32_t tx_interval);
946+
947+
/**
948+
* @method handleUpdateTxIntervalv6
949+
*
950+
* @brief handles update of interval_v6 field for ICMP_ECHO_SESSION in APP_ICMP_ECHO_SESSION_TABLE
951+
*
952+
* @return none
953+
*/
954+
void handleUpdateTxIntervalv6(std::string key, uint32_t tx_interval);
955+
956+
/**
957+
* @method processTsaEnableNotification
958+
*
914959
* @brief process each entery of ICMP_ECHO_SESSION_TABLE extract Port, Session_Type(Normal/Rx) and state itself
915-
*
960+
*
916961
* @return none
917962
*/
918963
void processIcmpEchoSessionStateNotification(std::deque<swss::KeyOpFieldsValuesTuple> &entries);
919964

920965
/**
921966
* @method processLinkFailureDetectionType
922-
*
923-
* @brief process Mux Cable Table enteries to get linkFailureDetectionType by defaut its software
924-
*
967+
*
968+
* @brief process Mux Cable Table enteries to get linkFailureDetectionType by defaut its software
969+
*
925970
* @return none
926971
*/
927972
void processLinkFailureDetectionType(std::vector<swss::KeyOpFieldsValuesTuple> &entries);
928973

929974
/**
930975
* @method getLinkFailureDetectionType
931-
*
976+
*
932977
* @brief retrieve the Link Failure Detection Type (HW/SW) from config
933-
*
978+
*
934979
* @return none
935980
*/
936981
void getLinkFailureDetectionType(std::shared_ptr<swss::DBConnector> configDbConnector);
937982

938983
/**
939984
* @method extractIfnameAndSessionType
940-
*
985+
*
941986
* @brief helper function to extract interface name and session_type from the key
942-
*
987+
*
943988
* @return none
944989
*/
945990
void extractIfnameAndSessionType(const std::string &key, std::string &ifname, std::string &sessionType);
@@ -977,7 +1022,7 @@ class DbInterface
9771022
std::shared_ptr<swss::Table> mStateDbLinkProbeStatsTablePtr;
9781023
// for writing mux switch reason to state db
9791024
std::shared_ptr<swss::Table> mStateDbSwitchCauseTablePtr;
980-
// for reading icmp echo session state from state db
1025+
// for reading icmp echo session state from state db
9811026
std::shared_ptr<swss::Table> mStateDbIcmpEchoSessionTablePtr;
9821027

9831028
std::shared_ptr<boost::thread> mSwssThreadPtr;

src/MuxManager.cpp

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,31 @@ void MuxManager::setUseWellKnownMacActiveActive(bool useWellKnownMac)
7070
}
7171
}
7272

73+
//
74+
// ---> setTimeoutIpv4_msec(uint32_t timeout_msec)
75+
//
76+
// update Interval Time
77+
//
78+
void MuxManager::setTimeoutIpv4_msec(uint32_t timeout_msec)
79+
{
80+
mMuxConfig.setTimeoutIpv4_msec(timeout_msec);
81+
for (const auto & [portName, muxPort] : mPortMap) {
82+
muxPort->setTimeoutIpv4_msec(timeout_msec);
83+
}
84+
}
85+
86+
//
87+
// ---> setTimeoutIpv6_msec(uint32_t timeout_msec)
88+
//
89+
// update Interval Time
90+
//
91+
void MuxManager::setTimeoutIpv6_msec(uint32_t timeout_msec)
92+
{
93+
mMuxConfig.setTimeoutIpv6_msec(timeout_msec);
94+
for (const auto & [portName, muxPort] : mPortMap) {
95+
muxPort->setTimeoutIpv6_msec(timeout_msec);
96+
}
97+
}
7398

7499
//
75100
// ---> initialize();
@@ -244,7 +269,7 @@ void MuxManager::updatePortCableType(const std::string &portName, const std::str
244269
//
245270
void MuxManager::updateLinkFailureDetectionState(const std::string &portName, const std::string &linkFailureDetectionState, const std::string &session_type)
246271
{
247-
MUXLOGWARNING(boost::format("%s: link failure detection state for %s : %s") % portName % session_type %linkFailureDetectionState );
272+
MUXLOGDEBUG(boost::format("%s: link failure detection state for %s : %s") % portName % session_type %linkFailureDetectionState );
248273
std::shared_ptr<MuxPort> muxPortPtr = getMuxPortPtrOrThrow(portName);
249274
common::MuxPortConfig::PortCableType portCableType = getMuxPortCableType(portName);
250275

@@ -261,7 +286,7 @@ void MuxManager::updateLinkFailureDetectionState(const std::string &portName, co
261286
//
262287
void MuxManager::updateLinkFailureDetectionType(const std::string &portName, const std::string &linkFailureDetectionType)
263288
{
264-
MUXLOGWARNING(boost::format("%s: link failure detection type for : %s") % portName % linkFailureDetectionType );
289+
MUXLOGDEBUG(boost::format("%s: link failure detection type for : %s") % portName % linkFailureDetectionType );
265290
std::shared_ptr<MuxPort> muxPortPtr = getMuxPortPtrOrThrow(portName);
266291
common::MuxPortConfig::PortCableType portCableType = getMuxPortCableType(portName);
267292

src/MuxManager.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class MuxManager
110110
*
111111
*@return none
112112
*/
113-
inline void setTimeoutIpv4_msec(uint32_t timeout_msec) {mMuxConfig.setTimeoutIpv4_msec(timeout_msec);};
113+
void setTimeoutIpv4_msec(uint32_t timeout_msec);
114114

115115
/**
116116
*@method setTimeoutIpv6_msec
@@ -121,7 +121,7 @@ class MuxManager
121121
*
122122
*@return none
123123
*/
124-
inline void setTimeoutIpv6_msec(uint32_t timeout_msec) {mMuxConfig.setTimeoutIpv6_msec(timeout_msec);};
124+
void setTimeoutIpv6_msec(uint32_t timeout_msec);
125125

126126
/**
127127
*@method setOscillationEnabled
@@ -506,24 +506,24 @@ class MuxManager
506506
*/
507507
void processResetSuspendTimer(const std::vector<std::string> &portNames);
508508

509-
/**
509+
/**
510510
* @method updateLinkFailureDetectionState
511511
*
512512
* @brief update state of ICMP_ECHO_SESSION
513513
*
514514
* @return none
515515
*/
516-
void updateLinkFailureDetectionState(const std::string &portName, const std::string &linkFailureDetectionState,
516+
void updateLinkFailureDetectionState(const std::string &portName, const std::string &linkFailureDetectionState,
517517
const std::string &session_type);
518518

519-
/**
519+
/**
520520
* @method updateLinkFailureDetectionType
521521
*
522522
* @brief updates link_failure_detection type for link_prober
523523
*
524524
* @return none
525525
*/
526-
void updateLinkFailureDetectionType(const std::string &portName, const std::string &linkFailureDetectionType);
526+
void updateLinkFailureDetectionType(const std::string &portName, const std::string &linkFailureDetectionType);
527527

528528
private:
529529
/**

0 commit comments

Comments
 (0)