Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions cfgmgr/buffermgrdyn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include "schema.h"
#include "warm_restart.h"

#include "buffer/bufferschema.h"

/*
* Some Tips
* 1. All keys in this file are in format of APPL_DB key.
Expand Down Expand Up @@ -896,6 +898,10 @@ void BufferMgrDynamic::updateBufferProfileToDb(const string &name, const buffer_
}
fvVector.emplace_back("xoff", profile.xoff);
}
if (!profile.packet_discard_action.empty())
{
fvVector.emplace_back(BUFFER_PROFILE_PACKET_DISCARD_ACTION, profile.packet_discard_action);
}
fvVector.emplace_back("size", profile.size);
fvVector.emplace_back("pool", profile.pool_name);
fvVector.emplace_back(mode, profile.threshold);
Expand Down Expand Up @@ -2631,6 +2637,10 @@ task_process_status BufferMgrDynamic::handleBufferProfileTable(KeyOpFieldsValues
profileApp.direction = BUFFER_INGRESS;
}
}
else if (field == BUFFER_PROFILE_PACKET_DISCARD_ACTION)
{
profileApp.packet_discard_action = value;
}
SWSS_LOG_INFO("Inserting BUFFER_PROFILE table field %s value %s", field.c_str(), value.c_str());
}

Expand Down
2 changes: 2 additions & 0 deletions cfgmgr/buffermgrdyn.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ typedef struct {
// port_pgs - stores pgs referencing this profile
// An element will be added or removed when a PG added or removed
port_pg_set_t port_pgs;
// packet trimming control
std::string packet_discard_action;
} buffer_profile_t;

typedef struct {
Expand Down
9 changes: 3 additions & 6 deletions fpmsyncd/routesync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2181,14 +2181,11 @@ string RouteSync::getNextHopWt(struct rtnl_route *route_obj)
struct rtnl_nexthop *nexthop = rtnl_route_nexthop_n(route_obj, i);
/* Get the weight of next hop */
uint8_t weight = rtnl_route_nh_get_weight(nexthop);
if (weight)
if (weight == 0)
{
result += to_string(weight);
}
else
{
return "";
weight = 1; // default weight is 1
}
result += to_string(weight);

if (i + 1 < rtnl_route_get_nnexthops(route_obj))
{
Expand Down
2 changes: 2 additions & 0 deletions orchagent/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ orchagent_SOURCES = \
saiattr.cpp \
switch/switch_capabilities.cpp \
switch/switch_helper.cpp \
switch/trimming/capabilities.cpp \
switch/trimming/helper.cpp \
switchorch.cpp \
pfcwdorch.cpp \
pfcactionhandler.cpp \
Expand Down
7 changes: 7 additions & 0 deletions orchagent/aclorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ static acl_rule_attr_lookup_t aclL3ActionLookup =
{ ACTION_PACKET_ACTION, SAI_ACL_ENTRY_ATTR_ACTION_PACKET_ACTION },
{ ACTION_REDIRECT_ACTION, SAI_ACL_ENTRY_ATTR_ACTION_REDIRECT },
{ ACTION_DO_NOT_NAT_ACTION, SAI_ACL_ENTRY_ATTR_ACTION_NO_NAT },
{ ACTION_DISABLE_TRIM, SAI_ACL_ENTRY_ATTR_ACTION_PACKET_TRIM_DISABLE }
};

