Skip to content

Commit

Permalink
Merge branch 'master' into project-phoenixwing-srv6-vpn
Browse files Browse the repository at this point in the history
  • Loading branch information
StormLiangMS authored Oct 24, 2024
2 parents 0fea2eb + bd945f6 commit 87f3488
Show file tree
Hide file tree
Showing 32 changed files with 402 additions and 207 deletions.
7 changes: 7 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,10 @@
# Chassis
/orchagent/fabricportsorch* @abdosi @judyjoseph
/tests/test_virtual_chassis.py @abdosi @judyjoseph

# Vnet Orch
/orchagent/vnet* @siqbal1986

# Acl Orch
/orchagent/acl* @siqbal1986

56 changes: 49 additions & 7 deletions cfgmgr/buffer_check_headroom_mellanox.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
-- KEYS - port name
-- ARGV[1] - profile name
-- ARGV[2] - new size
-- ARGV[3] - pg to add
-- ARGV[3] - new xon
-- ARGV[4] - new xoff
-- ARGV[5] - pg to add

local port = KEYS[1]
local input_profile_name = ARGV[1]
local input_profile_size = tonumber(ARGV[2])
local new_pg = ARGV[3]
local input_profile_xon = tonumber(ARGV[3])
local input_profile_xoff = tonumber(ARGV[4])
local new_pg = ARGV[5]

local function is_port_with_8lanes(lanes)
-- On Spectrum 3, ports with 8 lanes have doubled pipeline latency
Expand Down Expand Up @@ -55,17 +59,31 @@ end

local asic_keys = redis.call('KEYS', 'ASIC_TABLE*')
local pipeline_latency = tonumber(redis.call('HGET', asic_keys[1], 'pipeline_latency'))
local cell_size = tonumber(redis.call('HGET', asic_keys[1], 'cell_size'))
local port_reserved_shp = tonumber(redis.call('HGET', asic_keys[1], 'port_reserved_shp'))
local port_max_shp = tonumber(redis.call('HGET', asic_keys[1], 'port_max_shp'))
if is_port_with_8lanes(lanes) then
-- The pipeline latency should be adjusted accordingly for ports with 2 buffer units
pipeline_latency = pipeline_latency * 2 - 1
egress_mirror_size = egress_mirror_size * 2
port_reserved_shp = port_reserved_shp * 2
end

local lossy_pg_size = pipeline_latency * 1024
accumulative_size = accumulative_size + lossy_pg_size + egress_mirror_size

-- Fetch all keys in BUFFER_PG according to the port
redis.call('SELECT', appl_db)

local is_shp_enabled
local shp_size = tonumber(redis.call('HGET', 'BUFFER_POOL_TABLE:ingress_lossless_pool', 'xoff'))
if shp_size == nil or shp_size == 0 then
is_shp_enabled = false
else
is_shp_enabled = true
end
local accumulative_shared_headroom = 0

local debuginfo = {}

local function get_number_of_pgs(keyname)
Expand Down Expand Up @@ -122,26 +140,50 @@ end
table.insert(debuginfo, 'debug:other overhead:' .. accumulative_size)
for pg_key, profile in pairs(all_pgs) do
local current_profile_size
local current_profile_xon
local current_profile_xoff
local buffer_profile_table_name = 'BUFFER_PROFILE_TABLE:'
if profile ~= input_profile_name then
local referenced_profile_size = redis.call('HGET', 'BUFFER_PROFILE_TABLE:' .. profile, 'size')
local referenced_profile_size = redis.call('HGET', buffer_profile_table_name .. profile, 'size')
if not referenced_profile_size then
referenced_profile_size = redis.call('HGET', '_BUFFER_PROFILE_TABLE:' .. profile, 'size')
buffer_profile_table_name = '_BUFFER_PROFILE_TABLE:'
referenced_profile_size = redis.call('HGET', buffer_profile_table_name .. profile, 'size')
table.insert(debuginfo, 'debug:pending profile: ' .. profile)
end
current_profile_size = tonumber(referenced_profile_size)
current_profile_xon = tonumber(redis.call('HGET', buffer_profile_table_name .. profile, 'xon'))
current_profile_xoff = tonumber(redis.call('HGET', buffer_profile_table_name .. profile, 'xoff'))
else
current_profile_size = input_profile_size
current_profile_xon = input_profile_xon
current_profile_xoff = input_profile_xoff
end
if current_profile_size == 0 then
current_profile_size = lossy_pg_size
end
accumulative_size = accumulative_size + current_profile_size * get_number_of_pgs(pg_key)
table.insert(debuginfo, 'debug:' .. pg_key .. ':' .. profile .. ':' .. current_profile_size .. ':' .. get_number_of_pgs(pg_key) .. ':accu:' .. accumulative_size)

