Skip to content

Commit

Permalink
Merge branch 'master' of github.com:sonic-net/sonic-swss into multi-v…
Browse files Browse the repository at this point in the history
…lan-vrf
  • Loading branch information
theasianpianist committed May 24, 2024
2 parents 4541d7c + 3ee7361 commit c43d16e
Show file tree
Hide file tree
Showing 17 changed files with 1,592 additions and 49 deletions.
4 changes: 4 additions & 0 deletions doc/swss-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Stores information for physical switch ports managed by the switch chip. Ports t
preemphasis = 1*8HEXDIG *( "," 1*8HEXDIG) ; list of hex values, one per lane
idriver = 1*8HEXDIG *( "," 1*8HEXDIG) ; list of hex values, one per lane
ipredriver = 1*8HEXDIG *( "," 1*8HEXDIG) ; list of hex values, one per lane
pt_interface_id = 1*4DIGIT ; Path Tracing Interface ID (1-4095)
pt_timestamp_template = "template1" / "template2" / "template3" / "template4" ; Path Tracing Timestamp Template

;QOS Mappings
map_dscp_to_tc = ref_hash_key_reference
Expand Down Expand Up @@ -1021,6 +1023,8 @@ Stores information for physical switch ports managed by the switch chip. Ports t
mtu = 1*4DIGIT ; port MTU
fec = 1*64VCHAR ; port fec mode
autoneg = BIT ; auto-negotiation mode
pt_interface_id = 1*4DIGIT ; Path Tracing Interface ID (1-4095)
pt_timestamp_template = "template1" / "template2" / "template3" / "template4" ; Path Tracing Timestamp Template

### MGMT_PORT_TABLE
;Configuration for management port, including at least one key
Expand Down
4 changes: 4 additions & 0 deletions orchagent/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ class Port

int m_cap_an = -1; /* Capability - AutoNeg, -1 means not set */
int m_cap_lt = -1; /* Capability - LinkTraining, -1 means not set */

/* Path Tracing */
uint16_t m_pt_intf_id = 0;
sai_port_path_tracing_timestamp_type_t m_pt_timestamp_template = SAI_PORT_PATH_TRACING_TIMESTAMP_TYPE_16_23;
};

}
Expand Down
10 changes: 10 additions & 0 deletions orchagent/port/portcnt.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,16 @@ class PortConfig final
bool is_set = false;
} subport; // Port subport

struct {
std::uint16_t value;
bool is_set = false;
} pt_intf_id; // Port interface ID for Path Tracing

struct {
sai_port_path_tracing_timestamp_type_t value;
bool is_set = false;
} pt_timestamp_template; // Port timestamp template for Path Tracing

std::string key;
std::string op;

Expand Down
94 changes: 94 additions & 0 deletions orchagent/port/porthlpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ static const std::unordered_map<std::string, Port::Role> portRoleMap =
{ PORT_ROLE_DPC, Port::Role::Dpc }
};

static const std::unordered_map<std::string, sai_port_path_tracing_timestamp_type_t> portPtTimestampTemplateMap =
{
{ PORT_PT_TIMESTAMP_TEMPLATE_1, SAI_PORT_PATH_TRACING_TIMESTAMP_TYPE_8_15 },
{ PORT_PT_TIMESTAMP_TEMPLATE_2, SAI_PORT_PATH_TRACING_TIMESTAMP_TYPE_12_19 },
{ PORT_PT_TIMESTAMP_TEMPLATE_3, SAI_PORT_PATH_TRACING_TIMESTAMP_TYPE_16_23 },
{ PORT_PT_TIMESTAMP_TEMPLATE_4, SAI_PORT_PATH_TRACING_TIMESTAMP_TYPE_20_27 }
};

// functions ----------------------------------------------------------------------------------------------------------

template<typename T>
Expand Down Expand Up @@ -233,6 +241,11 @@ std::string PortHelper::getAdminStatusStr(const PortConfig &port) const
return this->getFieldValueStr(port, PORT_ADMIN_STATUS);
}

