Skip to content

Commit

Permalink
Merge branch 'master' into remove-enforce-wred-drop
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidZagury authored Sep 11, 2022
2 parents 0b02be3 + b62c716 commit 5538efe
Show file tree
Hide file tree
Showing 40 changed files with 1,762 additions and 434 deletions.
14 changes: 11 additions & 3 deletions cfgmgr/buffermgrdyn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3110,8 +3110,7 @@ task_process_status BufferMgrDynamic::handleSingleBufferQueueEntry(const string

if (op == SET_COMMAND)
{
auto &portQueue = m_portQueueLookup[port][queues];

bool successful = false;
SWSS_LOG_INFO("Inserting entry BUFFER_QUEUE_TABLE:%s to APPL_DB", key.c_str());

for (auto i : kfvFieldsValues(tuple))
Expand All @@ -3122,8 +3121,10 @@ task_process_status BufferMgrDynamic::handleSingleBufferQueueEntry(const string
auto rc = checkBufferProfileDirection(fvValue(i), BUFFER_EGRESS);
if (rc != task_process_status::task_success)
return rc;
portQueue.running_profile_name = fvValue(i);

m_portQueueLookup[port][queues].running_profile_name = fvValue(i);
SWSS_LOG_NOTICE("Queue %s has been configured on the system, referencing profile %s", key.c_str(), fvValue(i).c_str());
successful = true;
}
else
{
Expand All @@ -3134,8 +3135,15 @@ task_process_status BufferMgrDynamic::handleSingleBufferQueueEntry(const string
SWSS_LOG_INFO("Inserting field %s value %s", fvField(i).c_str(), fvValue(i).c_str());
}

if (!successful)
{
SWSS_LOG_ERROR("Invalid BUFFER_QUEUE configuration on %s: no profile configured", key.c_str());
return task_process_status::task_failed;
}

// TODO: check overlap. Currently, assume there is no overlap

auto &portQueue = m_portQueueLookup[port][queues];
if (PORT_ADMIN_DOWN == portInfo.state)
{
handleSetSingleBufferObjectOnAdminDownPort(BUFFER_QUEUE, port, key, portQueue.running_profile_name);
Expand Down
12 changes: 6 additions & 6 deletions cfgmgr/nbrmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ void NbrMgr::doStateSystemNeighTask(Consumer &consumer)

if (!addKernelNeigh(nbr_odev, ip_address, mac_address))
{
SWSS_LOG_ERROR("Neigh entry add on dev %s failed for '%s'", nbr_odev.c_str(), kfvKey(t).c_str());
SWSS_LOG_INFO("Neigh entry add on dev %s failed for '%s'", nbr_odev.c_str(), kfvKey(t).c_str());
// Delete neigh to take care of deletion of exiting nbr for mac change. This makes sure that
// re-try will be successful and route addtion (below) will be attempted and be successful
delKernelNeigh(nbr_odev, ip_address);
Expand All @@ -411,7 +411,7 @@ void NbrMgr::doStateSystemNeighTask(Consumer &consumer)

if (!addKernelRoute(nbr_odev, ip_address))
{
SWSS_LOG_ERROR("Route entry add on dev %s failed for '%s'", nbr_odev.c_str(), kfvKey(t).c_str());
SWSS_LOG_INFO("Route entry add on dev %s failed for '%s'", nbr_odev.c_str(), kfvKey(t).c_str());
delKernelNeigh(nbr_odev, ip_address);
// Delete route to take care of deletion of exiting route of nbr for mac change.
delKernelRoute(ip_address);
Expand Down Expand Up @@ -522,8 +522,8 @@ bool NbrMgr::addKernelRoute(string odev, IpAddress ip_addr)

if(ret)
{
/* Just log error and return */
SWSS_LOG_ERROR("Failed to add route for %s, error: %d", ip_str.c_str(), ret);
/* This failure the caller expects is due to mac move */
SWSS_LOG_INFO("Failed to add route for %s, error: %d", ip_str.c_str(), ret);
return false;
}

Expand Down Expand Up @@ -586,8 +586,8 @@ bool NbrMgr::addKernelNeigh(string odev, IpAddress ip_addr, MacAddress mac_addr)

if(ret)
{
/* Just log error and return */
SWSS_LOG_ERROR("Failed to add Nbr for %s, error: %d", ip_str.c_str(), ret);
/* This failure the caller expects is due to mac move */
SWSS_LOG_INFO("Failed to add Nbr for %s, error: %d", ip_str.c_str(), ret);
return false;
}

Expand Down
12 changes: 6 additions & 6 deletions neighsyncd/neighsync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ void NeighSync::onMsg(int nlmsg_type, struct nl_object *obj)
string key;
string family;
string intfName;
std::vector<std::string> peerSwitchKeys;
m_cfgPeerSwitchTable.getKeys(peerSwitchKeys);
bool is_dualtor = peerSwitchKeys.size() > 0;

if ((nlmsg_type != RTM_NEWNEIGH) && (nlmsg_type != RTM_GETNEIGH) &&
(nlmsg_type != RTM_DELNEIGH))
Expand All @@ -81,11 +84,11 @@ void NeighSync::onMsg(int nlmsg_type, struct nl_object *obj)

nl_addr2str(rtnl_neigh_get_dst(neigh), ipStr, MAX_ADDR_SIZE);

/* Ignore IPv4 link-local addresses as neighbors */
/* Ignore IPv4 link-local addresses as neighbors if subtype is dualtor */
IpAddress ipAddress(ipStr);
if (family == IPV4_NAME && ipAddress.getAddrScope() == IpAddress::AddrScope::LINK_SCOPE)
if (family == IPV4_NAME && ipAddress.getAddrScope() == IpAddress::AddrScope::LINK_SCOPE && is_dualtor)
{
SWSS_LOG_INFO("Link Local address received, ignoring for %s", ipStr);
SWSS_LOG_INFO("Link Local address received on dualtor, ignoring for %s", ipStr);
return;
}

Expand All @@ -109,11 +112,8 @@ void NeighSync::onMsg(int nlmsg_type, struct nl_object *obj)
return;
}

std::vector<std::string> peerSwitchKeys;
bool delete_key = false;
bool use_zero_mac = false;
m_cfgPeerSwitchTable.getKeys(peerSwitchKeys);
bool is_dualtor = peerSwitchKeys.size() > 0;
if (is_dualtor && (state == NUD_INCOMPLETE || state == NUD_FAILED))
{
SWSS_LOG_INFO("Unable to resolve %s, setting zero MAC", key.c_str());
Expand Down
24 changes: 24 additions & 0 deletions orchagent/aclorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1477,6 +1477,11 @@ const vector<AclRangeConfig>& AclRule::getRangeConfig() const
return m_rangeConfig;
}

bool AclRule::getCreateCounter() const
{
return m_createCounter;
}

shared_ptr<AclRule> AclRule::makeShared(AclOrch *acl, MirrorOrch *mirror, DTelOrch *dtel, const string& rule, const string& table, const KeyOpFieldsValuesTuple& data)
{
shared_ptr<AclRule> aclRule;
Expand Down Expand Up @@ -1624,6 +1629,13 @@ bool AclRule::createCounter()
bool AclRule::removeRanges()
{
SWSS_LOG_ENTER();
if (!m_ranges.size())
{
//The Acl Rules which have mirror action will not have ranges created till the mirror becomes active
SWSS_LOG_INFO("No Acl Range created for ACL Rule %s in table %s", m_id.c_str(), m_pTable->getId().c_str());
return true;
}

for (const auto& rangeConfig: m_rangeConfig)
{
if (!AclRange::remove(rangeConfig.rangeType, rangeConfig.min, rangeConfig.max))
Expand Down Expand Up @@ -1924,6 +1936,16 @@ bool AclRuleMirror::activate()
setAction(it.first, attr.value.aclaction);
}

// If the rule with mirror action is removed and then mirror is activated, create the counter before rule is created
if (!hasCounter())
{
if (getCreateCounter() && !createCounter())
{
SWSS_LOG_ERROR("createCounter failed for Rule %s session %s", m_id.c_str(), m_sessionName.c_str());
return false;
}
}

if (!AclRule::createRule())
{
return false;
Expand Down Expand Up @@ -2885,6 +2907,7 @@ void AclOrch::init(vector<TableConnector>& connectors, PortsOrch *portOrch, Mirr
platform == MRVL_PLATFORM_SUBSTRING ||
platform == INVM_PLATFORM_SUBSTRING ||
platform == NPS_PLATFORM_SUBSTRING ||
platform == XS_PLATFORM_SUBSTRING ||
platform == VS_PLATFORM_SUBSTRING)
{
m_mirrorTableCapabilities =
Expand Down Expand Up @@ -2913,6 +2936,7 @@ void AclOrch::init(vector<TableConnector>& connectors, PortsOrch *portOrch, Mirr
if (platform == MLNX_PLATFORM_SUBSTRING ||
platform == CISCO_8000_PLATFORM_SUBSTRING ||
platform == MRVL_PLATFORM_SUBSTRING ||
platform == XS_PLATFORM_SUBSTRING ||
(platform == BRCM_PLATFORM_SUBSTRING && sub_platform == BRCM_DNX_PLATFORM_SUBSTRING))
{
m_isCombinedMirrorV6Table = false;
Expand Down
1 change: 1 addition & 0 deletions orchagent/aclorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ class AclRule
sai_object_id_t getCounterOid() const;
bool hasCounter() const;
vector<sai_object_id_t> getInPorts() const;
bool getCreateCounter() const;

const vector<AclRangeConfig>& getRangeConfig() const;
static shared_ptr<AclRule> makeShared(AclOrch *acl, MirrorOrch *mirror, DTelOrch *dtel, const string& rule, const string& table, const KeyOpFieldsValuesTuple&);
Expand Down
11 changes: 11 additions & 0 deletions orchagent/bfdorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ BfdOrch::BfdOrch(DBConnector *db, string tableName, TableConnector stateDbBfdSes
DBConnector *notificationsDb = new DBConnector("ASIC_DB", 0);
m_bfdStateNotificationConsumer = new swss::NotificationConsumer(notificationsDb, "NOTIFICATIONS");
auto bfdStateNotificatier = new Notifier(m_bfdStateNotificationConsumer, this, "BFD_STATE_NOTIFICATIONS");

// Clean up state database BFD entries
vector<string> keys;

m_stateBfdSessionTable.getKeys(keys);

for (auto alias : keys)
{
m_stateBfdSessionTable.del(alias);
}

Orch::addExecutor(bfdStateNotificatier);
register_state_change_notif = false;
}
Expand Down
101 changes: 100 additions & 1 deletion orchagent/bufferorch.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "tokenize.h"
#include "bufferorch.h"
#include "directory.h"
#include "logger.h"
#include "sai_serialize.h"
#include "warm_restart.h"
Expand All @@ -16,6 +17,7 @@ extern sai_switch_api_t *sai_switch_api;
extern sai_buffer_api_t *sai_buffer_api;

extern PortsOrch *gPortsOrch;
extern Directory<Orch*> gDirectory;
extern sai_object_id_t gSwitchId;

#define BUFFER_POOL_WATERMARK_FLEX_STAT_COUNTER_POLL_MSECS "60000"
Expand All @@ -42,6 +44,9 @@ map<string, string> buffer_to_ref_table_map = {
{buffer_profile_list_field_name, APP_BUFFER_PROFILE_TABLE_NAME}
};

std::map<string, std::map<size_t, string>> pg_port_flags;
std::map<string, std::map<size_t, string>> queue_port_flags;

BufferOrch::BufferOrch(DBConnector *applDb, DBConnector *confDb, DBConnector *stateDb, vector<string> &tableNames) :
Orch(applDb, tableNames),
m_flexCounterDb(new DBConnector("FLEX_COUNTER_DB", 0)),
Expand Down Expand Up @@ -812,7 +817,54 @@ task_process_status BufferOrch::processQueue(KeyOpFieldsValuesTuple &tuple)
return handle_status;
}
}
// create/remove a port queue counter for the queue buffer
else
{
auto flexCounterOrch = gDirectory.get<FlexCounterOrch*>();
auto queues = tokens[1];
if (op == SET_COMMAND && flexCounterOrch->getQueueCountersState())
{
gPortsOrch->createPortBufferQueueCounters(port, queues);
}
else if (op == DEL_COMMAND && flexCounterOrch->getQueueCountersState())
{
gPortsOrch->removePortBufferQueueCounters(port, queues);
}
}
}

/* when we apply buffer configuration we need to increase the ref counter of this port
* or decrease the ref counter for this port when we remove buffer cfg
* so for each priority cfg in each port we will increase/decrease the ref counter
* also we need to know when the set command is for creating a buffer cfg or modifying buffer cfg -
* we need to increase ref counter only on create flow.
* so we added a map that will help us to know what was the last command for this port and priority -
* if the last command was set command then it is a modify command and we dont need to increase the buffer counter
* all other cases (no last command exist or del command was the last command) it means that we need to increase the ref counter */
if (op == SET_COMMAND)
{
if (queue_port_flags[port_name][ind] != SET_COMMAND)
{
/* if the last operation was not "set" then it's create and not modify - need to increase ref counter */
gPortsOrch->increasePortRefCount(port_name);
}
}
else if (op == DEL_COMMAND)
{
if (queue_port_flags[port_name][ind] == SET_COMMAND)
{
/* we need to decrease ref counter only if the last operation was "SET_COMMAND" */
gPortsOrch->decreasePortRefCount(port_name);
}
}
else
{
SWSS_LOG_ERROR("operation value is not SET or DEL (op = %s)", op.c_str());
return task_process_status::task_invalid_entry;
}
/* save the last command (set or delete) */
queue_port_flags[port_name][ind] = op;

}
}

Expand Down Expand Up @@ -871,7 +923,7 @@ task_process_status BufferOrch::processPriorityGroup(KeyOpFieldsValuesTuple &tup
if (op == SET_COMMAND)
{
ref_resolve_status resolve_result = resolveFieldRefValue(m_buffer_type_maps, buffer_profile_field_name,
buffer_to_ref_table_map.at(buffer_profile_field_name), tuple,
buffer_to_ref_table_map.at(buffer_profile_field_name), tuple,
sai_buffer_profile, buffer_profile_name);
if (ref_resolve_status::success != resolve_result)
{
Expand Down Expand Up @@ -944,8 +996,55 @@ task_process_status BufferOrch::processPriorityGroup(KeyOpFieldsValuesTuple &tup
return handle_status;
}
}
// create or remove a port PG counter for the PG buffer
else
{
auto flexCounterOrch = gDirectory.get<FlexCounterOrch*>();
auto pgs = tokens[1];
if (op == SET_COMMAND && flexCounterOrch->getPgWatermarkCountersState())
{
gPortsOrch->createPortBufferPgCounters(port, pgs);
}
else if (op == DEL_COMMAND && flexCounterOrch->getPgWatermarkCountersState())
{
gPortsOrch->removePortBufferPgCounters(port, pgs);
}
}
}
}

/* when we apply buffer configuration we need to increase the ref counter of this port
* or decrease the ref counter for this port when we remove buffer cfg
* so for each priority cfg in each port we will increase/decrease the ref counter
* also we need to know when the set command is for creating a buffer cfg or modifying buffer cfg -
* we need to increase ref counter only on create flow.
* so we added a map that will help us to know what was the last command for this port and priority -
* if the last command was set command then it is a modify command and we dont need to increase the buffer counter
* all other cases (no last command exist or del command was the last command) it means that we need to increase the ref counter */
if (op == SET_COMMAND)
{
if (pg_port_flags[port_name][ind] != SET_COMMAND)
{
/* if the last operation was not "set" then it's create and not modify - need to increase ref counter */
gPortsOrch->increasePortRefCount(port_name);
}
}
else if (op == DEL_COMMAND)
{
if (pg_port_flags[port_name][ind] == SET_COMMAND)
{
/* we need to decrease ref counter only if the last operation was "SET_COMMAND" */
gPortsOrch->decreasePortRefCount(port_name);
}
}
else
{
SWSS_LOG_ERROR("operation value is not SET or DEL (op = %s)", op.c_str());
return task_process_status::task_invalid_entry;
}
/* save the last command (set or delete) */
pg_port_flags[port_name][ind] = op;

}
}

Expand Down
2 changes: 1 addition & 1 deletion orchagent/bulker.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class EntityBulker
auto& attrs = it->second.first;
attrs.insert(attrs.end(), attr_list, attr_list + attr_count);
it->second.second = object_status;
SWSS_LOG_INFO("EntityBulker.create_entry %zu, %zu, %d, %d\n", creating_entries.size(), it->second.first.size(), (int)it->second.first[0].id, inserted);
SWSS_LOG_INFO("EntityBulker.create_entry %zu, %zu, %d\n", creating_entries.size(), it->second.first.size(), inserted);
*object_status = SAI_STATUS_NOT_EXECUTED;
return *object_status;
}
Expand Down
Loading

0 comments on commit 5538efe

Please sign in to comment.