if is_shp_enabled and current_profile_xon and current_profile_xoff then
if current_profile_size < current_profile_xon + current_profile_xoff then
accumulative_shared_headroom = accumulative_shared_headroom + (current_profile_xon + current_profile_xoff - current_profile_size) * get_number_of_pgs(pg_key)
end
end
table.insert(debuginfo, 'debug:' .. pg_key .. ':' .. profile .. ':' .. current_profile_size .. ':' .. get_number_of_pgs(pg_key) .. ':accu:' .. accumulative_size .. ':accu_shp:' .. accumulative_shared_headroom)
end

if max_headroom_size > accumulative_size then
table.insert(ret, "result:true")
table.insert(ret, "debug:Accumulative headroom on port " .. accumulative_size .. ", the maximum available headroom " .. max_headroom_size)
if is_shp_enabled then
local max_shp = (port_max_shp + port_reserved_shp) * cell_size
if accumulative_shared_headroom > max_shp then
table.insert(ret, "result:false")
else
table.insert(ret, "result:true")
end
table.insert(ret, "debug:Accumulative headroom on port " .. accumulative_size .. ", the maximum available headroom " .. max_headroom_size .. ", the port SHP " .. accumulative_shared_headroom .. ", max SHP " .. max_shp)
else
table.insert(ret, "result:true")
table.insert(ret, "debug:Accumulative headroom on port " .. accumulative_size .. ", the maximum available headroom " .. max_headroom_size)
end
else
table.insert(ret, "result:false")
table.insert(ret, "debug:Accumulative headroom on port " .. accumulative_size .. " exceeds the maximum available headroom which is " .. max_headroom_size)
Expand Down
6 changes: 4 additions & 2 deletions cfgmgr/buffermgrdyn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1056,14 +1056,16 @@ bool BufferMgrDynamic::isHeadroomResourceValid(const string &port, const buffer_

argv.emplace_back(profile.name);
argv.emplace_back(profile.size);
argv.emplace_back(profile.xon);
argv.emplace_back(profile.xoff);

if (!new_pg.empty())
{
argv.emplace_back(new_pg);
}

SWSS_LOG_INFO("Checking headroom for port %s with profile %s size %s pg %s",
port.c_str(), profile.name.c_str(), profile.size.c_str(), new_pg.c_str());
SWSS_LOG_INFO("Checking headroom for port %s with profile %s size %s xon %s xoff %s pg %s",
port.c_str(), profile.name.c_str(), profile.size.c_str(), profile.xon.c_str(), profile.xoff.c_str(), new_pg.c_str());

try
{
Expand Down
11 changes: 9 additions & 2 deletions cfgmgr/portmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,15 @@ void PortMgr::doTask(Consumer &consumer)
}
}

if (!portOk)
{
// Port configuration is handled by the orchagent. If the configuration is written to the APP DB using
// multiple Redis write commands, the orchagent may receive a partial configuration and create a port
// with incorrect settings.
field_values.emplace_back("mtu", mtu);
field_values.emplace_back("admin_status", admin_status);
}

