@@ -30,17 +30,6 @@ BufferMgr::BufferMgr(DBConnector *cfgDb, DBConnector *applDb, string pg_lookup_f
3030 m_applBufferEgressProfileListTable(applDb, APP_BUFFER_PORT_EGRESS_PROFILE_LIST_NAME)
3131{
3232 readPgProfileLookupFile (pg_lookup_file);
33-
34- char *platform = getenv (" ASIC_VENDOR" );
35- if (NULL == platform)
36- {
37- SWSS_LOG_WARN (" Platform environment variable is not defined" );
38- }
39- else
40- {
41- m_platform = platform;
42- }
43-
4433 dynamic_buffer_model = false ;
4534}
4635
@@ -133,9 +122,9 @@ Create/update two tables: profile (in m_cfgBufferProfileTable) and port buffer (
133122 }
134123 }
135124*/
136- task_process_status BufferMgr::doSpeedUpdateTask (string port, bool admin_up )
125+ task_process_status BufferMgr::doSpeedUpdateTask (string port)
137126{
138- vector<FieldValueTuple> fvVectorPg, fvVectorProfile ;
127+ vector<FieldValueTuple> fvVector ;
139128 string cable;
140129 string speed;
141130
@@ -153,54 +142,20 @@ task_process_status BufferMgr::doSpeedUpdateTask(string port, bool admin_up)
153142 }
154143
155144 speed = m_speedLookup[port];
156-
157- string buffer_pg_key = port + m_cfgBufferPgTable.getTableNameSeparator () + LOSSLESS_PGS;
158- // key format is pg_lossless_<speed>_<cable>_profile
159- string buffer_profile_key = " pg_lossless_" + speed + " _" + cable + " _profile" ;
160- string profile_ref = string (" [" ) +
161- CFG_BUFFER_PROFILE_TABLE_NAME +
162- m_cfgBufferPgTable.getTableNameSeparator () +
163- buffer_profile_key +
164- " ]" ;
165-
166- m_cfgBufferPgTable.get (buffer_pg_key, fvVectorPg);
167-
168- if (!admin_up && m_platform == " mellanox" )
169- {
170- // Remove the entry in BUFFER_PG table if any
171- if (!fvVectorPg.empty ())
172- {
173- for (auto &prop : fvVectorPg)
174- {
175- if (fvField (prop) == " profile" )
176- {
177- if (fvValue (prop) == profile_ref)
178- {
179- SWSS_LOG_NOTICE (" Removing PG %s from port %s which is administrative down" , buffer_pg_key.c_str (), port.c_str ());
180- m_cfgBufferPgTable.del (buffer_pg_key);
181- }
182- else
183- {
184- SWSS_LOG_NOTICE (" None default profile %s is configured on PG %s, won't reclaim buffer" , fvValue (prop).c_str (), buffer_pg_key.c_str ());
185- }
186- }
187- }
188- }
189-
190- return task_process_status::task_success;
191- }
192-
193145 if (m_pgProfileLookup.count (speed) == 0 || m_pgProfileLookup[speed].count (cable) == 0 )
194146 {
195147 SWSS_LOG_ERROR (" Unable to create/update PG profile for port %s. No PG profile configured for speed %s and cable length %s" ,
196148 port.c_str (), speed.c_str (), cable.c_str ());
197149 return task_process_status::task_invalid_entry;
198150 }
199151
152+ // Crete record in BUFFER_PROFILE table
153+ // key format is pg_lossless_<speed>_<cable>_profile
154+ string buffer_profile_key = " pg_lossless_" + speed + " _" + cable + " _profile" ;
155+
200156 // check if profile already exists - if yes - skip creation
201- m_cfgBufferProfileTable.get (buffer_profile_key, fvVectorProfile);
202- // Create record in BUFFER_PROFILE table
203- if (fvVectorProfile.size () == 0 )
157+ m_cfgBufferProfileTable.get (buffer_profile_key, fvVector);
158+ if (fvVector.size () == 0 )
204159 {
205160 SWSS_LOG_NOTICE (" Creating new profile '%s'" , buffer_profile_key.c_str ());
206161
@@ -218,24 +173,36 @@ task_process_status BufferMgr::doSpeedUpdateTask(string port, bool admin_up)
218173 m_cfgBufferProfileTable.getTableNameSeparator () +
219174 INGRESS_LOSSLESS_PG_POOL_NAME;
220175
221- fvVectorProfile .push_back (make_pair (" pool" , " [" + pg_pool_reference + " ]" ));
222- fvVectorProfile .push_back (make_pair (" xon" , m_pgProfileLookup[speed][cable].xon ));
176+ fvVector .push_back (make_pair (" pool" , " [" + pg_pool_reference + " ]" ));
177+ fvVector .push_back (make_pair (" xon" , m_pgProfileLookup[speed][cable].xon ));
223178 if (m_pgProfileLookup[speed][cable].xon_offset .length () > 0 ) {
224- fvVectorProfile .push_back (make_pair (" xon_offset" ,
179+ fvVector .push_back (make_pair (" xon_offset" ,
225180 m_pgProfileLookup[speed][cable].xon_offset ));
226181 }
227- fvVectorProfile .push_back (make_pair (" xoff" , m_pgProfileLookup[speed][cable].xoff ));
228- fvVectorProfile .push_back (make_pair (" size" , m_pgProfileLookup[speed][cable].size ));
229- fvVectorProfile .push_back (make_pair (mode, m_pgProfileLookup[speed][cable].threshold ));
230- m_cfgBufferProfileTable.set (buffer_profile_key, fvVectorProfile );
182+ fvVector .push_back (make_pair (" xoff" , m_pgProfileLookup[speed][cable].xoff ));
183+ fvVector .push_back (make_pair (" size" , m_pgProfileLookup[speed][cable].size ));
184+ fvVector .push_back (make_pair (mode, m_pgProfileLookup[speed][cable].threshold ));
185+ m_cfgBufferProfileTable.set (buffer_profile_key, fvVector );
231186 }
232187 else
233188 {
234189 SWSS_LOG_NOTICE (" Reusing existing profile '%s'" , buffer_profile_key.c_str ());
235190 }
236191
192+ fvVector.clear ();
193+
194+ string buffer_pg_key = port + m_cfgBufferPgTable.getTableNameSeparator () + LOSSLESS_PGS;
195+
196+ string profile_ref = string (" [" ) +
197+ CFG_BUFFER_PROFILE_TABLE_NAME +
198+ m_cfgBufferPgTable.getTableNameSeparator () +
199+ buffer_profile_key +
200+ " ]" ;
201+
237202 /* Check if PG Mapping is already then log message and return. */
238- for (auto & prop : fvVectorPg)
203+ m_cfgBufferPgTable.get (buffer_pg_key, fvVector);
204+
205+ for (auto & prop : fvVector)
239206 {
240207 if ((fvField (prop) == " profile" ) && (profile_ref == fvValue (prop)))
241208 {
@@ -244,10 +211,10 @@ task_process_status BufferMgr::doSpeedUpdateTask(string port, bool admin_up)
244211 }
245212 }
246213
247- fvVectorPg .clear ();
214+ fvVector .clear ();
248215
249- fvVectorPg .push_back (make_pair (" profile" , profile_ref));
250- m_cfgBufferPgTable.set (buffer_pg_key, fvVectorPg );
216+ fvVector .push_back (make_pair (" profile" , profile_ref));
217+ m_cfgBufferPgTable.set (buffer_pg_key, fvVector );
251218 return task_process_status::task_success;
252219}
253220
@@ -453,35 +420,26 @@ void BufferMgr::doTask(Consumer &consumer)
453420 task_process_status task_status = task_process_status::task_success;
454421 if (op == SET_COMMAND)
455422 {
456- if (table_name == CFG_PORT_CABLE_LEN_TABLE_NAME )
423+ for ( auto i : kfvFieldsValues (t) )
457424 {
458- // receive and cache cable length table
459- for (auto i : kfvFieldsValues (t))
425+ if (table_name == CFG_PORT_CABLE_LEN_TABLE_NAME)
460426 {
427+ // receive and cache cable length table
461428 task_status = doCableTask (fvField (i), fvValue (i));
462429 }
463- }
464- else if (m_pgfile_processed && table_name == CFG_PORT_TABLE_NAME)
465- {
466- bool admin_up = false ;
467- for (auto i : kfvFieldsValues (t))
430+ if (m_pgfile_processed && table_name == CFG_PORT_TABLE_NAME && (fvField (i) == " speed" || fvField (i) == " admin_status" ))
468431 {
469432 if (fvField (i) == " speed" )
470433 {
471434 m_speedLookup[port] = fvValue (i);
472435 }
473- if (fvField (i) == " admin_status" )
436+
437+ if (m_speedLookup.count (port) != 0 )
474438 {
475- admin_up = (" up" == fvValue (i));
439+ // create/update profile for port
440+ task_status = doSpeedUpdateTask (port);
476441 }
477442 }
478-
479- if (m_speedLookup.count (port) != 0 )
480- {
481- // create/update profile for port
482- task_status = doSpeedUpdateTask (port, admin_up);
483- }
484-
485443 if (task_status != task_process_status::task_success)
486444 {
487445 break ;
0 commit comments