2
2
#include " qosorch.h"
3
3
#include " logger.h"
4
4
#include " crmorch.h"
5
+ #include " sai_serialize.h"
5
6
6
7
#include < inttypes.h>
7
8
#include < stdlib.h>
@@ -41,8 +42,10 @@ enum {
41
42
RED_DROP_PROBABILITY_SET = (1U << 2 )
42
43
};
43
44
45
+ // field_name is what is expected in CONFIG_DB PORT_QOS_MAP table
44
46
map<string, sai_port_attr_t > qos_to_attr_map = {
45
47
{dscp_to_tc_field_name, SAI_PORT_ATTR_QOS_DSCP_TO_TC_MAP},
48
+ {dot1p_to_tc_field_name, SAI_PORT_ATTR_QOS_DOT1P_TO_TC_MAP},
46
49
{tc_to_queue_field_name, SAI_PORT_ATTR_QOS_TC_TO_QUEUE_MAP},
47
50
{tc_to_pg_map_field_name, SAI_PORT_ATTR_QOS_TC_TO_PRIORITY_GROUP_MAP},
48
51
{pfc_to_pg_map_name, SAI_PORT_ATTR_QOS_PFC_PRIORITY_TO_PRIORITY_GROUP_MAP},
@@ -51,6 +54,7 @@ map<string, sai_port_attr_t> qos_to_attr_map = {
51
54
52
55
type_map QosOrch::m_qos_maps = {
53
56
{CFG_DSCP_TO_TC_MAP_TABLE_NAME, new object_map ()},
57
+ {CFG_DOT1P_TO_TC_MAP_TABLE_NAME, new object_map ()},
54
58
{CFG_TC_TO_QUEUE_MAP_TABLE_NAME, new object_map ()},
55
59
{CFG_SCHEDULER_TABLE_NAME, new object_map ()},
56
60
{CFG_WRED_PROFILE_TABLE_NAME, new object_map ()},
@@ -216,6 +220,75 @@ task_process_status QosOrch::handleDscpToTcTable(Consumer& consumer)
216
220
return dscp_tc_handler.processWorkItem (consumer);
217
221
}
218
222
223
+ bool Dot1pToTcMapHandler::convertFieldValuesToAttributes (KeyOpFieldsValuesTuple &tuple, vector<sai_attribute_t > &attributes)
224
+ {
225
+ SWSS_LOG_ENTER ();
226
+ sai_qos_map_list_t dot1p_map_list;
227
+
228
+ // Allocated resources are freed in freeAttribResources() call
229
+ dot1p_map_list.list = new sai_qos_map_t [kfvFieldsValues (tuple).size ()];
230
+ int i = 0 ;
231
+ for (const auto &fv : kfvFieldsValues (tuple))
232
+ {
233
+ try
234
+ {
235
+ dot1p_map_list.list [i].key .dot1p = static_cast <sai_uint8_t >(stoi (fvField (fv)));
236
+ dot1p_map_list.list [i].value .tc = static_cast <sai_cos_t >(stoi (fvValue (fv)));
237
+ }
238
+ catch (const std::invalid_argument &e)
239
+ {
240
+ SWSS_LOG_ERROR (" Invalid dot1p to tc argument %s:%s to %s()" , fvField (fv).c_str (), fvValue (fv).c_str (), e.what ());
241
+ continue ;
242
+ }
243
+ catch (const std::out_of_range &e)
244
+ {
245
+ SWSS_LOG_ERROR (" Out of range dot1p to tc argument %s:%s to %s()" , fvField (fv).c_str (), fvValue (fv).c_str (), e.what ());
246
+ continue ;
247
+ }
248
+
249
+ i++;
250
+ }
251
+ dot1p_map_list.count = static_cast <uint32_t >(i);
252
+
253
+ sai_attribute_t attr;
254
+ attr.id = SAI_QOS_MAP_ATTR_MAP_TO_VALUE_LIST;
255
+ attr.value .qosmap .count = dot1p_map_list.count ;
256
+ attr.value .qosmap .list = dot1p_map_list.list ;
257
+ attributes.push_back (attr);
258
+
259
+ return true ;
260
+ }
261
+
262
+ sai_object_id_t Dot1pToTcMapHandler::addQosItem (const vector<sai_attribute_t > &attributes)
263
+ {
264
+ SWSS_LOG_ENTER ();
265
+ vector<sai_attribute_t > attrs;
266
+
267
+ sai_attribute_t attr;
268
+ attr.id = SAI_QOS_MAP_ATTR_TYPE;
269
+ attr.value .u32 = SAI_QOS_MAP_TYPE_DOT1P_TO_TC;
270
+ attrs.push_back (attr);
271
+
272
+ attrs.push_back (attributes[0 ]);
273
+
274
+ sai_object_id_t object_id;
275
+ sai_status_t sai_status = sai_qos_map_api->create_qos_map (&object_id, gSwitchId , (uint32_t )attrs.size (), attrs.data ());
276
+ if (SAI_STATUS_SUCCESS != sai_status)
277
+ {
278
+ SWSS_LOG_ERROR (" Failed to create dot1p_to_tc map. status: %s" , sai_serialize_status (sai_status).c_str ());
279
+ return SAI_NULL_OBJECT_ID;
280
+ }
281
+ SWSS_LOG_DEBUG (" created QosMap object: 0x%lx" , object_id);
282
+ return object_id;
283
+ }
284
+
285
+ task_process_status QosOrch::handleDot1pToTcTable (Consumer &consumer)
286
+ {
287
+ SWSS_LOG_ENTER ();
288
+ Dot1pToTcMapHandler dot1p_tc_handler;
289
+ return dot1p_tc_handler.processWorkItem (consumer);
290
+ }
291
+
219
292
bool TcToQueueMapHandler::convertFieldValuesToAttributes (KeyOpFieldsValuesTuple &tuple, vector<sai_attribute_t > &attributes)
220
293
{
221
294
SWSS_LOG_ENTER ();
@@ -800,6 +873,7 @@ void QosOrch::initTableHandlers()
800
873
{
801
874
SWSS_LOG_ENTER ();
802
875
m_qos_handler_map.insert (qos_handler_pair (CFG_DSCP_TO_TC_MAP_TABLE_NAME, &QosOrch::handleDscpToTcTable));
876
+ m_qos_handler_map.insert (qos_handler_pair (CFG_DOT1P_TO_TC_MAP_TABLE_NAME, &QosOrch::handleDot1pToTcTable));
803
877
m_qos_handler_map.insert (qos_handler_pair (CFG_TC_TO_QUEUE_MAP_TABLE_NAME, &QosOrch::handleTcToQueueTable));
804
878
m_qos_handler_map.insert (qos_handler_pair (CFG_SCHEDULER_TABLE_NAME, &QosOrch::handleSchedulerTable));
805
879
m_qos_handler_map.insert (qos_handler_pair (CFG_QUEUE_TABLE_NAME, &QosOrch::handleQueueTable));
0 commit comments