Skip to content

Commit

Permalink
Merge branch 'master' into flow-counter-review
Browse files Browse the repository at this point in the history
  • Loading branch information
Junchao-Mellanox authored Nov 17, 2021
2 parents 14e70eb + 18ea840 commit 5f63a7c
Show file tree
Hide file tree
Showing 36 changed files with 3,861 additions and 616 deletions.
5 changes: 4 additions & 1 deletion cfgmgr/buffer_check_headroom_mellanox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ end
-- Initialize the accumulative size with 4096
-- This is to absorb the possible deviation
local accumulative_size = 4096
-- Egress mirror size: 2 * maximum MTU (10k)
local egress_mirror_size = 20*1024

local appl_db = "0"
local state_db = "6"
Expand Down Expand Up @@ -56,8 +58,9 @@ local pipeline_latency = tonumber(redis.call('HGET', asic_keys[1], 'pipeline_lat
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
end
accumulative_size = accumulative_size + 2 * pipeline_latency * 1024
accumulative_size = accumulative_size + 2 * pipeline_latency * 1024 + egress_mirror_size

-- Fetch all keys in BUFFER_PG according to the port
redis.call('SELECT', appl_db)
Expand Down
25 changes: 24 additions & 1 deletion cfgmgr/buffer_headroom_mellanox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,23 @@ local state_db = "6"

local ret = {}

-- pause quanta should be taken for each operating speed is defined in IEEE 802.3 31B.3.7
-- the key of table pause_quanta_per_speed is operating speed at Mb/s
-- the value of table pause_quanta_per_speed is the number of pause_quanta
local pause_quanta_per_speed = {}
pause_quanta_per_speed[400000] = 905
pause_quanta_per_speed[200000] = 453
pause_quanta_per_speed[100000] = 394
pause_quanta_per_speed[50000] = 147
pause_quanta_per_speed[40000] = 118
pause_quanta_per_speed[25000] = 80
pause_quanta_per_speed[10000] = 67
pause_quanta_per_speed[1000] = 2
pause_quanta_per_speed[100] = 1

-- Get pause_quanta from the pause_quanta_per_speed table
local pause_quanta = pause_quanta_per_speed[port_speed]

if gearbox_delay == nil then
gearbox_delay = 0
end
Expand All @@ -55,7 +72,8 @@ for i = 1, #asic_table_content, 2 do
if asic_table_content[i] == "mac_phy_delay" then
mac_phy_delay = tonumber(asic_table_content[i+1]) * 1024
end
if asic_table_content[i] == "peer_response_time" then
-- If failed to get pause_quanta from the table, then use the default peer_response_time stored in state_db
if asic_table_content[i] == "peer_response_time" and pause_quanta == nil then
peer_response_time = tonumber(asic_table_content[i+1]) * 1024
end
end
Expand Down Expand Up @@ -124,6 +142,11 @@ else
bytes_on_gearbox = port_speed * gearbox_delay / (8 * 1024)
end

-- If successfully get pause_quanta from the table, then calculate peer_response_time from it
if pause_quanta ~= nil then
peer_response_time = (pause_quanta) * 512 / 8
end

bytes_on_cable = 2 * cable_length * port_speed * 1000000000 / speed_of_light / (8 * 1024)
propagation_delay = port_mtu + bytes_on_cable + 2 * bytes_on_gearbox + mac_phy_delay + peer_response_time

Expand Down
5 changes: 4 additions & 1 deletion cfgmgr/macsecmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,10 +547,13 @@ bool MACsecMgr::isPortStateOk(const std::string & port_name)

std::vector<FieldValueTuple> temp;
std::string state;
std::string oper_status;

if (m_statePortTable.get(port_name, temp)
&& get_value(temp, "state", state)
&& state == "ok")
&& state == "ok"
&& get_value(temp, "netdev_oper_status", oper_status)
&& oper_status == "up")
{
SWSS_LOG_DEBUG("Port '%s' is ready", port_name.c_str());
return true;
Expand Down
2 changes: 2 additions & 0 deletions doc/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,8 @@ name as object key and member list as attribute.
"pfc_enable": "3,4",
"pfc_to_queue_map": "AZURE",
"dscp_to_tc_map": "AZURE",
"dscp_to_fc_map": "AZURE",
"exp_to_fc_map": "AZURE",
"scheduler": "scheduler.port"
}
}
Expand Down
57 changes: 57 additions & 0 deletions doc/swss-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,28 @@ and reflects the LAG ports into the redis under: `LAG_TABLE:<team0>:port`
mpls_nh = STRING ; Comma-separated list of MPLS NH info.
weight = weight_list ; List of weights.

---------------------------------------------
### CLASS_BASED_NEXT_HOP_GROUP_TABLE
;Stores a list of groups of one or more next hop groups used for class based forwarding
;Status: Mandatory
key = CLASS_BASED_NEXT_HOP_GROUP_TABLE:string ; arbitrary index for the next hop group
members = NEXT_HOP_GROUP_TABLE.key ; one or more separated by ","
selection_map = FC_TO_NHG_INDEX_MAP_TABLE.key ; the NHG map to use for this CBF NHG

---------------------------------------------
### FC_TO_NHG_INDEX_MAP_TABLE
; FC to Next hop group index map
key = "FC_TO_NHG_INDEX_MAP_TABLE:"name
fc_num = 1*DIGIT ;value
nh_index = 1*DIGIT; index of NH inside NH group

Example:
127.0.0.1:6379> hgetall "FC_TO_NHG_INDEX_MAP_TABLE:AZURE"
1) "0" ;fc_num
2) "0" ;nhg_index
3) "1"
4) "0"

