diff --git a/.gitignore b/.gitignore index 164c5d9b4..3bf6401fd 100644 --- a/.gitignore +++ b/.gitignore @@ -73,3 +73,4 @@ meta/tests ################### **/*~ **/*.swp +**/*.rec diff --git a/lib/inc/sairedis.h b/lib/inc/sairedis.h index 679de6897..ac7b30fc4 100644 --- a/lib/inc/sairedis.h +++ b/lib/inc/sairedis.h @@ -8,6 +8,7 @@ extern "C" { #define SYNCD_INIT_VIEW "INIT_VIEW" #define SYNCD_APPLY_VIEW "APPLY_VIEW" #define ASIC_STATE_TABLE "ASIC_STATE" +#define TEMP_PREFIX "TEMP_" typedef enum _sai_redis_notify_syncd_t { diff --git a/lib/src/sai_redis_generic_create.cpp b/lib/src/sai_redis_generic_create.cpp index 979b4dead..4ad6ad66e 100644 --- a/lib/src/sai_redis_generic_create.cpp +++ b/lib/src/sai_redis_generic_create.cpp @@ -23,7 +23,7 @@ sai_object_id_t redis_create_virtual_object_id( sai_object_id_t objectId = (((sai_object_id_t)object_type) << 48) | virtual_id; - SWSS_LOG_DEBUG("created VID %llx", objectId); + SWSS_LOG_DEBUG("created VID 0x%lx", objectId); return objectId; } diff --git a/meta/sai_extra_tunnel.cpp b/meta/sai_extra_tunnel.cpp index ac98cc845..3a12f19bf 100644 --- a/meta/sai_extra_tunnel.cpp +++ b/meta/sai_extra_tunnel.cpp @@ -34,7 +34,7 @@ sai_status_t meta_pre_create_tunnel_map( const sai_tunnel_map_t* tunnel_map = &tunnel_map_list->list[i]; // TODO validate tunnel map - SWSS_LOG_DEBUG("tunnel map pointer: %llx", tunnel_map); + SWSS_LOG_DEBUG("tunnel map pointer: %p", tunnel_map); } } diff --git a/meta/sai_meta.cpp b/meta/sai_meta.cpp index 2fa16bbf5..f81a54402 100644 --- a/meta/sai_meta.cpp +++ b/meta/sai_meta.cpp @@ -368,7 +368,7 @@ bool object_reference_exists( bool exists = ObjectReferences.find(oid) != ObjectReferences.end(); - SWSS_LOG_DEBUG("object 0x%llx refrence: %s", oid, exists ? "exists" : "missing"); + SWSS_LOG_DEBUG("object 0x%lx refrence: %s", oid, exists ? "exists" : "missing"); return exists; } @@ -385,13 +385,13 @@ void object_reference_inc( if (!object_reference_exists(oid)) { - SWSS_LOG_ERROR("FATAL: object oid 0x%llx not in reference map", oid); + SWSS_LOG_ERROR("FATAL: object oid 0x%lx not in reference map", oid); throw; } ObjectReferences[oid]++; - SWSS_LOG_DEBUG("increased reference on oid 0x%llx to %d", oid, ObjectReferences[oid]); + SWSS_LOG_DEBUG("increased reference on oid 0x%lx to %d", oid, ObjectReferences[oid]); } void object_reference_dec( @@ -406,7 +406,7 @@ void object_reference_dec( if (!object_reference_exists(oid)) { - SWSS_LOG_ERROR("FATAL: object oid 0x%llx not in reference map", oid); + SWSS_LOG_ERROR("FATAL: object oid 0x%lx not in reference map", oid); throw; } @@ -414,11 +414,11 @@ void object_reference_dec( if (ObjectReferences[oid] < 0) { - SWSS_LOG_ERROR("FATAL: object oid 0x%llx reference count is negative!", oid); + SWSS_LOG_ERROR("FATAL: object oid 0x%lx reference count is negative!", oid); throw; } - SWSS_LOG_DEBUG("decreased reference on oid 0x%llx to %d", oid, ObjectReferences[oid]); + SWSS_LOG_DEBUG("decreased reference on oid 0x%lx to %d", oid, ObjectReferences[oid]); } void object_reference_dec( @@ -450,13 +450,13 @@ void object_reference_insert( if (object_reference_exists(oid)) { - SWSS_LOG_ERROR("FATAL: object oid 0x%llx already in reference map"); + SWSS_LOG_ERROR("FATAL: object oid 0x%lx already in reference map", oid); throw; } ObjectReferences[oid] = 0; - SWSS_LOG_DEBUG("inserted reference on 0x%llx", oid); + SWSS_LOG_DEBUG("inserted reference on 0x%lx", oid); } int32_t object_reference_count( @@ -468,12 +468,12 @@ int32_t object_reference_count( { int32_t count = ObjectReferences[oid]; - SWSS_LOG_DEBUG("reference count on oid 0x%llx is %d", oid, count); + SWSS_LOG_DEBUG("reference count on oid 0x%lx is %d", oid, count); return count; } - SWSS_LOG_ERROR("FATAL: object oid 0x%llx reference not in map", oid); + SWSS_LOG_ERROR("FATAL: object oid 0x%lx reference not in map", oid); throw; } @@ -488,12 +488,12 @@ void object_reference_remove( if (count > 0) { - SWSS_LOG_ERROR("FATAL: removing object oid 0x%llx but reference count is: %d", oid, count); + SWSS_LOG_ERROR("FATAL: removing object oid 0x%lx but reference count is: %d", oid, count); throw; } } - SWSS_LOG_DEBUG("removing object oid 0x%llx reference", oid); + SWSS_LOG_DEBUG("removing object oid 0x%lx reference", oid); ObjectReferences.erase(oid); } @@ -580,7 +580,7 @@ int32_t vlan_reference_count( return count; } - SWSS_LOG_ERROR("FATAL: vlan vlanid 0x%llx reference not in map", vlanid); + SWSS_LOG_ERROR("FATAL: vlan vlanid %d reference not in map", vlanid); throw; } @@ -595,7 +595,7 @@ void vlan_reference_remove( if (count > 0) { - SWSS_LOG_ERROR("FATAL: removing vlan vlanid 0x%llx but reference count is: %d", vlanid, count); + SWSS_LOG_ERROR("FATAL: removing vlan vlanid %d but reference count is: %d", vlanid, count); throw; } } @@ -841,7 +841,7 @@ sai_status_t meta_generic_validation_objlist( if (oids.find(oid) != oids.end()) { - META_LOG_ERROR(md, "object on list [%u] oid 0x%llx is duplicated, but not allowed", i, oid); + META_LOG_ERROR(md, "object on list [%u] oid 0x%lx is duplicated, but not allowed", i, oid); return SAI_STATUS_INVALID_PARAMETER; } @@ -865,21 +865,21 @@ sai_status_t meta_generic_validation_objlist( if (ot == SAI_NULL_OBJECT_ID) { - META_LOG_ERROR(md, "object on list [%u] oid 0x%llx is not valid, returned null object id", i, oid); + META_LOG_ERROR(md, "object on list [%u] oid 0x%lx is not valid, returned null object id", i, oid); return SAI_STATUS_INVALID_PARAMETER; } if (md.allowedobjecttypes.find(ot) == md.allowedobjecttypes.end()) { - META_LOG_ERROR(md, "object on list [%u] oid 0x%llx object type %d is not allowed on this attribute", i, oid, ot); + META_LOG_ERROR(md, "object on list [%u] oid 0x%lx object type %d is not allowed on this attribute", i, oid, ot); return SAI_STATUS_INVALID_PARAMETER; } if (!object_reference_exists(oid)) { - META_LOG_ERROR(md, "object on list [%u] oid 0x%llx object type %d does not exists in local DB", i, oid, ot); + META_LOG_ERROR(md, "object on list [%u] oid 0x%lx object type %d does not exists in local DB", i, oid, ot); return SAI_STATUS_INVALID_PARAMETER; } @@ -1304,7 +1304,7 @@ sai_status_t meta_generic_validation_create( if (value.u32range.min > value.u32range.max) { - META_LOG_ERROR(md, "invalid range %u .. %u", value.u32range.min > value.u32range.max); + META_LOG_ERROR(md, "invalid range %u .. %u", value.u32range.min, value.u32range.max); return SAI_STATUS_INVALID_PARAMETER; } @@ -1315,7 +1315,7 @@ sai_status_t meta_generic_validation_create( if (value.s32range.min > value.s32range.max) { - META_LOG_ERROR(md, "invalid range %u .. %u", value.s32range.min > value.s32range.max); + META_LOG_ERROR(md, "invalid range %u .. %u", value.s32range.min, value.s32range.max); return SAI_STATUS_INVALID_PARAMETER; } @@ -1649,21 +1649,21 @@ sai_status_t meta_generic_validation_remove( if (object_type == SAI_NULL_OBJECT_ID) { - SWSS_LOG_ERROR("oid 0x%llx is not valid, returned null object id", oid); + SWSS_LOG_ERROR("oid 0x%lx is not valid, returned null object id", oid); return SAI_STATUS_INVALID_PARAMETER; } if (object_type != meta_key.object_type) { - SWSS_LOG_ERROR("oid 0x%llx type %d is not accepted, expected object type %d", oid, object_type, meta_key.object_type); + SWSS_LOG_ERROR("oid 0x%lx type %d is not accepted, expected object type %d", oid, object_type, meta_key.object_type); return SAI_STATUS_INVALID_PARAMETER; } if (!object_reference_exists(oid)) { - SWSS_LOG_ERROR("object 0x%llx reference don't exists", oid); + SWSS_LOG_ERROR("object 0x%lx reference don't exists", oid); return SAI_STATUS_INVALID_PARAMETER; } @@ -1672,7 +1672,7 @@ sai_status_t meta_generic_validation_remove( if (count != 0) { - SWSS_LOG_ERROR("object 0x%llx reference count is %d, can't remove", oid, count); + SWSS_LOG_ERROR("object 0x%lx reference count is %d, can't remove", oid, count); return SAI_STATUS_INVALID_PARAMETER; } @@ -1921,7 +1921,7 @@ sai_status_t meta_generic_validation_set( if (value.u32range.min > value.u32range.max) { - META_LOG_ERROR(md, "invalid range %u .. %u", value.u32range.min > value.u32range.max); + META_LOG_ERROR(md, "invalid range %u .. %u", value.u32range.min, value.u32range.max); return SAI_STATUS_INVALID_PARAMETER; } @@ -1932,7 +1932,7 @@ sai_status_t meta_generic_validation_set( if (value.s32range.min > value.s32range.max) { - META_LOG_ERROR(md, "invalid range %u .. %u", value.s32range.min > value.s32range.max); + META_LOG_ERROR(md, "invalid range %u .. %u", value.s32range.min, value.s32range.max); return SAI_STATUS_INVALID_PARAMETER; } @@ -2056,14 +2056,14 @@ sai_status_t meta_generic_validation_set( if (object_type == SAI_NULL_OBJECT_ID) { - META_LOG_ERROR(md, "oid 0x%llx is not valid, returned null object id", oid); + META_LOG_ERROR(md, "oid 0x%lx is not valid, returned null object id", oid); return SAI_STATUS_INVALID_PARAMETER; } if (object_type != meta_key.object_type) { - META_LOG_ERROR(md, "oid 0x%llx type %d is not accepted, expected object type %d", oid, object_type, meta_key.object_type); + META_LOG_ERROR(md, "oid 0x%lx type %d is not accepted, expected object type %d", oid, object_type, meta_key.object_type); return SAI_STATUS_INVALID_PARAMETER; } @@ -2311,14 +2311,14 @@ sai_status_t meta_generic_validation_get( if (object_type == SAI_NULL_OBJECT_ID) { - SWSS_LOG_ERROR("oid 0x%llx is not valid, returned null object id", oid); + SWSS_LOG_ERROR("oid 0x%lx is not valid, returned null object id", oid); return SAI_STATUS_INVALID_PARAMETER; } if (object_type != meta_key.object_type) { - SWSS_LOG_ERROR("oid 0x%llx type %d is not accepted, expected object type %d", oid, object_type, meta_key.object_type); + SWSS_LOG_ERROR("oid 0x%lx type %d is not accepted, expected object type %d", oid, object_type, meta_key.object_type); return SAI_STATUS_INVALID_PARAMETER; } @@ -2392,13 +2392,13 @@ void meta_generic_validation_post_create( if (object_type == SAI_NULL_OBJECT_ID) { - SWSS_LOG_ERROR("created oid 0x%llx is not valid object type after create, returned null object id (vendor bug?)", oid); + SWSS_LOG_ERROR("created oid 0x%lx is not valid object type after create, returned null object id (vendor bug?)", oid); break; } if (object_type != meta_key.object_type) { - SWSS_LOG_ERROR("created oid 0x%llx type %d is wrond type, expected object type %d (vendor bug?)", oid, object_type, meta_key.object_type); + SWSS_LOG_ERROR("created oid 0x%lx type %d is wrond type, expected object type %d (vendor bug?)", oid, object_type, meta_key.object_type); break; } @@ -2956,13 +2956,13 @@ void meta_generic_validation_post_get_objlist( if (ot == SAI_NULL_OBJECT_ID) { - META_LOG_ERROR(md, "returned get object on list [%u] oid 0x%llx is not valid, returned null object id", i, oid); + META_LOG_ERROR(md, "returned get object on list [%u] oid 0x%lx is not valid, returned null object id", i, oid); continue; } if (md.allowedobjecttypes.find(ot) == md.allowedobjecttypes.end()) { - META_LOG_ERROR(md, "returned get object on list [%u] oid 0x%llx object type %d is not allowed on this attribute", i, oid, ot); + META_LOG_ERROR(md, "returned get object on list [%u] oid 0x%lx object type %d is not allowed on this attribute", i, oid, ot); } if (!object_reference_exists(oid)) @@ -2971,7 +2971,7 @@ void meta_generic_validation_post_get_objlist( // and first list was retrived ok, but second failed with overflow // then we may forget to snoop - META_LOG_INFO(md, "returned get object on list [%u] oid 0x%llx object type %d does not exists in local DB (snoop)", i, oid, ot); + META_LOG_INFO(md, "returned get object on list [%u] oid 0x%lx object type %d does not exists in local DB (snoop)", i, oid, ot); sai_object_meta_key_t key = { .object_type = ot, .key = { .object_id = oid } }; @@ -3149,7 +3149,7 @@ void meta_generic_validation_post_get( if (value.u32range.min > value.u32range.max) { - META_LOG_ERROR(md, "invalid range %u .. %u", value.u32range.min > value.u32range.max); + META_LOG_ERROR(md, "invalid range %u .. %u", value.u32range.min, value.u32range.max); } break; @@ -3158,7 +3158,7 @@ void meta_generic_validation_post_get( if (value.s32range.min > value.s32range.max) { - META_LOG_ERROR(md, "invalid range %u .. %u", value.s32range.min > value.s32range.max); + META_LOG_ERROR(md, "invalid range %u .. %u", value.s32range.min, value.s32range.max); } break; @@ -3632,7 +3632,7 @@ sai_status_t meta_sai_validate_neighbor_entry( if (object_type == SAI_NULL_OBJECT_ID) { - SWSS_LOG_ERROR("router interface oid 0x%llx is not valid object type, returned null object id", rif); + SWSS_LOG_ERROR("router interface oid 0x%lx is not valid object type, returned null object id", rif); return SAI_STATUS_INVALID_PARAMETER; } @@ -3641,7 +3641,7 @@ sai_status_t meta_sai_validate_neighbor_entry( if (object_type != expected) { - SWSS_LOG_ERROR("router interface oid 0x%llx type %d is wrond type, expected object type %d", rif, object_type, expected); + SWSS_LOG_ERROR("router interface oid 0x%lx type %d is wrond type, expected object type %d", rif, object_type, expected); return SAI_STATUS_INVALID_PARAMETER; } @@ -4182,7 +4182,7 @@ sai_status_t meta_sai_validate_route_entry( if (object_type == SAI_NULL_OBJECT_ID) { - SWSS_LOG_ERROR("virtual router oid 0x%llx is not valid object type, returned null object id", vr); + SWSS_LOG_ERROR("virtual router oid 0x%lx is not valid object type, returned null object id", vr); return SAI_STATUS_INVALID_PARAMETER; } @@ -4191,7 +4191,7 @@ sai_status_t meta_sai_validate_route_entry( if (object_type != expected) { - SWSS_LOG_ERROR("virtual router oid 0x%llx type %d is wrond type, expected object type %d", vr, object_type, expected); + SWSS_LOG_ERROR("virtual router oid 0x%lx type %d is wrond type, expected object type %d", vr, object_type, expected); return SAI_STATUS_INVALID_PARAMETER; } @@ -4613,7 +4613,7 @@ sai_status_t meta_sai_validate_oid( if (ot == SAI_NULL_OBJECT_ID) { - SWSS_LOG_ERROR("%s oid 0x%llx is not valid object type, returned null object id", otname, oid); + SWSS_LOG_ERROR("%s oid 0x%lx is not valid object type, returned null object id", otname, oid); return SAI_STATUS_INVALID_PARAMETER; } @@ -4622,7 +4622,7 @@ sai_status_t meta_sai_validate_oid( if (ot != expected) { - SWSS_LOG_ERROR("%s oid 0x%llx type %d is wrond type, expected object type %d", otname, oid, ot, expected); + SWSS_LOG_ERROR("%s oid 0x%lx type %d is wrond type, expected object type %d", otname, oid, ot, expected); return SAI_STATUS_INVALID_PARAMETER; } diff --git a/meta/saiserialize.cpp b/meta/saiserialize.cpp index 6294c86af..932130626 100644 --- a/meta/saiserialize.cpp +++ b/meta/saiserialize.cpp @@ -219,11 +219,6 @@ sai_status_t transfer_attribute( RETURN_ON_ERROR(transfer_list(src_attr.value.vlanlist, dst_attr.value.vlanlist, countOnly)); break; - case SAI_SERIALIZATION_TYPE_PORT_BREAKOUT: - transfer_primitive(src_attr.value.portbreakout.breakout_mode, dst_attr.value.portbreakout.breakout_mode); - RETURN_ON_ERROR(transfer_list(src_attr.value.portbreakout.port_list, dst_attr.value.portbreakout.port_list, countOnly)); - break; - case SAI_SERIALIZATION_TYPE_QOS_MAP_LIST: RETURN_ON_ERROR(transfer_list(src_attr.value.qosmap, dst_attr.value.qosmap, countOnly)); break; @@ -2526,7 +2521,7 @@ void sai_deserialize_free_attribute_value( break; default: - SWSS_LOG_ERROR("unsupported type on deserialize free %s, FIXME", type); + SWSS_LOG_ERROR("unsupported type %d on deserialize free, FIXME", type); throw std::runtime_error("unsupported type on deserialize free, FIXME"); } } diff --git a/meta/tests.cpp b/meta/tests.cpp index c277f03c9..3f626c0ba 100644 --- a/meta/tests.cpp +++ b/meta/tests.cpp @@ -43,7 +43,7 @@ sai_object_id_t create_dummy_object_id( sai_object_id_t oid = (((sai_object_id_t)objecttype) << 48) | ++index; - SWSS_LOG_DEBUG("created oid 0x%llx", oid); + SWSS_LOG_DEBUG("created oid 0x%lx", oid); return oid; } @@ -58,7 +58,7 @@ sai_object_type_t sai_object_type_query( if ((objecttype <= SAI_OBJECT_TYPE_NULL) || (objecttype >= SAI_OBJECT_TYPE_MAX)) { - SWSS_LOG_ERROR("invalid oid %d", oid); + SWSS_LOG_ERROR("invalid oid 0x%lx", oid); return SAI_OBJECT_TYPE_NULL; } diff --git a/saidump/saidump.cpp b/saidump/saidump.cpp index 3adea43c2..8c9fa177d 100644 --- a/saidump/saidump.cpp +++ b/saidump/saidump.cpp @@ -23,6 +23,7 @@ struct CmdOptions bool disableColors; bool skipAttributes; bool followReferences; + bool dumpTempView; }; CmdOptions g_cmdOptions; @@ -32,11 +33,13 @@ void printUsage() { SWSS_LOG_ENTER(); - std::cout << "Usage: saidump [-C] [-s] [-h]" << std::endl; + std::cout << "Usage: saidump [-C] [-s] [-h] [-t]" << std::endl; std::cout << " -C --disableColors" << std::endl; std::cout << " Disable colors" << std::endl; std::cout << " -s --shortNames:" << std::endl; std::cout << " Use short names" << std::endl; + std::cout << " -t --tempView:" << std::endl; + std::cout << " Dump temp view" << std::endl; std::cout << " -h --help:" << std::endl; std::cout << " Print out this message" << std::endl; } @@ -49,8 +52,9 @@ CmdOptions handleCmdLine(int argc, char **argv) options.shortNames = false; options.disableColors = false; + options.dumpTempView = false; - const char* const optstring = "Csh"; + const char* const optstring = "Csht"; while(true) { @@ -58,6 +62,7 @@ CmdOptions handleCmdLine(int argc, char **argv) { { "disableColors", no_argument, 0, 'C' }, { "shortNames", no_argument, 0, 's' }, + { "tempView", no_argument, 0, 't' }, { "help", no_argument, 0, 'h' }, { 0, 0, 0, 0 } }; @@ -73,6 +78,11 @@ CmdOptions handleCmdLine(int argc, char **argv) switch (c) { + case 't': + SWSS_LOG_NOTICE("Dump temp vie"); + options.dumpTempView = true; + break; + case 'C': SWSS_LOG_NOTICE("Disable colors"); options.disableColors = true; @@ -137,7 +147,7 @@ const TableMap* get_table_map(sai_object_id_t object_id) if (it == g_oid_map.end()) { - SWSS_LOG_ERROR("unable to find oid %llx in oid map", object_id); + SWSS_LOG_ERROR("unable to find oid 0x%lx in oid map", object_id); throw; } @@ -183,7 +193,14 @@ int main(int argc, char ** argv) swss::DBConnector db(ASIC_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); - swss::Table t(&db, ASIC_STATE_TABLE); + std::string table = ASIC_STATE_TABLE; + + if (g_cmdOptions.dumpTempView) + { + table = TEMP_PREFIX + table; + } + + swss::Table t(&db, table); TableDump dump; diff --git a/saiplayer/saiplayer.cpp b/saiplayer/saiplayer.cpp index f9a5638dd..de8c20c23 100644 --- a/saiplayer/saiplayer.cpp +++ b/saiplayer/saiplayer.cpp @@ -384,10 +384,6 @@ void translate_local_to_redis( translate_local_to_redis(attr.value.aclaction.parameter.objlist); break; - case SAI_SERIALIZATION_TYPE_PORT_BREAKOUT: - translate_local_to_redis(attr.value.portbreakout.port_list); - break; - default: break; } @@ -491,10 +487,6 @@ void match_list_lengths( CHECK_LIST(value.vlanlist); break; - case SAI_SERIALIZATION_TYPE_PORT_BREAKOUT: - CHECK_LIST(value.portbreakout.port_list); - break; - case SAI_SERIALIZATION_TYPE_QOS_MAP_LIST: CHECK_LIST(value.qosmap); break; @@ -615,10 +607,6 @@ void match_redis_with_rec( match_redis_with_rec(get_attr.value.aclaction.parameter.objlist, attr.value.aclaction.parameter.objlist); break; - case SAI_SERIALIZATION_TYPE_PORT_BREAKOUT: - match_redis_with_rec(get_attr.value.portbreakout.port_list, attr.value.portbreakout.port_list); - break; - default: break; } @@ -967,7 +955,7 @@ void performSleep(const std::string& line) { useconds *= 1000; // 1ms resolution is enough for sleep - SWSS_LOG_NOTICE("usleep(%lu)", useconds); + SWSS_LOG_NOTICE("usleep(%u)", useconds); usleep(useconds); } } diff --git a/syncd/syncd.cpp b/syncd/syncd.cpp index 56fd6444f..4d81f93f6 100644 --- a/syncd/syncd.cpp +++ b/syncd/syncd.cpp @@ -4,10 +4,37 @@ std::mutex g_mutex; -swss::RedisClient *g_redisClient = NULL; +swss::RedisClient *g_redisClient = NULL; std::map gProfileMap; +// by default we are in APPLY mode +volatile bool g_asicInitViewMode = false; + +struct cmdOptions +{ + int countersThreadIntervalInSeconds; + bool diagShell; + bool useTempView; + int startType; + bool disableCountersThread; + std::string profileMapFile; +#ifdef SAITHRIFT + bool run_rpc_server; + std::string portMapFile; +#endif // SAITHRIFT + ~cmdOptions() {} +}; + +cmdOptions options; + +bool inline isInitViewMode() +{ + SWSS_LOG_ENTER(); + + return g_asicInitViewMode && options.useTempView; +} + bool g_veryFirstRun = false; void exit_and_notify(int status) @@ -72,7 +99,7 @@ sai_object_id_t redis_create_virtual_object_id( sai_object_id_t vid = (((sai_object_id_t)object_type) << 48) | virtual_id; - SWSS_LOG_DEBUG("created virtual object id %llx for object type %x", vid, object_type); + SWSS_LOG_DEBUG("created virtual object id 0x%lx for object type %d", vid, object_type); return vid; } @@ -80,6 +107,8 @@ sai_object_id_t redis_create_virtual_object_id( std::unordered_map local_rid_to_vid; std::unordered_map local_vid_to_rid; +std::set floating_vid_set; + void save_rid_and_vid_to_local( _In_ sai_object_id_t rid, _In_ sai_object_id_t vid) @@ -133,24 +162,24 @@ sai_object_id_t translate_rid_to_vid( sai_deserialize_object_id(str_vid, vid); - SWSS_LOG_DEBUG("translated RID %llx to VID %llx", rid, vid); + SWSS_LOG_DEBUG("translated RID 0x%lx to VID 0x%lx", rid, vid); return vid; } - SWSS_LOG_INFO("spotted new RID %llx", rid); + SWSS_LOG_INFO("spotted new RID 0x%lx", rid); sai_object_type_t object_type = sai_object_type_query(rid); if (object_type == SAI_OBJECT_TYPE_NULL) { - SWSS_LOG_ERROR("sai_object_type_query returned NULL type for RID %llx", rid); + SWSS_LOG_ERROR("sai_object_type_query returned NULL type for RID 0x%lx", rid); exit_and_notify(EXIT_FAILURE); } vid = redis_create_virtual_object_id(object_type); - SWSS_LOG_DEBUG("translated RID %llx to VID %llx", rid, vid); + SWSS_LOG_DEBUG("translated RID 0x%lx to VID 0x%lx", rid, vid); str_vid = sai_serialize_object_id(vid); @@ -162,9 +191,8 @@ sai_object_id_t translate_rid_to_vid( return vid; } -template void translate_list_rid_to_vid( - _In_ T &element) + _In_ sai_object_list_t &element) { SWSS_LOG_ENTER(); @@ -192,7 +220,7 @@ void translate_rid_to_vid_list( if (meta == NULL) { - SWSS_LOG_ERROR("unable to get metadata for object type %x, attribute %x", object_type, attr.id); + SWSS_LOG_ERROR("unable to get metadata for object type %x, attribute %d", object_type, attr.id); exit_and_notify(EXIT_FAILURE); } @@ -222,9 +250,6 @@ void translate_rid_to_vid_list( translate_list_rid_to_vid(attr.value.aclaction.parameter.objlist); break; - case SAI_SERIALIZATION_TYPE_PORT_BREAKOUT: - translate_list_rid_to_vid(attr.value.portbreakout.port_list); - default: break; } @@ -257,6 +282,11 @@ sai_object_id_t translate_vid_to_rid( if (prid == NULL) { + if (isInitViewMode()) + { + SWSS_LOG_ERROR("can't get RID in init view mode - don't query created objects"); + } + SWSS_LOG_ERROR("unable to get RID for VID: %s", str_vid.c_str()); exit_and_notify(EXIT_FAILURE); } @@ -269,11 +299,20 @@ sai_object_id_t translate_vid_to_rid( local_vid_to_rid[vid] = rid; - SWSS_LOG_DEBUG("translated VID %llx to RID %llx", vid, rid); + SWSS_LOG_DEBUG("translated VID 0x%lx to RID 0x%lx", vid, rid); return rid; } +void translate_list_vid_to_rid( + _In_ sai_object_list_t &element) +{ + for (uint32_t i = 0; i < element.count; i++) + { + element.list[i] = translate_vid_to_rid(element.list[i]); + } +} + void translate_vid_to_rid_list( _In_ sai_object_type_t object_type, _In_ uint32_t attr_count, @@ -292,7 +331,7 @@ void translate_vid_to_rid_list( if (meta == NULL) { - SWSS_LOG_ERROR("unable to get metadata for object type %x, attribute %x", object_type, attr.id); + SWSS_LOG_ERROR("unable to get metadata for object type %x, attribute %d", object_type, attr.id); exit_and_notify(EXIT_FAILURE); } @@ -322,17 +361,156 @@ void translate_vid_to_rid_list( translate_list_vid_to_rid(attr.value.aclaction.parameter.objlist); break; - case SAI_SERIALIZATION_TYPE_PORT_BREAKOUT: - translate_list_vid_to_rid(attr.value.portbreakout.port_list); + default: + break; + } + } +} + +void snoop_get_attr( + _In_ sai_object_type_t object_type, + _In_ const std::string &str_object_id, + _In_ const std::string &attr_id, + _In_ const std::string &attr_value) +{ + SWSS_LOG_ENTER(); + + std::string str_object_type = sai_serialize_object_type(object_type); + + std::string key = TEMP_PREFIX + (ASIC_STATE_TABLE + (":" + str_object_type + ":" + str_object_id)); + + SWSS_LOG_DEBUG("%s", key.c_str()); + + g_redisClient->hset(key, attr_id, attr_value); +} + +void snoop_get_oid( + _In_ sai_object_id_t vid) +{ + SWSS_LOG_ENTER(); + + if (vid == SAI_NULL_OBJECT_ID) + { + return; + } + + // this is redis version of sai_object_type_query + sai_object_type_t object_type = getObjectTypeFromVid(vid); + + std::string str_vid = sai_serialize_object_id(vid); + + snoop_get_attr(object_type, str_vid, "NULL", "NULL"); +} + +void snoop_get_oid_list( + _In_ const sai_object_list_t &list) +{ + SWSS_LOG_ENTER(); + + for (uint32_t i = 0; i < list.count; i++) + { + snoop_get_oid(list.list[i]); + } +} + +void snoop_get_attr_value( + _In_ const std::string &str_object_id, + _In_ const sai_attr_metadata_t *meta, + _In_ const sai_attribute_t &attr) +{ + SWSS_LOG_ENTER(); + + std::string value = sai_serialize_attr_value(*meta, attr); + + SWSS_LOG_NOTICE("%s:%s", meta->attridname, value.c_str()); + + snoop_get_attr(meta->objecttype, str_object_id, meta->attridname, value); +} + +void snoop_get_response( + _In_ sai_object_type_t object_type, + _In_ const std::string &str_object_id, + _In_ uint32_t attr_count, + _In_ const sai_attribute_t *attr_list) +{ + SWSS_LOG_ENTER(); + + if (object_type == SAI_OBJECT_TYPE_VLAN) + { + // vlan (including vlan 1) will need to be put into TEMP view + // this should also be valid for all objects that were queried + // only for readonly attributes + snoop_get_attr(object_type, str_object_id, "NULL", "NULL"); + } + + for (uint32_t idx = 0; idx < attr_count; ++idx) + { + const sai_attribute_t &attr = attr_list[idx]; + + auto meta = get_attribute_metadata(object_type, attr.id); + + if (meta == NULL) + { + SWSS_LOG_ERROR("unable to get metadata for object type %d, attribute %d", object_type, attr.id); + exit_and_notify(EXIT_FAILURE); + } + + // we should snoop oid values even if they are readonly + // we just note in temp view that those objects exist on switch + + switch (meta->serializationtype) + { + case SAI_SERIALIZATION_TYPE_OBJECT_ID: + snoop_get_oid(attr.value.oid); + break; + + case SAI_SERIALIZATION_TYPE_OBJECT_LIST: + snoop_get_oid_list(attr.value.objlist); + break; + + case SAI_SERIALIZATION_TYPE_ACL_FIELD_DATA_OBJECT_ID: + snoop_get_oid(attr.value.aclfield.data.oid); + break; + + case SAI_SERIALIZATION_TYPE_ACL_FIELD_DATA_OBJECT_LIST: + snoop_get_oid_list(attr.value.aclfield.data.objlist); + break; + + case SAI_SERIALIZATION_TYPE_ACL_ACTION_DATA_OBJECT_ID: + snoop_get_oid(attr.value.aclaction.parameter.oid); + break; + + case SAI_SERIALIZATION_TYPE_ACL_ACTION_DATA_OBJECT_LIST: + snoop_get_oid_list(attr.value.aclaction.parameter.objlist); + break; default: break; } + + if (HAS_FLAG_READ_ONLY(meta->flags)) + { + // if value is read only, we skip it, since after + // syncd restart we won't be able to set/create it anyway + continue; + } + + if (meta->objecttype == SAI_OBJECT_TYPE_PORT && + meta->attrid == SAI_PORT_ATTR_HW_LANE_LIST) + { + // skip port lanes for now since we don't create ports + + SWSS_LOG_INFO("skipping %s for %s", meta->attridname, str_object_id.c_str()); + continue; + } + + snoop_get_attr_value(str_object_id, meta, attr); } } void internal_syncd_get_send( _In_ sai_object_type_t object_type, + _In_ const std::string &str_object_id, _In_ sai_status_t status, _In_ uint32_t attr_count, _In_ sai_attribute_t *attr_list) @@ -351,6 +529,13 @@ void internal_syncd_get_send( attr_count, attr_list, false); + + if (isInitViewMode()) + { + // all oid values here are VID's + + snoop_get_response(object_type, str_object_id, attr_count, attr_list); + } } else if (status == SAI_STATUS_BUFFER_OVERFLOW) { @@ -769,10 +954,44 @@ void sendResponse(sai_status_t status) getResponse->set(str_status, entry, "notify"); } +void clearTempView() +{ + SWSS_LOG_ENTER(); + + SWSS_LOG_NOTICE("clearing current TEMP VIEW"); + + SWSS_LOG_TIMER("clear temp view"); + + std::string pattern = TEMP_PREFIX + (ASIC_STATE_TABLE + std::string(":*")); + + // TODO optimize with lua script (this takes ~0.2s now) + + for (const auto &key: g_redisClient->keys(pattern)) + { + g_redisClient->del(key); + } +} + +void syncdApplyView() +{ + SWSS_LOG_ENTER(); + + SWSS_LOG_ERROR("apply view is not implemented yet"); +} + sai_status_t notifySyncd(const std::string& op) { SWSS_LOG_ENTER(); + if (!options.useTempView) + { + SWSS_LOG_NOTICE("received %s, ignored since TEMP VIEW is not used, returning success", op.c_str()); + + sendResponse(SAI_STATUS_SUCCESS); + + return SAI_STATUS_SUCCESS; + } + if (g_veryFirstRun) { SWSS_LOG_NOTICE("very first run is TRUE, op = %s", op.c_str()); @@ -781,37 +1000,197 @@ sai_status_t notifySyncd(const std::string& op) // applied on device, since it will make it easier to switch // to new asic state later on when we restart orch agent - if (op == SYNCD_APPLY_VIEW) + if (op == SYNCD_INIT_VIEW) + { + // on first start we just do "apply" directly on asic so + // we set init to false instead of true + g_asicInitViewMode = false; + + floating_vid_set.clear(); + + clearTempView(); + } + else if (op == SYNCD_APPLY_VIEW) { g_veryFirstRun = false; + g_asicInitViewMode = false; + SWSS_LOG_NOTICE("setting very first run to FALSE, op = %s", op.c_str()); } + else + { + SWSS_LOG_ERROR("unknown operation: %s", op.c_str()); + exit_and_notify(EXIT_FAILURE); + } sendResponse(SAI_STATUS_SUCCESS); + return SAI_STATUS_SUCCESS; } if (op == SYNCD_INIT_VIEW) { - SWSS_LOG_WARN("op = %s - not implemented, but sending success", op.c_str()); + if (g_asicInitViewMode) + { + SWSS_LOG_WARN("syncd is already in asic INIT VIEW mode, but received init again, orchagent restarted before apply?"); + } + + g_asicInitViewMode = true; + + floating_vid_set.clear(); + + clearTempView(); + + SWSS_LOG_WARN("syncd switched to INIT VIEW mode, all op will be saved to TEMP view"); + sendResponse(SAI_STATUS_SUCCESS); } else if (op == SYNCD_APPLY_VIEW) { - SWSS_LOG_WARN("op = %s - not implemented, but sending success", op.c_str()); + g_asicInitViewMode = false; + + SWSS_LOG_WARN("syncd received APPLY VIEW, will translate"); + + syncdApplyView(); + sendResponse(SAI_STATUS_SUCCESS); } else { SWSS_LOG_ERROR("unknown operation: %s", op.c_str()); + sendResponse(SAI_STATUS_NOT_IMPLEMENTED); + exit_and_notify(EXIT_FAILURE); } return SAI_STATUS_SUCCESS; } +sai_status_t processEventInInitViewMode( + _In_ sai_object_type_t object_type, + _In_ const std::string &str_object_id, + _In_ sai_common_api_t api, + _In_ uint32_t attr_count, + _In_ sai_attribute_t *attr_list) +{ + SWSS_LOG_ENTER(); + + // since attributes are not checked, it may happen that user will send + // some invalid VID in object id/list in attribute, metadata should handle + // that, but if that happen, this id will be treated as "new" object instead + // of existing one + + if (api == SAI_COMMON_API_CREATE) + { + switch (object_type) + { + case SAI_OBJECT_TYPE_FDB: + case SAI_OBJECT_TYPE_NEIGHBOR: + case SAI_OBJECT_TYPE_ROUTE: + case SAI_OBJECT_TYPE_TRAP: + case SAI_OBJECT_TYPE_SWITCH: + case SAI_OBJECT_TYPE_VLAN: + + // we assume create of those non object id object types will succeed + + break; + + default: + + { + sai_object_id_t object_id; + sai_deserialize_object_id(str_object_id, object_id); + + // object ID here is actual VID returned from redis during creation + // this is floating VID in init view mode + + SWSS_LOG_DEBUG("generic create (init view) for %s, floating VID: %s", + sai_serialize_object_type(object_type).c_str(), + sai_serialize_object_id(object_id).c_str()); + + // floating vid set will contain all created objects + // from TEMP asic view which don't have real id assigned + + floating_vid_set.insert(object_id); + } + + break; + } + + return SAI_STATUS_SUCCESS; + } + + if (api == SAI_COMMON_API_GET) + { + sai_status_t status; + + switch (object_type) + { + case SAI_OBJECT_TYPE_FDB: + case SAI_OBJECT_TYPE_NEIGHBOR: + case SAI_OBJECT_TYPE_ROUTE: + case SAI_OBJECT_TYPE_TRAP: + + // those object's are user created, so if user created ROUTE + // he passed some attributes, there is no sense to support GET + // since user explicitly know what attributes were set, similar + // for other object types here + + SWSS_LOG_ERROR("get is not supported on %s in init view mode", sai_serialize_object_type(object_type).c_str()); + + status = SAI_STATUS_NOT_SUPPORTED; + break; + + case SAI_OBJECT_TYPE_SWITCH: + status = sai_switch_api->get_switch_attribute(attr_count, attr_list); + break; + + case SAI_OBJECT_TYPE_VLAN: + + { + sai_vlan_id_t vlan_id; + sai_deserialize_vlan_id(str_object_id, vlan_id); + + status = sai_vlan_api->get_vlan_attribute(vlan_id, attr_count, attr_list); + } + + break; + + default: + + { + sai_object_id_t object_id; + sai_deserialize_object_id(str_object_id, object_id); + + SWSS_LOG_DEBUG("generic get (init view) for object type %s", sai_serialize_object_type(object_type).c_str()); + + // object must exists, we can't call GET on created object in init view mode + // get here can be called on existing objects like default trap group to + // get some vendor specific values + + sai_object_id_t rid = translate_vid_to_rid(object_id); + + get_attribute_fn get = common_get_attribute[object_type]; + + status = get(rid, attr_count, attr_list); + } + + break; + } + + internal_syncd_get_send(object_type, str_object_id, status, attr_count, attr_list); + + return status; + } + + // we assume that SET and REMOVE succeeded, no real asic operations + // this is only DB operation in TEMP asic view + + return SAI_STATUS_SUCCESS; +} + sai_status_t processEvent(swss::ConsumerTable &consumer) { std::lock_guard lock(g_mutex); @@ -819,7 +1198,16 @@ sai_status_t processEvent(swss::ConsumerTable &consumer) SWSS_LOG_ENTER(); swss::KeyOpFieldsValuesTuple kco; - consumer.pop(kco); + + if (isInitViewMode()) + { + // in init mode we put all data to TEMP view and we snoop + consumer.pop(kco, TEMP_PREFIX); + } + else + { + consumer.pop(kco); + } const std::string &key = kfvKey(kco); const std::string &op = kfvOp(kco); @@ -843,8 +1231,7 @@ sai_status_t processEvent(swss::ConsumerTable &consumer) return notifySyncd(key); else { - if (op != "delget") - SWSS_LOG_ERROR("api %s is not implemented", op.c_str()); + SWSS_LOG_ERROR("api %s is not implemented", op.c_str()); return SAI_STATUS_NOT_SUPPORTED; } @@ -864,12 +1251,19 @@ sai_status_t processEvent(swss::ConsumerTable &consumer) SaiAttributeList list(object_type, values, false); - if (api != SAI_COMMON_API_GET) - translate_vid_to_rid_list(object_type, list.get_attr_count(), list.get_attr_list()); - sai_attribute_t *attr_list = list.get_attr_list(); uint32_t attr_count = list.get_attr_count(); + if (isInitViewMode()) + { + return processEventInInitViewMode(object_type, str_object_id, api, attr_count, attr_list); + } + + if (api != SAI_COMMON_API_GET) + { + translate_vid_to_rid_list(object_type, attr_count, attr_list); + } + sai_status_t status; switch (object_type) { @@ -904,7 +1298,7 @@ sai_status_t processEvent(swss::ConsumerTable &consumer) if (api == SAI_COMMON_API_GET) { - internal_syncd_get_send(object_type, status, attr_count, attr_list); + internal_syncd_get_send(object_type, str_object_id, status, attr_count, attr_list); } else if (status != SAI_STATUS_SUCCESS) { @@ -961,21 +1355,6 @@ void updateLogLevel() } } -struct cmdOptions -{ - int countersThreadIntervalInSeconds; - bool diagShell; - bool useTempView; - int startType; - bool disableCountersThread; - std::string profileMapFile; -#ifdef SAITHRIFT - bool run_rpc_server; - std::string portMapFile; -#endif // SAITHRIFT - ~cmdOptions() {} -}; - void printUsage() { std::cout << "Usage: syncd [-N] [-d] [-p profile] [-i interval] [-t [cold|warm|fast]] [-h] [-u]" << std::endl; @@ -1001,12 +1380,10 @@ void printUsage() std::cout << " Print out this message" << std::endl; } -cmdOptions handleCmdLine(int argc, char **argv) +void handleCmdLine(int argc, char **argv) { SWSS_LOG_ENTER(); - cmdOptions options; - const int defaultCountersThreadIntervalInSeconds = 1; options.countersThreadIntervalInSeconds = defaultCountersThreadIntervalInSeconds; @@ -1131,8 +1508,6 @@ cmdOptions handleCmdLine(int argc, char **argv) exit(EXIT_FAILURE); } } - - return options; } void handleProfileMap(const std::string& profileMapFile) @@ -1234,7 +1609,7 @@ bool handleRestartQuery(swss::NotificationConsumer &restartQuery) restartQuery.pop(op, data, values); - SWSS_LOG_DEBUG("op = %d", op.c_str()); + SWSS_LOG_DEBUG("op = %s", op.c_str()); if (op == "COLD") { @@ -1281,7 +1656,7 @@ int main(int argc, char **argv) meta_init_db(); - auto options = handleCmdLine(argc, argv); + handleCmdLine(argc, argv); handleProfileMap(options.profileMapFile); #ifdef SAITHRIFT diff --git a/syncd/syncd.h b/syncd/syncd.h index 434f8f12c..43ee7b22c 100644 --- a/syncd/syncd.h +++ b/syncd/syncd.h @@ -86,24 +86,6 @@ extern swss::RedisClient *g_redisClient; sai_object_id_t redis_create_virtual_object_id( _In_ sai_object_type_t object_type); -sai_object_id_t translate_vid_to_rid( - _In_ sai_object_id_t vid); - -void translate_vid_to_rid_list( - _In_ sai_object_type_t object_type, - _In_ uint32_t attr_count, - _In_ sai_attribute_t *attr_list); - -template -void translate_list_vid_to_rid( - _In_ T &element) -{ - for (uint32_t i = 0; i < element.count; i++) - { - element.list[i] = translate_vid_to_rid(element.list[i]); - } -} - sai_object_id_t translate_rid_to_vid( _In_ sai_object_id_t rid); @@ -173,6 +155,8 @@ std::unordered_map redisGetLaneMap(); std::vector saiGetPortList(); +sai_object_type_t getObjectTypeFromVid(sai_object_id_t sai_object_id); + void start_cli(); void stop_cli(); diff --git a/syncd/syncd_cli.cpp b/syncd/syncd_cli.cpp index f180dc6d0..e6978c8c0 100644 --- a/syncd/syncd_cli.cpp +++ b/syncd/syncd_cli.cpp @@ -23,8 +23,8 @@ std::shared_ptr cli_thread; volatile bool run_cli = false; volatile bool run_user = false; -int cli_server_socket = 0; -int cli_client_socket = 0; +volatile int cli_server_socket = 0; +volatile int cli_client_socket = 0; bool sendtoclient(const std::string& s) { @@ -262,8 +262,9 @@ void stop_cli() run_cli = false; + // close actually don't break accept :/ close(cli_client_socket); close(cli_server_socket); - cli_thread->join(); + // cli_thread->join(); // TODO fix } diff --git a/syncd/syncd_counters.cpp b/syncd/syncd_counters.cpp index 824b92011..0e10ed4d9 100644 --- a/syncd/syncd_counters.cpp +++ b/syncd/syncd_counters.cpp @@ -28,7 +28,7 @@ void collectCounters(swss::Table &countersTable, if (status != SAI_STATUS_SUCCESS) { - SWSS_LOG_ERROR("failed to collect counters for port %llx: %d", portId, status); + SWSS_LOG_ERROR("failed to collect counters for port 0x%lx: %d", portId, status); return; } @@ -77,7 +77,7 @@ std::vector getSupportedCounters(sai_object_id_t portId { const std::string &name = sai_serialize_port_stat(counter); - SWSS_LOG_WARN("counter %s is not supported on port RID %llx: %d", name.c_str(), portId, status); + SWSS_LOG_WARN("counter %s is not supported on port RID 0x%lx: %d", name.c_str(), portId, status); continue; } diff --git a/syncd/syncd_hard_reinit.cpp b/syncd/syncd_hard_reinit.cpp index 27cfde323..d0f6a4b6b 100644 --- a/syncd/syncd_hard_reinit.cpp +++ b/syncd/syncd_hard_reinit.cpp @@ -42,7 +42,7 @@ sai_object_type_t getObjectTypeFromVid(sai_object_id_t sai_object_id) if (objectType >= SAI_OBJECT_TYPE_MAX || objectType == SAI_OBJECT_TYPE_NULL) { - SWSS_LOG_ERROR("invalid object type: %x on object id: %llx", objectType, sai_object_id); + SWSS_LOG_ERROR("invalid object type: %x on object id: 0x%lx", objectType, sai_object_id); exit_and_notify(EXIT_FAILURE); } @@ -133,7 +133,7 @@ void checkAllIds() if (it == g_vidToRidMap.end()) { - SWSS_LOG_ERROR("failed to find vid %llx in previous map", kv.first); + SWSS_LOG_ERROR("failed to find vid 0x%lx in previous map", kv.first); exit_and_notify(EXIT_FAILURE); } @@ -151,7 +151,9 @@ void checkAllIds() { sai_object_type_t objectType = getObjectTypeFromVid(kv.first); - SWSS_LOG_ERROR("vid not translated: %llx, object type: %llx", kv.first, objectType); + SWSS_LOG_ERROR("vid not translated: %s, object type: %s", + sai_serialize_object_id(kv.first).c_str(), + sai_serialize_object_type(objectType).c_str()); } exit_and_notify(EXIT_FAILURE); @@ -200,7 +202,7 @@ void saiRemoveDefaultVlanMembers() if (status != SAI_STATUS_SUCCESS) { - SWSS_LOG_ERROR("Failed to remove vlan member 0x%llx from vlan %d", vm, DEFAULT_VLAN_NUMBER); + SWSS_LOG_ERROR("Failed to remove vlan member 0x%lx from vlan %d", vm, DEFAULT_VLAN_NUMBER); exit_and_notify(EXIT_FAILURE); } @@ -284,7 +286,7 @@ bool shouldSkipCreateion( if (it == g_vidToRidMap.end()) { - SWSS_LOG_ERROR("failed to find VID %llx in VIDTORID map", vid); + SWSS_LOG_ERROR("failed to find VID 0x%lx in VIDTORID map", vid); exit_and_notify(EXIT_FAILURE); } @@ -351,7 +353,7 @@ void trapGroupWorkaround( exit_and_notify(EXIT_FAILURE); } - SWSS_LOG_DEBUG("created TRAP_GROUP, processed VID %llx to RID %llx", objectType, vid, rid); + SWSS_LOG_DEBUG("created TRAP_GROUP (%d), processed VID 0x%lx to RID 0x%lx", objectType, vid, rid); } void listFailedAttributes( @@ -395,7 +397,7 @@ sai_object_id_t processSingleVid(sai_object_id_t vid) // this object was already processed, // just return real object id - SWSS_LOG_DEBUG("processed VID %llx to RID %llx", vid, it->second); + SWSS_LOG_DEBUG("processed VID 0x%lx to RID 0x%lx", vid, it->second); return it->second; } @@ -430,35 +432,35 @@ sai_object_id_t processSingleVid(sai_object_id_t vid) { if (shouldSkipCreateion(vid, rid, createObject, [](sai_object_id_t id) { return id == redisGetDefaultVirtualRouterId(); })) { - SWSS_LOG_INFO("default virtual router will not be created, processed VID %llx to RID %llx", vid, rid); + SWSS_LOG_INFO("default virtual router will not be created, processed VID 0x%lx to RID 0x%lx", vid, rid); } } else if (objectType == SAI_OBJECT_TYPE_QUEUE) { if (shouldSkipCreateion(vid, rid, createObject, [&](sai_object_id_t queueId) { return g_defaultQueuesRids.find(queueId) != g_defaultQueuesRids.end(); })) { - SWSS_LOG_DEBUG("default queue will not be created, processed VID %llx to RID %llx", vid, rid); + SWSS_LOG_DEBUG("default queue will not be created, processed VID 0x%lx to RID 0x%lx", vid, rid); } } else if (objectType == SAI_OBJECT_TYPE_PRIORITY_GROUP) { if (shouldSkipCreateion(vid, rid, createObject, [&](sai_object_id_t pgId) { return g_defaultPriorityGroupsRids.find(pgId) != g_defaultPriorityGroupsRids.end(); })) { - SWSS_LOG_DEBUG("default priority group will not be created, processed VID %llx to RID %llx", vid, rid); + SWSS_LOG_DEBUG("default priority group will not be created, processed VID 0x%lx to RID 0x%lx", vid, rid); } } else if (objectType == SAI_OBJECT_TYPE_SCHEDULER_GROUP) { if (shouldSkipCreateion(vid, rid, createObject, [&](sai_object_id_t sgId) { return g_defaultSchedulerGroupsRids.find(sgId) != g_defaultSchedulerGroupsRids.end(); })) { - SWSS_LOG_DEBUG("default scheduler group will not be created, processed VID %llx to RID %llx", vid, rid); + SWSS_LOG_DEBUG("default scheduler group will not be created, processed VID 0x%lx to RID 0x%lx", vid, rid); } } else if (objectType == SAI_OBJECT_TYPE_TRAP_GROUP) { if (shouldSkipCreateion(vid, rid, createObject, [](sai_object_id_t id) { return id == redisGetDefaultTrapGroupId(); })) { - SWSS_LOG_INFO("default trap group will not be created, processed VID %llx to RID %llx", vid, rid); + SWSS_LOG_INFO("default trap group will not be created, processed VID 0x%lx to RID 0x%lx", vid, rid); } trapGroupWorkaround(vid, rid, createObject, attrCount, attrList); @@ -467,7 +469,7 @@ sai_object_id_t processSingleVid(sai_object_id_t vid) { if (shouldSkipCreateion(vid, rid, createObject, [](sai_object_id_t) { return true; })) { - SWSS_LOG_INFO("port will not be created, processed VID %llx to RID %llx", vid, rid); + SWSS_LOG_INFO("port will not be created, processed VID 0x%lx to RID 0x%lx", vid, rid); } } @@ -493,11 +495,11 @@ sai_object_id_t processSingleVid(sai_object_id_t vid) exit_and_notify(EXIT_FAILURE); } - SWSS_LOG_DEBUG("created object of type %x, processed VID %llx to RID %llx", objectType, vid, rid); + SWSS_LOG_DEBUG("created object of type %x, processed VID 0x%lx to RID 0x%lx", objectType, vid, rid); } else { - SWSS_LOG_DEBUG("setting attributes on object of type %x, processed VID %llx to RID %llx", objectType, vid, rid); + SWSS_LOG_DEBUG("setting attributes on object of type %x, processed VID 0x%lx to RID 0x%lx", objectType, vid, rid); set_attribute_fn set = common_set_attribute[objectType]; @@ -537,7 +539,7 @@ void processAttributesForOids(sai_object_type_t objectType, std::shared_ptrget_attr_list(); @@ -590,11 +592,6 @@ void processAttributesForOids(sai_object_type_t objectType, std::shared_ptrid, status); + SWSS_LOG_ERROR("failed to set_switch_attribute %d: %d", attr->id, status); exit_and_notify(EXIT_FAILURE); } @@ -717,7 +714,7 @@ void processVlans() if (status != SAI_STATUS_SUCCESS) { - SWSS_LOG_ERROR("failed to set_vlan_attribute %llx: %d", attr->id, status); + SWSS_LOG_ERROR("failed to set_vlan_attribute %d: %d", attr->id, status); exit_and_notify(EXIT_FAILURE); } diff --git a/syncd/syncd_reinit.cpp b/syncd/syncd_reinit.cpp index 7f977ef33..da304fe63 100644 --- a/syncd/syncd_reinit.cpp +++ b/syncd/syncd_reinit.cpp @@ -45,7 +45,7 @@ sai_object_id_t saiGetCpuId() exit_and_notify(EXIT_FAILURE); } - SWSS_LOG_DEBUG("cpu port RID %llx", attr.value.oid); + SWSS_LOG_DEBUG("cpu port RID 0x%lx", attr.value.oid); return attr.value.oid; } @@ -316,7 +316,7 @@ void helperCheckLaneMap() if (redisLaneMap[lane] != portId) { // if this happens, we need to remap VIDTORID and RIDTOVID - SWSS_LOG_ERROR("FIXME: lane port id differs: %llx vs %llx, port ids must be remapped", portId, redisLaneMap[lane]); + SWSS_LOG_ERROR("FIXME: lane port id differs: 0x%lx vs 0x%lx, port ids must be remapped", portId, redisLaneMap[lane]); exit_and_notify(EXIT_FAILURE); } @@ -399,7 +399,7 @@ void redisCreateRidAndVidMapping(sai_object_id_t rid, sai_object_id_t vid) g_redisClient->hset(VIDTORID, strVid, strRid); g_redisClient->hset(RIDTOVID, strRid, strVid); - SWSS_LOG_DEBUG("set VID %llx and RID %llx", vid, rid); + SWSS_LOG_DEBUG("set VID 0x%lx and RID 0x%lx", vid, rid); } void redisSetDummyAsicStateForRealObjectId(sai_object_id_t rid) @@ -410,7 +410,7 @@ void redisSetDummyAsicStateForRealObjectId(sai_object_id_t rid) if (objectType == SAI_OBJECT_TYPE_NULL) { - SWSS_LOG_ERROR("sai_object_type_query returned NULL type for RID %llx", rid); + SWSS_LOG_ERROR("sai_object_type_query returned NULL type for RID 0x%lx", rid); exit_and_notify(EXIT_FAILURE); } @@ -450,7 +450,7 @@ void helperCheckDefaultVirtualRouterId() if (vrId != redisVrId) { // if this happens, we need to remap VIDTORID and RIDTOVID - SWSS_LOG_ERROR("FIXME: default virtual router id differs: %llx vs %llx, ids must be remapped", vrId, redisVrId); + SWSS_LOG_ERROR("FIXME: default virtual router id differs: 0x%lx vs 0x%lx, ids must be remapped", vrId, redisVrId); exit_and_notify(EXIT_FAILURE); } @@ -478,7 +478,7 @@ void helperCheckDefaultTrapGroup() if (tgId != redisTgId) { // if this happens, we need to remap VIDTORID and RIDTOVID - SWSS_LOG_ERROR("FIXME: default trap group id differs: %llx vs %llx, ids must be remapped", tgId, redisTgId); + SWSS_LOG_ERROR("FIXME: default trap group id differs: 0x%lx vs 0x%lx, ids must be remapped", tgId, redisTgId); exit_and_notify(EXIT_FAILURE); } @@ -515,7 +515,7 @@ void helperCheckCpuId() if (cpuId != redisCpuId) { // if this happens, we need to remap VIDTORID and RIDTOVID - SWSS_LOG_ERROR("FIXME: cpu id differs: %llx vs %llx, ids must be remapped", cpuId, redisCpuId); + SWSS_LOG_ERROR("FIXME: cpu id differs: 0x%lx vs 0x%lx, ids must be remapped", cpuId, redisCpuId); exit_and_notify(EXIT_FAILURE); } @@ -531,7 +531,7 @@ void redisCreateDummyEntryInAsicView(sai_object_id_t objectId) if (objectType == SAI_OBJECT_TYPE_NULL) { - SWSS_LOG_ERROR("sai_object_type_query returned NULL type for RID %llx", objectId); + SWSS_LOG_ERROR("sai_object_type_query returned NULL type for RID 0x%lx", objectId); exit_and_notify(EXIT_FAILURE); } @@ -598,7 +598,7 @@ sai_uint32_t saiGetPortNumberOfQueues(sai_object_id_t portId) exit_and_notify(EXIT_FAILURE); } - SWSS_LOG_DEBUG("port 0x%llx queues number: %u", portId, attr.value.u32); + SWSS_LOG_DEBUG("port 0x%lx queues number: %u", portId, attr.value.u32); return attr.value.u32; } @@ -647,7 +647,7 @@ void helperCheckQueuesIds() for (const auto& portId: ports) { - SWSS_LOG_DEBUG("getting queues for port 0x%llx", portId); + SWSS_LOG_DEBUG("getting queues for port 0x%lx", portId); std::vector queues = saiGetPortQueues(portId); @@ -683,7 +683,7 @@ sai_uint32_t saiGetPortNumberOfPriorityGroups(sai_object_id_t portId) exit_and_notify(EXIT_FAILURE); } - SWSS_LOG_DEBUG("port 0x%llx priority groups number: %u", portId, attr.value.u32); + SWSS_LOG_DEBUG("port 0x%lx priority groups number: %u", portId, attr.value.u32); return attr.value.u32; } @@ -732,7 +732,7 @@ void helperCheckPriorityGroupsIds() for (const auto& portId: ports) { - SWSS_LOG_DEBUG("getting priority groups for port 0x%llx", portId); + SWSS_LOG_DEBUG("getting priority groups for port 0x%lx", portId); std::vector pgs = saiGetPortPriorityGroups(portId); @@ -781,7 +781,7 @@ uint32_t saiGetQosNumberOfSchedulerGroups(sai_object_id_t portId) if (status != SAI_STATUS_SUCCESS) { - SWSS_LOG_ERROR("Failed to get number of scheduler groups for port: 0x%llx", portId); + SWSS_LOG_ERROR("Failed to get number of scheduler groups for port: 0x%lx", portId); exit_and_notify(EXIT_FAILURE); } @@ -810,7 +810,7 @@ std::vector saiGetSchedulerGroupList(sai_object_id_t portId) if (status != SAI_STATUS_SUCCESS) { - SWSS_LOG_ERROR("Failed to get scheduler group list for port: 0x%llx", portId); + SWSS_LOG_ERROR("Failed to get scheduler group list for port: 0x%lx", portId); exit_and_notify(EXIT_FAILURE); } @@ -818,7 +818,7 @@ std::vector saiGetSchedulerGroupList(sai_object_id_t portId) // just in case groups.resize(attr.value.objlist.count); - SWSS_LOG_DEBUG("got %zu scheduler groups on port 0x%llx", groups.size(), portId); + SWSS_LOG_DEBUG("got %zu scheduler groups on port 0x%lx", groups.size(), portId); return groups; } @@ -835,7 +835,7 @@ uint32_t saiGetSchedulerGroupChildCount(sai_object_id_t schedulerGroupId) if (status != SAI_STATUS_SUCCESS) { - SWSS_LOG_ERROR("Failed to get child count for scheduler group: 0x%llx", schedulerGroupId); + SWSS_LOG_ERROR("Failed to get child count for scheduler group: 0x%lx", schedulerGroupId); exit_and_notify(EXIT_FAILURE); } @@ -849,6 +849,8 @@ std::vector saiGetSchedulerGroupChildList(sai_object_id_t sched uint32_t childCount = saiGetSchedulerGroupChildCount(schedulerGroupId); + SWSS_LOG_DEBUG("child count for SG 0x%lx is %u", schedulerGroupId, childCount); + std::vector childs; childs.resize(childCount); @@ -863,14 +865,14 @@ std::vector saiGetSchedulerGroupChildList(sai_object_id_t sched if (status != SAI_STATUS_SUCCESS) { - SWSS_LOG_ERROR("Failed to get child list for scheduler group: 0x%llx", schedulerGroupId); + SWSS_LOG_ERROR("Failed to get child list for scheduler group: 0x%lx", schedulerGroupId); exit_and_notify(EXIT_FAILURE); } childs.resize(attr.value.objlist.count); - SWSS_LOG_DEBUG("got %zu childs on scheduler group 0x%llx", childs.size(), schedulerGroupId); + SWSS_LOG_DEBUG("got %zu childs on scheduler group 0x%lx", childs.size(), schedulerGroupId); return childs; // scheduler groups + queues } diff --git a/vslib/inc/sai_vs.h b/vslib/inc/sai_vs.h index 6e3641a6e..01fa8cf24 100644 --- a/vslib/inc/sai_vs.h +++ b/vslib/inc/sai_vs.h @@ -15,6 +15,8 @@ extern "C" { extern std::recursive_mutex g_recursive_mutex; +extern sai_switch_notification_t vs_switch_notifications; + extern const sai_acl_api_t vs_acl_api; extern const sai_buffer_api_t vs_buffer_api; extern const sai_fdb_api_t vs_fdb_api; diff --git a/vslib/src/sai_vs_generic_create.cpp b/vslib/src/sai_vs_generic_create.cpp index 4b8fd6804..82acfaa07 100644 --- a/vslib/src/sai_vs_generic_create.cpp +++ b/vslib/src/sai_vs_generic_create.cpp @@ -30,7 +30,7 @@ sai_object_id_t vs_create_real_object_id( sai_object_id_t object_id = (((sai_object_id_t)object_type) << 32) | real_id; - SWSS_LOG_DEBUG("created RID %llx", object_id); + SWSS_LOG_DEBUG("created RID 0x%lx", object_id); return object_id; } diff --git a/vslib/src/sai_vs_vlan.cpp b/vslib/src/sai_vs_vlan.cpp index 5db2c655c..624da89b4 100644 --- a/vslib/src/sai_vs_vlan.cpp +++ b/vslib/src/sai_vs_vlan.cpp @@ -129,7 +129,7 @@ sai_vlan_id_t get_vlan_id_from_member( return (sai_vlan_id_t)attr.value.u16; } - SWSS_LOG_ERROR("failed to get vlan id from vlan member 0x%llx, status: %d", vlan_member_id, status); + SWSS_LOG_ERROR("failed to get vlan id from vlan member 0x%lx, status: %d", vlan_member_id, status); throw std::runtime_error("failed to get vlan id from vlan member"); } @@ -182,7 +182,7 @@ sai_status_t vs_remove_vlan_member( if (it == vlan_members_map[vlan_id].end()) { - SWSS_LOG_ERROR("failed to find vlan member 0x%llx in vlan members map", vlan_member_id); + SWSS_LOG_ERROR("failed to find vlan member 0x%lx in vlan members map", vlan_member_id); return SAI_STATUS_FAILURE; }