static acl_rule_attr_lookup_t aclMirrorStageLookup =
Expand Down Expand Up @@ -1948,6 +1949,12 @@ bool AclRulePacket::validateAddAction(string attr_name, string _attr_value)
actionData.parameter.booldata = true;
action_str = ACTION_DO_NOT_NAT_ACTION;
}
// handle PACKET_ACTION_DISABLE_TRIM in ACTION_PACKET_ACTION
else if (attr_value == PACKET_ACTION_DISABLE_TRIM)
{
actionData.parameter.booldata = true;
action_str = ACTION_DISABLE_TRIM;
}
else
{
return false;
Expand Down
12 changes: 7 additions & 5 deletions orchagent/aclorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
#define ACTION_PACKET_ACTION "PACKET_ACTION"
#define ACTION_REDIRECT_ACTION "REDIRECT_ACTION"
#define ACTION_DO_NOT_NAT_ACTION "DO_NOT_NAT_ACTION"
#define ACTION_DISABLE_TRIM "DISABLE_TRIM_ACTION"
#define ACTION_MIRROR_ACTION "MIRROR_ACTION"
#define ACTION_MIRROR_INGRESS_ACTION "MIRROR_INGRESS_ACTION"
#define ACTION_MIRROR_EGRESS_ACTION "MIRROR_EGRESS_ACTION"
Expand All @@ -74,11 +75,12 @@
#define ACTION_META_DATA "META_DATA_ACTION"
#define ACTION_DSCP "DSCP_ACTION"

#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"
#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"
#define PACKET_ACTION_DISABLE_TRIM "DISABLE_TRIM"

#define DTEL_FLOW_OP_NOP "NOP"
#define DTEL_FLOW_OP_POSTCARD "POSTCARD"
Expand Down
8 changes: 8 additions & 0 deletions orchagent/buffer/bufferschema.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

// defines ------------------------------------------------------------------------------------------------------------

#define BUFFER_PROFILE_PACKET_DISCARD_ACTION_DROP "drop"
#define BUFFER_PROFILE_PACKET_DISCARD_ACTION_TRIM "trim"

#define BUFFER_PROFILE_PACKET_DISCARD_ACTION "packet_discard_action"
24 changes: 24 additions & 0 deletions orchagent/bufferorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <sstream>
#include <iostream>

#include "buffer/bufferschema.h"

using namespace std;

extern sai_port_api_t *sai_port_api;
Expand Down Expand Up @@ -710,6 +712,28 @@ task_process_status BufferOrch::processBufferProfile(KeyOpFieldsValuesTuple &tup
attr.value.u64 = (uint64_t)stoul(value);
attribs.push_back(attr);
}
else if (field == BUFFER_PROFILE_PACKET_DISCARD_ACTION)
{
attr.id = SAI_BUFFER_PROFILE_ATTR_PACKET_ADMISSION_FAIL_ACTION;

if (value == BUFFER_PROFILE_PACKET_DISCARD_ACTION_DROP)
{
attr.value.s32 = SAI_BUFFER_PROFILE_PACKET_ADMISSION_FAIL_ACTION_DROP;
}
else if (value == BUFFER_PROFILE_PACKET_DISCARD_ACTION_TRIM)
{
attr.value.s32 = SAI_BUFFER_PROFILE_PACKET_ADMISSION_FAIL_ACTION_DROP_AND_TRIM;
}
else
{
SWSS_LOG_ERROR("Failed to parse buffer profile(%s) field(%s): invalid value(%s)",
object_name.c_str(), field.c_str(), value.c_str()
);
return task_process_status::task_failed;
}

attribs.push_back(attr);
}
else
{
SWSS_LOG_ERROR("Unknown buffer profile field specified:%s, ignoring", field.c_str());
Expand Down
1 change: 1 addition & 0 deletions orchagent/flex_counter/flex_counter_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const unordered_map<CounterType, string> FlexCounterManager::counter_id_field_lo
{ CounterType::HOSTIF_TRAP, FLOW_COUNTER_ID_LIST },
{ CounterType::ROUTE, FLOW_COUNTER_ID_LIST },
{ CounterType::ENI, ENI_COUNTER_ID_LIST },
{ CounterType::SRV6, SRV6_COUNTER_ID_LIST },
};

FlexManagerDirectory g_FlexManagerDirectory;
Expand Down
3 changes: 2 additions & 1 deletion orchagent/flex_counter/flex_counter_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ enum class CounterType
TUNNEL,
HOSTIF_TRAP,
ROUTE,
ENI
ENI,
SRV6
};

extern bool gTraditionalFlexCounter;
Expand Down
7 changes: 7 additions & 0 deletions orchagent/flexcounterorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ extern BufferOrch *gBufferOrch;
extern Directory<Orch*> gDirectory;
extern CoppOrch *gCoppOrch;
extern FlowCounterRouteOrch *gFlowCounterRouteOrch;
extern Srv6Orch *gSrv6Orch;
extern sai_object_id_t gSwitchId;

