@@ -853,56 +853,64 @@ cfg::SwitchConfig genPortVlanCfg(
853853 } else {
854854 std::map<SwitchID, cfg::SwitchInfo> defaultSwitchIdToSwitchInfo;
855855 std::map<SwitchID, const HwAsic*> defaultHwAsicTable;
856- auto switchType = asic->getSwitchType ();
857856 auto asicType = asic->getAsicType ();
858857 int64_t switchId{0 };
858+ std::string connectionHandle;
859859 if (asic->getSwitchId ().has_value ()) {
860860 switchId = *asic->getSwitchId ();
861861 }
862- defaultHwAsicTable.insert ({SwitchID (switchId), asic});
863- cfg::SwitchInfo switchInfo;
864862 cfg::Range64 portIdRange;
865863 portIdRange.minimum () =
866864 cfg::switch_config_constants::DEFAULT_PORT_ID_RANGE_MIN ();
867865 portIdRange.maximum () = cfg::switch_config_constants::
868866 DEFAULT_DUAL_STAGE_3Q_2Q_PORT_ID_RANGE_MAX ();
869- switchInfo.portIdRange () = portIdRange;
870- switchInfo.switchIndex () = 0 ;
871- switchInfo.switchType () = switchType;
872- switchInfo.asicType () = asicType;
867+
873868 // TODO: Instead of using hard codings for connection handle and
874869 // src mac, get the configs from AgentConfig
875870 if (asicType == cfg::AsicType::ASIC_TYPE_RAMON) {
876- switchInfo.connectionHandle () = " 0c:00" ;
877- } else if (asicType == cfg::AsicType::ASIC_TYPE_RAMON3) {
878- switchInfo.connectionHandle () = " 15:00" ;
871+ connectionHandle = " 0c:00" ;
872+ } else if (
873+ asicType == cfg::AsicType::ASIC_TYPE_RAMON3 ||
874+ asicType == cfg::AsicType::ASIC_TYPE_JERICHO3) {
875+ connectionHandle = " 15:00" ;
879876 } else if (asicType == cfg::AsicType::ASIC_TYPE_JERICHO2) {
880- switchInfo.switchMac () = " 02:00:00:00:00:01" ;
881- switchInfo.connectionHandle () = " 68:00" ;
882- } else if (asicType == cfg::AsicType::ASIC_TYPE_JERICHO3) {
883- switchInfo.switchMac () = " 02:00:00:00:00:01" ;
884- switchInfo.connectionHandle () = " 15:00" ;
877+ connectionHandle = " 68:00" ;
885878 } else if (
886879 asicType == cfg::AsicType::ASIC_TYPE_EBRO ||
887880 asicType == cfg::AsicType::ASIC_TYPE_YUBA ||
888881 asicType == cfg::AsicType::ASIC_TYPE_G202X) {
889- switchInfo.connectionHandle () = " /dev/uio0" ;
890- }
891- switchInfo.systemPortRanges () = asic->getSystemPortRanges ();
892- if (asic->getLocalSystemPortOffset ().has_value ()) {
893- switchInfo.localSystemPortOffset () = *asic->getLocalSystemPortOffset ();
894- }
895- if (asic->getGlobalSystemPortOffset ().has_value ()) {
896- switchInfo.globalSystemPortOffset () = *asic->getGlobalSystemPortOffset ();
897- }
898- if (asic->getInbandPortId ().has_value ()) {
899- switchInfo.inbandPortId () = *asic->getInbandPortId ();
882+ connectionHandle = " /dev/uio0" ;
900883 }
884+
901885 if (platformType.has_value () &&
902886 platformType.value () == PlatformType::PLATFORM_LADAKH800BCLS) {
903- populateSwitchInfoForLadakh (static_cast <SwitchID>(switchId), switchInfo);
887+ portIdRange.maximum () =
888+ cfg::switch_config_constants::DEFAULT_PORT_ID_RANGE_MAX ();
889+ defaultSwitchIdToSwitchInfo.insert (
890+ {SwitchID (0 ),
891+ generateSwitchInfo ((SwitchID)0 , portIdRange, " 0000:15:00=0" , asic)});
892+ defaultHwAsicTable.insert ({SwitchID (0 ), asic});
893+
894+ // Add switch info for switch ID 1
895+ auto numPorts =
896+ (cfg::switch_config_constants::DEFAULT_PORT_ID_RANGE_MAX () -
897+ cfg::switch_config_constants::DEFAULT_PORT_ID_RANGE_MIN ()) +
898+ 1 ;
899+ portIdRange.minimum () =
900+ cfg::switch_config_constants::DEFAULT_PORT_ID_RANGE_MAX () + 1 ;
901+ portIdRange.maximum () =
902+ cfg::switch_config_constants::DEFAULT_PORT_ID_RANGE_MAX () + numPorts;
903+
904+ defaultSwitchIdToSwitchInfo.insert (
905+ {SwitchID (1 ),
906+ generateSwitchInfo ((SwitchID)1 , portIdRange, " 0000:18:00=0" , asic)});
907+ defaultHwAsicTable.insert ({SwitchID (1 ), asic});
908+ } else {
909+ cfg::SwitchInfo switchInfo = generateSwitchInfo (
910+ (SwitchID)switchId, portIdRange, connectionHandle, asic);
911+ defaultSwitchIdToSwitchInfo.insert ({SwitchID (switchId), switchInfo});
912+ defaultHwAsicTable.insert ({SwitchID (switchId), asic});
904913 }
905- defaultSwitchIdToSwitchInfo.insert ({SwitchID (switchId), switchInfo});
906914 populateSwitchInfo (
907915 config, defaultSwitchIdToSwitchInfo, defaultHwAsicTable, platformType);
908916 }
@@ -1083,21 +1091,34 @@ void populateSwitchInfo(
10831091 config.dsfNodes () = newDsfNodes;
10841092}
10851093
1086- void populateSwitchInfoForLadakh (
1094+ cfg::SwitchInfo generateSwitchInfo (
10871095 SwitchID switchId,
1088- cfg::SwitchInfo& switchInfo) {
1089- cfg::Range64 portIdRange;
1090- switchInfo.switchIndex () = static_cast <int64_t >(switchId);
1091- if (switchId == SwitchID (0 )) {
1092- portIdRange.minimum () = 1 ;
1093- portIdRange.maximum () = 512 ;
1094- switchInfo.connectionHandle () = " 0000:15:00=0" ;
1095- } else {
1096- portIdRange.minimum () = 2049 ;
1097- portIdRange.maximum () = 2560 ;
1098- switchInfo.connectionHandle () = " 0000:18:00=0" ;
1099- }
1096+ const cfg::Range64 portIdRange,
1097+ std::string connectionHandle,
1098+ const HwAsic* asic) {
1099+ cfg::SwitchInfo switchInfo;
1100+ auto asicType = asic->getAsicType ();
11001101 switchInfo.portIdRange () = portIdRange;
1102+ switchInfo.switchIndex () = switchId;
1103+ switchInfo.switchType () = asic->getSwitchType ();
1104+ switchInfo.asicType () = asicType;
1105+
1106+ if (asicType == cfg::AsicType::ASIC_TYPE_JERICHO2 ||
1107+ asicType == cfg::AsicType::ASIC_TYPE_JERICHO3) {
1108+ switchInfo.switchMac () = " 02:00:00:00:00:01" ;
1109+ }
1110+ switchInfo.systemPortRanges () = asic->getSystemPortRanges ();
1111+ if (asic->getLocalSystemPortOffset ().has_value ()) {
1112+ switchInfo.localSystemPortOffset () = *asic->getLocalSystemPortOffset ();
1113+ }
1114+ if (asic->getGlobalSystemPortOffset ().has_value ()) {
1115+ switchInfo.globalSystemPortOffset () = *asic->getGlobalSystemPortOffset ();
1116+ }
1117+ if (asic->getInbandPortId ().has_value ()) {
1118+ switchInfo.inbandPortId () = *asic->getInbandPortId ();
1119+ }
1120+ switchInfo.connectionHandle () = connectionHandle;
1121+ return switchInfo;
11011122}
11021123
11031124cfg::SwitchConfig
0 commit comments