Skip to content

Commit 32da647

Browse files
committed
2 parents dc51470 + 06b16c3 commit 32da647

36 files changed

Lines changed: 2078 additions & 63 deletions

cfgmgr/buffermgrdyn.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include "schema.h"
1515
#include "warm_restart.h"
1616

17+
#include "buffer/bufferschema.h"
18+
1719
/*
1820
* Some Tips
1921
* 1. All keys in this file are in format of APPL_DB key.
@@ -896,6 +898,10 @@ void BufferMgrDynamic::updateBufferProfileToDb(const string &name, const buffer_
896898
}
897899
fvVector.emplace_back("xoff", profile.xoff);
898900
}
901+
if (!profile.packet_discard_action.empty())
902+
{
903+
fvVector.emplace_back(BUFFER_PROFILE_PACKET_DISCARD_ACTION, profile.packet_discard_action);
904+
}
899905
fvVector.emplace_back("size", profile.size);
900906
fvVector.emplace_back("pool", profile.pool_name);
901907
fvVector.emplace_back(mode, profile.threshold);
@@ -2631,6 +2637,10 @@ task_process_status BufferMgrDynamic::handleBufferProfileTable(KeyOpFieldsValues
26312637
profileApp.direction = BUFFER_INGRESS;
26322638
}
26332639
}
2640+
else if (field == BUFFER_PROFILE_PACKET_DISCARD_ACTION)
2641+
{
2642+
profileApp.packet_discard_action = value;
2643+
}
26342644
SWSS_LOG_INFO("Inserting BUFFER_PROFILE table field %s value %s", field.c_str(), value.c_str());
26352645
}
26362646

cfgmgr/buffermgrdyn.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ typedef struct {
7676
// port_pgs - stores pgs referencing this profile
7777
// An element will be added or removed when a PG added or removed
7878
port_pg_set_t port_pgs;
79+
// packet trimming control
80+
std::string packet_discard_action;
7981
} buffer_profile_t;
8082

8183
typedef struct {

fpmsyncd/routesync.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,6 +1613,9 @@ void RouteSync::onRouteMsg(int nlmsg_type, struct nl_object *obj, char *vrf)
16131613
{
16141614
sendOffloadReply(route_obj);
16151615
}
1616+
auto proto_num = rtnl_route_get_protocol(route_obj);
1617+
auto proto_str = getProtocolString(proto_num);
1618+
FieldValueTuple proto("protocol", proto_str);
16161619

16171620
switch (rtnl_route_get_type(route_obj))
16181621
{
@@ -1621,6 +1624,7 @@ void RouteSync::onRouteMsg(int nlmsg_type, struct nl_object *obj, char *vrf)
16211624
vector<FieldValueTuple> fvVector;
16221625
FieldValueTuple fv("blackhole", "true");
16231626
fvVector.push_back(fv);
1627+
fvVector.push_back(proto);
16241628
m_routeTable.set(destipprefix, fvVector);
16251629
return;
16261630
}
@@ -1692,11 +1696,8 @@ void RouteSync::onRouteMsg(int nlmsg_type, struct nl_object *obj, char *vrf)
16921696
}
16931697
}
16941698

1695-
auto proto_num = rtnl_route_get_protocol(route_obj);
1696-
auto proto_str = getProtocolString(proto_num);
16971699

16981700
vector<FieldValueTuple> fvVector;
1699-
FieldValueTuple proto("protocol", proto_str);
17001701
FieldValueTuple gw("nexthop", gw_list);
17011702
FieldValueTuple intf("ifname", intf_list);
17021703

@@ -1776,13 +1777,18 @@ void RouteSync::onLabelRouteMsg(int nlmsg_type, struct nl_object *obj)
17761777
return;
17771778
}
17781779

1780+
auto proto_num = rtnl_route_get_protocol(route_obj);
1781+
auto proto_str = getProtocolString(proto_num);
1782+
FieldValueTuple proto("protocol", proto_str);
1783+
17791784
switch (rtnl_route_get_type(route_obj))
17801785
{
17811786
case RTN_BLACKHOLE:
17821787
{
17831788
vector<FieldValueTuple> fvVector;
17841789
FieldValueTuple fv("blackhole", "true");
17851790
fvVector.push_back(fv);
1791+
fvVector.push_back(proto);
17861792
m_label_routeTable.set(destaddr, fvVector);
17871793
return;
17881794
}
@@ -2181,14 +2187,11 @@ string RouteSync::getNextHopWt(struct rtnl_route *route_obj)
21812187
struct rtnl_nexthop *nexthop = rtnl_route_nexthop_n(route_obj, i);
21822188
/* Get the weight of next hop */
21832189
uint8_t weight = rtnl_route_nh_get_weight(nexthop);
2184-
if (weight)
2185-
{
2186-
result += to_string(weight);
2187-
}
2188-
else
2190+
if (weight == 0)
21892191
{
2190-
return "";
2192+
weight = 1; // default weight is 1
21912193
}
2194+
result += to_string(weight);
21922195

