Skip to content

Commit

Permalink
Merge branch 'dualtor-neigh-miss' of github.com:theasianpianist/sonic…
Browse files Browse the repository at this point in the history
…-swss into dualtor-neigh-miss
  • Loading branch information
theasianpianist committed Aug 19, 2022
2 parents 7252b28 + 06113a3 commit c8c7e82
Show file tree
Hide file tree
Showing 32 changed files with 1,223 additions and 216 deletions.
22 changes: 19 additions & 3 deletions .azure-pipelines/test-docker-sonic-vs-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,32 @@ jobs:
if [ '${{ parameters.archive_gcov }}' == True ]; then
all_tests=$(ls test_*.py)
all_tests="${all_tests} p4rt"
test_set=()
# Run 20 tests as a set.
for test in ${all_tests}; do
test_name=$(echo "${test}" | cut -d "." -f 1)
sudo py.test -v --force-flaky --junitxml="${test_name}_tr.xml" --keeptb --imgname=docker-sonic-vs:$(Build.DefinitionName).$(Build.BuildNumber) ${test}
test_set+=("${test}")
if [ ${#test_set[@]} -ge 20 ]; then
test_name=$(echo "${test_set[0]}" | cut -d "." -f 1)
echo "${test_set[*]}" | xargs sudo py.test -v --force-flaky --junitxml="${test_name}_tr.xml" --keeptb --imgname=docker-sonic-vs:$(Build.DefinitionName).$(Build.BuildNumber)
container_count=$(docker ps -q -a | wc -l)
if [ ${container_count} -gt 0 ]; then
./gcov_support.sh set_environment $(Build.ArtifactStagingDirectory)
docker stop $(docker ps -q -a)
docker rm $(docker ps -q -a)
fi
test_set=()
fi
done
if [ ${#test_set[@]} -gt 0 ]; then
test_name=$(echo "${test_set[0]}" | cut -d "." -f 1)
echo "${test_set[*]}" | xargs sudo py.test -v --force-flaky --junitxml="${test_name}_tr.xml" --keeptb --imgname=docker-sonic-vs:$(Build.DefinitionName).$(Build.BuildNumber)
container_count=$(docker ps -q -a | wc -l)
if [ ${container_count} -gt 0 ]; then
./gcov_support.sh set_environment $(Build.ArtifactStagingDirectory)
docker stop $(docker ps -q -a)
docker rm $(docker ps -q -a)
fi
done
fi
else
sudo py.test -v --force-flaky --junitxml=tests_tr.xml --imgname=docker-sonic-vs:$(Build.DefinitionName).$(Build.BuildNumber)
fi
Expand Down
20 changes: 16 additions & 4 deletions cfgmgr/teammgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ void TeamMgr::doLagTask(Consumer &consumer)
{
int min_links = 0;
bool fallback = false;
bool fast_rate = false;
string admin_status = DEFAULT_ADMIN_STATUS_STR;
string mtu = DEFAULT_MTU_STR;
string learn_mode;
Expand Down Expand Up @@ -293,12 +294,18 @@ void TeamMgr::doLagTask(Consumer &consumer)
{
tpid = fvValue(i);
SWSS_LOG_INFO("Get TPID %s", tpid.c_str());
}
}
else if (fvField(i) == "fast_rate")
{
fast_rate = fvValue(i) == "true";
SWSS_LOG_INFO("Get fast_rate `%s`",
fast_rate ? "true" : "false");
}
}

if (m_lagList.find(alias) == m_lagList.end())
{
if (addLag(alias, min_links, fallback) == task_need_retry)
if (addLag(alias, min_links, fallback, fast_rate) == task_need_retry)
{
it++;
continue;
Expand Down Expand Up @@ -553,7 +560,7 @@ bool TeamMgr::setLagLearnMode(const string &alias, const string &learn_mode)
return true;
}

task_process_status TeamMgr::addLag(const string &alias, int min_links, bool fallback)
task_process_status TeamMgr::addLag(const string &alias, int min_links, bool fallback, bool fast_rate)
{
SWSS_LOG_ENTER();

Expand Down Expand Up @@ -610,6 +617,11 @@ task_process_status TeamMgr::addLag(const string &alias, int min_links, bool fal
conf << ",\"fallback\":true";
}

if (fast_rate)
{
conf << ",\"fast_rate\":true";
}

conf << "}}'";

SWSS_LOG_INFO("Port channel %s teamd configuration: %s",
Expand Down Expand Up @@ -652,7 +664,7 @@ bool TeamMgr::removeLag(const string &alias)
}

// Port-channel names are in the pattern of "PortChannel####"
//
//
// The LACP key could be generated in 3 ways based on the value in config DB:
// 1. "auto" - LACP key is extracted from the port-channel name and is set to be the number at the end of the port-channel name
// We are adding 1 at the beginning to avoid LACP key collisions between similar LACP keys e.g. PortChannel10 and PortChannel010.
Expand Down
2 changes: 1 addition & 1 deletion cfgmgr/teammgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class TeamMgr : public Orch
void doLagMemberTask(Consumer &consumer);
void doPortUpdateTask(Consumer &consumer);

task_process_status addLag(const std::string &alias, int min_links, bool fall_back);
task_process_status addLag(const std::string &alias, int min_links, bool fall_back, bool fast_rate);
bool removeLag(const std::string &alias);
task_process_status addLagMember(const std::string &lag, const std::string &member);
bool removeLagMember(const std::string &lag, const std::string &member);
Expand Down
31 changes: 27 additions & 4 deletions orchagent/fdborch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ void FdbOrch::handleSyncdFlushNotif(const sai_object_id_t& bv_id,
for (auto itr = m_entries.begin(); itr != m_entries.end();)
{
auto curr = itr++;
if (curr->second.type != "static" && (curr->first.mac == mac || mac == flush_mac))
if (curr->second.type != "static" && (curr->first.mac == mac || mac == flush_mac) && curr->second.is_flush_pending)
{
clearFdbEntry(curr->first);
}
Expand All @@ -233,7 +233,7 @@ void FdbOrch::handleSyncdFlushNotif(const sai_object_id_t& bv_id,
auto curr = itr++;
if (curr->second.bridge_port_id == bridge_port_id)
{
if (curr->second.type != "static" && (curr->first.mac == mac || mac == flush_mac))
if (curr->second.type != "static" && (curr->first.mac == mac || mac == flush_mac) && curr->second.is_flush_pending)
{
clearFdbEntry(curr->first);
}
Expand All @@ -248,7 +248,7 @@ void FdbOrch::handleSyncdFlushNotif(const sai_object_id_t& bv_id,
auto curr = itr++;
if (curr->first.bv_id == bv_id)
{
if (curr->second.type != "static" && (curr->first.mac == mac || mac == flush_mac))
if (curr->second.type != "static" && (curr->first.mac == mac || mac == flush_mac) && curr->second.is_flush_pending)
{
clearFdbEntry(curr->first);
}
Expand All @@ -263,7 +263,7 @@ void FdbOrch::handleSyncdFlushNotif(const sai_object_id_t& bv_id,
auto curr = itr++;
if (curr->first.bv_id == bv_id && curr->second.bridge_port_id == bridge_port_id)
{
if (curr->second.type != "static" && (curr->first.mac == mac || mac == flush_mac))
if (curr->second.type != "static" && (curr->first.mac == mac || mac == flush_mac) && curr->second.is_flush_pending)
{
clearFdbEntry(curr->first);
}
Expand Down Expand Up @@ -819,6 +819,7 @@ void FdbOrch::doTask(Consumer& consumer)
fdbData.remote_ip = remote_ip;
fdbData.esi = esi;
fdbData.vni = vni;
fdbData.is_flush_pending = false;
if (addFdbEntry(entry, port, fdbData))
{
if (origin == FDB_ORIGIN_MCLAG_ADVERTIZED)
Expand Down Expand Up @@ -907,6 +908,14 @@ void FdbOrch::doTask(NotificationConsumer& consumer)
SWSS_LOG_ERROR("Flush fdb failed, return code %x", status);
}

if (status == SAI_STATUS_SUCCESS) {
for (map<FdbEntry, FdbData>::iterator it = m_entries.begin();
it != m_entries.end(); it++)
{
it->second.is_flush_pending = true;
}
}

return;
}
else if (op == "PORT")
Expand Down Expand Up @@ -1071,6 +1080,20 @@ void FdbOrch::flushFDBEntries(sai_object_id_t bridge_port_oid,
{
SWSS_LOG_ERROR("Flushing FDB failed. rv:%d", rv);
}

if (SAI_STATUS_SUCCESS == rv) {
for (map<FdbEntry, FdbData>::iterator it = m_entries.begin();
it != m_entries.end(); it++)
{
if ((bridge_port_oid != SAI_NULL_OBJECT_ID &&
it->second.bridge_port_id == bridge_port_oid) ||
(vlan_oid != SAI_NULL_OBJECT_ID &&
it->first.bv_id == vlan_oid))
{
it->second.is_flush_pending = true;
}
}
}
}

void FdbOrch::notifyObserversFDBFlush(Port &port, sai_object_id_t& bvid)
Expand Down
1 change: 1 addition & 0 deletions orchagent/fdborch.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ struct FdbData
{"static", FDB_ORIGIN_PROVISIONED} => statically provisioned
{"static", FDB_ORIGIN_ADVERTIZED} => sticky synced from remote device
*/
bool is_flush_pending;

/* Remote FDB related info */
string remote_ip;
Expand Down
4 changes: 4 additions & 0 deletions orchagent/muxorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,10 @@ bool MuxOrch::isNeighborActive(const IpAddress& nbr, const MacAddress& mac, stri

if (ptr)
{
if (ptr->getSkipNeighborsSet().find(nbr) != ptr->getSkipNeighborsSet().end())
{
return true;
}
return ptr->isActive();
}

Expand Down
4 changes: 4 additions & 0 deletions orchagent/muxorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ class MuxCable
{
return nbr_handler_->getNextHopId(nh);
}
std::set<IpAddress> getSkipNeighborsSet()
{
return skip_neighbors_;
}

private:
bool stateActive();
Expand Down
27 changes: 20 additions & 7 deletions orchagent/orchdaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,13 +597,26 @@ bool OrchDaemon::init()
SAI_QUEUE_ATTR_PAUSE_STATUS,
};

m_orchList.push_back(new PfcWdSwOrch<PfcWdAclHandler, PfcWdLossyHandler>(
m_configDb,
pfc_wd_tables,
portStatIds,
queueStatIds,
queueAttrIds,
PFC_WD_POLL_MSECS));
if(gSwitchOrch->checkPfcDlrInitEnable())
{
m_orchList.push_back(new PfcWdSwOrch<PfcWdDlrHandler, PfcWdLossyHandler>(
m_configDb,
pfc_wd_tables,
portStatIds,
queueStatIds,
queueAttrIds,
PFC_WD_POLL_MSECS));
}
else
{
m_orchList.push_back(new PfcWdSwOrch<PfcWdAclHandler, PfcWdLossyHandler>(
m_configDb,
pfc_wd_tables,
portStatIds,
queueStatIds,
queueAttrIds,
PFC_WD_POLL_MSECS));
}
} else if (platform == CISCO_8000_PLATFORM_SUBSTRING)
{
static const vector<sai_port_stat_t> portStatIds;
Expand Down
2 changes: 1 addition & 1 deletion orchagent/p4orch/tests/fake_portorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ bool PortsOrch::getPortPvid(Port &port, sai_uint32_t &pvid)
return true;
}

bool PortsOrch::setPortFec(Port &port, sai_port_fec_mode_t mode)
bool PortsOrch::setPortFec(Port &port, std::string &mode)
{
return true;
}
Expand Down
43 changes: 43 additions & 0 deletions orchagent/pfcactionhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,49 @@ PfcWdSaiDlrInitHandler::~PfcWdSaiDlrInitHandler(void)
}
}

PfcWdDlrHandler::PfcWdDlrHandler(sai_object_id_t port, sai_object_id_t queue,
uint8_t queueId, shared_ptr<Table> countersTable):
PfcWdLossyHandler(port, queue, queueId, countersTable)
{
SWSS_LOG_ENTER();

sai_attribute_t attr;
attr.id = SAI_QUEUE_ATTR_PFC_DLR_INIT;
attr.value.booldata = true;

// Set DLR init to true to start PFC deadlock recovery
sai_status_t status = sai_queue_api->set_queue_attribute(queue, &attr);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to set PFC DLR INIT on port 0x%" PRIx64 " queue 0x%" PRIx64
" queueId %d : %d",
port, queue, queueId, status);
return;
}
}

PfcWdDlrHandler::~PfcWdDlrHandler(void)
{
SWSS_LOG_ENTER();

sai_object_id_t port = getPort();
sai_object_id_t queue = getQueue();
uint8_t queueId = getQueueId();

sai_attribute_t attr;
attr.id = SAI_QUEUE_ATTR_PFC_DLR_INIT;
attr.value.booldata = false;

// Set DLR init to false to stop PFC deadlock recovery
sai_status_t status = sai_queue_api->set_queue_attribute(getQueue(), &attr);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to clear PFC DLR INIT on port 0x%" PRIx64 " queue 0x%" PRIx64
" queueId %d : %d", port, queue, queueId, status);
return;
}
}

PfcWdAclHandler::PfcWdAclHandler(sai_object_id_t port, sai_object_id_t queue,
uint8_t queueId, shared_ptr<Table> countersTable):
PfcWdLossyHandler(port, queue, queueId, countersTable)
Expand Down
8 changes: 8 additions & 0 deletions orchagent/pfcactionhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ class PfcWdAclHandler: public PfcWdLossyHandler
void updatePfcAclRule(shared_ptr<AclRule> rule, uint8_t queueId, string strTable, vector<sai_object_id_t> port);
};

class PfcWdDlrHandler: public PfcWdLossyHandler
{
public:
PfcWdDlrHandler(sai_object_id_t port, sai_object_id_t queue,
uint8_t queueId, shared_ptr<Table> countersTable);
virtual ~PfcWdDlrHandler(void);
};

// PFC queue that implements drop action by draining queue with buffer of zero size
class PfcWdZeroBufferHandler: public PfcWdLossyHandler
{
Expand Down
34 changes: 34 additions & 0 deletions orchagent/pfcwdorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@
#define PFC_WD_TC_MAX 8
#define COUNTER_CHECK_POLL_TIMEOUT_SEC 1

extern sai_object_id_t gSwitchId;
extern sai_switch_api_t* sai_switch_api;
extern sai_port_api_t *sai_port_api;
extern sai_queue_api_t *sai_queue_api;

extern SwitchOrch *gSwitchOrch;
extern PortsOrch *gPortsOrch;

template <typename DropHandler, typename ForwardHandler>
Expand Down Expand Up @@ -229,6 +232,36 @@ task_process_status PfcWdOrch<DropHandler, ForwardHandler>::createEntry(const st
SWSS_LOG_ERROR("Unsupported action %s for platform %s", value.c_str(), m_platform.c_str());
return task_process_status::task_invalid_entry;
}
if(m_platform == BRCM_PLATFORM_SUBSTRING)
{
if(gSwitchOrch->checkPfcDlrInitEnable())
{
if(getPfcDlrPacketAction() == PfcWdAction::PFC_WD_ACTION_UNKNOWN)
{
sai_attribute_t attr;
attr.id = SAI_SWITCH_ATTR_PFC_DLR_PACKET_ACTION;
attr.value.u32 = (sai_uint32_t)action;

sai_status_t status = sai_switch_api->set_switch_attribute(gSwitchId, &attr);
if(status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to set switch level PFC DLR packet action rv : %d", status);
return task_process_status::task_invalid_entry;
}
setPfcDlrPacketAction(action);
}
else
{
if(getPfcDlrPacketAction() != action)
{
string DlrPacketAction = serializeAction(getPfcDlrPacketAction());
SWSS_LOG_ERROR("Invalid PFC Watchdog action %s as switch level action %s is set",
value.c_str(), DlrPacketAction.c_str());
return task_process_status::task_invalid_entry;
}
}
}
}
}
else
{
Expand Down Expand Up @@ -1064,4 +1097,5 @@ bool PfcWdSwOrch<DropHandler, ForwardHandler>::bake()
// Trick to keep member functions in a separate file
template class PfcWdSwOrch<PfcWdZeroBufferHandler, PfcWdLossyHandler>;
template class PfcWdSwOrch<PfcWdAclHandler, PfcWdLossyHandler>;
template class PfcWdSwOrch<PfcWdDlrHandler, PfcWdLossyHandler>;
template class PfcWdSwOrch<PfcWdSaiDlrInitHandler, PfcWdActionHandler>;
3 changes: 3 additions & 0 deletions orchagent/pfcwdorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class PfcWdOrch: public Orch

virtual task_process_status createEntry(const string& key, const vector<FieldValueTuple>& data);
task_process_status deleteEntry(const string& name);
PfcWdAction getPfcDlrPacketAction() { return PfcDlrPacketAction; }
void setPfcDlrPacketAction(PfcWdAction action) { PfcDlrPacketAction = action; }

protected:
virtual bool startWdActionOnQueue(const string &event, sai_object_id_t queueId) = 0;
Expand All @@ -58,6 +60,7 @@ class PfcWdOrch: public Orch

shared_ptr<DBConnector> m_countersDb = nullptr;
shared_ptr<Table> m_countersTable = nullptr;
PfcWdAction PfcDlrPacketAction = PfcWdAction::PFC_WD_ACTION_UNKNOWN;
};

template <typename DropHandler, typename ForwardHandler>
Expand Down
Loading

0 comments on commit c8c7e82

Please sign in to comment.