if (field_values.size())
{
writeConfigToAppDb(alias, field_values);
Expand All @@ -201,8 +210,6 @@ void PortMgr::doTask(Consumer &consumer)
{
SWSS_LOG_INFO("Port %s is not ready, pending...", alias.c_str());

writeConfigToAppDb(alias, "mtu", mtu);
writeConfigToAppDb(alias, "admin_status", admin_status);
/* Retry setting these params after the netdev is created */
field_values.clear();
field_values.emplace_back("mtu", mtu);
Expand Down
6 changes: 5 additions & 1 deletion cfgmgr/teammgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,11 +396,15 @@ bool TeamMgr::checkPortIffUp(const string &port)
if (fd == -1 || ioctl(fd, SIOCGIFFLAGS, &ifr) == -1)
{
SWSS_LOG_ERROR("Failed to get port %s flags", port.c_str());
if (fd != -1)
{
close(fd);
}
return false;
}

SWSS_LOG_INFO("Get port %s flags %i", port.c_str(), ifr.ifr_flags);

close(fd);
return ifr.ifr_flags & IFF_UP;
}

Expand Down
2 changes: 0 additions & 2 deletions orchagent/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ INCLUDES = -I $(top_srcdir)/lib \
-I pbh \
-I nhg

if GCOV_ENABLED
SUBDIRS = p4orch/tests
endif

CFLAGS_SAI = -I /usr/include/sai

Expand Down
24 changes: 23 additions & 1 deletion orchagent/aclorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ static acl_packet_action_lookup_t aclPacketActionLookup =
{
{ PACKET_ACTION_FORWARD, SAI_PACKET_ACTION_FORWARD },
{ PACKET_ACTION_DROP, SAI_PACKET_ACTION_DROP },
{ PACKET_ACTION_COPY, SAI_PACKET_ACTION_COPY },
};

static acl_dtel_flow_op_type_lookup_t aclDTelFlowOpTypeLookup =
Expand Down Expand Up @@ -2023,6 +2024,23 @@ bool AclRuleMirror::validate()
return true;
}

bool AclRuleMirror::createCounter()
{
SWSS_LOG_ENTER();

bool state = false;

m_pMirrorOrch->getSessionStatus(m_sessionName, state);

// If the mirror session is active, create the ACL counter
if(state)
{
return AclRule::createCounter();
}

return true;
}

