Skip to content

Commit a3fdaf4

Browse files
QOS fieldvalue reference ABNF format to string changes (sonic-net#1754)
* QOS field reference ABNF format to string changes
1 parent a8fcadf commit a3fdaf4

20 files changed

+202
-236
lines changed

cfgmgr/buffer_check_headroom_mellanox.lua

+3-3
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ end
9191
table.insert(debuginfo, 'debug:other overhead:' .. accumulative_size)
9292
local pg_keys = redis.call('KEYS', 'BUFFER_PG_TABLE:' .. port .. ':*')
9393
for i = 1, #pg_keys do
94-
local profile = string.sub(redis.call('HGET', pg_keys[i], 'profile'), 2, -2)
94+
local profile = redis.call('HGET', pg_keys[i], 'profile')
9595
local current_profile_size
96-
if profile ~= 'BUFFER_PROFILE_TABLE:ingress_lossy_profile' and (no_input_pg or new_pg ~= pg_keys[i]) then
96+
if profile ~= 'ingress_lossy_profile' and (no_input_pg or new_pg ~= pg_keys[i]) then
9797
if profile ~= input_profile_name and not no_input_pg then
98-
local referenced_profile = redis.call('HGETALL', profile)
98+
local referenced_profile = redis.call('HGETALL', 'BUFFER_PROFILE_TABLE:' .. profile)
9999
for j = 1, #referenced_profile, 2 do
100100
if referenced_profile[j] == 'size' then
101101
current_profile_size = tonumber(referenced_profile[j+1])

cfgmgr/buffer_pool_mellanox.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ local function iterate_all_items(all_items, check_lossless)
4444
if not profile_name then
4545
return 1
4646
end
47-
profile_name = string.sub(profile_name, 2, -2)
47+
profile_name = "BUFFER_PROFILE_TABLE:" .. profile_name
4848
local profile_ref_count = profiles[profile_name]
4949
if profile_ref_count == nil then
5050
-- Indicate an error in case the referenced profile hasn't been inserted or has been removed

cfgmgr/buffermgr.cpp

+4-45
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Create/update two tables: profile (in m_cfgBufferProfileTable) and port buffer (
107107
108108
"BUFFER_PROFILE": {
109109
"pg_lossless_100G_300m_profile": {
110-
"pool":"[BUFFER_POOL_TABLE:ingress_lossless_pool]",
110+
"pool":"ingress_lossless_pool",
111111
"xon":"18432",
112112
"xon_offset":"2496",
113113
"xoff":"165888",
@@ -117,7 +117,7 @@ Create/update two tables: profile (in m_cfgBufferProfileTable) and port buffer (
117117
}
118118
"BUFFER_PG" :{
119119
Ethernet44|3-4": {
120-
"profile" : "[BUFFER_PROFILE:pg_lossless_100000_300m_profile]"
120+
"profile" : "pg_lossless_100000_300m_profile"
121121
}
122122
}
123123
*/
@@ -168,11 +168,8 @@ task_process_status BufferMgr::doSpeedUpdateTask(string port)
168168

169169
// profile threshold field name
170170
mode += "_th";
171-
string pg_pool_reference = string(CFG_BUFFER_POOL_TABLE_NAME) +
172-
m_cfgBufferProfileTable.getTableNameSeparator() +
173-
INGRESS_LOSSLESS_PG_POOL_NAME;
174171

175-
fvVector.push_back(make_pair("pool", "[" + pg_pool_reference + "]"));
172+
fvVector.push_back(make_pair("pool", INGRESS_LOSSLESS_PG_POOL_NAME));
176173
fvVector.push_back(make_pair("xon", m_pgProfileLookup[speed][cable].xon));
177174
if (m_pgProfileLookup[speed][cable].xon_offset.length() > 0) {
178175
fvVector.push_back(make_pair("xon_offset",
@@ -192,11 +189,7 @@ task_process_status BufferMgr::doSpeedUpdateTask(string port)
192189

193190
string buffer_pg_key = port + m_cfgBufferPgTable.getTableNameSeparator() + LOSSLESS_PGS;
194191

195-
string profile_ref = string("[") +
196-
CFG_BUFFER_PROFILE_TABLE_NAME +
197-
m_cfgBufferPgTable.getTableNameSeparator() +
198-
buffer_profile_key +
199-
"]";
192+
string profile_ref = buffer_profile_key;
200193

201194
/* Check if PG Mapping is already then log message and return. */
202195
m_cfgBufferPgTable.get(buffer_pg_key, fvVector);
@@ -224,32 +217,6 @@ void BufferMgr::transformSeperator(string &name)
224217
name.replace(pos, 1, ":");
225218
}
226219

227-
void BufferMgr::transformReference(string &name)
228-
{
229-
auto references = tokenize(name, list_item_delimiter);
230-
int ref_index = 0;
231-
232-
name = "";
233-
234-
for (auto &reference : references)
235-
{
236-
if (ref_index != 0)
237-
name += list_item_delimiter;
238-
ref_index ++;
239-
240-
auto keys = tokenize(reference, config_db_key_delimiter);
241-
int key_index = 0;
242-
for (auto &key : keys)
243-
{
244-
if (key_index == 0)
245-
name += key + "_TABLE";
246-
else
247-
name += delimiter + key;
248-
key_index ++;
249-
}
250-
}
251-
}
252-
253220
/*
254221
* This function copies the data from tables in CONFIG_DB to APPL_DB.
255222
* With dynamically buffer calculation supported, the following tables
@@ -292,14 +259,6 @@ void BufferMgr::doBufferTableTask(Consumer &consumer, ProducerStateTable &applTa
292259

293260
for (auto i : kfvFieldsValues(t))
294261
{
295-
SWSS_LOG_INFO("Inserting field %s value %s", fvField(i).c_str(), fvValue(i).c_str());
296-
//transform the separator in values from "|" to ":"
297-
if (fvField(i) == "pool")
298-
transformReference(fvValue(i));
299-
if (fvField(i) == "profile")
300-
transformReference(fvValue(i));
301-
if (fvField(i) == "profile_list")
302-
transformReference(fvValue(i));
303262
fvVector.emplace_back(FieldValueTuple(fvField(i), fvValue(i)));
304263
SWSS_LOG_INFO("Inserting field %s value %s", fvField(i).c_str(), fvValue(i).c_str());
305264
}

cfgmgr/buffermgr.h

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ class BufferMgr : public Orch
6161
void doBufferTableTask(Consumer &consumer, ProducerStateTable &applTable);
6262

6363
void transformSeperator(std::string &name);
64-
void transformReference(std::string &name);
6564

6665
void doTask(Consumer &consumer);
6766
};

cfgmgr/buffermgrdyn.cpp

+4-56
Original file line numberDiff line numberDiff line change
@@ -202,32 +202,6 @@ void BufferMgrDynamic::transformSeperator(string &name)
202202
name.replace(pos, 1, ":");
203203
}
204204

205-
void BufferMgrDynamic::transformReference(string &name)
206-
{
207-
auto references = tokenize(name, list_item_delimiter);
208-
int ref_index = 0;
209-
210-
name = "";
211-
212-
for (auto &reference : references)
213-
{
214-
if (ref_index != 0)
215-
name += list_item_delimiter;
216-
ref_index ++;
217-
218-
auto keys = tokenize(reference, config_db_key_delimiter);
219-
int key_index = 0;
220-
for (auto &key : keys)
221-
{
222-
if (key_index == 0)
223-
name += key + "_TABLE";
224-
else
225-
name += delimiter + key;
226-
key_index ++;
227-
}
228-
}
229-
}
230-
231205
// For string "TABLE_NAME|objectname", returns "objectname"
232206
string BufferMgrDynamic::parseObjectNameFromKey(const string &key, size_t pos = 0)
233207
{
@@ -240,13 +214,6 @@ string BufferMgrDynamic::parseObjectNameFromKey(const string &key, size_t pos =
240214
return keys[pos];
241215
}
242216

243-
// For string "[foo]", returns "foo"
244-
string BufferMgrDynamic::parseObjectNameFromReference(const string &reference)
245-
{
246-
auto objName = reference.substr(1, reference.size() - 2);
247-
return parseObjectNameFromKey(objName, 1);
248-
}
249-
250217
string BufferMgrDynamic::getDynamicProfileName(const string &speed, const string &cable, const string &mtu, const string &threshold, const string &gearbox_model, long lane_count)
251218
{
252219
string buffer_profile_key;
@@ -619,17 +586,14 @@ void BufferMgrDynamic::updateBufferProfileToDb(const string &name, const buffer_
619586

620587
// profile threshold field name
621588
mode += "_th";
622-
string pg_pool_reference = string(APP_BUFFER_POOL_TABLE_NAME) +
623-
m_applBufferProfileTable.getTableNameSeparator() +
624-
INGRESS_LOSSLESS_PG_POOL_NAME;
625589

626590
fvVector.emplace_back("xon", profile.xon);
627591
if (!profile.xon_offset.empty()) {
628592
fvVector.emplace_back("xon_offset", profile.xon_offset);
629593
}
630594
fvVector.emplace_back("xoff", profile.xoff);
631595
fvVector.emplace_back("size", profile.size);
632-
fvVector.emplace_back("pool", "[" + pg_pool_reference + "]");
596+
fvVector.emplace_back("pool", INGRESS_LOSSLESS_PG_POOL_NAME);
633597
fvVector.emplace_back(mode, profile.threshold);
634598

635599
m_applBufferProfileTable.set(name, fvVector);
@@ -646,15 +610,7 @@ void BufferMgrDynamic::updateBufferPgToDb(const string &key, const string &profi
646610

647611
fvVector.clear();
648612

649-
string profile_ref = string("[") +
650-
APP_BUFFER_PROFILE_TABLE_NAME +
651-
m_applBufferPgTable.getTableNameSeparator() +
652-
profile +
653-
"]";
654-
655-
fvVector.clear();
656-
657-
fvVector.push_back(make_pair("profile", profile_ref));
613+
fvVector.push_back(make_pair("profile", profile));
658614
m_applBufferPgTable.set(key, fvVector);
659615
}
660616
else
@@ -1779,8 +1735,7 @@ task_process_status BufferMgrDynamic::handleBufferProfileTable(KeyOpFieldsValues
17791735
{
17801736
if (!value.empty())
17811737
{
1782-
transformReference(value);
1783-
auto poolName = parseObjectNameFromReference(value);
1738+
auto poolName = value;
17841739
if (poolName.empty())
17851740
{
17861741
SWSS_LOG_ERROR("BUFFER_PROFILE: Invalid format of reference to pool: %s", value.c_str());
@@ -1953,8 +1908,7 @@ task_process_status BufferMgrDynamic::handleOneBufferPgEntry(const string &key,
19531908
{
19541909
// Headroom override
19551910
pureDynamic = false;
1956-
transformReference(value);
1957-
string profileName = parseObjectNameFromReference(value);
1911+
string profileName = value;
19581912
if (profileName.empty())
19591913
{
19601914
SWSS_LOG_ERROR("BUFFER_PG: Invalid format of reference to profile: %s", value.c_str());
@@ -2170,12 +2124,6 @@ task_process_status BufferMgrDynamic::doBufferTableTask(KeyOpFieldsValuesTuple &
21702124
for (auto i : kfvFieldsValues(tuple))
21712125
{
21722126
// Transform the separator in values from "|" to ":"
2173-
if (fvField(i) == "pool")
2174-
transformReference(fvValue(i));
2175-
if (fvField(i) == "profile")
2176-
transformReference(fvValue(i));
2177-
if (fvField(i) == "profile_list")
2178-
transformReference(fvValue(i));
21792127
fvVector.emplace_back(fvField(i), fvValue(i));
21802128
SWSS_LOG_INFO("Inserting field %s value %s", fvField(i).c_str(), fvValue(i).c_str());
21812129
}

cfgmgr/buffermgrdyn.h

-2
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,7 @@ class BufferMgrDynamic : public Orch
222222
// Tool functions to parse keys and references
223223
std::string getPgPoolMode();
224224
void transformSeperator(std::string &name);
225-
void transformReference(std::string &name);
226225
std::string parseObjectNameFromKey(const std::string &key, size_t pos/* = 1*/);
227-
std::string parseObjectNameFromReference(const std::string &reference);
228226
std::string getDynamicProfileName(const std::string &speed, const std::string &cable, const std::string &mtu, const std::string &threshold, const std::string &gearbox_model, long lane_count);
229227
inline bool isNonZero(const std::string &value) const
230228
{

doc/Configuration.md

+21-21
Original file line numberDiff line numberDiff line change
@@ -343,13 +343,13 @@ When the system is running in traditional buffer model, profiles needs to explic
343343
{
344344
"BUFFER_PG": {
345345
"Ethernet0|3-4": {
346-
"profile": "[BUFFER_PROFILE|pg_lossless_40000_5m_profile]"
346+
"profile": "pg_lossless_40000_5m_profile"
347347
},
348348
"Ethernet1|3-4": {
349-
"profile": "[BUFFER_PROFILE|pg_lossless_40000_5m_profile]"
349+
"profile": "pg_lossless_40000_5m_profile"
350350
},
351351
"Ethernet2|3-4": {
352-
"profile": "[BUFFER_PROFILE|pg_lossless_40000_5m_profile]"
352+
"profile": "pg_lossless_40000_5m_profile"
353353
}
354354
}
355355
}
@@ -371,7 +371,7 @@ When the system is running in dynamic buffer model, profiles can be:
371371
"profile": "NULL"
372372
},
373373
"Ethernet2|3-4": {
374-
"profile": "[BUFFER_PROFILE|static_profile]"
374+
"profile": "static_profile"
375375
}
376376
}
377377
}
@@ -437,33 +437,33 @@ When the system is running in dynamic buffer model, the size of some of the buff
437437
"BUFFER_PROFILE": {
438438
"egress_lossless_profile": {
439439
"static_th": "3995680",
440-
"pool": "[BUFFER_POOL|egress_lossless_pool]",
440+
"pool": "egress_lossless_pool",
441441
"size": "1518"
442442
},
443443
"egress_lossy_profile": {
444444
"dynamic_th": "3",
445-
"pool": "[BUFFER_POOL|egress_lossy_pool]",
445+
"pool": "egress_lossy_pool",
446446
"size": "1518"
447447
},
448448
"ingress_lossy_profile": {
449449
"dynamic_th": "3",
450-
"pool": "[BUFFER_POOL|ingress_lossless_pool]",
450+
"pool": "ingress_lossless_pool",
451451
"size": "0"
452452
},
453453
"pg_lossless_40000_5m_profile": {
454454
"xon_offset": "2288",
455455
"dynamic_th": "-3",
456456
"xon": "2288",
457457
"xoff": "66560",
458-
"pool": "[BUFFER_POOL|ingress_lossless_pool]",
458+
"pool": "ingress_lossless_pool",
459459
"size": "1248"
460460
},
461461
"pg_lossless_40000_40m_profile": {
462462
"xon_offset": "2288",
463463
"dynamic_th": "-3",
464464
"xon": "2288",
465465
"xoff": "71552",
466-
"pool": "[BUFFER_POOL|ingress_lossless_pool]",
466+
"pool": "ingress_lossless_pool",
467467
"size": "1248"
468468
}
469469
}
@@ -491,13 +491,13 @@ This kind of profiles will be handled by buffer manager and won't be applied to
491491
{
492492
"BUFFER_QUEUE": {
493493
"Ethernet50,Ethernet52,Ethernet54,Ethernet56|0-2": {
494-
"profile": "[BUFFER_PROFILE|egress_lossy_profile]"
494+
"profile": "egress_lossy_profile"
495495
},
496496
"Ethernet50,Ethernet52,Ethernet54,Ethernet56|3-4": {
497-
"profile": "[BUFFER_PROFILE|egress_lossless_profile]"
497+
"profile": "egress_lossless_profile"
498498
},
499499
"Ethernet50,Ethernet52,Ethernet54,Ethernet56|5-6": {
500-
"profile": "[BUFFER_PROFILE|egress_lossy_profile]"
500+
"profile": "egress_lossy_profile"
501501
}
502502
}
503503
}
@@ -1104,12 +1104,12 @@ name as object key and member list as attribute.
11041104
{
11051105
"PORT_QOS_MAP": {
11061106
"Ethernet50,Ethernet52,Ethernet54,Ethernet56": {
1107-
"tc_to_pg_map": "[TC_TO_PRIORITY_GROUP_MAP|AZURE]",
1108-
"tc_to_queue_map": "[TC_TO_QUEUE_MAP|AZURE]",
1107+
"tc_to_pg_map": "AZURE",
1108+
"tc_to_queue_map": "AZURE",
11091109
"pfc_enable": "3,4",
1110-
"pfc_to_queue_map": "[MAP_PFC_PRIORITY_TO_QUEUE|AZURE]",
1111-
"dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]",
1112-
"scheduler": "[SCHEDULER|scheduler.port]"
1110+
"pfc_to_queue_map": "AZURE",
1111+
"dscp_to_tc_map": "AZURE",
1112+
"scheduler": "scheduler.port"
11131113
}
11141114
}
11151115
}
@@ -1120,14 +1120,14 @@ name as object key and member list as attribute.
11201120
{
11211121
"QUEUE": {
11221122
"Ethernet56|4": {
1123-
"wred_profile": "[WRED_PROFILE|AZURE_LOSSLESS]",
1124-
"scheduler": "[SCHEDULER|scheduler.1]"
1123+
"wred_profile": "AZURE_LOSSLESS",
1124+
"scheduler": "scheduler.1"
11251125
},
11261126
"Ethernet56|5": {
1127-
"scheduler": "[SCHEDULER|scheduler.0]"
1127+
"scheduler": "scheduler.0"
11281128
},
11291129
"Ethernet56|6": {
1130-
"scheduler": "[SCHEDULER|scheduler.0]"
1130+
"scheduler": "scheduler.0"
11311131
}
11321132
}
11331133
}

doc/swss-schema.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ Stores information for physical switch ports managed by the switch chip. Ports t
3535
Example:
3636
127.0.0.1:6379> hgetall PORT_TABLE:ETHERNET4
3737
1) "dscp_to_tc_map"
38-
2) "[DSCP_TO_TC_MAP_TABLE:AZURE]"
38+
2) "AZURE"
3939
3) "tc_to_queue_map"
40-
4) "[TC_TO_QUEUE_MAP_TABLE:AZURE]"
40+
4) "AZURE"
4141

4242
---------------------------------------------
4343
### INTF_TABLE
@@ -209,9 +209,9 @@ and reflects the LAG ports into the redis under: `LAG_TABLE:<team0>:port`
209209
Example:
210210
127.0.0.1:6379> hgetall QUEUE_TABLE:ETHERNET4:1
211211
1) "scheduler"
212-
2) "[SCHEDULER_TABLE:BEST_EFFORT]"
212+
2) "BEST_EFFORT"
213213
3) "wred_profile"
214-
4) "[WRED_PROFILE_TABLE:AZURE]"
214+
4) "AZURE"
215215

216216
---------------------------------------------
217217
### TC\_TO\_QUEUE\_MAP\_TABLE

0 commit comments

Comments
 (0)