#define FLEX_COUNTER_DELAY_SEC 60
Expand All @@ -46,6 +47,7 @@ extern sai_object_id_t gSwitchId;
#define ENI_KEY "ENI"
#define WRED_QUEUE_KEY "WRED_ECN_QUEUE"
#define WRED_PORT_KEY "WRED_ECN_PORT"
#define SRV6_KEY "SRV6"

unordered_map<string, string> flexCounterGroupMap =
{
Expand All @@ -71,6 +73,7 @@ unordered_map<string, string> flexCounterGroupMap =
{"ENI", ENI_STAT_COUNTER_FLEX_COUNTER_GROUP},
{"WRED_ECN_PORT", WRED_PORT_STAT_COUNTER_FLEX_COUNTER_GROUP},
{"WRED_ECN_QUEUE", WRED_QUEUE_STAT_COUNTER_FLEX_COUNTER_GROUP},
{SRV6_KEY, SRV6_STAT_COUNTER_FLEX_COUNTER_GROUP},
};


Expand Down Expand Up @@ -270,6 +273,10 @@ void FlexCounterOrch::doTask(Consumer &consumer)
m_route_flow_counter_enabled = false;
}
}
if (gSrv6Orch && (key == SRV6_KEY))
{
gSrv6Orch->setCountersState((value == "enable"));
}

gPortsOrch->flushCounters();
setFlexCounterGroupOperation(flexCounterGroupMap[key], value);
Expand Down
2 changes: 2 additions & 0 deletions orchagent/orchdaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,12 @@ bool OrchDaemon::init()
TableConnector app_switch_table(m_applDb, APP_SWITCH_TABLE_NAME);
TableConnector conf_asic_sensors(m_configDb, CFG_ASIC_SENSORS_TABLE_NAME);
TableConnector conf_switch_hash(m_configDb, CFG_SWITCH_HASH_TABLE_NAME);
TableConnector conf_switch_trim(m_configDb, CFG_SWITCH_TRIMMING_TABLE_NAME);
TableConnector conf_suppress_asic_sdk_health_categories(m_configDb, CFG_SUPPRESS_ASIC_SDK_HEALTH_EVENT_NAME);