bool AclRuleMirror::createRule()
{
SWSS_LOG_ENTER();
Expand Down Expand Up @@ -2152,7 +2170,11 @@ void AclRuleMirror::onUpdate(SubjectType type, void *cntx)
if (update->active)
{
SWSS_LOG_INFO("Activating mirroring ACL %s for session %s", m_id.c_str(), m_sessionName.c_str());
activate();
// During mirror session activation, the newly created counter needs to be registered to the FC.
if(activate() && hasCounter())
{
m_pAclOrch->registerFlexCounter(*this);
}
}
else
{
Expand Down
2 changes: 2 additions & 0 deletions orchagent/aclorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@

#define PACKET_ACTION_FORWARD "FORWARD"
#define PACKET_ACTION_DROP "DROP"
#define PACKET_ACTION_COPY "COPY"
#define PACKET_ACTION_REDIRECT "REDIRECT"
#define PACKET_ACTION_DO_NOT_NAT "DO_NOT_NAT"

Expand Down Expand Up @@ -343,6 +344,7 @@ class AclRuleMirror: public AclRule
AclRuleMirror(AclOrch *m_pAclOrch, MirrorOrch *m_pMirrorOrch, string rule, string table);
bool validateAddAction(string attr_name, string attr_value);
bool validate();
bool createCounter();
bool createRule();
bool removeRule();
void onUpdate(SubjectType, void *) override;
Expand Down
27 changes: 22 additions & 5 deletions orchagent/crmorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
#define CRM_EXCEEDED_MSG_MAX 10
#define CRM_ACL_RESOURCE_COUNT 256

using namespace std;
using namespace swss;

extern sai_object_id_t gSwitchId;
extern sai_switch_api_t *sai_switch_api;
extern sai_acl_api_t *sai_acl_api;
extern event_handle_t g_events_handle;

using namespace std;
using namespace swss;

extern string gMySwitchType;

const map<CrmResourceType, string> crmResTypeNameMap =
{
Expand Down Expand Up @@ -808,6 +808,12 @@ bool CrmOrch::getResAvailability(CrmResourceType type, CrmResourceEntry &res)

bool CrmOrch::getDashAclGroupResAvailability(CrmResourceType type, CrmResourceEntry &res)
{
if (gMySwitchType != "dpu")
{
res.resStatus = CrmResourceStatus::CRM_RES_NOT_SUPPORTED;
return false;
}

sai_object_type_t objType = crmResSaiObjAttrMap.at(type);

for (auto &cnt : res.countersMap)
Expand Down Expand Up @@ -872,6 +878,12 @@ void CrmOrch::getResAvailableCounters()
case CrmResourceType::CRM_SRV6_MY_SID_ENTRY:
case CrmResourceType::CRM_MPLS_NEXTHOP:
case CrmResourceType::CRM_SRV6_NEXTHOP:
case CrmResourceType::CRM_TWAMP_ENTRY:
{
getResAvailability(res.first, res.second);
break;
}

case CrmResourceType::CRM_DASH_VNET:
case CrmResourceType::CRM_DASH_ENI:
case CrmResourceType::CRM_DASH_ENI_ETHER_ADDRESS_MAP:
Expand All @@ -885,8 +897,13 @@ void CrmOrch::getResAvailableCounters()
case CrmResourceType::CRM_DASH_IPV6_OUTBOUND_CA_TO_PA:
case CrmResourceType::CRM_DASH_IPV4_ACL_GROUP:
case CrmResourceType::CRM_DASH_IPV6_ACL_GROUP:
case CrmResourceType::CRM_TWAMP_ENTRY:
{
if (gMySwitchType != "dpu")
{
res.second.resStatus = CrmResourceStatus::CRM_RES_NOT_SUPPORTED;
break;
}

getResAvailability(res.first, res.second);
break;
}
Expand Down
19 changes: 10 additions & 9 deletions orchagent/dash/dashorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,15 +394,16 @@ bool DashOrch::addEniObject(const string& eni, EniEntry& entry)
eni_attrs.push_back(eni_attr);
}

// auto eni_route_it = eni_route_entries_.find(eni);
// if (eni_route_it != eni_route_entries_.end())
// {
// SWSS_LOG_INFO("ENI %s has route group %s", eni.c_str(), eni_route_it->second.group_id().c_str());
// DashRouteOrch *dash_route_orch = gDirectory.get<DashRouteOrch*>();
// eni_attr.id = SAI_ENI_ATTR_OUTBOUND_ROUTING_GROUP_ID;
// eni_attr.value.oid = dash_route_orch->getRouteGroupOid(eni_route_it->second.group_id());
// eni_attrs.push_back(eni_attr);
// }
if (entry.metadata.has_pl_sip_encoding())
{
eni_attr.id = SAI_ENI_ATTR_PL_SIP;
to_sai(entry.metadata.pl_sip_encoding().ip(), eni_attr.value.ipaddr);
eni_attrs.push_back(eni_attr);

eni_attr.id = SAI_ENI_ATTR_PL_SIP_MASK;
to_sai(entry.metadata.pl_sip_encoding().mask(), eni_attr.value.ipaddr);
eni_attrs.push_back(eni_attr);
}

sai_status_t status = sai_dash_eni_api->create_eni(&eni_id, gSwitchId,
(uint32_t)eni_attrs.size(), eni_attrs.data());
Expand Down
Loading

0 comments on commit 87f3488

Please sign in to comment.