@@ -22,6 +22,15 @@ BufferMgr::BufferMgr(DBConnector *cfgDb, DBConnector *stateDb, string pg_lookup_
22
22
m_cfgLosslessPgPoolTable(cfgDb, CFG_BUFFER_POOL_TABLE_NAME)
23
23
{
24
24
readPgProfileLookupFile (pg_lookup_file);
25
+ char *platform = getenv (" ASIC_VENDOR" );
26
+ if (NULL == platform)
27
+ {
28
+ SWSS_LOG_WARN (" Platform environment variable is not defined" );
29
+ }
30
+ else
31
+ {
32
+ m_platform = platform;
33
+ }
25
34
}
26
35
27
36
// # speed, cable, size, xon, xoff, threshold, xon_offset
@@ -112,11 +121,27 @@ Create/update two tables: profile (in m_cfgBufferProfileTable) and port buffer (
112
121
}
113
122
}
114
123
*/
115
- task_process_status BufferMgr::doSpeedUpdateTask (string port, string speed)
124
+ task_process_status BufferMgr::doPortTableUpdateTask (string port, string speed, bool admin_up )
116
125
{
117
- vector<FieldValueTuple> fvVector ;
126
+ vector<FieldValueTuple> fvVectorPg, fvVectorProfile ;
118
127
string cable;
119
128
129
+ string buffer_pg_key = port + m_cfgBufferPgTable.getTableNameSeparator () + LOSSLESS_PGS;
130
+
131
+ m_cfgBufferPgTable.get (buffer_pg_key, fvVectorPg);
132
+
133
+ if (!admin_up && m_platform == " mellanox" )
134
+ {
135
+ // Remove the entry in BUFFER_PG table if any
136
+ if (!fvVectorPg.empty ())
137
+ {
138
+ SWSS_LOG_NOTICE (" Removing PG %s from port %s which is administrative down" , buffer_pg_key.c_str (), port.c_str ());
139
+ m_cfgBufferPgTable.del (buffer_pg_key);
140
+ }
141
+
142
+ return task_process_status::task_success;
143
+ }
144
+
120
145
if (m_cableLenLookup.count (port) == 0 )
121
146
{
122
147
SWSS_LOG_INFO (" Unable to create/update PG profile for port %s. Cable length is not set" , port.c_str ());
@@ -137,8 +162,8 @@ task_process_status BufferMgr::doSpeedUpdateTask(string port, string speed)
137
162
string buffer_profile_key = " pg_lossless_" + speed + " _" + cable + " _profile" ;
138
163
139
164
// check if profile already exists - if yes - skip creation
140
- m_cfgBufferProfileTable.get (buffer_profile_key, fvVector );
141
- if (fvVector .size () == 0 )
165
+ m_cfgBufferProfileTable.get (buffer_profile_key, fvVectorProfile );
166
+ if (fvVectorProfile .size () == 0 )
142
167
{
143
168
SWSS_LOG_NOTICE (" Creating new profile '%s'" , buffer_profile_key.c_str ());
144
169
@@ -156,49 +181,42 @@ task_process_status BufferMgr::doSpeedUpdateTask(string port, string speed)
156
181
m_cfgBufferProfileTable.getTableNameSeparator () +
157
182
INGRESS_LOSSLESS_PG_POOL_NAME;
158
183
159
- fvVector .push_back (make_pair (" pool" , " [" + pg_pool_reference + " ]" ));
160
- fvVector .push_back (make_pair (" xon" , m_pgProfileLookup[speed][cable].xon ));
184
+ fvVectorProfile .push_back (make_pair (" pool" , " [" + pg_pool_reference + " ]" ));
185
+ fvVectorProfile .push_back (make_pair (" xon" , m_pgProfileLookup[speed][cable].xon ));
161
186
if (m_pgProfileLookup[speed][cable].xon_offset .length () > 0 ) {
162
- fvVector .push_back (make_pair (" xon_offset" ,
187
+ fvVectorProfile .push_back (make_pair (" xon_offset" ,
163
188
m_pgProfileLookup[speed][cable].xon_offset ));
164
189
}
165
- fvVector .push_back (make_pair (" xoff" , m_pgProfileLookup[speed][cable].xoff ));
166
- fvVector .push_back (make_pair (" size" , m_pgProfileLookup[speed][cable].size ));
167
- fvVector .push_back (make_pair (mode, m_pgProfileLookup[speed][cable].threshold ));
168
- m_cfgBufferProfileTable.set (buffer_profile_key, fvVector );
190
+ fvVectorProfile .push_back (make_pair (" xoff" , m_pgProfileLookup[speed][cable].xoff ));
191
+ fvVectorProfile .push_back (make_pair (" size" , m_pgProfileLookup[speed][cable].size ));
192
+ fvVectorProfile .push_back (make_pair (mode, m_pgProfileLookup[speed][cable].threshold ));
193
+ m_cfgBufferProfileTable.set (buffer_profile_key, fvVectorProfile );
169
194
}
170
195
else
171
196
{
172
197
SWSS_LOG_NOTICE (" Reusing existing profile '%s'" , buffer_profile_key.c_str ());
173
198
}
174
199
175
- fvVector.clear ();
176
-
177
- string buffer_pg_key = port + m_cfgBufferPgTable.getTableNameSeparator () + LOSSLESS_PGS;
178
-
179
200
string profile_ref = string (" [" ) +
180
201
CFG_BUFFER_PROFILE_TABLE_NAME +
181
202
m_cfgBufferPgTable.getTableNameSeparator () +
182
203
buffer_profile_key +
183
204
" ]" ;
184
205
185
206
/* Check if PG Mapping is already then log message and return. */
186
-
187
- m_cfgBufferPgTable.get (buffer_pg_key, fvVector);
188
-
189
- for (auto & prop : fvVector)
207
+ for (auto & prop : fvVectorPg)
190
208
{
191
209
if ((fvField (prop) == " profile" ) && (profile_ref == fvValue (prop)))
192
210
{
193
211
SWSS_LOG_NOTICE (" PG to Buffer Profile Mapping %s already present" , buffer_pg_key.c_str ());
194
212
return task_process_status::task_success;
195
213
}
196
214
}
197
-
198
- fvVector .clear ();
199
-
200
- fvVector .push_back (make_pair (" profile" , profile_ref));
201
- m_cfgBufferPgTable.set (buffer_pg_key, fvVector );
215
+
216
+ fvVectorPg .clear ();
217
+
218
+ fvVectorPg .push_back (make_pair (" profile" , profile_ref));
219
+ m_cfgBufferPgTable.set (buffer_pg_key, fvVectorPg );
202
220
return task_process_status::task_success;
203
221
}
204
222
@@ -221,23 +239,34 @@ void BufferMgr::doTask(Consumer &consumer)
221
239
task_process_status task_status = task_process_status::task_success;
222
240
if (op == SET_COMMAND)
223
241
{
224
- for ( auto i : kfvFieldsValues (t) )
242
+ if (table_name == CFG_PORT_CABLE_LEN_TABLE_NAME )
225
243
{
226
- if (table_name == CFG_PORT_CABLE_LEN_TABLE_NAME)
244
+ // receive and cache cable length table
245
+ for (auto i : kfvFieldsValues (t))
227
246
{
228
- // receive and cache cable length table
229
247
task_status = doCableTask (fvField (i), fvValue (i));
230
248
}
231
- // In case of PORT table update, Buffer Manager is interested in speed update only
232
- if (m_pgfile_processed && table_name == CFG_PORT_TABLE_NAME && fvField (i) == " speed" )
233
- {
234
- // create/update profile for port
235
- task_status = doSpeedUpdateTask (port, fvValue (i));
236
- }
237
- if (task_status != task_process_status::task_success)
249
+ }
250
+ else if (m_pgfile_processed && table_name == CFG_PORT_TABLE_NAME)
251
+ {
252
+ bool speed_updated = false , admin_status_updated = false , admin_up = false ;
253
+ string speed;
254
+ for (auto i : kfvFieldsValues (t))
238
255
{
239
- break ;
256
+ if (fvField (i) == " speed" )
257
+ {
258
+ speed_updated = true ;
259
+ speed = fvValue (i);
260
+ }
261
+ else if (fvField (i) == " admin_status" )
262
+ {
263
+ admin_status_updated = true ;
264
+ admin_up = (" up" == fvValue (i));
265
+ }
240
266
}
267
+
268
+ if (speed_updated || admin_status_updated)
269
+ task_status = doPortTableUpdateTask (port, speed, admin_up);
241
270
}
242
271
}
243
272
0 commit comments