std::string PortHelper::getPtTimestampTemplateStr(const PortConfig &port) const
{
return this->getFieldValueStr(port, PORT_PT_TIMESTAMP_TEMPLATE);
}

bool PortHelper::parsePortAlias(PortConfig &port, const std::string &field, const std::string &value) const
{
SWSS_LOG_ENTER();
Expand Down Expand Up @@ -773,6 +786,73 @@ bool PortHelper::parsePortSubport(PortConfig &port, const std::string &field, co
return true;
}

bool PortHelper::parsePortPtIntfId(PortConfig &port, const std::string &field, const std::string &value) const
{
SWSS_LOG_ENTER();

uint16_t pt_intf_id;
try
{
if (value != "None")
{
pt_intf_id = to_uint<std::uint16_t>(value);
if (pt_intf_id < 1 || pt_intf_id > 4095)
{
throw std::invalid_argument("Out of range Path Tracing Interface ID: " + value);
}

port.pt_intf_id.value = pt_intf_id;
}
else
{
/*
* In SAI, Path Tracing Interface ID 0 means Path Tracing disabled.
* When Path Tracing Interface ID is not set (i.e., value is None),
* we set the Interface ID to 0 in ASIC DB in order to disable
* Path Tracing on the port.
*/
port.pt_intf_id.value = 0;
}
port.pt_intf_id.is_set = true;
}
catch (const std::exception &e)
{
SWSS_LOG_ERROR("Failed to parse field(%s): %s", field.c_str(), e.what());
return false;
}

return true;
}

bool PortHelper::parsePortPtTimestampTemplate(PortConfig &port, const std::string &field, const std::string &value) const
{
SWSS_LOG_ENTER();
std::unordered_map<std::string, sai_port_path_tracing_timestamp_type_t>::const_iterator cit;

if (value != "None")
{
cit = portPtTimestampTemplateMap.find(value);
}
else
{
/*
* When Path Tracing Timestamp Template is not specified (i.e., value is None),
* we use Template3 (which is the default template in SAI).
*/
cit = portPtTimestampTemplateMap.find("template3");
}
if (cit == portPtTimestampTemplateMap.cend())
{
SWSS_LOG_ERROR("Failed to parse field(%s): invalid value(%s)", field.c_str(), value.c_str());
return false;
}

port.pt_timestamp_template.value = cit->second;
port.pt_timestamp_template.is_set = true;

return true;
}

bool PortHelper::parsePortConfig(PortConfig &port) const
{
SWSS_LOG_ENTER();
Expand Down Expand Up @@ -1027,6 +1107,20 @@ bool PortHelper::parsePortConfig(PortConfig &port) const
return false;
}
}
else if (field == PORT_PT_INTF_ID)
{
if (!this->parsePortPtIntfId(port, field, value))
{
return false;
}
}
else if (field == PORT_PT_TIMESTAMP_TEMPLATE)
{
if (!this->parsePortPtTimestampTemplate(port, field, value))
{
return false;
}
}
else
{
SWSS_LOG_WARN("Unknown field(%s): skipping ...", field.c_str());
Expand Down
3 changes: 3 additions & 0 deletions orchagent/port/porthlpr.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class PortHelper final
std::string getLearnModeStr(const PortConfig &port) const;
std::string getLinkTrainingStr(const PortConfig &port) const;
std::string getAdminStatusStr(const PortConfig &port) const;
std::string getPtTimestampTemplateStr(const PortConfig &port) const;

bool parsePortConfig(PortConfig &port) const;
bool validatePortConfig(PortConfig &port) const;
Expand Down Expand Up @@ -54,4 +55,6 @@ class PortHelper final
bool parsePortAdminStatus(PortConfig &port, const std::string &field, const std::string &value) const;
bool parsePortDescription(PortConfig &port, const std::string &field, const std::string &value) const;
bool parsePortSubport(PortConfig &port, const std::string &field, const std::string &value) const;
bool parsePortPtIntfId(PortConfig &port, const std::string &field, const std::string &value) const;
bool parsePortPtTimestampTemplate(PortConfig &port, const std::string &field, const std::string &value) const;
};
77 changes: 42 additions & 35 deletions orchagent/port/portschema.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,38 +53,45 @@
#define PORT_ROLE_REC "Rec"
#define PORT_ROLE_DPC "Dpc"