---------------------------------------------
### NEIGH_TABLE
; Stores the neighbors or next hop IP address and output port or
Expand Down Expand Up @@ -321,6 +343,41 @@ and reflects the LAG ports into the redis under: `LAG_TABLE:<team0>:port`
9) "4"
10) "8"

### DSCP_TO_FC_TABLE_NAME
; dscp to FC map
;SAI mapping - qos_map object with SAI_QOS_MAP_ATTR_TYPE == sai_qos_map_type_t::SAI_QOS_MAP_TYPE_DSCP_TO_FORWARDING_CLASS
key = "DSCP_TO_FC_MAP_TABLE:"name
;field value
dscp_value = 1*DIGIT
fc_value = 1*DIGIT

Example:
127.0.0.1:6379> hgetall "DSCP_TO_FC_MAP_TABLE:AZURE"
1) "0" ;dscp
2) "1" ;fc
3) "1"
4) "1"
5) "2"
6) "3"
7)
---------------------------------------------
### EXP_TO_FC_MAP_TABLE
; dscp to FC map
;SAI mapping - qos_map object with SAI_QOS_MAP_ATTR_TYPE == sai_qos_map_type_t::SAI_QOS_MAP_TYPE_MPLS_EXP_TO_FORWARDING_CLASS
key = "EXP_TO_FC_MAP_TABLE:"name
;field value
mpls_exp_value = 1*DIGIT
fc_value = 1*DIGIT

Example:
127.0.0.1:6379> hgetall "EXP_TO_FC_MAP_TABLE:AZURE"
1) "0" ;mpls_exp
2) "1" ;fc
3) "1"
4) "1"
5) "2"
6) "3"

---------------------------------------------
### SCHEDULER_TABLE
; Scheduler table
Expand Down
113 changes: 113 additions & 0 deletions lib/subintf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#include <cerrno>
#include <cstring>
#include <array>
#include <net/if.h>
#include "subintf.h"

using namespace swss;

subIntf::subIntf(const std::string &ifName)
{
alias = ifName;
size_t found = alias.find(VLAN_SUB_INTERFACE_SEPARATOR);
if (found != std::string::npos)
{
parentIf = alias.substr(0, found);
if (!parentIf.compare(0, strlen("Eth"), "Eth"))
{
std::string parentIfName;
if (!parentIf.compare(0, strlen("Ethernet"), "Ethernet"))
{
parentIfShortName = "Eth" + parentIf.substr(strlen("Ethernet"));
isCompressed = false;
parentIfName = "Ethernet" + parentIf.substr(strlen("Ethernet"));
}
else
{
parentIfShortName = "Eth" + parentIf.substr(strlen("Eth"));
isCompressed = true;
parentIfName = "Ethernet" + parentIf.substr(strlen("Eth"));
}
parentIf = parentIfName;
subIfIdx = alias.substr(found + 1);
}
else if (!parentIf.compare(0, strlen("Po"), "Po"))
{
if (!parentIf.compare(0, strlen("PortChannel"), "PortChannel"))
{
isCompressed = false;
parentIfShortName = "Po" + parentIf.substr(strlen("PortChannel"));
parentIf = "PortChannel" + parentIf.substr(strlen("PortChannel"));
}
else
{
isCompressed = true;
parentIfShortName = "Po" + parentIf.substr(strlen("Po"));
parentIf = "PortChannel" + parentIf.substr(strlen("Po"));
}
subIfIdx = alias.substr(found + 1);
}
else
{
subIfIdx = "";
}
}
}

bool subIntf::isValid() const
{
if (subIfIdx == "")
{
return false;
}
else if (alias.length() >= IFNAMSIZ)
{
return false;
}

return true;
}

std::string subIntf::parentIntf() const
{
return parentIf;
}

int subIntf::subIntfIdx() const
{
uint16_t id;
try
{
id = static_cast<uint16_t>(stoul(subIfIdx));
}
catch (const std::invalid_argument &e)
{
return -1;
}
catch (const std::out_of_range &e)
{
return -1;
}
return id;
}

std::string subIntf::longName() const
{
if (isValid() == false)
return "";

return (parentIf + VLAN_SUB_INTERFACE_SEPARATOR + subIfIdx);
}

std::string subIntf::shortName() const
{
if (isValid() == false)
return "";

return (parentIfShortName + VLAN_SUB_INTERFACE_SEPARATOR + subIfIdx);
}

bool subIntf::isShortName() const
{
return ((isCompressed == true) ? true : false);
}
23 changes: 23 additions & 0 deletions lib/subintf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once

#define VLAN_SUB_INTERFACE_SEPARATOR "."
namespace swss {
class subIntf
{
public:
subIntf(const std::string &ifName);
bool isValid() const;
std::string parentIntf() const;
int subIntfIdx() const;
std::string longName() const;
std::string shortName() const;
bool isShortName() const;

private:
std::string alias;
std::string subIfIdx;
std::string parentIf;
std::string parentIfShortName;
bool isCompressed = false;
};
}
6 changes: 5 additions & 1 deletion orchagent/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ INCLUDES = -I $(top_srcdir)/lib \
-I flex_counter \
-I debug_counter \
-I flow_counter \
-I pbh
-I pbh \
-I nhg

CFLAGS_SAI = -I /usr/include/sai

Expand Down Expand Up @@ -43,6 +44,9 @@ orchagent_SOURCES = \
orch.cpp \
notifications.cpp \
nhgorch.cpp \
nhgbase.cpp \
cbf/cbfnhgorch.cpp \
cbf/nhgmaporch.cpp \
routeorch.cpp \
mplsrouteorch.cpp \
neighorch.cpp \
Expand Down
Loading

0 comments on commit 5f63a7c

Please sign in to comment.