21932196
if (i + 1 < rtnl_route_get_nnexthops(route_obj))
21942197
{

orchagent/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ orchagent_SOURCES = \
8080
saiattr.cpp \
8181
switch/switch_capabilities.cpp \
8282
switch/switch_helper.cpp \
83+
switch/trimming/capabilities.cpp \
84+
switch/trimming/helper.cpp \
8385
switchorch.cpp \
8486
pfcwdorch.cpp \
8587
pfcactionhandler.cpp \

orchagent/aclorch.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ static acl_rule_attr_lookup_t aclL3ActionLookup =
102102
{ ACTION_PACKET_ACTION, SAI_ACL_ENTRY_ATTR_ACTION_PACKET_ACTION },
103103
{ ACTION_REDIRECT_ACTION, SAI_ACL_ENTRY_ATTR_ACTION_REDIRECT },
104104
{ ACTION_DO_NOT_NAT_ACTION, SAI_ACL_ENTRY_ATTR_ACTION_NO_NAT },
105+
{ ACTION_DISABLE_TRIM, SAI_ACL_ENTRY_ATTR_ACTION_PACKET_TRIM_DISABLE }
105106
};
106107

107108
static acl_rule_attr_lookup_t aclMirrorStageLookup =
@@ -1948,6 +1949,12 @@ bool AclRulePacket::validateAddAction(string attr_name, string _attr_value)
19481949
actionData.parameter.booldata = true;
19491950
action_str = ACTION_DO_NOT_NAT_ACTION;
19501951
}
1952+
// handle PACKET_ACTION_DISABLE_TRIM in ACTION_PACKET_ACTION
1953+
else if (attr_value == PACKET_ACTION_DISABLE_TRIM)
1954+
{
1955+
actionData.parameter.booldata = true;
1956+
action_str = ACTION_DISABLE_TRIM;
1957+
}
19511958
else
19521959
{
19531960
return false;

orchagent/aclorch.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
#define ACTION_PACKET_ACTION "PACKET_ACTION"
6262
#define ACTION_REDIRECT_ACTION "REDIRECT_ACTION"
6363
#define ACTION_DO_NOT_NAT_ACTION "DO_NOT_NAT_ACTION"
64+
#define ACTION_DISABLE_TRIM "DISABLE_TRIM_ACTION"
6465
#define ACTION_MIRROR_ACTION "MIRROR_ACTION"
6566
#define ACTION_MIRROR_INGRESS_ACTION "MIRROR_INGRESS_ACTION"
6667
#define ACTION_MIRROR_EGRESS_ACTION "MIRROR_EGRESS_ACTION"
@@ -74,11 +75,12 @@
7475
#define ACTION_META_DATA "META_DATA_ACTION"
7576
#define ACTION_DSCP "DSCP_ACTION"
7677

77-
#define PACKET_ACTION_FORWARD "FORWARD"
78-
#define PACKET_ACTION_DROP "DROP"
79-
#define PACKET_ACTION_COPY "COPY"
80-
#define PACKET_ACTION_REDIRECT "REDIRECT"
81-
#define PACKET_ACTION_DO_NOT_NAT "DO_NOT_NAT"
78+
#define PACKET_ACTION_FORWARD "FORWARD"
79+
#define PACKET_ACTION_DROP "DROP"
80+
#define PACKET_ACTION_COPY "COPY"
81+
#define PACKET_ACTION_REDIRECT "REDIRECT"
82+
#define PACKET_ACTION_DO_NOT_NAT "DO_NOT_NAT"
83+
#define PACKET_ACTION_DISABLE_TRIM "DISABLE_TRIM"
8284

8385
#define DTEL_FLOW_OP_NOP "NOP"
8486
#define DTEL_FLOW_OP_POSTCARD "POSTCARD"

orchagent/buffer/bufferschema.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#pragma once
2+
3+
// defines ------------------------------------------------------------------------------------------------------------
4+
5+
#define BUFFER_PROFILE_PACKET_DISCARD_ACTION_DROP "drop"
6+
#define BUFFER_PROFILE_PACKET_DISCARD_ACTION_TRIM "trim"
7+
8+
#define BUFFER_PROFILE_PACKET_DISCARD_ACTION "packet_discard_action"

orchagent/bufferorch.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include <sstream>
1010
#include <iostream>
1111

12+
#include "buffer/bufferschema.h"
13+
1214
using namespace std;
1315

1416
extern sai_port_api_t *sai_port_api;
@@ -710,6 +712,28 @@ task_process_status BufferOrch::processBufferProfile(KeyOpFieldsValuesTuple &tup
710712
attr.value.u64 = (uint64_t)stoul(value);
711713
attribs.push_back(attr);
712714
}
715+
else if (field == BUFFER_PROFILE_PACKET_DISCARD_ACTION)
716+
{
717+
attr.id = SAI_BUFFER_PROFILE_ATTR_PACKET_ADMISSION_FAIL_ACTION;
718+
719+
if (value == BUFFER_PROFILE_PACKET_DISCARD_ACTION_DROP)
720+
{
721+
attr.value.s32 = SAI_BUFFER_PROFILE_PACKET_ADMISSION_FAIL_ACTION_DROP;
722+
}
723+
else if (value == BUFFER_PROFILE_PACKET_DISCARD_ACTION_TRIM)
724+
{
725+
attr.value.s32 = SAI_BUFFER_PROFILE_PACKET_ADMISSION_FAIL_ACTION_DROP_AND_TRIM;
726+
}
727+
else
728+
{
729+
SWSS_LOG_ERROR("Failed to parse buffer profile(%s) field(%s): invalid value(%s)",
730+
object_name.c_str(), field.c_str(), value.c_str()
731+
);
732+
return task_process_status::task_failed;
733+
}
734+
735+
attribs.push_back(attr);
736+
}
713737
else
714738
{
715739
SWSS_LOG_ERROR("Unknown buffer profile field specified:%s, ignoring", field.c_str());

orchagent/flex_counter/flex_counter_manager.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const unordered_map<CounterType, string> FlexCounterManager::counter_id_field_lo
5050
{ CounterType::HOSTIF_TRAP, FLOW_COUNTER_ID_LIST },
5151
{ CounterType::ROUTE, FLOW_COUNTER_ID_LIST },
5252
{ CounterType::ENI, ENI_COUNTER_ID_LIST },
53+
{ CounterType::SRV6, SRV6_COUNTER_ID_LIST },
5354
};
5455

5556
FlexManagerDirectory g_FlexManagerDirectory;

orchagent/flex_counter/flex_counter_manager.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ enum class CounterType
3838
TUNNEL,
3939
HOSTIF_TRAP,
4040
ROUTE,
41-
ENI
41+
ENI,
42+
SRV6
4243
};
4344

4445
extern bool gTraditionalFlexCounter;

0 commit comments

Comments
 (0)