Skip to content

Commit 5d8d1fb

Browse files
prsunnyyxieca
authored andcommitted
Revert "Revert "[buffermgr] Support maximum port headroom checking (#1607)" (#1675)" (#1682)
This reverts commit acfcb85 effectively re-merging #1607
1 parent f8df1f8 commit 5d8d1fb

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
@@ -110,6 +110,7 @@ class Port
110110
uint32_t m_vnid = VNID_NONE;
111111
uint32_t m_fdb_count = 0;
112112
uint32_t m_up_member_count = 0;
113+
uint32_t m_maximum_headroom = 0;
113114

114115
/*
115116
* Following two bit vectors are used to lock

orchagent/portsorch.cpp

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

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

267270
string queueWmSha, pgWmSha;
@@ -3290,6 +3293,25 @@ void PortsOrch::initializePriorityGroups(Port &port)
32903293
SWSS_LOG_INFO("Get priority groups for port %s", port.m_alias.c_str());
32913294
}
32923295

3296+
void PortsOrch::initializePortMaximumHeadroom(Port &port)
3297+
{
3298+
sai_attribute_t attr;
3299+
3300+
attr.id = SAI_PORT_ATTR_QOS_MAXIMUM_HEADROOM_SIZE;
3301+
3302+
sai_status_t status = sai_port_api->get_port_attribute(port.m_port_id, 1, &attr);
3303+
if (status != SAI_STATUS_SUCCESS)
3304+
{
3305+
SWSS_LOG_NOTICE("Unable to get the maximum headroom for port %s rv:%d, ignored", port.m_alias.c_str(), status);
3306+
return;
3307+
}
3308+
3309+
vector<FieldValueTuple> fvVector;
3310+
port.m_maximum_headroom = attr.value.u32;
3311+
fvVector.emplace_back("max_headroom_size", to_string(port.m_maximum_headroom));
3312+
m_stateBufferMaximumValueTable->set(port.m_alias, fvVector);
3313+
}
3314+
32933315
bool PortsOrch::initializePort(Port &port)
32943316
{
32953317
SWSS_LOG_ENTER();
@@ -3298,6 +3320,7 @@ bool PortsOrch::initializePort(Port &port)
32983320

32993321
initializePriorityGroups(port);
33003322
initializeQueues(port);
3323+
initializePortMaximumHeadroom(port);
33013324

33023325
/* Create host interface */
33033326
if (!addHostIntfs(port, port.m_alias, port.m_hif_id))

orchagent/portsorch.h

+3
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ class PortsOrch : public Orch, public Subject
150150
unique_ptr<Table> m_pgTable;
151151
unique_ptr<Table> m_pgPortTable;
152152
unique_ptr<Table> m_pgIndexTable;
153+
unique_ptr<Table> m_stateBufferMaximumValueTable;
153154
unique_ptr<ProducerTable> m_flexCounterTable;
154155
unique_ptr<ProducerTable> m_flexCounterGroupTable;
155156

@@ -160,6 +161,7 @@ class PortsOrch : public Orch, public Subject
160161

161162
shared_ptr<DBConnector> m_counter_db;
162163
shared_ptr<DBConnector> m_flex_db;
164+
shared_ptr<DBConnector> m_state_db;
163165

164166
FlexCounterManager port_stat_manager;
165167
FlexCounterManager port_buffer_drop_stat_manager;
@@ -222,6 +224,7 @@ class PortsOrch : public Orch, public Subject
222224

223225
bool initializePort(Port &port);
224226
void initializePriorityGroups(Port &port);
227+
void initializePortMaximumHeadroom(Port &port);
225228
void initializeQueues(Port &port);
226229

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

0 commit comments

Comments
 (0)