Skip to content

Commit 1b44d4f

Browse files
prsunnyraphaelt-nvidia
authored andcommitted
Revert "Revert "[buffermgr] Support maximum port headroom checking (sonic-net#1607)" (sonic-net#1675)" (sonic-net#1682)
This reverts commit acfcb85 effectively re-merging sonic-net#1607
1 parent d83469e commit 1b44d4f

File tree

4 files changed

+29
-26
lines changed

4 files changed

+29
-26
lines changed

cfgmgr/buffer_check_headroom_mellanox.lua

+2-26
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,15 @@ local new_pg = ARGV[3]
1010
local accumulative_size = 0
1111

1212
local appl_db = "0"
13-
local config_db = "4"
1413
local state_db = "6"
1514

1615
local ret_true = {}
17-
local ret_false = {}
1816
local ret = {}
1917
local default_ret = {}
2018

2119
table.insert(ret_true, "result:true")
22-
table.insert(ret_false, "result:false")
2320

24-
-- Fetch the cable length from CONFIG_DB
25-
redis.call('SELECT', config_db)
26-
local cable_length_keys = redis.call('KEYS', 'CABLE_LENGTH*')
27-
if #cable_length_keys == 0 then
28-
return ret_true
29-
end
30-
31-
-- Check whether cable length exceeds 300m (maximum value in the non-dynamic-buffer solution)
32-
local cable_length_str = redis.call('HGET', cable_length_keys[1], port)
33-
if cable_length_str == nil then
34-
return ret_true
35-
end
36-
local cable_length = tonumber(string.sub(cable_length_str, 1, -2))
37-
if cable_length > 300 then
38-
default_ret = ret_false
39-
else
40-
default_ret = ret_true
41-
end
42-
table.insert(default_ret, 'debug:no max_headroom_size configured, check cable length instead')
21+
default_ret = ret_true
4322

4423
local speed = redis.call('HGET', 'PORT|' .. port, 'speed')
4524

@@ -67,7 +46,6 @@ local function get_number_of_pgs(keyname)
6746
local range = string.match(keyname, "Ethernet%d+:([^%s]+)$")
6847
local size
6948
if range == nil then
70-
table.insert(debuginfo, "debug:invalid pg:" .. keyname)
7149
return 0
7250
end
7351
if string.len(range) == 1 then
@@ -119,11 +97,9 @@ if max_headroom_size > accumulative_size then
11997
table.insert(ret, "result:true")
12098
else
12199
table.insert(ret, "result:false")
100+
table.insert(ret, "debug:Accumulative headroom on port " .. accumulative_size .. " exceeds the maximum available headroom which is " .. max_headroom_size)
122101
end
123102

124-
table.insert(ret, "debug:max headroom:" .. max_headroom_size)
125-
table.insert(ret, "debug:accumulative headroom:" .. accumulative_size)
126-
127103
for i = 1, #debuginfo do
128104
table.insert(ret, debuginfo[i])
129105
end

orchagent/port.h

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ class Port
124124
uint32_t m_vnid = VNID_NONE;
125125
uint32_t m_fdb_count = 0;
126126
uint32_t m_up_member_count = 0;
127+
uint32_t m_maximum_headroom = 0;
127128

128129
/*
129130
* Following two bit vectors are used to lock

orchagent/portsorch.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,9 @@ PortsOrch::PortsOrch(DBConnector *db, vector<table_name_with_pri_t> &tableNames)
263263
m_flexCounterTable = unique_ptr<ProducerTable>(new ProducerTable(m_flex_db.get(), FLEX_COUNTER_TABLE));
264264
m_flexCounterGroupTable = unique_ptr<ProducerTable>(new ProducerTable(m_flex_db.get(), FLEX_COUNTER_GROUP_TABLE));
265265

266+
m_state_db = shared_ptr<DBConnector>(new DBConnector("STATE_DB", 0));
267+
m_stateBufferMaximumValueTable = unique_ptr<Table>(new Table(m_state_db.get(), STATE_BUFFER_MAXIMUM_VALUE_TABLE));
268+
266269
initGearbox();
267270

268271
string queueWmSha, pgWmSha;
@@ -3322,6 +3325,25 @@ void PortsOrch::initializePriorityGroups(Port &port)
33223325
SWSS_LOG_INFO("Get priority groups for port %s", port.m_alias.c_str());
33233326
}
33243327

3328+
void PortsOrch::initializePortMaximumHeadroom(Port &port)
3329+
{
3330+
sai_attribute_t attr;
3331+
3332+
attr.id = SAI_PORT_ATTR_QOS_MAXIMUM_HEADROOM_SIZE;
3333+
3334+
sai_status_t status = sai_port_api->get_port_attribute(port.m_port_id, 1, &attr);
3335+
if (status != SAI_STATUS_SUCCESS)
3336+
{
3337+
SWSS_LOG_NOTICE("Unable to get the maximum headroom for port %s rv:%d, ignored", port.m_alias.c_str(), status);
3338+
return;
3339+
}
3340+
3341+
vector<FieldValueTuple> fvVector;
3342+
port.m_maximum_headroom = attr.value.u32;
3343+
fvVector.emplace_back("max_headroom_size", to_string(port.m_maximum_headroom));
3344+
m_stateBufferMaximumValueTable->set(port.m_alias, fvVector);
3345+
}
3346+
33253347
bool PortsOrch::initializePort(Port &port)
33263348
{
33273349
SWSS_LOG_ENTER();
@@ -3330,6 +3352,7 @@ bool PortsOrch::initializePort(Port &port)
33303352

33313353
initializePriorityGroups(port);
33323354
initializeQueues(port);
3355+
initializePortMaximumHeadroom(port);
33333356

33343357
/* Create host interface */
33353358
if (!addHostIntfs(port, port.m_alias, port.m_hif_id))

orchagent/portsorch.h

+3
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ class PortsOrch : public Orch, public Subject
155155
unique_ptr<Table> m_pgTable;
156156
unique_ptr<Table> m_pgPortTable;
157157
unique_ptr<Table> m_pgIndexTable;
158+
unique_ptr<Table> m_stateBufferMaximumValueTable;
158159
unique_ptr<ProducerTable> m_flexCounterTable;
159160
unique_ptr<ProducerTable> m_flexCounterGroupTable;
160161

@@ -165,6 +166,7 @@ class PortsOrch : public Orch, public Subject
165166

166167
shared_ptr<DBConnector> m_counter_db;
167168
shared_ptr<DBConnector> m_flex_db;
169+
shared_ptr<DBConnector> m_state_db;
168170

169171
FlexCounterManager port_stat_manager;
170172
FlexCounterManager port_buffer_drop_stat_manager;
@@ -227,6 +229,7 @@ class PortsOrch : public Orch, public Subject
227229

228230
bool initializePort(Port &port);
229231
void initializePriorityGroups(Port &port);
232+
void initializePortMaximumHeadroom(Port &port);
230233
void initializeQueues(Port &port);
231234

232235
bool addHostIntfs(Port &port, string alias, sai_object_id_t &host_intfs_id);

0 commit comments

Comments
 (0)