@@ -79,6 +79,8 @@ type_map QosOrch::m_qos_maps = {
79
79
{CFG_PFC_PRIORITY_TO_QUEUE_MAP_TABLE_NAME, new object_reference_map ()},
80
80
{CFG_DSCP_TO_FC_MAP_TABLE_NAME, new object_reference_map ()},
81
81
{CFG_EXP_TO_FC_MAP_TABLE_NAME, new object_reference_map ()},
82
+ {CFG_TC_TO_DSCP_MAP_TABLE_NAME, new object_reference_map ()},
83
+ {APP_TUNNEL_DECAP_TABLE_NAME, new object_reference_map ()}
82
84
};
83
85
84
86
map<string, string> qos_to_ref_table_map = {
@@ -92,7 +94,11 @@ map<string, string> qos_to_ref_table_map = {
92
94
{scheduler_field_name, CFG_SCHEDULER_TABLE_NAME},
93
95
{wred_profile_field_name, CFG_WRED_PROFILE_TABLE_NAME},
94
96
{dscp_to_fc_field_name, CFG_DSCP_TO_FC_MAP_TABLE_NAME},
95
- {exp_to_fc_field_name, CFG_EXP_TO_FC_MAP_TABLE_NAME}
97
+ {exp_to_fc_field_name, CFG_EXP_TO_FC_MAP_TABLE_NAME},
98
+ {decap_dscp_to_tc_field_name, CFG_DSCP_TO_TC_MAP_TABLE_NAME},
99
+ {decap_tc_to_pg_field_name, CFG_TC_TO_PRIORITY_GROUP_MAP_TABLE_NAME},
100
+ {encap_tc_to_dscp_field_name, CFG_TC_TO_DSCP_MAP_TABLE_NAME},
101
+ {encap_tc_to_queue_field_name, CFG_TC_TO_QUEUE_MAP_TABLE_NAME}
96
102
};
97
103
98
104
#define DSCP_MAX_VAL 63
@@ -1063,6 +1069,82 @@ sai_object_id_t ExpToFcMapHandler::addQosItem(const vector<sai_attribute_t> &att
1063
1069
return sai_object;
1064
1070
}
1065
1071
1072
+ bool TcToDscpMapHandler::convertFieldValuesToAttributes (KeyOpFieldsValuesTuple &tuple,
1073
+ vector<sai_attribute_t > &attributes)
1074
+ {
1075
+ SWSS_LOG_ENTER ();
1076
+
1077
+ sai_attribute_t list_attr;
1078
+ list_attr.id = SAI_QOS_MAP_ATTR_MAP_TO_VALUE_LIST;
1079
+ list_attr.value .qosmap .count = (uint32_t )kfvFieldsValues (tuple).size ();
1080
+ list_attr.value .qosmap .list = new sai_qos_map_t [list_attr.value .qosmap .count ]();
1081
+ uint32_t ind = 0 ;
1082
+
1083
+ for (auto i = kfvFieldsValues (tuple).begin (); i != kfvFieldsValues (tuple).end (); i++, ind++)
1084
+ {
1085
+ try
1086
+ {
1087
+ auto value = stoi (fvValue (*i));
1088
+ if (value < 0 )
1089
+ {
1090
+ SWSS_LOG_ERROR (" DSCP value %d is negative" , value);
1091
+ delete[] list_attr.value .qosmap .list ;
1092
+ return false ;
1093
+ }
1094
+ else if (value > DSCP_MAX_VAL)
1095
+ {
1096
+ SWSS_LOG_ERROR (" DSCP value %d is greater than max value %d" , value, DSCP_MAX_VAL);
1097
+ delete[] list_attr.value .qosmap .list ;
1098
+ return false ;
1099
+ }
1100
+ list_attr.value .qosmap .list [ind].key .tc = static_cast <sai_uint8_t >(stoi (fvField (*i)));
1101
+ list_attr.value .qosmap .list [ind].value .dscp = static_cast <sai_uint8_t >(value);
1102
+
1103
+ SWSS_LOG_DEBUG (" key.tc:%d, value.dscp:%d" ,
1104
+ list_attr.value .qosmap .list [ind].key .tc ,
1105
+ list_attr.value .qosmap .list [ind].value .dscp );
1106
+ }
1107
+ catch (const invalid_argument& e)
1108
+ {
1109
+ SWSS_LOG_ERROR (" Got exception during conversion: %s" , e.what ());
1110
+ delete[] list_attr.value .qosmap .list ;
1111
+ return false ;
1112
+ }
1113
+ }
1114
+ attributes.push_back (list_attr);
1115
+ return true ;
1116
+ }
1117
+
1118
+ sai_object_id_t TcToDscpMapHandler::addQosItem (const vector<sai_attribute_t > &attributes)
1119
+ {
1120
+ SWSS_LOG_ENTER ();
1121
+ sai_status_t sai_status;
1122
+ sai_object_id_t sai_object;
1123
+ vector<sai_attribute_t > qos_map_attrs;
1124
+
1125
+ sai_attribute_t qos_map_attr;
1126
+ qos_map_attr.id = SAI_QOS_MAP_ATTR_TYPE;
1127
+ qos_map_attr.value .u32 = SAI_QOS_MAP_TYPE_TC_AND_COLOR_TO_DSCP;
1128
+ qos_map_attrs.push_back (qos_map_attr);
1129
+
1130
+ qos_map_attr.id = SAI_QOS_MAP_ATTR_MAP_TO_VALUE_LIST;
1131
+ qos_map_attr.value .qosmap .count = attributes[0 ].value .qosmap .count ;
1132
+ qos_map_attr.value .qosmap .list = attributes[0 ].value .qosmap .list ;
1133
+ qos_map_attrs.push_back (qos_map_attr);
1134
+
1135
+ sai_status = sai_qos_map_api->create_qos_map (&sai_object,
1136
+ gSwitchId ,
1137
+ (uint32_t )qos_map_attrs.size (),
1138
+ qos_map_attrs.data ());
1139
+ if (SAI_STATUS_SUCCESS != sai_status)
1140
+ {
1141
+ SWSS_LOG_ERROR (" Failed to create tc_to_dscp map. status:%d" , sai_status);
1142
+ return SAI_NULL_OBJECT_ID;
1143
+ }
1144
+ SWSS_LOG_DEBUG (" created QosMap object:%" PRIx64, sai_object);
1145
+ return sai_object;
1146
+ }
1147
+
1066
1148
task_process_status QosOrch::handleExpToFcTable (Consumer& consumer, KeyOpFieldsValuesTuple &tuple)
1067
1149
{
1068
1150
SWSS_LOG_ENTER ();
@@ -1077,6 +1159,13 @@ task_process_status QosOrch::handlePfcToQueueTable(Consumer& consumer, KeyOpFiel
1077
1159
return pfc_to_queue_handler.processWorkItem (consumer, tuple);
1078
1160
}
1079
1161
1162
+ task_process_status QosOrch::handleTcToDscpTable (Consumer& consumer, KeyOpFieldsValuesTuple &tuple)
1163
+ {
1164
+ SWSS_LOG_ENTER ();
1165
+ TcToDscpMapHandler tc_to_dscp_handler;
1166
+ return tc_to_dscp_handler.processWorkItem (consumer, tuple);
1167
+ }
1168
+
1080
1169
QosOrch::QosOrch (DBConnector *db, vector<string> &tableNames) : Orch(db, tableNames)
1081
1170
{
1082
1171
SWSS_LOG_ENTER ();
@@ -1103,6 +1192,7 @@ void QosOrch::initTableHandlers()
1103
1192
m_qos_handler_map.insert (qos_handler_pair (CFG_WRED_PROFILE_TABLE_NAME, &QosOrch::handleWredProfileTable));
1104
1193
m_qos_handler_map.insert (qos_handler_pair (CFG_DSCP_TO_FC_MAP_TABLE_NAME, &QosOrch::handleDscpToFcTable));
1105
1194
m_qos_handler_map.insert (qos_handler_pair (CFG_EXP_TO_FC_MAP_TABLE_NAME, &QosOrch::handleExpToFcTable));
1195
+ m_qos_handler_map.insert (qos_handler_pair (CFG_TC_TO_DSCP_MAP_TABLE_NAME, &QosOrch::handleTcToDscpTable));
1106
1196
1107
1197
m_qos_handler_map.insert (qos_handler_pair (CFG_TC_TO_PRIORITY_GROUP_MAP_TABLE_NAME, &QosOrch::handleTcToPgTable));
1108
1198
m_qos_handler_map.insert (qos_handler_pair (CFG_PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_TABLE_NAME, &QosOrch::handlePfcPrioToPgTable));
@@ -1859,3 +1949,35 @@ void QosOrch::doTask(Consumer &consumer)
1859
1949
}
1860
1950
}
1861
1951
}
1952
+
1953
+ /* *
1954
+ * Function Description:
1955
+ * @brief Resolve the id of QoS map that is referenced by tunnel
1956
+ *
1957
+ * Arguments:
1958
+ * @param[in] referencing_table_name - The name of table that is referencing the QoS map
1959
+ * @param[in] tunnle_name - The name of tunnel
1960
+ * @param[in] map_type_name - The type of referenced QoS map
1961
+ * @param[in] tuple - The KeyOpFieldsValuesTuple that contains keys - values
1962
+ *
1963
+ * Return Values:
1964
+ * @return The sai_object_id of referenced map, or SAI_NULL_OBJECT_ID if there's an error
1965
+ */
1966
+ sai_object_id_t QosOrch::resolveTunnelQosMap (std::string referencing_table_name, std::string tunnel_name, std::string map_type_name, KeyOpFieldsValuesTuple& tuple)
1967
+ {
1968
+ sai_object_id_t id;
1969
+ string object_name;
1970
+ ref_resolve_status status = resolveFieldRefValue (m_qos_maps, map_type_name, qos_to_ref_table_map.at (map_type_name), tuple, id, object_name);
1971
+ if (status == ref_resolve_status::success)
1972
+ {
1973
+
1974
+ setObjectReference (m_qos_maps, referencing_table_name, tunnel_name, map_type_name, object_name);
1975
+ SWSS_LOG_INFO (" Resolved QoS map for table %s tunnel %s type %s name %s" , referencing_table_name.c_str (), tunnel_name.c_str (), map_type_name.c_str (), object_name.c_str ());
1976
+ return id;
1977
+ }
1978
+ else
1979
+ {
1980
+ SWSS_LOG_ERROR (" Failed to resolve QoS map for table %s tunnel %s type %s" , referencing_table_name.c_str (), tunnel_name.c_str (), map_type_name.c_str ());
1981
+ return SAI_NULL_OBJECT_ID;
1982
+ }
1983
+ }
0 commit comments