#define PORT_ALIAS "alias"
#define PORT_INDEX "index"
#define PORT_LANES "lanes"
#define PORT_SPEED "speed"
#define PORT_AUTONEG "autoneg"
#define PORT_ADV_SPEEDS "adv_speeds"
#define PORT_INTERFACE_TYPE "interface_type"
#define PORT_ADV_INTERFACE_TYPES "adv_interface_types"
#define PORT_FEC "fec"
#define PORT_MTU "mtu"
#define PORT_TPID "tpid"
#define PORT_PFC_ASYM "pfc_asym"
#define PORT_LEARN_MODE "learn_mode"
#define PORT_LINK_TRAINING "link_training"
#define PORT_PREEMPHASIS "preemphasis"
#define PORT_IDRIVER "idriver"
#define PORT_IPREDRIVER "ipredriver"
#define PORT_PRE1 "pre1"
#define PORT_PRE2 "pre2"
#define PORT_PRE3 "pre3"
#define PORT_MAIN "main"
#define PORT_POST1 "post1"
#define PORT_POST2 "post2"
#define PORT_POST3 "post3"
#define PORT_ATTN "attn"
#define PORT_OB_M2LP "ob_m2lp"
#define PORT_OB_ALEV_OUT "ob_alev_out"
#define PORT_OBPLEV "obplev"
#define PORT_OBNLEV "obnlev"
#define PORT_REGN_BFM1P "regn_bfm1p"
#define PORT_REGN_BFM1N "regn_bfm1n"
#define PORT_ROLE "role"
#define PORT_ADMIN_STATUS "admin_status"
#define PORT_DESCRIPTION "description"
#define PORT_SUBPORT "subport"
#define PORT_PT_TIMESTAMP_TEMPLATE_1 "template1"
#define PORT_PT_TIMESTAMP_TEMPLATE_2 "template2"
#define PORT_PT_TIMESTAMP_TEMPLATE_3 "template3"
#define PORT_PT_TIMESTAMP_TEMPLATE_4 "template4"

#define PORT_ALIAS "alias"
#define PORT_INDEX "index"
#define PORT_LANES "lanes"
#define PORT_SPEED "speed"
#define PORT_AUTONEG "autoneg"
#define PORT_ADV_SPEEDS "adv_speeds"
#define PORT_INTERFACE_TYPE "interface_type"
#define PORT_ADV_INTERFACE_TYPES "adv_interface_types"
#define PORT_FEC "fec"
#define PORT_MTU "mtu"
#define PORT_TPID "tpid"
#define PORT_PFC_ASYM "pfc_asym"
#define PORT_LEARN_MODE "learn_mode"
#define PORT_LINK_TRAINING "link_training"
#define PORT_PREEMPHASIS "preemphasis"
#define PORT_IDRIVER "idriver"
#define PORT_IPREDRIVER "ipredriver"
#define PORT_PRE1 "pre1"
#define PORT_PRE2 "pre2"
#define PORT_PRE3 "pre3"
#define PORT_MAIN "main"
#define PORT_POST1 "post1"
#define PORT_POST2 "post2"
#define PORT_POST3 "post3"
#define PORT_ATTN "attn"
#define PORT_OB_M2LP "ob_m2lp"
#define PORT_OB_ALEV_OUT "ob_alev_out"
#define PORT_OBPLEV "obplev"
#define PORT_OBNLEV "obnlev"
#define PORT_REGN_BFM1P "regn_bfm1p"
#define PORT_REGN_BFM1N "regn_bfm1n"
#define PORT_ROLE "role"
#define PORT_ADMIN_STATUS "admin_status"
#define PORT_DESCRIPTION "description"
#define PORT_SUBPORT "subport"
#define PORT_PT_INTF_ID "pt_interface_id"
#define PORT_PT_TIMESTAMP_TEMPLATE "pt_timestamp_template"
Loading

0 comments on commit c43d16e

Please sign in to comment.