vector<TableConnector> switch_tables = {
conf_switch_hash,
conf_switch_trim,
conf_asic_sensors,
conf_suppress_asic_sdk_health_categories,
app_switch_table
Expand Down
2 changes: 2 additions & 0 deletions orchagent/p4orch/tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ p4orch_tests_SOURCES = $(ORCHAGENT_DIR)/orch.cpp \
$(ORCHAGENT_DIR)/copporch.cpp \
$(ORCHAGENT_DIR)/switch/switch_capabilities.cpp \
$(ORCHAGENT_DIR)/switch/switch_helper.cpp \
$(ORCHAGENT_DIR)/switch/trimming/capabilities.cpp \
$(ORCHAGENT_DIR)/switch/trimming/helper.cpp \
$(ORCHAGENT_DIR)/switchorch.cpp \
$(ORCHAGENT_DIR)/request_parser.cpp \
$(top_srcdir)/lib/recorder.cpp \
Expand Down
42 changes: 17 additions & 25 deletions orchagent/pfc_detect_mellanox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,22 @@ if timestamp_last ~= false then
redis.call('HSET', 'TIMESTAMP', 'effective_pfcwd_poll_time_last', global_effective_poll_time)
end

-- Get timestamp from TIME_STAMP table for PFC_WD counters
-- Use a field name without spaces to avoid issues
local port_timestamp_current = tonumber(redis.call('HGET', 'COUNTERS:TIME_STAMP', 'PFC_WD_Port_Counter_time_stamp'))
local port_timestamp_last = tonumber(redis.call('HGET', 'COUNTERS:TIME_STAMP', 'PFC_WD_Port_Counter_time_stamp_last'))

-- Update the last timestamp for all ports at once
if port_timestamp_current ~= nil then
redis.call('HSET', 'COUNTERS:TIME_STAMP', 'PFC_WD_Port_Counter_time_stamp_last', port_timestamp_current)
end

local effective_poll_time
local effective_poll_time_lasttime
local port_timestamp_last_cache = {}
if port_timestamp_current ~= nil and port_timestamp_last ~= nil then
effective_poll_time = (port_timestamp_current - port_timestamp_last) / 1000
else
effective_poll_time = global_effective_poll_time
end

local debug_storm_global = redis.call('HGET', 'DEBUG_STORM', 'enabled') == 'true'
local debug_storm_threshold = tonumber(redis.call('HGET', 'DEBUG_STORM', 'threshold'))
Expand Down Expand Up @@ -63,27 +76,6 @@ for i = n, 1, -1 do
local pfc_rx_pkt_key = 'SAI_PORT_STAT_PFC_' .. queue_index .. '_RX_PKTS'
local pfc_duration_key = 'SAI_PORT_STAT_PFC_' .. queue_index .. '_RX_PAUSE_DURATION_US'

-- Get port specific timestamp
local port_timestamp_current = tonumber(redis.call('HGET', counters_table_name .. ':' .. port_id, 'PFC_WD_time_stamp'))
if port_timestamp_current ~= nil then
local port_timestamp_lasttime = port_timestamp_last_cache[port_id]
if port_timestamp_lasttime == nil then
port_timestamp_lasttime = tonumber(redis.call('HGET', counters_table_name .. ':' .. port_id, 'PFC_WD_time_stamp_last'))
port_timestamp_last_cache[port_id] = port_timestamp_lasttime
redis.call('HSET', counters_table_name .. ':' .. port_id, 'PFC_WD_time_stamp_last', port_timestamp_current)
end

if port_timestamp_lasttime ~= nil then
effective_poll_time = (port_timestamp_current - port_timestamp_lasttime) / 1000
else
effective_poll_time = global_effective_poll_time
end
effective_poll_time_lasttime = false
else
effective_poll_time = global_effective_poll_time
effective_poll_time_lasttime = global_effective_poll_time_lasttime
end

-- Get all counters
local occupancy_bytes = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES')
local packets = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'SAI_QUEUE_STAT_PACKETS')
Expand Down Expand Up @@ -132,8 +124,8 @@ for i = n, 1, -1 do
local pfc_rx_packets_string = '"pfc_rx_packets","' .. tostring(pfc_rx_packets) .. '","pfc_rx_packets_last","' .. tostring(pfc_rx_packets_last) .. '",'
local storm_condition_string = '"pfc_duration","' .. tostring(pfc_duration) .. '","pfc_duration_last","' .. tostring(pfc_duration_last) .. '",'
local timestamps = '"timestamp","' .. timestamp_string .. '","timestamp_last","' .. timestamp_last .. '","effective_poll_time","' .. effective_poll_time .. '"'
if effective_poll_time_lasttime ~= false then
timestamps = timestamps .. ',"effective_pfcwd_poll_time_last","' .. effective_poll_time_lasttime .. '"'
if global_effective_poll_time_lasttime ~= false then
timestamps = timestamps .. ',"effective_pfcwd_poll_time_last","' .. global_effective_poll_time_lasttime .. '"'
end
redis.call('PUBLISH', 'PFC_WD_ACTION', '["' .. KEYS[i] .. '","storm",' .. occupancy_string .. packets_string .. pfc_rx_packets_string .. storm_condition_string .. timestamps .. ']')
is_deadlock = true
Expand Down
4 changes: 3 additions & 1 deletion orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ const vector<sai_port_stat_t> port_stat_ids =
SAI_PORT_STAT_IF_IN_FEC_CODEWORD_ERRORS_S13,
SAI_PORT_STAT_IF_IN_FEC_CODEWORD_ERRORS_S14,
SAI_PORT_STAT_IF_IN_FEC_CODEWORD_ERRORS_S15,
SAI_PORT_STAT_IF_IN_FEC_CORRECTED_BITS
SAI_PORT_STAT_IF_IN_FEC_CORRECTED_BITS,
SAI_PORT_STAT_TRIM_PACKETS
};

const vector<sai_port_stat_t> gbport_stat_ids =
Expand Down Expand Up @@ -290,6 +291,7 @@ static const vector<sai_queue_stat_t> queue_stat_ids =
SAI_QUEUE_STAT_BYTES,
SAI_QUEUE_STAT_DROPPED_PACKETS,
SAI_QUEUE_STAT_DROPPED_BYTES,
SAI_QUEUE_STAT_TRIM_PACKETS
};
static const vector<sai_queue_stat_t> voq_stat_ids =
{
Expand Down
Loading
Loading