Skip to content
Merged
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 @@ -2651,6 +2657,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
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 @@ -109,6 +109,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 aclInnerActionLookup =
Expand Down Expand Up @@ -2016,6 +2017,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 @@ -65,6 +65,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 @@ -79,11 +80,12 @@
#define ACTION_DSCP "DSCP_ACTION"
#define ACTION_INNER_SRC_MAC_REWRITE_ACTION "INNER_SRC_MAC_REWRITE_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
2 changes: 2 additions & 0 deletions orchagent/orchdaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,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
4 changes: 3 additions & 1 deletion orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,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 @@ -292,6 +293,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