diff --git a/Makefile.am b/Makefile.am index c966f44aa1..f2a71687db 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,4 @@ - -SUBDIRS = fpmsyncd neighsyncd portsyncd mclagsyncd natsyncd orchagent swssconfig cfgmgr tests +SUBDIRS = fpmsyncd neighsyncd portsyncd mclagsyncd natsyncd orchagent swssconfig cfgmgr tests gearsyncd if HAVE_LIBTEAM SUBDIRS += teamsyncd tlm_teamd diff --git a/cfgmgr/Makefile.am b/cfgmgr/Makefile.am index 7178cad1c6..001c6f1f99 100644 --- a/cfgmgr/Makefile.am +++ b/cfgmgr/Makefile.am @@ -1,4 +1,4 @@ -INCLUDES = -I $(top_srcdir) -I $(top_srcdir)/orchagent -I $(top_srcdir)/warmrestart -I $(top_srcdir)/orchagent/flex_counter +INCLUDES = -I$(top_srcdir)/lib -I $(top_srcdir) -I $(top_srcdir)/orchagent -I $(top_srcdir)/warmrestart -I $(top_srcdir)/orchagent/flex_counter CFLAGS_SAI = -I /usr/include/sai LIBNL_CFLAGS = -I/usr/include/libnl3 LIBNL_LIBS = -lnl-genl-3 -lnl-route-3 -lnl-3 diff --git a/configure.ac b/configure.ac index 974744a4f8..11c793201d 100644 --- a/configure.ac +++ b/configure.ac @@ -91,6 +91,7 @@ AC_CONFIG_FILES([ orchagent/Makefile fpmsyncd/Makefile neighsyncd/Makefile + gearsyncd/Makefile natsyncd/Makefile portsyncd/Makefile teamsyncd/Makefile diff --git a/gearsyncd/Makefile.am b/gearsyncd/Makefile.am new file mode 100644 index 0000000000..34bffb7633 --- /dev/null +++ b/gearsyncd/Makefile.am @@ -0,0 +1,15 @@ +INCLUDES = -I $(top_srcdir)/lib -I $(top_srcdir) -I $(top_srcdir)/warmrestart -I $(top_srcdir)/cfgmgr + +bin_PROGRAMS = gearsyncd + +if DEBUG +DBGFLAGS = -ggdb -DDEBUG +else +DBGFLAGS = -g +endif + +gearsyncd_SOURCES = $(top_srcdir)/lib/gearboxutils.cpp gearsyncd.cpp gearparserbase.cpp gearboxparser.cpp phyparser.cpp $(top_srcdir)/cfgmgr/shellcmd.h + +gearsyncd_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(COV_CFLAGS) $(ASAN_CFLAGS) + +gearsyncd_LDADD = -lnl-3 -lnl-route-3 -lswsscommon $(COV_LDFLAGS) $(ASAN_LDFLAGS) diff --git a/gearsyncd/gearboxparser.cpp b/gearsyncd/gearboxparser.cpp new file mode 100644 index 0000000000..65e0b4f05d --- /dev/null +++ b/gearsyncd/gearboxparser.cpp @@ -0,0 +1,286 @@ +/* + * Copyright 2019-2020 Broadcom Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gearboxparser.h" +#include "phyparser.h" +#include + +void GearboxParser::notifyGearboxConfigDone(bool success) +{ + swss::ProducerStateTable *p = getProducerStateTable().get(); + + swss::FieldValueTuple finish_notice("success", std::to_string(success)); + std::vector attrs = { finish_notice }; + + p->set("GearboxConfigDone", attrs); +} + +bool GearboxParser::parse() +{ + json root; + + try + { + root = getJSONRoot(); + } + catch (const std::exception& e) + { + SWSS_LOG_ERROR("JSON root not parseable"); + return false; + } + + json phys, phy, interfaces, interface, val, lanes; + + std::vector attrs; + + try + { + phys = root["phys"]; + if (phys.size() == 0) + { + SWSS_LOG_ERROR("zero-sized 'phys' field in gearbox configuration"); + return false; + } + } + catch (const std::exception& e) + { + SWSS_LOG_ERROR("unable to read gearbox configuration (invalid format)"); + return false; + } + + for (uint32_t iter = 0; iter < phys.size(); iter++) + { + phy = phys[iter]; + try + { + attrs.clear(); + swss::FieldValueTuple attr; + if (phy.find("phy_id") == phy.end()) + { + SWSS_LOG_ERROR("missing 'phy_id' field in 'phys' item %d in gearbox configuration", iter); + return false; + } + val = phy["phy_id"]; + int phyId = val.get(); + attr = std::make_pair("phy_id", std::to_string(phyId)); + attrs.push_back(attr); + if (phy.find("name") == phy.end()) + { + SWSS_LOG_ERROR("missing 'name' field in 'phys' item %d in gearbox configuration", iter); + return false; + } + val = phy["name"]; + std::string name(val.get()); + attr = std::make_pair("name", std::string(val.get())); + attrs.push_back(attr); + if (phy.find("address") == phy.end()) { + SWSS_LOG_ERROR("missing 'address' field in 'phys' item %d in gearbox configuration", iter); + return false; + } + val = phy["address"]; + attr = std::make_pair("address", std::string(val.get())); + attrs.push_back(attr); + if (phy.find("lib_name") == phy.end()) + { + SWSS_LOG_ERROR("missing 'lib_name' field in 'phys' item %d in gearbox configuration", iter); + return false; + } + val = phy["lib_name"]; + attr = std::make_pair("lib_name", std::string(val.get())); + attrs.push_back(attr); + if (phy.find("firmware_path") == phy.end()) + { + SWSS_LOG_ERROR("missing 'firmware_path' field in 'phys' item %d in gearbox configuration", iter); + return false; + } + val = phy["firmware_path"]; + attr = std::make_pair("firmware_path", std::string(val.get())); + attrs.push_back(attr); + if (phy.find("config_file") == phy.end()) + { + SWSS_LOG_ERROR("missing 'config_file' field in 'phys' item %d in gearbox configuration", iter); + return false; + } + val = phy["config_file"]; + std::string cfgFile(val.get()); + attr = std::make_pair("config_file", cfgFile); + attrs.push_back(attr); + if (phy.find("sai_init_config_file") == phy.end()) + { + SWSS_LOG_ERROR("missing 'sai_init_config_file' field in 'phys' item %d in gearbox configuration", iter); + return false; + } + val = phy["sai_init_config_file"]; + std::string bcmCfgFile(std::string(val.get())); + attr = std::make_pair("sai_init_config_file", bcmCfgFile); + attrs.push_back(attr); + if (phy.find("phy_access") == phy.end()) + { + SWSS_LOG_ERROR("missing 'phy_access' field in 'phys' item %d in gearbox configuration", iter); + return false; + } + val = phy["phy_access"]; + attr = std::make_pair("phy_access", std::string(val.get())); + attrs.push_back(attr); + if (phy.find("bus_id") == phy.end()) + { + SWSS_LOG_ERROR("missing 'bus_id' field in 'phys' item %d in gearbox configuration", iter); + return false; + } + val = phy["bus_id"]; + attr = std::make_pair("bus_id", std::to_string(val.get())); + attrs.push_back(attr); + std::string key; + key = "phy:" + std::to_string(phyId); + if (getWriteToDb() == true) + { + writeToDb(key, attrs); + } + PhyParser p; + p.setPhyId(phyId); + p.setWriteToDb(getWriteToDb()); + p.setConfigPath(cfgFile); + if (p.parse() == false) + { + SWSS_LOG_ERROR("phy parser failed to parse item %d in gearbox configuration", iter); + return false; + } + } + catch (const std::exception& e) + { + SWSS_LOG_ERROR("unable to read 'phys' item %d in gearbox configuration (invalid format)", iter); + return false; + } + } + + if (root.find("interfaces") != root.end()) + { + interfaces = root["interfaces"]; // vec + if (interfaces.size() == 0) + { + SWSS_LOG_ERROR("zero-sized 'interfaces' field in gearbox configuration"); + return false; + } + for (uint32_t iter = 0; iter < interfaces.size(); iter++) + { + attrs.clear(); + interface = interfaces[iter]; + try + { + swss::FieldValueTuple attr; + + if (interface.find("name") == interface.end()) + { + SWSS_LOG_ERROR("missing 'name' field in 'interfaces' item %d in gearbox configuration", iter); + return false; + } + val = interface["name"]; + attr = std::make_pair("name", std::string(val.get())); + attrs.push_back(attr); + + if (interface.find("index") == interface.end()) + { + SWSS_LOG_ERROR("missing 'index' field in 'interfaces' item %d in gearbox configuration", iter); + return false; + } + val = interface["index"]; + int index = val.get(); + attr = std::make_pair("index", std::to_string(index)); + attrs.push_back(attr); + + if (interface.find("phy_id") == interface.end()) + { + SWSS_LOG_ERROR("missing 'phy_id' field in 'interfaces' item %d in gearbox configuration", iter); + return false; + } + val = interface["phy_id"]; + attr = std::make_pair("phy_id", std::to_string(val.get())); + attrs.push_back(attr); + + if (interface.find("system_lanes") != interface.end()) + { + lanes = interface["system_lanes"]; // vec + std::string laneStr(""); + if (lanes.size() == 0) + { + SWSS_LOG_ERROR("zero-sized 'system_lanes' field in 'interfaces' item %d in gearbox configuration", iter); + return false; + } + for (uint32_t iter2 = 0; iter2 < lanes.size(); iter2++) + { + val = lanes[iter2]; + if (laneStr.length() > 0) + { + laneStr += ","; + } + laneStr += std::to_string(val.get()); + } + attr = std::make_pair("system_lanes", laneStr); + attrs.push_back(attr); + } + else + { + SWSS_LOG_ERROR("missing 'system_lanes' field in 'interfaces' item %d in gearbox configuration", iter); + return false; + } + + if (interface.find("line_lanes") != interface.end()) + { + lanes = interface["line_lanes"]; // vec + std::string laneStr(""); + if (lanes.size() == 0) + { + SWSS_LOG_ERROR("zero-sized 'line_lanes' field in 'interfaces' item %d in gearbox configuration", iter); + return false; + } + for (uint32_t iter2 = 0; iter2 < lanes.size(); iter2++) + { + val = lanes[iter2]; + if (laneStr.length() > 0) + { + laneStr += ","; + } + laneStr += std::to_string(val.get()); + } + attr = std::make_pair("line_lanes", laneStr); + attrs.push_back(attr); + } + else + { + SWSS_LOG_ERROR("missing 'line_lanes' field in 'interfaces' item %d in gearbox configuration", iter); + return false; + } + std::string key; + key = "interface:" + std::to_string(index); + if (getWriteToDb() == true) + { + writeToDb(key, attrs); + } + } + catch (const std::exception& e) + { + SWSS_LOG_ERROR("unable to read 'interfaces' item %d in gearbox configuration (invalid format)", iter); + return false; + } + } + } + else + { + SWSS_LOG_ERROR("unable to read 'interfaces' item in gearbox configuration"); + return false; + } + return true; +} diff --git a/gearsyncd/gearboxparser.h b/gearsyncd/gearboxparser.h new file mode 100644 index 0000000000..dc5ec39683 --- /dev/null +++ b/gearsyncd/gearboxparser.h @@ -0,0 +1,27 @@ +/* + * Copyright 2019-2020 Broadcom Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "gearparserbase.h" + +class GearboxParser: public GearParserBase +{ +public: + bool parse(); + void notifyGearboxConfigDone(bool success); +}; + diff --git a/gearsyncd/gearparserbase.cpp b/gearsyncd/gearparserbase.cpp new file mode 100644 index 0000000000..c6cae36253 --- /dev/null +++ b/gearsyncd/gearparserbase.cpp @@ -0,0 +1,69 @@ +/* + * Copyright 2020 Broadcom Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gearparserbase.h" +#include +#include +#include + +void +GearParserBase::init() +{ + m_writeToDb = false; + m_rootInit = false; + m_applDb = std::unique_ptr{new swss::DBConnector(APPL_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0)}; + m_producerStateTable = std::unique_ptr{new swss::ProducerStateTable(m_applDb.get(), APP_GEARBOX_TABLE_NAME)}; +} + +GearParserBase::GearParserBase() +{ + init(); +} + +GearParserBase::~GearParserBase() +{ +} + +json & GearParserBase::getJSONRoot() +{ + // lazy instantiate + + if (m_rootInit == false) + { + std::ifstream infile(getConfigPath()); + if (infile.is_open()) + { + std::string jsonBuffer; + std::string line; + + while (getline(infile, line)) + { + jsonBuffer += line; + } + infile.close(); + + m_root = json::parse(jsonBuffer.c_str()); + m_rootInit = true; + } + } + return m_root; +} + +bool GearParserBase::writeToDb(std::string &key, std::vector &attrs) +{ + m_producerStateTable.get()->set(key.c_str(), attrs); + return true; +} diff --git a/gearsyncd/gearparserbase.h b/gearsyncd/gearparserbase.h new file mode 100644 index 0000000000..d9db7556d9 --- /dev/null +++ b/gearsyncd/gearparserbase.h @@ -0,0 +1,60 @@ +/* + * Copyright 2019-2020 Broadcom Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "dbconnector.h" +#include "producerstatetable.h" +#include +#include +#include + + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wshadow" +#include "swss/json.hpp" +#pragma GCC diagnostic pop + +using json = nlohmann::json; + +class GearParserBase +{ +public: + GearParserBase(); + virtual ~GearParserBase(); + virtual bool parse() = 0; + void setWriteToDb(bool val) {m_writeToDb = val;} + bool getWriteToDb() {return m_writeToDb;} + void setConfigPath(std::string &path) {m_cfgPath = path;} + const std::string getConfigPath() {return m_cfgPath;} + std::unique_ptr &getProducerStateTable() {return m_producerStateTable;} + +protected: + bool writeToDb(std::string &key, std::vector &attrs); + json &getJSONRoot(); + +private: + void init(); + std::unique_ptr m_cfgDb; + std::unique_ptr m_applDb; + std::unique_ptr m_stateDb; + std::unique_ptr m_producerStateTable; + std::string m_cfgPath; + bool m_writeToDb; + json m_root; + bool m_rootInit; +}; + diff --git a/gearsyncd/gearsyncd.cpp b/gearsyncd/gearsyncd.cpp new file mode 100644 index 0000000000..a447416da3 --- /dev/null +++ b/gearsyncd/gearsyncd.cpp @@ -0,0 +1,158 @@ +/* + * Copyright 2020 Broadcom Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include "dbconnector.h" +#include "producerstatetable.h" +#include "warm_restart.h" +#include "gearboxparser.h" +#include "gearboxutils.h" +#include "schema.h" + +#include + +using namespace std; +using namespace swss; + +void usage() +{ + cout << "Usage: gearsyncd [-p gear_config.json]" << endl; + cout << " -p gearbox_config.json: import gearbox config" << endl; + cout << " use configDB data if not specified" << endl; +} + +bool handleGearboxConfigFile(string file, bool warm); +bool handleGearboxConfigFromConfigDB(ProducerStateTable &p, DBConnector &cfgDb, bool warm); + +static void notifyGearboxConfigDone(ProducerStateTable &p, bool success) +{ + /* Notify that gearbox config successfully written */ + + FieldValueTuple finish_notice("success", to_string(success)); + std::vector attrs = { finish_notice }; + + p.set("GearboxConfigDone", attrs); +} + +int main(int argc, char **argv) +{ + Logger::linkToDbNative("gearsyncd"); + int opt; + string gearbox_config_file; + map gearbox_cfg_map; + GearboxUtils utils; + + while ((opt = getopt(argc, argv, "p:ht")) != -1 ) + { + switch (opt) + { + case 'p': + gearbox_config_file.assign(optarg); + break; + case 'h': + usage(); + return 1; + default: /* '?' */ + usage(); + return EXIT_FAILURE; + } + } + + DBConnector cfgDb(CONFIG_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); + DBConnector applDb(APPL_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); + ProducerStateTable producerStateTable(&applDb, APP_GEARBOX_TABLE_NAME); + + WarmStart::initialize("gearsyncd", "swss"); + WarmStart::checkWarmStart("gearsyncd", "swss"); + const bool warm = WarmStart::isWarmStart(); + + try + { + if (utils.platformHasGearbox() == false) + { + // no gearbox, move on + + notifyGearboxConfigDone(producerStateTable, true); + } + else if (!handleGearboxConfigFromConfigDB(producerStateTable, cfgDb, warm)) + { + // if gearbox config is missing in ConfigDB + // attempt to use gearbox_config.json + if (!gearbox_config_file.empty()) + { + handleGearboxConfigFile(gearbox_config_file, warm); + } + } + } + catch (const std::exception& e) + { + cerr << "Exception \"" << e.what() << "\" had been thrown in gearsyncd daemon" << endl; + return EXIT_FAILURE; + } + return 1; +} + +bool handleGearboxConfigFromConfigDB(ProducerStateTable &p, DBConnector &cfgDb, bool warm) +{ + cout << "Get gearbox configuration from ConfigDB..." << endl; + + Table table(&cfgDb, CFG_GEARBOX_TABLE_NAME); + std::vector ovalues; + std::vector keys; + table.getKeys(keys); + + if (keys.empty()) + { + cout << "No gearbox configuration in ConfigDB" << endl; + return false; + } + + for ( auto &k : keys ) + { + table.get(k, ovalues); + vector attrs; + for ( auto &v : ovalues ) + { + FieldValueTuple attr(v.first, v.second); + attrs.push_back(attr); + } + if (!warm) + { + p.set(k, attrs); + } + } + if (!warm) + { + notifyGearboxConfigDone(p, true); + } + + return true; +} + +bool handleGearboxConfigFile(string file, bool warm) +{ + GearboxParser parser; + bool ret; + + parser.setWriteToDb(true); + parser.setConfigPath(file); + ret = parser.parse(); + parser.notifyGearboxConfigDone(ret); // if (!warm....) + return ret; +} diff --git a/gearsyncd/phyparser.cpp b/gearsyncd/phyparser.cpp new file mode 100644 index 0000000000..69ddcc0264 --- /dev/null +++ b/gearsyncd/phyparser.cpp @@ -0,0 +1,453 @@ +/* + * Copyright 2019-2020 Broadcom Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "phyparser.h" + +bool PhyParser::parse() +{ + json root; + + try + { + root = getJSONRoot(); + } + catch (const std::exception& e) + { + SWSS_LOG_ERROR("JSON root not parseable"); + return false; + } + + std::vector attrs; + swss::FieldValueTuple attr; + json val, vals, ports, port, lanes, lane; + std::string valsStr; + + try + { + lanes = root["lanes"]; + if (lanes.size() == 0) + { + SWSS_LOG_ERROR("zero-sized 'lanes' field in phy configuration"); + return false; + } + } + catch (const std::exception& e) + { + SWSS_LOG_ERROR("unable to read phy configuration (invalid format)"); + return false; + } + for (uint32_t iter = 0; iter < lanes.size(); iter++) + { + lane = lanes[iter]; + try + { + attrs.clear(); + + /* index */ + if (lane.find("index") == lane.end()) + { + SWSS_LOG_ERROR("missing 'index' field of item %d of 'lanes' field in phy configuration", iter); + return false; + } + val = lane["index"]; + int id = val.get(); + attr = std::make_pair("index", std::to_string(id)); + attrs.push_back(attr); + + /* system_side */ + if (lane.find("system_side") == lane.end()) + { + SWSS_LOG_ERROR("missing 'system_side' field of item %d of 'lanes' field in phy configuration", iter); + return false; + } + val = lane["system_side"]; + if (val.get() != false && val.get() != true) + { + SWSS_LOG_ERROR("not a boolean: 'system_side' field of item %d of 'lanes' field in phy configuration", iter); + return false; + } + std::string systemSideStr = val.get() == true ? "true" : "false"; + attr = std::make_pair("system_side", systemSideStr); + attrs.push_back(attr); + + /* local_lane_id */ + if (lane.find("local_lane_id") == lane.end()) + { + SWSS_LOG_ERROR("missing 'local_lane_id' field of item %d of 'lanes' field in phy configuration", iter); + return false; + } + val = lane["local_lane_id"]; + attr = std::make_pair("local_lane_id", std::to_string(val.get())); + attrs.push_back(attr); + + /* tx_polarity */ + if (lane.find("tx_polarity") == lane.end()) + { + SWSS_LOG_ERROR("missing 'tx_polarity' field of item %d of 'lanes' field in phy configuration", iter); + return false; + } + val = lane["tx_polarity"]; + attr = std::make_pair("tx_polarity", std::to_string(val.get())); + attrs.push_back(attr); + + /* rx_polarity */ + if (lane.find("rx_polarity") == lane.end()) + { + SWSS_LOG_ERROR("missing 'rx_polarity' field of item %d of 'lanes' field in phy configuration", iter); + return false; + } + val = lane["rx_polarity"]; + attr = std::make_pair("rx_polarity", std::to_string(val.get())); + attrs.push_back(attr); + + /* line_tx_lanemap */ + if (lane.find("line_tx_lanemap") == lane.end()) + { + SWSS_LOG_ERROR("missing 'line_tx_lanemap' field of item %d of 'lanes' field in phy configuration", iter); + return false; + } + val = lane["line_tx_lanemap"]; + attr = std::make_pair("line_tx_lanemap", std::to_string(val.get())); + attrs.push_back(attr); + + /* line_rx_lanemap */ + if (lane.find("line_rx_lanemap") == lane.end()) + { + SWSS_LOG_ERROR("missing 'line_rx_lanemap' field of item %d of 'lanes' field in phy configuration", iter); + return false; + } + val = lane["line_rx_lanemap"]; + attr = std::make_pair("line_rx_lanemap", std::to_string(val.get())); + attrs.push_back(attr); + + /* line_to_system_lanemap */ + if (lane.find("line_to_system_lanemap") == lane.end()) + { + SWSS_LOG_ERROR("missing 'line_to_system_lanemap' field of item %d of 'lanes' field in phy configuration", iter); + return false; + } + val = lane["line_to_system_lanemap"]; + attr = std::make_pair("line_to_system_lanemap", std::to_string(val.get())); + attrs.push_back(attr); + + /* mdio_addr */ + if (lane.find("mdio_addr") == lane.end()) + { + SWSS_LOG_ERROR("missing 'mdio_addr' field of item %d of 'lanes' field in phy configuration", iter); + return false; + } + val = lane["mdio_addr"]; + attr = std::make_pair("mdio_addr", val.get()); + attrs.push_back(attr); + + std::string key; + key = "phy:" + std::to_string(getPhyId()) + ":lanes:" + std::to_string(id); + if (getWriteToDb() == true) + { + writeToDb(key, attrs); + } + } + catch (const std::exception& e) + { + SWSS_LOG_ERROR("unable to read lanes configuration item %d (invalid format)", iter); + return false; + } + } + if (root.find("ports") != root.end()) + { + ports = root["ports"]; + if (ports.size() == 0) + { + SWSS_LOG_ERROR("zero-sized 'ports' field in phy configuration"); + return false; + } + for (uint32_t iter = 0; iter < ports.size(); iter++) + { + port = ports[iter]; + try + { + attrs.clear(); + swss::FieldValueTuple attr; + + /* index */ + if (port.find("index") == port.end()) + { + SWSS_LOG_ERROR("missing 'index' field of item %d of 'ports' field in phy configuration", iter); + return false; + } + val = port["index"]; + int id = val.get(); + attr = std::make_pair("index", std::to_string(id)); + attrs.push_back(attr); + + /* mdio_addr */ + if (port.find("mdio_addr") == port.end()) + { + SWSS_LOG_ERROR("missing 'mdio_addr' field of item %d of 'ports' field in phy configuration", iter); + return false; + } + val = port["mdio_addr"]; + attr = std::make_pair("mdio_addr", val.get()); + attrs.push_back(attr); + + /* system_speed */ + if (port.find("system_speed") == port.end()) + { + SWSS_LOG_ERROR("missing 'system_speed' field of item %d of 'ports' field in phy configuration", iter); + return false; + } + val = port["system_speed"]; + attr = std::make_pair("system_speed", std::to_string(val.get())); + attrs.push_back(attr); + + /* system_fec */ + if (port.find("system_fec") == port.end()) + { + SWSS_LOG_ERROR("missing 'system_fec' field of item %d of 'ports' field in phy configuration", iter); + return false; + } + val = port["system_fec"]; + attr = std::make_pair("system_fec", val.get()); + attrs.push_back(attr); + + /* system_auto_neg */ + if (port.find("system_auto_neg") == port.end()) + { + SWSS_LOG_ERROR("missing 'system_auto_neg' field of item %d of 'ports' field in phy configuration", iter); + return false; + } + val = port["system_auto_neg"]; + if (val.get() != false && val.get() != true) + { + SWSS_LOG_ERROR("not a boolean: 'system_auto_neg' field of item %d of 'ports' field in phy configuration", iter); + return false; + } + std::string systemAutoNegStr = val.get() == true ? "true" : "false"; + attr = std::make_pair("system_auto_neg", systemAutoNegStr); + attrs.push_back(attr); + + /* system_loopback */ + if (port.find("system_loopback") == port.end()) + { + SWSS_LOG_ERROR("missing 'system_loopback' field of item %d of 'ports' field in phy configuration", iter); + return false; + } + val = port["system_loopback"]; + attr = std::make_pair("system_loopback", val.get()); + attrs.push_back(attr); + + /* system_training */ + if (port.find("system_training") == port.end()) + { + SWSS_LOG_ERROR("missing 'system_training' field of item %d of 'ports' field in phy configuration", iter); + return false; + } + val = port["system_training"]; + if (val.get() != false && val.get() != true) + { + SWSS_LOG_ERROR("not a boolean: 'system_training' field of item %d of 'ports' field in phy configuration", iter); + return false; + } + std::string systemTrainingStr = val.get() == true ? "true" : "false"; + attr = std::make_pair("system_training", systemTrainingStr); + attrs.push_back(attr); + + /* line_speed */ + if (port.find("line_speed") == port.end()) + { + SWSS_LOG_ERROR("missing 'line_speed' field of item %d of 'ports' field in phy configuration", iter); + return false; + } + val = port["line_speed"]; + attr = std::make_pair("line_speed", std::to_string(val.get())); + attrs.push_back(attr); + + /* line_fec */ + if (port.find("line_fec") == port.end()) + { + SWSS_LOG_ERROR("missing 'line_fec' field of item %d of 'ports' field in phy configuration", iter); + return false; + } + val = port["line_fec"]; + attr = std::make_pair("line_fec", val.get()); + attrs.push_back(attr); + + /* line_auto_neg */ + if (port.find("line_auto_neg") == port.end()) + { + SWSS_LOG_ERROR("missing 'line_auto_neg' field of item %d of 'ports' field in phy configuration", iter); + return false; + } + val = port["line_auto_neg"]; + if (val.get() != false && val.get() != true) + { + SWSS_LOG_ERROR("not a boolean: 'line_auto_neg' field of item %d of 'ports' field in phy configuration", iter); + return false; + } + std::string lineAutoNegStr = val.get() == true ? "true" : "false"; + attr = std::make_pair("line_auto_neg", lineAutoNegStr); + attrs.push_back(attr); + + /* line_media_type */ + if (port.find("line_media_type") == port.end()) + { + SWSS_LOG_ERROR("missing 'line_media_type' field of item %d of 'ports' field in phy configuration", iter); + return false; + } + val = port["line_media_type"]; + attr = std::make_pair("line_media_type", val.get()); + attrs.push_back(attr); + + /* line_intf_type */ + if (port.find("line_intf_type") == port.end()) + { + SWSS_LOG_ERROR("missing 'line_intf_type' field of item %d of 'ports' field in phy configuration", iter); + return false; + } + val = port["line_intf_type"]; + attr = std::make_pair("line_intf_type", val.get()); + attrs.push_back(attr); + + /* line_loopback */ + if (port.find("line_loopback") == port.end()) + { + SWSS_LOG_ERROR("missing 'line_loopback' field of item %d of 'ports' field in phy configuration", iter); + return false; + } + val = port["line_loopback"]; + attr = std::make_pair("line_loopback", val.get()); + attrs.push_back(attr); + + /* line_training */ + if (port.find("line_training") == port.end()) + { + SWSS_LOG_ERROR("missing 'line_training' field of item %d of 'ports' field in phy configuration", iter); + return false; + } + val = port["line_training"]; + if (val.get() != false && val.get() != true) + { + SWSS_LOG_ERROR("not a boolean: 'line_training' field of item %d of 'ports' field in phy configuration", iter); + return false; + } + std::string lineTrainingStr = val.get() == true ? "true" : "false"; + attr = std::make_pair("line_training", lineTrainingStr); + attrs.push_back(attr); + + /* line_adver_speed */ + if (port.find("line_adver_speed") == port.end()) + { + SWSS_LOG_ERROR("missing 'line_adver_speed' field of item %d of 'ports' field in phy configuration", iter); + return false; + } + vals = port["line_adver_speed"]; // vec + valsStr = ""; + for (uint32_t iter1 = 0; iter1 < vals.size(); iter1++) + { + val = vals[iter1]; + if (valsStr.length() > 0) + { + valsStr += ","; + } + valsStr += std::to_string(val.get()); + } + attr = std::make_pair("line_adver_speed", valsStr); + attrs.push_back(attr); + + /* line_adver_fec */ + if (port.find("line_adver_fec") == port.end()) + { + SWSS_LOG_ERROR("missing 'line_adver_fec' field of item %d of 'ports' field in phy configuration", iter); + return false; + } + vals = port["line_adver_fec"]; // vec + valsStr = ""; + for (uint32_t iter1 = 0; iter1 < vals.size(); iter1++) + { + val = vals[iter1]; + if (valsStr.length() > 0) + { + valsStr += ","; + } + valsStr += std::to_string(val.get()); + } + attr = std::make_pair("line_adver_fec", valsStr); + attrs.push_back(attr); + + /* line_adver_auto_neg */ + if (port.find("line_adver_auto_neg") == port.end()) + { + SWSS_LOG_ERROR("missing 'line_adver_auto_neg' field of item %d of 'ports' field in phy configuration", iter); + return false; + } + val = port["line_adver_auto_neg"]; + if (val.get() != false && val.get() != true) + { + SWSS_LOG_ERROR("not a boolean: 'line_adver_auto_neg' field of item %d of 'ports' field in phy configuration", iter); + return false; + } + std::string lineAdverAutoNegStr = val.get() == true ? "true" : "false"; + attr = std::make_pair("line_adver_auto_neg", lineAdverAutoNegStr); + attrs.push_back(attr); + + /* line_adver_asym_pause */ + if (port.find("line_adver_asym_pause") == port.end()) + { + SWSS_LOG_ERROR("missing 'line_adver_asym_pause' field of item %d of 'ports' field in phy configuration", iter); + return false; + } + val = port["line_adver_asym_pause"]; + if (val.get() != false && val.get() != true) + { + SWSS_LOG_ERROR("not a boolean: 'line_adver_asym_pause' field of item %d of 'ports' field in phy configuration", iter); + return false; + } + std::string lineAdverAsymPauseStr = val.get() == true ? "true" : "false"; + attr = std::make_pair("line_adver_asym_pause", lineAdverAsymPauseStr); + attrs.push_back(attr); + + /* line_adver_media_type */ + if (port.find("line_adver_media_type") == port.end()) + { + SWSS_LOG_ERROR("missing 'line_adver_media_type' field of item %d of 'ports' field in phy configuration", iter); + return false; + } + val = port["line_adver_media_type"]; + attr = std::make_pair("line_adver_media_type", val.get()); + attrs.push_back(attr); + + std::string key; + int phyId = getPhyId(); + key = "phy:" + std::to_string(phyId) + ":ports:" + std::to_string(id); + if (getWriteToDb() == true) + { + writeToDb(key, attrs); + } + } + catch (const std::exception& e) + { + SWSS_LOG_ERROR("unable to read ports configuration item %d (invalid format): %s", iter, e.what()); + return false; + } + } + } + else + { + SWSS_LOG_ERROR("missing 'ports' field in phy configuration"); + return false; + } + return true; +} diff --git a/gearsyncd/phyparser.h b/gearsyncd/phyparser.h new file mode 100644 index 0000000000..dcb42d70d5 --- /dev/null +++ b/gearsyncd/phyparser.h @@ -0,0 +1,30 @@ +/* + * Copyright 2019-2020 Broadcom Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "gearparserbase.h" + +class PhyParser: public GearParserBase +{ +public: + bool parse(); + void setPhyId(int id) {m_phyId = id;}; + int getPhyId() {return m_phyId;}; +private: + int m_phyId; +}; + diff --git a/gearsyncd/tests/configs/negative/gearbox_config_empty_ethernet_line_lanes.json b/gearsyncd/tests/configs/negative/gearbox_config_empty_ethernet_line_lanes.json new file mode 100644 index 0000000000..16a790b519 --- /dev/null +++ b/gearsyncd/tests/configs/negative/gearbox_config_empty_ethernet_line_lanes.json @@ -0,0 +1,49 @@ +{ + "phys": [ + { + "phy_id": 0, + "name": "example-1", + "address": "0x1000", + "lib_name": "libsai_phy_example1.so", + "firmware_path": "/tmp/phy-example1.bin", + "config_file": "tests/configs/positive/phy1_config_1.json", + "sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm", + "phy_access": "mdio", + "bus_id": 0 + }, + { + "phy_id": 1, + "name": "example-2", + "address": "0x2000", + "lib_name": "libsai_phy_example2.so", + "firmware_path": "/tmp/phy-example2.bin", + "config_file": "tests/configs/positive/phy2_config_1.json", + "sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm", + "phy_access": "i2c", + "bus_id": 1 + } + ], + "interfaces": [ + { + "name": "Ethernet0", + "index": 0, + "phy_id" : 0, + "system_lanes": [38,39], + "line_lanes": [] + }, + { + "name": "Ethernet1", + "index": 1, + "phy_id" : 0, + "system_lanes": [40,41], + "line_lanes": [34,35,36,37] + }, + { + "name": "Ethernet2", + "index": 2, + "phy_id" : 1, + "system_lanes": [4,5], + "line_lanes": [0,1,2,3] + } + ] +} diff --git a/gearsyncd/tests/configs/negative/gearbox_config_empty_ethernet_system_lanes.json b/gearsyncd/tests/configs/negative/gearbox_config_empty_ethernet_system_lanes.json new file mode 100644 index 0000000000..86bedc7c1d --- /dev/null +++ b/gearsyncd/tests/configs/negative/gearbox_config_empty_ethernet_system_lanes.json @@ -0,0 +1,49 @@ +{ + "phys": [ + { + "phy_id": 0, + "name": "example-1", + "address": "0x1000", + "lib_name": "libsai_phy_example1.so", + "firmware_path": "/tmp/phy-example1.bin", + "config_file": "tests/configs/positive/phy1_config_1.json", + "sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm", + "phy_access": "mdio", + "bus_id": 0 + }, + { + "phy_id": 1, + "name": "example-2", + "address": "0x2000", + "lib_name": "libsai_phy_example2.so", + "firmware_path": "/tmp/phy-example2.bin", + "config_file": "tests/configs/positive/phy2_config_1.json", + "sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm", + "phy_access": "i2c", + "bus_id": 1 + } + ], + "interfaces": [ + { + "name": "Ethernet0", + "index": 0, + "phy_id" : 0, + "system_lanes": [], + "line_lanes": [30,31,32,33] + }, + { + "name": "Ethernet1", + "index": 1, + "phy_id" : 0, + "system_lanes": [40,41], + "line_lanes": [34,35,36,37] + }, + { + "name": "Ethernet2", + "index": 2, + "phy_id" : 1, + "system_lanes": [4,5], + "line_lanes": [0,1,2,3] + } + ] +} diff --git a/gearsyncd/tests/configs/negative/gearbox_config_invalid_array.json b/gearsyncd/tests/configs/negative/gearbox_config_invalid_array.json new file mode 100644 index 0000000000..3533c0e54b --- /dev/null +++ b/gearsyncd/tests/configs/negative/gearbox_config_invalid_array.json @@ -0,0 +1,49 @@ +{ + "phys": [ + { + "phy_id": 0, + "name": "example-1", + "address": "0x1000", + "lib_name": "libsai_phy_example1.so", + "firmware_path": "/tmp/phy-example1.bin", + "config_file": "tests/configs/positive/phy1_config_1.json", + "sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm", + "phy_access": "mdio", + "bus_id": 0 + }, + { + "phy_id": 1, + "name": "example-2", + "address": "0x2000", + "lib_name": "libsai_phy_example2.so", + "firmware_path": "/tmp/phy-example2.bin", + "config_file": "tests/configs/positive/phy2_config_1.json", + "sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm", + "phy_access": "i2c", + "bus_id": 1 + } + ], + "interfaces": [ + { + "name": "Ethernet0", + "index": 0, + "phy_id" : 0, + "system_lanes": false, + "line_lanes": [30,31,32,33] + }, + { + "name": "Ethernet1", + "index": 1, + "phy_id" : 0, + "system_lanes": [40,41], + "line_lanes": [34,35,36,37] + }, + { + "name": "Ethernet2", + "index": 2, + "phy_id" : 1, + "system_lanes": [4,5], + "line_lanes": [0,1,2,3] + } + ] +} diff --git a/gearsyncd/tests/configs/negative/gearbox_config_invalid_json.json b/gearsyncd/tests/configs/negative/gearbox_config_invalid_json.json new file mode 100644 index 0000000000..eae5bc7aa2 --- /dev/null +++ b/gearsyncd/tests/configs/negative/gearbox_config_invalid_json.json @@ -0,0 +1,49 @@ + + "phys": [ + { + "phy_id": 0, + "name": "example-1", + "address": "0x1000", + "lib_name": "libsai_phy_example1.so", + "firmware_path": "/tmp/phy-example1.bin", + "config_file": "tests/configs/positive/phy1_config_1.json", + "sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm", + "phy_access": "mdio", + "bus_id": 0 + }, + { + "phy_id": 1, + "name": "example-2", + "address": "0x2000", + "lib_name": "libsai_phy_example2.so", + "firmware_path": "/tmp/phy-example2.bin", + "config_file": "tests/configs/positive/phy2_config_1.json", + "sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm", + "phy_access": "i2c", + "bus_id": 1 + } + ], + "interfaces": [ + { + "name": "Ethernet0", + "index": 0, + "phy_id" : 0, + "system_lanes": [38,39], + "line_lanes": [30,31,32,33] + }, + { + "name": "Ethernet1", + "index": 1, + "phy_id" : 0, + "system_lanes": [40,41], + "line_lanes": [34,35,36,37] + }, + { + "name": "Ethernet2", + "index": 2, + "phy_id" : 1, + "system_lanes": [4,5], + "line_lanes": [0,1,2,3] + } + ] +} diff --git a/gearsyncd/tests/configs/negative/gearbox_config_invalid_phy_config_file.json b/gearsyncd/tests/configs/negative/gearbox_config_invalid_phy_config_file.json new file mode 100644 index 0000000000..c567489538 --- /dev/null +++ b/gearsyncd/tests/configs/negative/gearbox_config_invalid_phy_config_file.json @@ -0,0 +1,49 @@ +{ + "phys": [ + { + "phy_id": 0, + "name": "example-1", + "address": "0x1000", + "lib_name": "libsai_phy_example1.so", + "firmware_path": "/tmp/phy-example1.bin", + "config_file": "tests/configs/positive/phy_config_does_not_exist.json", + "sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm", + "phy_access": "mdio", + "bus_id": 0 + }, + { + "phy_id": 1, + "name": "example-2", + "address": "0x2000", + "lib_name": "libsai_phy_example2.so", + "firmware_path": "/tmp/phy-example2.bin", + "config_file": "tests/configs/positive/phy2_config_1.json", + "sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm", + "phy_access": "i2c", + "bus_id": 1 + } + ], + "interfaces": [ + { + "name": "Ethernet0", + "index": 0, + "phy_id" : 0, + "system_lanes": [38,39], + "line_lanes": [30,31,32,33] + }, + { + "name": "Ethernet1", + "index": 1, + "phy_id" : 0, + "system_lanes": [40,41], + "line_lanes": [34,35,36,37] + }, + { + "name": "Ethernet2", + "index": 2, + "phy_id" : 1, + "system_lanes": [4,5], + "line_lanes": [0,1,2,3] + } + ] +} diff --git a/gearsyncd/tests/configs/negative/gearbox_config_missing_ethernet_index.json b/gearsyncd/tests/configs/negative/gearbox_config_missing_ethernet_index.json new file mode 100644 index 0000000000..b863410e64 --- /dev/null +++ b/gearsyncd/tests/configs/negative/gearbox_config_missing_ethernet_index.json @@ -0,0 +1,47 @@ +{ + "phys": [ + { + "phy_id": 0, + "name": "example-1", + "address": "0x1000", + "lib_name": "libsai_phy_example1.so", + "firmware_path": "/tmp/phy-example1.bin", + "config_file": "tests/configs/positive/phy1_config_1.json", + "sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm", + "phy_access": "mdio", + "bus_id": 0 + }, + { + "phy_id": 1, + "name": "example-2", + "address": "0x2000", + "lib_name": "libsai_phy_example2.so", + "firmware_path": "/tmp/phy-example2.bin", + "config_file": "tests/configs/positive/phy2_config_1.json", + "sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm", + "phy_access": "i2c", + "bus_id": 1 + } + ], + "interfaces": [ + { + "name": "Ethernet0", + "system_lanes": [38,39], + "line_lanes": [30,31,32,33] + }, + { + "name": "Ethernet1", + "index": 1, + "phy_id" : 0, + "system_lanes": [40,41], + "line_lanes": [34,35,36,37] + }, + { + "name": "Ethernet2", + "index": 2, + "phy_id" : 1, + "system_lanes": [4,5], + "line_lanes": [0,1,2,3] + } + ] +} diff --git a/gearsyncd/tests/configs/negative/gearbox_config_missing_ethernet_line_lane_speed.json b/gearsyncd/tests/configs/negative/gearbox_config_missing_ethernet_line_lane_speed.json new file mode 100644 index 0000000000..b3dea20955 --- /dev/null +++ b/gearsyncd/tests/configs/negative/gearbox_config_missing_ethernet_line_lane_speed.json @@ -0,0 +1,49 @@ +{ + "phys": [ + { + "phy_id": 0, + "name": "example-1", + "address": "0x1000", + "lib_name": "libsai_phy_example1.so", + "firmware_path": "/tmp/phy-example1.bin", + "config_file": "tests/configs/positive/phy1_config_1.json", + "sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm", + "phy_access": "mdio", + "bus_id": 0 + }, + { + "phy_id": 1, + "name": "example-2", + "address": "0x2000", + "lib_name": "libsai_phy_example2.so", + "firmware_path": "/tmp/phy-example2.bin", + "config_file": "tests/configs/positive/phy2_config_1.json", + "sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm", + "phy_access": "i2c", + "bus_id": 1 + } + ], + "interfaces": [ + { + "name": "Ethernet0", + "index": 0, + "phy_id" : 0, + "system_lanes": [38,39], + "line_lanes": [30,31,32,33] + }, + { + "name": "Ethernet1", + "index": 1, + "phy_id" : 0, + "system_lanes": [40,41], + "line_lanes": [34,35,36,37] + }, + { + "name": "Ethernet2", + "index": 2, + "phy_id" : 1, + "system_lanes": [4,5], + "line_lanes": [0,1,2,3] + } + ] +} diff --git a/gearsyncd/tests/configs/negative/gearbox_config_missing_ethernet_line_lanes.json b/gearsyncd/tests/configs/negative/gearbox_config_missing_ethernet_line_lanes.json new file mode 100644 index 0000000000..f245b8adf7 --- /dev/null +++ b/gearsyncd/tests/configs/negative/gearbox_config_missing_ethernet_line_lanes.json @@ -0,0 +1,48 @@ +{ + "phys": [ + { + "phy_id": 0, + "name": "example-1", + "address": "0x1000", + "lib_name": "libsai_phy_example1.so", + "firmware_path": "/tmp/phy-example1.bin", + "config_file": "tests/configs/positive/phy1_config_1.json", + "sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm", + "phy_access": "mdio", + "bus_id": 0 + }, + { + "phy_id": 1, + "name": "example-2", + "address": "0x2000", + "lib_name": "libsai_phy_example2.so", + "firmware_path": "/tmp/phy-example2.bin", + "config_file": "tests/configs/positive/phy2_config_1.json", + "sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm", + "phy_access": "i2c", + "bus_id": 1 + } + ], + "interfaces": [ + { + "name": "Ethernet0", + "index": 0, + "phy_id" : 0, + "system_lanes": [38,39] + }, + { + "name": "Ethernet1", + "index": 1, + "phy_id" : 0, + "system_lanes": [40,41], + "line_lanes": [34,35,36,37] + }, + { + "name": "Ethernet2", + "index": 2, + "phy_id" : 1, + "system_lanes": [4,5], + "line_lanes": [0,1,2,3] + } + ] +} diff --git a/gearsyncd/tests/configs/negative/gearbox_config_missing_ethernet_phy_id.json b/gearsyncd/tests/configs/negative/gearbox_config_missing_ethernet_phy_id.json new file mode 100644 index 0000000000..b76e613a44 --- /dev/null +++ b/gearsyncd/tests/configs/negative/gearbox_config_missing_ethernet_phy_id.json @@ -0,0 +1,48 @@ +{ + "phys": [ + { + "phy_id": 0, + "name": "example-1", + "address": "0x1000", + "lib_name": "libsai_phy_example1.so", + "firmware_path": "/tmp/phy-example1.bin", + "config_file": "tests/configs/positive/phy1_config_1.json", + "sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm", + "phy_access": "mdio", + "bus_id": 0 + }, + { + "phy_id": 1, + "name": "example-2", + "address": "0x2000", + "lib_name": "libsai_phy_example2.so", + "firmware_path": "/tmp/phy-example2.bin", + "config_file": "tests/configs/positive/phy2_config_1.json", + "sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm", + "phy_access": "i2c", + "bus_id": 1 + } + ], + "interfaces": [ + { + "name": "Ethernet0", + "index": 0, + "system_lanes": [38,39], + "line_lanes": [30,31,32,33] + }, + { + "name": "Ethernet1", + "index": 1, + "phy_id" : 0, + "system_lanes": [40,41], + "line_lanes": [34,35,36,37] + }, + { + "name": "Ethernet2", + "index": 2, + "phy_id" : 1, + "system_lanes": [4,5], + "line_lanes": [0,1,2,3] + } + ] +} diff --git a/gearsyncd/tests/configs/negative/gearbox_config_missing_ethernet_system_lane_speed.json b/gearsyncd/tests/configs/negative/gearbox_config_missing_ethernet_system_lane_speed.json new file mode 100644 index 0000000000..b3dea20955 --- /dev/null +++ b/gearsyncd/tests/configs/negative/gearbox_config_missing_ethernet_system_lane_speed.json @@ -0,0 +1,49 @@ +{ + "phys": [ + { + "phy_id": 0, + "name": "example-1", + "address": "0x1000", + "lib_name": "libsai_phy_example1.so", + "firmware_path": "/tmp/phy-example1.bin", + "config_file": "tests/configs/positive/phy1_config_1.json", + "sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm", + "phy_access": "mdio", + "bus_id": 0 + }, + { + "phy_id": 1, + "name": "example-2", + "address": "0x2000", + "lib_name": "libsai_phy_example2.so", + "firmware_path": "/tmp/phy-example2.bin", + "config_file": "tests/configs/positive/phy2_config_1.json", + "sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm", + "phy_access": "i2c", + "bus_id": 1 + } + ], + "interfaces": [ + { + "name": "Ethernet0", + "index": 0, + "phy_id" : 0, + "system_lanes": [38,39], + "line_lanes": [30,31,32,33] + }, + { + "name": "Ethernet1", + "index": 1, + "phy_id" : 0, + "system_lanes": [40,41], + "line_lanes": [34,35,36,37] + }, + { + "name": "Ethernet2", + "index": 2, + "phy_id" : 1, + "system_lanes": [4,5], + "line_lanes": [0,1,2,3] + } + ] +} diff --git a/gearsyncd/tests/configs/negative/gearbox_config_missing_ethernet_system_lanes.json b/gearsyncd/tests/configs/negative/gearbox_config_missing_ethernet_system_lanes.json new file mode 100644 index 0000000000..1a6a60dc0d --- /dev/null +++ b/gearsyncd/tests/configs/negative/gearbox_config_missing_ethernet_system_lanes.json @@ -0,0 +1,48 @@ +{ + "phys": [ + { + "phy_id": 0, + "name": "example-1", + "address": "0x1000", + "lib_name": "libsai_phy_example1.so", + "firmware_path": "/tmp/phy-example1.bin", + "config_file": "tests/configs/positive/phy1_config_1.json", + "sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm", + "phy_access": "mdio", + "bus_id": 0 + }, + { + "phy_id": 1, + "name": "example-2", + "address": "0x2000", + "lib_name": "libsai_phy_example2.so", + "firmware_path": "/tmp/phy-example2.bin", + "config_file": "tests/configs/positive/phy2_config_1.json", + "sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm", + "phy_access": "i2c", + "bus_id": 1 + } + ], + "interfaces": [ + { + "name": "Ethernet0", + "index": 0, + "phy_id" : 0, + "line_lanes": [30,31,32,33] + }, + { + "name": "Ethernet1", + "index": 1, + "phy_id" : 0, + "system_lanes": [40,41], + "line_lanes": [34,35,36,37] + }, + { + "name": "Ethernet2", + "index": 2, + "phy_id" : 1, + "system_lanes": [4,5], + "line_lanes": [0,1,2,3] + } + ] +} diff --git a/gearsyncd/tests/configs/negative/gearbox_config_missing_interfaces.json b/gearsyncd/tests/configs/negative/gearbox_config_missing_interfaces.json new file mode 100644 index 0000000000..84b2056780 --- /dev/null +++ b/gearsyncd/tests/configs/negative/gearbox_config_missing_interfaces.json @@ -0,0 +1,26 @@ +{ + "phys": [ + { + "phy_id": 0, + "name": "example-1", + "address": "0x1000", + "lib_name": "libsai_phy_example1.so", + "firmware_path": "/tmp/phy-example1.bin", + "config_file": "tests/configs/positive/phy1_config_1.json", + "sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm", + "phy_access": "mdio", + "bus_id": 0 + }, + { + "phy_id": 1, + "name": "example-2", + "address": "0x2000", + "lib_name": "libsai_phy_example2.so", + "firmware_path": "/tmp/phy-example2.bin", + "config_file": "tests/configs/positive/phy2_config_1.json", + "sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm", + "phy_access": "i2c", + "bus_id": 1 + } + ] +} diff --git a/gearsyncd/tests/configs/negative/gearbox_config_missing_phy_address.json b/gearsyncd/tests/configs/negative/gearbox_config_missing_phy_address.json new file mode 100644 index 0000000000..5989dd0856 --- /dev/null +++ b/gearsyncd/tests/configs/negative/gearbox_config_missing_phy_address.json @@ -0,0 +1,44 @@ +{ + "phys": [ + { + "phy_id": 0, + "name": "example-1", + "lib_name": "libsai_phy_example1.so", + "firmware_path": "/tmp/phy-example1.bin", + "config_file": "tests/configs/positive/phy1_config_1.json", + "phy_access": "MDIO(NPU)", + "bus_id": 0 + }, + { + "phy_id": 1, + "name": "example-2", + "address": "0x2000", + "lib_name": "libsai_phy_example2.so", + "firmware_path": "/tmp/phy-example2.bin", + "config_file": "tests/configs/positive/phy2_config_1.json", + "phy_access": "I2C", + "bus_id": 1 + } + ], + "interfaces": [ + { + "index": 1, + "phy_id" : 0, + "system_lanes": [38,39], + "line_lanes": [30,31,32,33] + }, + { + "index": 1, + "phy_id" : 0, + "system_lanes": [40,41], + "line_lanes": [34,35,36,37] + }, + { + "index": 1, + "phy_id" : 1, + "system_lanes": [4,5], + "line_lanes": [0,1,2,3] + } + ] +} + diff --git a/gearsyncd/tests/configs/negative/gearbox_config_missing_phy_bus_id.json b/gearsyncd/tests/configs/negative/gearbox_config_missing_phy_bus_id.json new file mode 100644 index 0000000000..1b37dfbec2 --- /dev/null +++ b/gearsyncd/tests/configs/negative/gearbox_config_missing_phy_bus_id.json @@ -0,0 +1,44 @@ +{ + "phys": [ + { + "phy_id": 0, + "name": "example-1", + "address": "0x1000", + "lib_name": "libsai_phy_example1.so", + "firmware_path": "/tmp/phy-example1.bin", + "config_file": "tests/configs/positive/phy1_config_1.json", + "phy_access": "MDIO(NPU)" + }, + { + "phy_id": 1, + "name": "example-2", + "address": "0x2000", + "lib_name": "libsai_phy_example2.so", + "firmware_path": "/tmp/phy-example2.bin", + "config_file": "tests/configs/positive/phy2_config_1.json", + "phy_access": "I2C", + "bus_id": 1 + } + ], + "interfaces": [ + { + "index": 1, + "phy_id" : 0, + "system_lanes": [38,39], + "line_lanes": [30,31,32,33] + }, + { + "index": 1, + "phy_id" : 0, + "system_lanes": [40,41], + "line_lanes": [34,35,36,37] + }, + { + "index": 1, + "phy_id" : 1, + "system_lanes": [4,5], + "line_lanes": [0,1,2,3] + } + ] +} + diff --git a/gearsyncd/tests/configs/negative/gearbox_config_missing_phy_config_file.json b/gearsyncd/tests/configs/negative/gearbox_config_missing_phy_config_file.json new file mode 100644 index 0000000000..e9589d4daa --- /dev/null +++ b/gearsyncd/tests/configs/negative/gearbox_config_missing_phy_config_file.json @@ -0,0 +1,44 @@ +{ + "phys": [ + { + "phy_id": 0, + "name": "example-1", + "address": "0x1000", + "lib_name": "libsai_phy_example1.so", + "firmware_path": "/tmp/phy-example1.bin", + "phy_access": "MDIO(NPU)", + "bus_id": 0 + }, + { + "phy_id": 1, + "name": "example-2", + "address": "0x2000", + "lib_name": "libsai_phy_example2.so", + "firmware_path": "/tmp/phy-example2.bin", + "config_file": "tests/configs/positive/phy2_config_1.json", + "phy_access": "I2C", + "bus_id": 1 + } + ], + "interfaces": [ + { + "index": 1, + "phy_id" : 0, + "system_lanes": [38,39], + "line_lanes": [30,31,32,33] + }, + { + "index": 1, + "phy_id" : 0, + "system_lanes": [40,41], + "line_lanes": [34,35,36,37] + }, + { + "index": 1, + "phy_id" : 1, + "system_lanes": [4,5], + "line_lanes": [0,1,2,3] + } + ] +} + diff --git a/gearsyncd/tests/configs/negative/gearbox_config_missing_phy_firmware_path.json b/gearsyncd/tests/configs/negative/gearbox_config_missing_phy_firmware_path.json new file mode 100644 index 0000000000..33cbfc176c --- /dev/null +++ b/gearsyncd/tests/configs/negative/gearbox_config_missing_phy_firmware_path.json @@ -0,0 +1,44 @@ +{ + "phys": [ + { + "phy_id": 0, + "name": "example-1", + "address": "0x1000", + "lib_name": "libsai_phy_example1.so", + "config_file": "tests/configs/positive/phy1_config_1.json", + "phy_access": "MDIO(NPU)", + "bus_id": 0 + }, + { + "phy_id": 1, + "name": "example-2", + "address": "0x2000", + "lib_name": "libsai_phy_example2.so", + "firmware_path": "/tmp/phy-example2.bin", + "config_file": "tests/configs/positive/phy2_config_1.json", + "phy_access": "I2C", + "bus_id": 1 + } + ], + "interfaces": [ + { + "index": 1, + "phy_id" : 0, + "system_lanes": [38,39], + "line_lanes": [30,31,32,33] + }, + { + "index": 1, + "phy_id" : 0, + "system_lanes": [40,41], + "line_lanes": [34,35,36,37] + }, + { + "index": 1, + "phy_id" : 1, + "system_lanes": [4,5], + "line_lanes": [0,1,2,3] + } + ] +} + diff --git a/gearsyncd/tests/configs/negative/gearbox_config_missing_phy_id.json b/gearsyncd/tests/configs/negative/gearbox_config_missing_phy_id.json new file mode 100644 index 0000000000..39b4a0e57a --- /dev/null +++ b/gearsyncd/tests/configs/negative/gearbox_config_missing_phy_id.json @@ -0,0 +1,45 @@ +{ + "phys": [ + { + "name": "example-1", + "address": "0x1000", + "lib_name": "libsai_phy_example1.so", + "firmware_path": "/tmp/phy-example1.bin", + "config_file": "tests/configs/positive/phy1_config_1.json", + "sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm", + "phy_access": "mdio", + "bus_id": 0 + }, + { + "phy_id": 1, + "name": "example-2", + "address": "0x2000", + "lib_name": "libsai_phy_example2.so", + "firmware_path": "/tmp/phy-example2.bin", + "config_file": "tests/configs/positive/phy2_config_1.json", + "sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm", + "phy_access": "i2c", + "bus_id": 1 + } + ], + "interfaces": [ + { + "index": 1, + "phy_id" : 0, + "system_lanes": [38,39], + "line_lanes": [30,31,32,33] + }, + { + "index": 1, + "phy_id" : 0, + "system_lanes": [40,41], + "line_lanes": [34,35,36,37] + }, + { + "index": 1, + "phy_id" : 1, + "system_lanes": [4,5], + "line_lanes": [0,1,2,3] + } + ] +} diff --git a/gearsyncd/tests/configs/negative/gearbox_config_missing_phy_lib_name.json b/gearsyncd/tests/configs/negative/gearbox_config_missing_phy_lib_name.json new file mode 100644 index 0000000000..3a204e07d7 --- /dev/null +++ b/gearsyncd/tests/configs/negative/gearbox_config_missing_phy_lib_name.json @@ -0,0 +1,44 @@ +{ + "phys": [ + { + "phy_id": 0, + "name": "example-1", + "address": "0x1000", + "firmware_path": "/tmp/phy-example1.bin", + "config_file": "tests/configs/positive/phy1_config_1.json", + "phy_access": "MDIO(NPU)", + "bus_id": 0 + }, + { + "phy_id": 1, + "name": "example-2", + "address": "0x2000", + "lib_name": "libsai_phy_example2.so", + "firmware_path": "/tmp/phy-example2.bin", + "config_file": "tests/configs/positive/phy2_config_1.json", + "phy_access": "I2C", + "bus_id": 1 + } + ], + "interfaces": [ + { + "index": 1, + "phy_id" : 0, + "system_lanes": [38,39], + "line_lanes": [30,31,32,33] + }, + { + "index": 1, + "phy_id" : 0, + "system_lanes": [40,41], + "line_lanes": [34,35,36,37] + }, + { + "index": 1, + "phy_id" : 1, + "system_lanes": [4,5], + "line_lanes": [0,1,2,3] + } + ] +} + diff --git a/gearsyncd/tests/configs/negative/gearbox_config_missing_phy_name.json b/gearsyncd/tests/configs/negative/gearbox_config_missing_phy_name.json new file mode 100644 index 0000000000..f74dfb154a --- /dev/null +++ b/gearsyncd/tests/configs/negative/gearbox_config_missing_phy_name.json @@ -0,0 +1,44 @@ +{ + "phys": [ + { + "phy_id": 0, + "address": "0x1000", + "lib_name": "libsai_phy_example1.so", + "firmware_path": "/tmp/phy-example1.bin", + "config_file": "tests/configs/positive/phy1_config_1.json", + "phy_access": "MDIO(NPU)", + "bus_id": 0 + }, + { + "phy_id": 1, + "name": "example-2", + "address": "0x2000", + "lib_name": "libsai_phy_example2.so", + "firmware_path": "/tmp/phy-example2.bin", + "config_file": "tests/configs/positive/phy2_config_1.json", + "phy_access": "I2C", + "bus_id": 1 + } + ], + "interfaces": [ + { + "index": 1, + "phy_id" : 0, + "system_lanes": [38,39], + "line_lanes": [30,31,32,33] + }, + { + "index": 1, + "phy_id" : 0, + "system_lanes": [40,41], + "line_lanes": [34,35,36,37] + }, + { + "index": 1, + "phy_id" : 1, + "system_lanes": [4,5], + "line_lanes": [0,1,2,3] + } + ] +} + diff --git a/gearsyncd/tests/configs/negative/gearbox_config_missing_phy_phy_access.json b/gearsyncd/tests/configs/negative/gearbox_config_missing_phy_phy_access.json new file mode 100644 index 0000000000..33fd9f368f --- /dev/null +++ b/gearsyncd/tests/configs/negative/gearbox_config_missing_phy_phy_access.json @@ -0,0 +1,44 @@ +{ + "phys": [ + { + "phy_id": 0, + "name": "example-1", + "address": "0x1000", + "lib_name": "libsai_phy_example1.so", + "firmware_path": "/tmp/phy-example1.bin", + "config_file": "tests/configs/positive/phy1_config_1.json", + "bus_id": 0 + }, + { + "phy_id": 1, + "name": "example-2", + "address": "0x2000", + "lib_name": "libsai_phy_example2.so", + "firmware_path": "/tmp/phy-example2.bin", + "config_file": "tests/configs/positive/phy2_config_1.json", + "phy_access": "I2C", + "bus_id": 1 + } + ], + "interfaces": [ + { + "index": 1, + "phy_id" : 0, + "system_lanes": [38,39], + "line_lanes": [30,31,32,33] + }, + { + "index": 1, + "phy_id" : 0, + "system_lanes": [40,41], + "line_lanes": [34,35,36,37] + }, + { + "index": 1, + "phy_id" : 1, + "system_lanes": [4,5], + "line_lanes": [0,1,2,3] + } + ] +} + diff --git a/gearsyncd/tests/configs/negative/gearbox_config_missing_phy_sai_init_config_file.json b/gearsyncd/tests/configs/negative/gearbox_config_missing_phy_sai_init_config_file.json new file mode 100644 index 0000000000..fd28a59ef1 --- /dev/null +++ b/gearsyncd/tests/configs/negative/gearbox_config_missing_phy_sai_init_config_file.json @@ -0,0 +1,45 @@ +{ + "phys": [ + { + "phy_id": 0, + "name": "example-1", + "address": "0x1000", + "lib_name": "libsai_phy_example1.so", + "firmware_path": "/tmp/phy-example1.bin", + "config_file": "tests/configs/positive/phy1_config_1.json", + "phy_access": "mdio", + "bus_id": 0 + }, + { + "phy_id": 1, + "name": "example-2", + "address": "0x2000", + "lib_name": "libsai_phy_example2.so", + "firmware_path": "/tmp/phy-example2.bin", + "config_file": "tests/configs/positive/phy2_config_1.json", + "sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm", + "phy_access": "i2c", + "bus_id": 1 + } + ], + "interfaces": [ + { + "index": 1, + "phy_id" : 0, + "system_lanes": [38,39], + "line_lanes": [30,31,32,33] + }, + { + "index": 1, + "phy_id" : 0, + "system_lanes": [40,41], + "line_lanes": [34,35,36,37] + }, + { + "index": 1, + "phy_id" : 1, + "system_lanes": [4,5], + "line_lanes": [0,1,2,3] + } + ] +} diff --git a/gearsyncd/tests/configs/negative/gearbox_config_missing_phys.json b/gearsyncd/tests/configs/negative/gearbox_config_missing_phys.json new file mode 100644 index 0000000000..fda33ee3ba --- /dev/null +++ b/gearsyncd/tests/configs/negative/gearbox_config_missing_phys.json @@ -0,0 +1,23 @@ +{ + "interfaces": [ + { + "index": 1, + "phy_id" : 0, + "system_lanes": [38,39], + "line_lanes": [30,31,32,33] + }, + { + "index": 1, + "phy_id" : 0, + "system_lanes": [40,41], + "line_lanes": [34,35,36,37] + }, + { + "index": 1, + "phy_id" : 1, + "system_lanes": [4,5], + "line_lanes": [0,1,2,3] + } + ] +} + diff --git a/gearsyncd/tests/configs/negative/phy_config_invalid_array.json b/gearsyncd/tests/configs/negative/phy_config_invalid_array.json new file mode 100644 index 0000000000..e5011b0bd7 --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_invalid_array.json @@ -0,0 +1,146 @@ +{ + "name": "example-1", + "address": "0x1000", + "mode": "gearbox", + "port_ref_clk": "600Mhz", + "lanes": [ + { + "id": 30, + "system_side": false, + "local_lane_id": 0, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "id": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "id": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "id": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "id": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "id": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "id": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "id": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "id": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "mdio_addr": "0x1009" + }, + { + "id": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 1, + "mdio_addr": "0x1010" + }, + { + "id": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 1, + "mdio_addr": "0x1011" + }, + { + "id": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 1, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "id": 0, + "system_lanes": 12345, + "system_lane_speed": "50G", + "line_lanes": [30,31,32,33], + "line_lane_speed": "25G", + "line_adver_speed": [], + "line_adver_fec": [], + "mdio_addr": "0x2000" + }, + { + "id": 1, + "system_lanes": [40,41], + "system_lane_speed": "50G", + "line_lanes": [34,35,36,37], + "line_lane_speed": "25G", + "line_adver_speed": [], + "line_adver_fec": [], + "mdio_addr": "0x3000" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_invalid_boolean.json b/gearsyncd/tests/configs/negative/phy_config_invalid_boolean.json new file mode 100644 index 0000000000..c4bc571102 --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_invalid_boolean.json @@ -0,0 +1,180 @@ +{ + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "system_side": 99999, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fed": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fed": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_invalid_boolean2.json b/gearsyncd/tests/configs/negative/phy_config_invalid_boolean2.json new file mode 100644 index 0000000000..31ae33eaf2 --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_invalid_boolean2.json @@ -0,0 +1,181 @@ +{ + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "system_side": "hello", + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_lane_speed": "25G", + "line_adver_speed": [], + "line_adver_fed": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fed": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_invalid_json.json b/gearsyncd/tests/configs/negative/phy_config_invalid_json.json new file mode 100644 index 0000000000..7d7a46428b --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_invalid_json.json @@ -0,0 +1,180 @@ + + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "system_side": false, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fed": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fed": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_lanes_missing_id.json b/gearsyncd/tests/configs/negative/phy_config_lanes_missing_id.json new file mode 100644 index 0000000000..3307b17a9d --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_lanes_missing_id.json @@ -0,0 +1,179 @@ +{ + "lanes": [ + { + "local_lane_id": 0, + "system_side": false, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_lanes_missing_line_rx_lanemap.json b/gearsyncd/tests/configs/negative/phy_config_lanes_missing_line_rx_lanemap.json new file mode 100644 index 0000000000..79e6e16d8b --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_lanes_missing_line_rx_lanemap.json @@ -0,0 +1,179 @@ +{ + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "system_side": false, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_lanes_missing_line_to_system_lanemap.json b/gearsyncd/tests/configs/negative/phy_config_lanes_missing_line_to_system_lanemap.json new file mode 100644 index 0000000000..ff10837354 --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_lanes_missing_line_to_system_lanemap.json @@ -0,0 +1,179 @@ +{ + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "system_side": false, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_lanes_missing_line_tx_lanemap.json b/gearsyncd/tests/configs/negative/phy_config_lanes_missing_line_tx_lanemap.json new file mode 100644 index 0000000000..71d053c99d --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_lanes_missing_line_tx_lanemap.json @@ -0,0 +1,179 @@ +{ + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "system_side": false, + "tx_polarity": 0, + "rx_polarity": 0, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_lanes_missing_local_lane_id.json b/gearsyncd/tests/configs/negative/phy_config_lanes_missing_local_lane_id.json new file mode 100644 index 0000000000..3ce5a327c5 --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_lanes_missing_local_lane_id.json @@ -0,0 +1,179 @@ +{ + "lanes": [ + { + "index": 30, + "system_side": false, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_lanes_missing_mdio_addr.json b/gearsyncd/tests/configs/negative/phy_config_lanes_missing_mdio_addr.json new file mode 100644 index 0000000000..0817acacf7 --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_lanes_missing_mdio_addr.json @@ -0,0 +1,179 @@ +{ + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "system_side": false, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38 + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_lanes_missing_rx_polarity.json b/gearsyncd/tests/configs/negative/phy_config_lanes_missing_rx_polarity.json new file mode 100644 index 0000000000..f4fafdcdcf --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_lanes_missing_rx_polarity.json @@ -0,0 +1,179 @@ +{ + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "system_side": false, + "tx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_lanes_missing_system_side.json b/gearsyncd/tests/configs/negative/phy_config_lanes_missing_system_side.json new file mode 100644 index 0000000000..1158244607 --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_lanes_missing_system_side.json @@ -0,0 +1,179 @@ +{ + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_lanes_missing_tx_polarity.json b/gearsyncd/tests/configs/negative/phy_config_lanes_missing_tx_polarity.json new file mode 100644 index 0000000000..4dcdd48f7f --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_lanes_missing_tx_polarity.json @@ -0,0 +1,179 @@ +{ + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "system_side": false, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_missing_address.json b/gearsyncd/tests/configs/negative/phy_config_missing_address.json new file mode 100644 index 0000000000..ea28ff8695 --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_missing_address.json @@ -0,0 +1,180 @@ +{ + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "system_side": false, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_missing_lanes.json b/gearsyncd/tests/configs/negative/phy_config_missing_lanes.json new file mode 100644 index 0000000000..2b603612cc --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_missing_lanes.json @@ -0,0 +1,46 @@ +{ + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_missing_mode.json b/gearsyncd/tests/configs/negative/phy_config_missing_mode.json new file mode 100644 index 0000000000..f1b14c7b8c --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_missing_mode.json @@ -0,0 +1,145 @@ +{ + "name": "example-1", + "address": "0x1000", + "port_ref_clk": "600Mhz", + "lanes": [ + { + "id": 30, + "system_side": false, + "local_lane_id": 0, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "id": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "id": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "id": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "id": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "id": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "id": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "id": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "id": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "mdio_addr": "0x1009" + }, + { + "id": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 1, + "mdio_addr": "0x1010" + }, + { + "id": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 1, + "mdio_addr": "0x1011" + }, + { + "id": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 1, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "id": 0, + "system_lanes": [34,35], + "system_lane_speed": "50G", + "line_lanes": [30,31,32,33], + "line_lane_speed": "25G", + "line_adver_speed": [], + "line_adver_fec": [], + "mdio_addr": "0x2000" + }, + { + "id": 1, + "system_lanes": [40,41], + "system_lane_speed": "50G", + "line_lanes": [34,35,36,37], + "line_lane_speed": "25G", + "line_adver_speed": [], + "line_adver_fec": [], + "mdio_addr": "0x3000" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_missing_name.json b/gearsyncd/tests/configs/negative/phy_config_missing_name.json new file mode 100644 index 0000000000..672ae777c1 --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_missing_name.json @@ -0,0 +1,145 @@ +{ + "address": "0x1000", + "mode": "gearbox", + "port_ref_clk": "600Mhz", + "lanes": [ + { + "id": 30, + "system_side": false, + "local_lane_id": 0, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "id": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "id": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "id": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "id": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "id": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "id": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "id": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "id": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "mdio_addr": "0x1009" + }, + { + "id": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 1, + "mdio_addr": "0x1010" + }, + { + "id": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 1, + "mdio_addr": "0x1011" + }, + { + "id": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 1, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "id": 0, + "system_lanes": [34,35], + "system_lane_speed": "50G", + "line_lanes": [30,31,32,33], + "line_lane_speed": "25G", + "line_adver_speed": [], + "line_adver_fec": [], + "mdio_addr": "0x2000" + }, + { + "id": 1, + "system_lanes": [40,41], + "system_lane_speed": "50G", + "line_lanes": [34,35,36,37], + "line_lane_speed": "25G", + "line_adver_speed": [], + "line_adver_fec": [], + "mdio_addr": "0x3000" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_missing_port_ref_clk.json b/gearsyncd/tests/configs/negative/phy_config_missing_port_ref_clk.json new file mode 100644 index 0000000000..6e481ec759 --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_missing_port_ref_clk.json @@ -0,0 +1,145 @@ +{ + "name": "example-1", + "address": "0x1000", + "mode": "gearbox", + "lanes": [ + { + "id": 30, + "system_side": false, + "local_lane_id": 0, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "id": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "id": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "id": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "id": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "id": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "id": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "id": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "id": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "mdio_addr": "0x1009" + }, + { + "id": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 1, + "mdio_addr": "0x1010" + }, + { + "id": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 1, + "mdio_addr": "0x1011" + }, + { + "id": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 1, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "id": 0, + "system_lanes": [34,35], + "system_lane_speed": "50G", + "line_lanes": [30,31,32,33], + "line_lane_speed": "25G", + "line_adver_speed": [], + "line_adver_fec": [], + "mdio_addr": "0x2000" + }, + { + "id": 1, + "system_lanes": [40,41], + "system_lane_speed": "50G", + "line_lanes": [34,35,36,37], + "line_lane_speed": "25G", + "line_adver_speed": [], + "line_adver_fec": [], + "mdio_addr": "0x3000" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_ports_empty_line_lanes.json b/gearsyncd/tests/configs/negative/phy_config_ports_empty_line_lanes.json new file mode 100644 index 0000000000..ffb94cf33c --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_ports_empty_line_lanes.json @@ -0,0 +1,146 @@ +{ + "name": "example-1", + "address": "0x1000", + "mode": "gearbox", + "port_ref_clk": "600Mhz", + "lanes": [ + { + "id": 30, + "system_side": false, + "local_lane_id": 0, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "id": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "id": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "id": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "id": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "id": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "id": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "id": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "id": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "mdio_addr": "0x1009" + }, + { + "id": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 1, + "mdio_addr": "0x1010" + }, + { + "id": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 1, + "mdio_addr": "0x1011" + }, + { + "id": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 1, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "id": 0, + "system_lanes": [34,35], + "system_lane_speed": "50G", + "line_lanes": [], + "line_lane_speed": "25G", + "line_adver_speed": [], + "line_adver_fec": [], + "mdio_addr": "0x2000" + }, + { + "id": 1, + "system_lanes": [40,41], + "system_lane_speed": "50G", + "line_lanes": [34,35,36,37], + "line_lane_speed": "25G", + "line_adver_speed": [], + "line_adver_fec": [], + "mdio_addr": "0x3000" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_ports_empty_system_lanes.json b/gearsyncd/tests/configs/negative/phy_config_ports_empty_system_lanes.json new file mode 100644 index 0000000000..fddf60b55c --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_ports_empty_system_lanes.json @@ -0,0 +1,146 @@ +{ + "name": "example-1", + "address": "0x1000", + "mode": "gearbox", + "port_ref_clk": "600Mhz", + "lanes": [ + { + "id": 30, + "system_side": false, + "local_lane_id": 0, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "id": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "id": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "id": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "id": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "id": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "id": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "id": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "id": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "mdio_addr": "0x1009" + }, + { + "id": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 1, + "mdio_addr": "0x1010" + }, + { + "id": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 1, + "mdio_addr": "0x1011" + }, + { + "id": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 1, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "id": 0, + "system_lanes": [], + "system_lane_speed": "50G", + "line_lanes": [30,31,32,33], + "line_lane_speed": "25G", + "line_adver_speed": [], + "line_adver_fec": [], + "mdio_addr": "0x2000" + }, + { + "id": 1, + "system_lanes": [40,41], + "system_lane_speed": "50G", + "line_lanes": [34,35,36,37], + "line_lane_speed": "25G", + "line_adver_speed": [], + "line_adver_fec": [], + "mdio_addr": "0x3000" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_ports_missing_id.json b/gearsyncd/tests/configs/negative/phy_config_ports_missing_id.json new file mode 100644 index 0000000000..dc3c326278 --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_ports_missing_id.json @@ -0,0 +1,179 @@ +{ + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "system_side": false, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_adver_asym_pause.json b/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_adver_asym_pause.json new file mode 100644 index 0000000000..520c6e9c27 --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_adver_asym_pause.json @@ -0,0 +1,179 @@ +{ + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "system_side": false, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_adver_auto_neg.json b/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_adver_auto_neg.json new file mode 100644 index 0000000000..ad2b26fff4 --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_adver_auto_neg.json @@ -0,0 +1,179 @@ +{ + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "system_side": false, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_adver_fec.json b/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_adver_fec.json new file mode 100644 index 0000000000..1c7762be4e --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_adver_fec.json @@ -0,0 +1,179 @@ +{ + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "system_side": false, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_adver_media_type.json b/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_adver_media_type.json new file mode 100644 index 0000000000..dba61a2a11 --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_adver_media_type.json @@ -0,0 +1,179 @@ +{ + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "system_side": false, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_adver_speed.json b/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_adver_speed.json new file mode 100644 index 0000000000..0645d4bb31 --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_adver_speed.json @@ -0,0 +1,179 @@ +{ + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "system_side": false, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_auto_neg.json b/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_auto_neg.json new file mode 100644 index 0000000000..00dab90175 --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_auto_neg.json @@ -0,0 +1,179 @@ +{ + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "system_side": false, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_fec.json b/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_fec.json new file mode 100644 index 0000000000..1d48128a73 --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_fec.json @@ -0,0 +1,179 @@ +{ + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "system_side": false, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_intf_type.json b/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_intf_type.json new file mode 100644 index 0000000000..7c7c8fb1f5 --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_intf_type.json @@ -0,0 +1,179 @@ +{ + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "system_side": false, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_lane_speed.json b/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_lane_speed.json new file mode 100644 index 0000000000..ed846b042d --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_lane_speed.json @@ -0,0 +1,179 @@ +{ + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "system_side": false, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_lanes.json b/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_lanes.json new file mode 100644 index 0000000000..0b85fb99f0 --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_lanes.json @@ -0,0 +1,145 @@ +{ + "name": "example-1", + "address": "0x1000", + "mode": "gearbox", + "port_ref_clk": "600Mhz", + "lanes": [ + { + "id": 30, + "system_side": false, + "local_lane_id": 0, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "id": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "id": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "id": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "id": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "id": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "id": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "id": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "id": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "mdio_addr": "0x1009" + }, + { + "id": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 1, + "mdio_addr": "0x1010" + }, + { + "id": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 1, + "mdio_addr": "0x1011" + }, + { + "id": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 1, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "id": 0, + "system_lanes": [34,35], + "system_lane_speed": "50G", + "line_lane_speed": "25G", + "line_adver_speed": [], + "line_adver_fec": [], + "mdio_addr": "0x2000" + }, + { + "id": 1, + "system_lanes": [40,41], + "system_lane_speed": "50G", + "line_lanes": [34,35,36,37], + "line_lane_speed": "25G", + "line_adver_speed": [], + "line_adver_fec": [], + "mdio_addr": "0x3000" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_loopback.json b/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_loopback.json new file mode 100644 index 0000000000..87c89828d7 --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_loopback.json @@ -0,0 +1,179 @@ +{ + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "system_side": false, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_media_type.json b/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_media_type.json new file mode 100644 index 0000000000..a6aeed9b6a --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_media_type.json @@ -0,0 +1,179 @@ +{ + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "system_side": false, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_speed.json b/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_speed.json new file mode 100644 index 0000000000..ed846b042d --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_speed.json @@ -0,0 +1,179 @@ +{ + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "system_side": false, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_training.json b/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_training.json new file mode 100644 index 0000000000..ed5647b0ee --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_ports_missing_line_training.json @@ -0,0 +1,179 @@ +{ + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "system_side": false, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_ports_missing_mdio_addr.json b/gearsyncd/tests/configs/negative/phy_config_ports_missing_mdio_addr.json new file mode 100644 index 0000000000..1a24028f72 --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_ports_missing_mdio_addr.json @@ -0,0 +1,179 @@ +{ + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "system_side": false, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_ports_missing_system_auto_neg.json b/gearsyncd/tests/configs/negative/phy_config_ports_missing_system_auto_neg.json new file mode 100644 index 0000000000..fa247c4a89 --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_ports_missing_system_auto_neg.json @@ -0,0 +1,179 @@ +{ + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "system_side": false, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_ports_missing_system_fec.json b/gearsyncd/tests/configs/negative/phy_config_ports_missing_system_fec.json new file mode 100644 index 0000000000..1cffe24e5c --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_ports_missing_system_fec.json @@ -0,0 +1,179 @@ +{ + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "system_side": false, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_ports_missing_system_lane_speed.json b/gearsyncd/tests/configs/negative/phy_config_ports_missing_system_lane_speed.json new file mode 100644 index 0000000000..d3970648ff --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_ports_missing_system_lane_speed.json @@ -0,0 +1,179 @@ +{ + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "system_side": false, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_ports_missing_system_lanes.json b/gearsyncd/tests/configs/negative/phy_config_ports_missing_system_lanes.json new file mode 100644 index 0000000000..59b6de87b8 --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_ports_missing_system_lanes.json @@ -0,0 +1,145 @@ +{ + "name": "example-1", + "address": "0x1000", + "mode": "gearbox", + "port_ref_clk": "600Mhz", + "lanes": [ + { + "id": 30, + "system_side": false, + "local_lane_id": 0, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "id": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "id": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "id": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "id": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "id": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "id": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "id": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "id": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "mdio_addr": "0x1009" + }, + { + "id": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 1, + "mdio_addr": "0x1010" + }, + { + "id": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 1, + "mdio_addr": "0x1011" + }, + { + "id": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 1, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "id": 0, + "system_lanes": [34,35], + "system_lane_speed": "50G", + "line_lanes": [30,31,32,33], + "line_lane_speed": "25G", + "line_adver_speed": [], + "line_adver_fec": [], + "mdio_addr": "0x2000" + }, + { + "id": 1, + "system_lane_speed": "50G", + "line_lanes": [34,35,36,37], + "line_lane_speed": "25G", + "line_adver_speed": [], + "line_adver_fec": [], + "mdio_addr": "0x3000" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_ports_missing_system_loopback.json b/gearsyncd/tests/configs/negative/phy_config_ports_missing_system_loopback.json new file mode 100644 index 0000000000..cf04dcd39a --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_ports_missing_system_loopback.json @@ -0,0 +1,179 @@ +{ + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "system_side": false, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_ports_missing_system_speed.json b/gearsyncd/tests/configs/negative/phy_config_ports_missing_system_speed.json new file mode 100644 index 0000000000..117a29ee36 --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_ports_missing_system_speed.json @@ -0,0 +1,178 @@ +{ + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "system_side": false, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/negative/phy_config_ports_missing_system_training.json b/gearsyncd/tests/configs/negative/phy_config_ports_missing_system_training.json new file mode 100644 index 0000000000..d07e69324f --- /dev/null +++ b/gearsyncd/tests/configs/negative/phy_config_ports_missing_system_training.json @@ -0,0 +1,179 @@ +{ + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "system_side": false, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/positive/gearbox_config_1.json b/gearsyncd/tests/configs/positive/gearbox_config_1.json new file mode 100644 index 0000000000..b3dea20955 --- /dev/null +++ b/gearsyncd/tests/configs/positive/gearbox_config_1.json @@ -0,0 +1,49 @@ +{ + "phys": [ + { + "phy_id": 0, + "name": "example-1", + "address": "0x1000", + "lib_name": "libsai_phy_example1.so", + "firmware_path": "/tmp/phy-example1.bin", + "config_file": "tests/configs/positive/phy1_config_1.json", + "sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm", + "phy_access": "mdio", + "bus_id": 0 + }, + { + "phy_id": 1, + "name": "example-2", + "address": "0x2000", + "lib_name": "libsai_phy_example2.so", + "firmware_path": "/tmp/phy-example2.bin", + "config_file": "tests/configs/positive/phy2_config_1.json", + "sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm", + "phy_access": "i2c", + "bus_id": 1 + } + ], + "interfaces": [ + { + "name": "Ethernet0", + "index": 0, + "phy_id" : 0, + "system_lanes": [38,39], + "line_lanes": [30,31,32,33] + }, + { + "name": "Ethernet1", + "index": 1, + "phy_id" : 0, + "system_lanes": [40,41], + "line_lanes": [34,35,36,37] + }, + { + "name": "Ethernet2", + "index": 2, + "phy_id" : 1, + "system_lanes": [4,5], + "line_lanes": [0,1,2,3] + } + ] +} diff --git a/gearsyncd/tests/configs/positive/phy1_config_1.json b/gearsyncd/tests/configs/positive/phy1_config_1.json new file mode 100644 index 0000000000..ea28ff8695 --- /dev/null +++ b/gearsyncd/tests/configs/positive/phy1_config_1.json @@ -0,0 +1,180 @@ +{ + "lanes": [ + { + "index": 30, + "local_lane_id": 0, + "system_side": false, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 3, + "line_rx_lanemap": 3, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1001" + }, + { + "index": 31, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 38, + "mdio_addr": "0x1002" + }, + { + "index": 32, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1003" + }, + { + "index": 33, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 39, + "mdio_addr": "0x1004" + }, + { + "index": 34, + "system_side": false, + "local_lane_id": 4, + "line_tx_lanemap": 0, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1005" + }, + { + "index": 35, + "system_side": false, + "local_lane_id": 5, + "line_tx_lanemap": 1, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 1, + "line_to_system_lanemap": 40, + "mdio_addr": "0x1006" + }, + { + "index": 36, + "system_side": false, + "local_lane_id": 6, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 2, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1007" + }, + { + "index": 37, + "system_side": false, + "local_lane_id": 7, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 3, + "rx_polarity": 1, + "line_to_system_lanemap": 41, + "mdio_addr": "0x1008" + }, + { + "index": 38, + "system_side": true, + "local_lane_id": 0, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1009" + }, + { + "index": 39, + "system_side": true, + "local_lane_id": 1, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1010" + }, + { + "index": 40, + "system_side": true, + "local_lane_id": 2, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1011" + }, + { + "index": 41, + "system_side": true, + "local_lane_id": 3, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x1012" + } + ], + "ports": [ + { + "index": 0, + "mdio_addr": "0x2000", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "copper", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "copper" + }, + { + "index": 1, + "mdio_addr": "0x2001", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/configs/positive/phy2_config_1.json b/gearsyncd/tests/configs/positive/phy2_config_1.json new file mode 100644 index 0000000000..940d9087dd --- /dev/null +++ b/gearsyncd/tests/configs/positive/phy2_config_1.json @@ -0,0 +1,115 @@ +{ + "lanes": [ + { + "index": 0, + "system_side": false, + "local_lane_id": 0, + "line_tx_lanemap": 3, + "tx_polarity": 0, + "line_rx_lanemap": 0, + "rx_polarity": 0, + "line_to_system_lanemap": 4, + "mdio_addr": "0x3001" + }, + { + "index": 1, + "system_side": false, + "local_lane_id": 1, + "line_tx_lanemap": 2, + "tx_polarity": 0, + "line_rx_lanemap": 1, + "rx_polarity": 0, + "line_to_system_lanemap": 4, + "mdio_addr": "0x3002" + }, + { + "index": 2, + "system_side": false, + "local_lane_id": 2, + "line_tx_lanemap": 1, + "tx_polarity": 1, + "line_rx_lanemap": 2, + "rx_polarity": 0, + "line_to_system_lanemap": 5, + "mdio_addr": "0x3003" + }, + { + "index": 3, + "system_side": false, + "local_lane_id": 3, + "line_tx_lanemap": 0, + "tx_polarity": 1, + "line_rx_lanemap": 3, + "rx_polarity": 0, + "line_to_system_lanemap": 5, + "mdio_addr": "0x3004" + }, + { + "index": 4, + "system_side": true, + "local_lane_id": 4, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x3005" + }, + { + "index": 5, + "system_side": true, + "local_lane_id": 5, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x3006" + }, + { + "index": 6, + "system_side": true, + "local_lane_id": 6, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x3007" + }, + { + "index": 7, + "system_side": true, + "local_lane_id": 7, + "tx_polarity": 0, + "rx_polarity": 0, + "line_tx_lanemap": 0, + "line_rx_lanemap": 0, + "line_to_system_lanemap": 0, + "mdio_addr": "0x3008" + } + ], + "ports": [ + { + "index": 2, + "mdio_addr": "0x3100", + "system_speed": 25000, + "system_fec": "none", + "system_auto_neg": true, + "system_loopback": "none", + "system_training": false, + "line_speed": 50000, + "line_fec": "none", + "line_auto_neg": true, + "line_media_type": "fiber", + "line_intf_type": "none", + "line_loopback": "none", + "line_training": false, + "line_adver_speed": [], + "line_adver_fec": [], + "line_adver_auto_neg": false, + "line_adver_asym_pause": false, + "line_adver_media_type": "fiber" + } + ] +} diff --git a/gearsyncd/tests/testgearparser.cpp b/gearsyncd/tests/testgearparser.cpp new file mode 100644 index 0000000000..2642258999 --- /dev/null +++ b/gearsyncd/tests/testgearparser.cpp @@ -0,0 +1,152 @@ +/* + * Copyright 2020 Broadcom Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gearboxparser.h" +#include +#include +#include "cunit/Basic.h" +#include "logger.h" + +void usage() +{ + std::cout << "Usage: testgearparser" << std::endl; +} + +bool handleGearboxConfigFile(std::string file, bool warm); + +void positiveConfigTest() +{ + bool ret; + + ret = handleGearboxConfigFile("tests/configs/positive/gearbox_config_1.json", false); + CU_ASSERT_EQUAL(ret, true); +} + +void negativeConfigTest() +{ + bool ret; + + ret = handleGearboxConfigFile("tests/configs/negative/gearbox_config_invalid_array.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handleGearboxConfigFile("tests/configs/negative/gearbox_config_invalid_json.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handleGearboxConfigFile("tests/configs/negative/gearbox_config_missing_phys.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handleGearboxConfigFile("tests/configs/negative/gearbox_config_missing_phy_id.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handleGearboxConfigFile("tests/configs/negative/gearbox_config_missing_phy_name.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handleGearboxConfigFile("tests/configs/negative/gearbox_config_missing_phy_address.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handleGearboxConfigFile("tests/configs/negative/gearbox_config_missing_phy_lib_name.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handleGearboxConfigFile("tests/configs/negative/gearbox_config_missing_phy_firmware_path.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handleGearboxConfigFile("tests/configs/negative/gearbox_config_missing_phy_config_file.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handleGearboxConfigFile("tests/configs/negative/gearbox_config_missing_phy_sai_init_config_file.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handleGearboxConfigFile("tests/configs/negative/gearbox_config_missing_phy_phy_access.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handleGearboxConfigFile("tests/configs/negative/gearbox_config_missing_phy_bus_id.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handleGearboxConfigFile("tests/configs/negative/gearbox_config_invalid_phy_config_file.json", false); + CU_ASSERT_EQUAL(ret, false); + + ret = handleGearboxConfigFile("tests/configs/negative/gearbox_config_missing_interfaces.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handleGearboxConfigFile("tests/configs/negative/gearbox_config_missing_ethernet_index.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handleGearboxConfigFile("tests/configs/negative/gearbox_config_missing_ethernet_phy_id.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handleGearboxConfigFile("tests/configs/negative/gearbox_config_missing_ethernet_line_lanes.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handleGearboxConfigFile("tests/configs/negative/gearbox_config_missing_ethernet_system_lanes.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handleGearboxConfigFile("tests/configs/negative/gearbox_config_empty_ethernet_system_lanes.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handleGearboxConfigFile("tests/configs/negative/gearbox_config_empty_ethernet_line_lanes.json", false); + CU_ASSERT_EQUAL(ret, false); +} + +int unitTestMain() +{ + CU_pSuite pSuite = NULL; + CU_pTest pTest = NULL; + int ret = 0; + + if (CUE_SUCCESS != CU_initialize_registry()) + { + printf("%s: cunit failed to initialize registry\n", __FUNCTION__); + ret = CU_get_error(); + } + else + { + CU_basic_set_mode(CU_BRM_VERBOSE); + + // Run the tests and show the run summary + pSuite = CU_add_suite("gearbox_config_suite", 0, 0); + if (NULL == pSuite) + { + printf("%s: cunit failed to create suite\n", __FUNCTION__); + CU_cleanup_registry(); + ret = CU_get_error(); + } + } + + // Add the test to the suite + if (ret == 0) + { + pTest = CU_add_test(pSuite, "gearbox_positive_config_test", positiveConfigTest); + if (pTest != NULL) + { + pTest = CU_add_test(pSuite, "gearbox_negative_config_test", negativeConfigTest); + } + + if (pTest == NULL) + { + CU_cleanup_registry(); + printf("%s: cunit failed to add test\n", __FUNCTION__); + ret = CU_get_error(); + } + } + + if (ret == 0) + { + CU_basic_run_tests(); + } + return ret; +} + +bool handleGearboxConfigFile(std::string file, bool warm) +{ + GearboxParser p; + bool ret; + + p.setWriteToDb(true); + p.setConfigPath(file); + ret = p.parse(); + return ret; +} + +int main(int argc, char **argv) +{ + swss::Logger::linkToDbNative("testgearparser"); + + unitTestMain(); + return 1; +} + diff --git a/gearsyncd/tests/testphyparser.cpp b/gearsyncd/tests/testphyparser.cpp new file mode 100644 index 0000000000..4acc6f634a --- /dev/null +++ b/gearsyncd/tests/testphyparser.cpp @@ -0,0 +1,174 @@ +/* + * Copyright 2020 Broadcom Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "phyparser.h" +#include +#include +#include "cunit/Basic.h" +#include "logger.h" + +void usage() +{ + std::cout << "Usage: testphyparser" << std::endl; +} + +bool handlePhyConfigFile(std::string file, bool warm); + +void positiveConfigTest() +{ + bool ret; + + ret = handlePhyConfigFile("tests/configs/positive/phy1_config_1.json", false); + CU_ASSERT_EQUAL(ret, true); + ret = handlePhyConfigFile("tests/configs/positive/phy2_config_1.json", false); + CU_ASSERT_EQUAL(ret, true); +} + +void negativeConfigTest() +{ + bool ret; + + ret = handlePhyConfigFile("tests/configs/negative/phy_config_invalid_json.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handlePhyConfigFile("tests/configs/negative/phy_config_missing_lanes.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handlePhyConfigFile("tests/configs/negative/phy_config_lanes_missing_id.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handlePhyConfigFile("tests/configs/negative/phy_config_lanes_missing_system_side.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handlePhyConfigFile("tests/configs/negative/phy_config_lanes_missing_local_lane_id.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handlePhyConfigFile("tests/configs/negative/phy_config_lanes_missing_tx_polarity.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handlePhyConfigFile("tests/configs/negative/phy_config_lanes_missing_rx_polarity.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handlePhyConfigFile("tests/configs/negative/phy_config_lanes_missing_line_tx_lanemap.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handlePhyConfigFile("tests/configs/negative/phy_config_lanes_missing_line_rx_lanemap.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handlePhyConfigFile("tests/configs/negative/phy_config_lanes_missing_line_to_system_lanemap.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handlePhyConfigFile("tests/configs/negative/phy_config_lanes_missing_mdio_addr.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handlePhyConfigFile("tests/configs/negative/phy_config_ports_missing_id.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handlePhyConfigFile("tests/configs/negative/phy_config_ports_missing_mdio_addr.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handlePhyConfigFile("tests/configs/negative/phy_config_ports_missing_system_speed.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handlePhyConfigFile("tests/configs/negative/phy_config_ports_missing_system_fec.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handlePhyConfigFile("tests/configs/negative/phy_config_ports_missing_system_auto_neg.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handlePhyConfigFile("tests/configs/negative/phy_config_ports_missing_system_loopback.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handlePhyConfigFile("tests/configs/negative/phy_config_ports_missing_system_training.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handlePhyConfigFile("tests/configs/negative/phy_config_ports_missing_line_speed.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handlePhyConfigFile("tests/configs/negative/phy_config_ports_missing_line_fec.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handlePhyConfigFile("tests/configs/negative/phy_config_ports_missing_line_auto_neg.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handlePhyConfigFile("tests/configs/negative/phy_config_ports_missing_line_media_type.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handlePhyConfigFile("tests/configs/negative/phy_config_ports_missing_line_intf_type.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handlePhyConfigFile("tests/configs/negative/phy_config_ports_missing_line_loopback.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handlePhyConfigFile("tests/configs/negative/phy_config_ports_missing_line_training.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handlePhyConfigFile("tests/configs/negative/phy_config_ports_missing_line_adver_speed.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handlePhyConfigFile("tests/configs/negative/phy_config_ports_missing_line_adver_fec.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handlePhyConfigFile("tests/configs/negative/phy_config_ports_missing_line_adver_auto_neg.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handlePhyConfigFile("tests/configs/negative/phy_config_ports_missing_line_adver_asym_pause.json", false); + CU_ASSERT_EQUAL(ret, false); + ret = handlePhyConfigFile("tests/configs/negative/phy_config_ports_missing_line_adver_media_type.json", false); + CU_ASSERT_EQUAL(ret, false); +} + +int unitTestMain() +{ + CU_pSuite pSuite = NULL; + CU_pTest pTest = NULL; + int ret = 0; + + if (CUE_SUCCESS != CU_initialize_registry()) + { + printf("%s: cunit failed to initialize registry\n", __FUNCTION__); + ret = CU_get_error(); + } + else + { + + CU_basic_set_mode(CU_BRM_VERBOSE); + + // Run the tests and show the run summary + pSuite = CU_add_suite("phy_config_suite", 0, 0); + if (NULL == pSuite) + { + printf("%s: cunit failed to create suite\n", __FUNCTION__); + CU_cleanup_registry(); + ret = CU_get_error(); + } + } + + // Add the test to the suite + if (ret == 0) + { + pTest = CU_add_test(pSuite, "phy_positive_config_test", positiveConfigTest); + + if (pTest != NULL) + { + pTest = CU_add_test(pSuite, "phy_negative_config_test", negativeConfigTest); + } + + if (pTest == NULL) + { + CU_cleanup_registry(); + printf("%s: cunit failed to add test\n", __FUNCTION__); + ret = CU_get_error(); + } + } + if (ret == 0) + { + CU_basic_run_tests(); + } + return ret; +} + +bool handlePhyConfigFile(std::string file, bool warm) +{ + PhyParser p; + bool ret; + + p.setWriteToDb(true); + p.setConfigPath(file); + ret = p.parse(); + return ret; +} + +int main(int argc, char **argv) +{ + swss::Logger::linkToDbNative("testphyparser"); + + unitTestMain(); + return 1; +} + diff --git a/lib/gearboxutils.cpp b/lib/gearboxutils.cpp new file mode 100644 index 0000000000..d17ed3a02f --- /dev/null +++ b/lib/gearboxutils.cpp @@ -0,0 +1,458 @@ +/* + * Copyright 2019-2020 Broadcom Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gearboxutils.h" + +namespace swss { + +std::tuple GearboxUtils::parseGearboxKey(std::string key_str) +{ + /* + * The Gearbox key string has a few formats based on the number of tokens. + * Parse and return accordingly; + * phy::ports: rtn: ports + * phy::lanes: rtn: lanes + * phy: rtn: phy + * interface: rtn: interface + */ + + std::string str1, str2, str3; + std::vector token = tokenize(key_str, ':'); + + if (token.size() == 4) + { + str1 = token.at(2); + str2 = token.at(1); + str3 = token.at(3); + } + else if (token.size() == 2) + { + str1 = token.at(0); + str2 = token.at(1); + } + + SWSS_LOG_DEBUG("Parsed key:%s, Return:(%s)(%s)(%s)", key_str.c_str(), str1.c_str(), str2.c_str(), str3.c_str()); + + return make_tuple(str1, str2, str3); +} + +bool GearboxUtils::platformHasGearbox() +{ + bool ret = false; + + if (access("/usr/share/sonic/hwsku/gearbox_config.json", F_OK) != -1) + { + ret = true; + } + return ret; +} + +bool GearboxUtils::isGearboxConfigDone(Table &gearboxTable) +{ + std::vector tuples; + bool gearboxConfigDone = false; + + // this will return false if GearboxConfigDone is not set in the database + + gearboxConfigDone = gearboxTable.get("GearboxConfigDone", tuples); + return gearboxConfigDone; +} + +bool GearboxUtils::isGearboxConfigDone(Table *gearboxTable) +{ + std::vector tuples; + bool gearboxConfigDone = false; + + // this will return false if GearboxConfigDone is not set in the database + + gearboxConfigDone = gearboxTable->get("GearboxConfigDone", tuples); + return gearboxConfigDone; +} + +bool GearboxUtils::isGearboxEnabled(Table *gearboxTable) +{ + int count = 10; // 10 seconds is more than enough time + bool gearboxDone = false; + + SWSS_LOG_ENTER(); + + if (platformHasGearbox() != true) + { + return gearboxDone; + } + + // wait until gearbox table is ready + while (count > 0) + { + if (!isGearboxConfigDone(gearboxTable)) + { + sleep(1); + count--; + continue; + } + else + { + gearboxDone = true; + break; + } + } + + return gearboxDone; +} + +std::map GearboxUtils::loadPhyMap(Table *gearboxTable) +{ + std::vector ovalues; + std::tuple keyt; + std::vector keys; + + SWSS_LOG_ENTER(); + + gearboxTable->getKeys(keys); + + if (keys.empty()) + { + SWSS_LOG_ERROR("No Gearbox records in ApplDB!"); + return gearboxPhyMap; + } + + for (auto &k : keys) + { + keyt = parseGearboxKey(k); + + if (std::get<0>(keyt).compare("phy") == 0) + { + gearbox_phy_t phy = {}; + + gearboxTable->get(k, ovalues); + for (auto &val : ovalues) + { + if (val.first == "phy_id") + { + phy.phy_id = std::stoi(val.second); + } + else if (val.first == "phy_oid") + { + // oid is from create_switch (not config) + phy.phy_oid = val.second; + } + else if (val.first == "name") + { + phy.name = val.second; + } + else if (val.first == "lib_name") + { + phy.lib_name = val.second; + } + else if (val.first == "firmware_path") + { + phy.firmware = val.second; + } + else if (val.first == "config_file") + { + phy.config_file = val.second; + } + else if (val.first == "sai_init_config_file") + { + phy.sai_init_config_file = val.second; + } + else if (val.first == "phy_access") + { + phy.access = val.second; + } + else if (val.first == "address") + { + phy.address = std::stoi(val.second); + } + else if (val.first == "bus_id") + { + phy.bus_id = std::stoi(val.second); + } + } + gearboxPhyMap[phy.phy_id] = phy; + } + } + + return gearboxPhyMap; +} + +std::map GearboxUtils::loadInterfaceMap(Table *gearboxTable) +{ + std::vector ovalues; + std::tuple keyt; + std::vector keys; + + SWSS_LOG_ENTER(); + + gearboxTable->getKeys(keys); + + if (keys.empty()) + { + SWSS_LOG_ERROR("No Gearbox records in ApplDB!"); + return gearboxInterfaceMap; + } + + for (auto &k : keys) + { + keyt = parseGearboxKey(k); + + if (std::get<0>(keyt).compare("interface") == 0) + { + gearbox_interface_t interface = {}; + + gearboxTable->get(k, ovalues); + for (auto &val : ovalues) + { + if (val.first == "index") + { + interface.index = std::stoi(val.second); + SWSS_LOG_DEBUG("BOX interface = %d", interface.index); + } + else if (val.first == "phy_id") + { + interface.phy_id = std::stoi(val.second); + SWSS_LOG_DEBUG("BOX phy_id = %d", interface.phy_id); + } + else if (val.first == "line_lanes") + { + std::stringstream ss(val.second); + + for (int i; ss >> i;) + { + SWSS_LOG_DEBUG("Parsed key:%s, val:%s,inserted %d", val.first.c_str(), val.second.c_str(), i); + interface.line_lanes.insert(i); + if (ss.peek() == ',') + { + ss.ignore(); + } + } + } + else if (val.first == "system_lanes") + { + std::stringstream ss(val.second); + + for (int i; ss >> i;) + { + SWSS_LOG_DEBUG("Parsed key:%s, val:%s,inserted %d", val.first.c_str(), val.second.c_str(), i); + interface.system_lanes.insert(i); + if (ss.peek() == ',') + { + ss.ignore(); + } + } + } + } + gearboxInterfaceMap[interface.index] = interface; + } + } + + return gearboxInterfaceMap; +} + +std::map GearboxUtils::loadLaneMap(Table *gearboxTable) +{ + std::vector ovalues; + std::tuple keyt; + std::vector keys; + + SWSS_LOG_ENTER(); + + gearboxTable->getKeys(keys); + + if (keys.empty()) + { + SWSS_LOG_ERROR("No Gearbox records in ApplDB!"); + return gearboxLaneMap; + } + + for (auto &k : keys) + { + keyt = parseGearboxKey(k); + + if (std::get<0>(keyt).compare("lanes") == 0) + { + gearbox_lane_t lane = {}; + + gearboxTable->get(k, ovalues); + for (auto &val : ovalues) + { + if (val.first == "index") + { + lane.index = std::stoi(val.second); + } + else if (val.first == "tx_polarity") + { + lane.tx_polarity = std::stoi(val.second); + } + else if (val.first == "rx_polarity") + { + lane.rx_polarity = std::stoi(val.second); + } + else if (val.first == "line_tx_lanemap") + { + lane.line_tx_lanemap = std::stoi(val.second); + } + else if (val.first == "line_rx_lanemap") + { + lane.line_rx_lanemap = std::stoi(val.second); + } + else if (val.first == "line_to_system_lanemap") + { + lane.line_to_system_lanemap = std::stoi(val.second); + } + else if (val.first == "mdio_addr") + { + lane.mdio_addr = val.second; + } + else if (val.first == "system_side") + { + lane.system_side = (val.second == "true") ? true : false; + } + } + gearboxLaneMap[lane.index] = lane; + } + } + + return gearboxLaneMap; +} + +std::map GearboxUtils::loadPortMap(Table *gearboxTable) +{ + std::vector ovalues; + std::tuple keyt; + std::vector keys; + + SWSS_LOG_ENTER(); + + gearboxTable->getKeys(keys); + + if (keys.empty()) + { + SWSS_LOG_ERROR("No Gearbox records in ApplDB!"); + return gearboxPortMap; + } + + for (auto &k : keys) + { + keyt = parseGearboxKey(k); + + if (std::get<0>(keyt).compare("ports") == 0) + { + gearbox_port_t port = {}; + + gearboxTable->get(k, ovalues); + for (auto &val : ovalues) + { + if (val.first == "index") + { + port.index = std::stoi(val.second); + } + else if (val.first == "mdio_addr") + { + port.mdio_addr = val.second; + } + else if (val.first == "system_speed") + { + port.system_speed = std::stoi(val.second); + } + else if (val.first == "system_fec") + { + port.system_fec = val.second; + } + else if (val.first == "system_auto_neg") + { + port.system_auto_neg = (val.second == "true") ? true : false; + } + else if (val.first == "system_loopback") + { + port.system_loopback = val.second; + } + else if (val.first == "system_training") + { + port.system_training = (val.second == "true") ? true : false; + } + else if (val.first == "line_speed") + { + port.line_speed = std::stoi(val.second); + } + else if (val.first == "line_fec") + { + port.line_fec = val.second; + } + else if (val.first == "line_auto_neg") + { + port.line_auto_neg = (val.second == "true") ? true : false; + } + else if (val.first == "line_media_type") + { + port.line_media_type = val.second; + } + else if (val.first == "line_intf_type") + { + port.line_intf_type = val.second; + } + else if (val.first == "line_loopback") + { + port.line_loopback = val.second; + } + else if (val.first == "line_training") + { + port.line_training = (val.second == "true") ? true : false; + } + else if (val.first == "line_adver_speed") + { + std::stringstream ss(val.second); + for (int i; ss >> i;) + { + port.line_adver_speed.insert(i); + if (ss.peek() == ',') + { + ss.ignore(); + } + } + } + else if (val.first == "line_adver_fec") + { + std::stringstream ss(val.second); + for (int i; ss >> i;) + { + port.line_adver_fec.insert(i); + if (ss.peek() == ',') + { + ss.ignore(); + } + } + } + else if (val.first == "line_adver_auto_neg") + { + port.line_adver_auto_neg = (val.second == "true") ? true : false; + } + else if (val.first == "line_adver_asym_pause") + { + port.line_adver_asym_pause = (val.second == "true") ? true : false; + } + else if (val.first == "line_adver_media_type") + { + port.line_adver_media_type = val.second; + } + } + gearboxPortMap[port.index] = port; + } + } + return gearboxPortMap; +} + +} diff --git a/lib/gearboxutils.h b/lib/gearboxutils.h new file mode 100644 index 0000000000..95e362d20e --- /dev/null +++ b/lib/gearboxutils.h @@ -0,0 +1,112 @@ +/* + * Copyright 2019-2020 Broadcom Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SWSS_COMMON_GEARBOX_UTILS_H +#define SWSS_COMMON_GEARBOX_UTILS_H + +#include +#include +#include +#include +#include +#include +#include + +#include "tokenize.h" +#include "table.h" + +namespace swss { + +typedef struct +{ + int phy_id; + std::string phy_oid; + std::string name; + std::string lib_name; + std::string firmware; + std::string firmware_major_version; + std::string sai_init_config_file; + std::string config_file; + std::string access; + uint32_t address; + uint32_t bus_id; +} gearbox_phy_t; + +typedef struct +{ + int index; + int phy_id; + std::set line_lanes; + std::set system_lanes; +} gearbox_interface_t; + +typedef struct +{ + int index; + bool system_side; + int tx_polarity; + int rx_polarity; + int line_tx_lanemap; + int line_rx_lanemap; + int line_to_system_lanemap; + std::string mdio_addr; +} gearbox_lane_t; + +typedef struct +{ + int index; + std::string mdio_addr; + int system_speed; + std::string system_fec; + bool system_auto_neg; + std::string system_loopback; + bool system_training; + int line_speed; + std::string line_fec; + bool line_auto_neg; + std::string line_media_type; + std::string line_intf_type; + std::string line_loopback; + bool line_training; + std::set line_adver_speed; + std::set line_adver_fec; + bool line_adver_auto_neg; + bool line_adver_asym_pause; + std::string line_adver_media_type; +} gearbox_port_t; + +class GearboxUtils +{ + private: + std::map gearboxPhyMap; + std::map gearboxInterfaceMap; + std::map gearboxLaneMap; + std::map gearboxPortMap; + std::tuple parseGearboxKey(std::string key_str); + public: + bool platformHasGearbox(); + bool isGearboxConfigDone(Table &gearboxTable); + bool isGearboxConfigDone(Table *gearboxTable); + bool isGearboxEnabled(Table *gearboxTable); + std::map loadPhyMap(Table *gearboxTable); + std::map loadInterfaceMap(Table *gearboxTable); + std::map loadLaneMap(Table *gearboxTable); + std::map loadPortMap(Table *gearboxTable); +}; + +} + +#endif /* SWSS_COMMON_GEARBOX_UTILS_H */ diff --git a/orchagent/Makefile.am b/orchagent/Makefile.am index d431557b5c..e4a988b65d 100644 --- a/orchagent/Makefile.am +++ b/orchagent/Makefile.am @@ -1,4 +1,4 @@ -INCLUDES = -I $(top_srcdir) -I $(top_srcdir)/warmrestart -I flex_counter -I debug_counter +INCLUDES = -I $(top_srcdir)/lib -I $(top_srcdir) -I $(top_srcdir)/warmrestart -I flex_counter -I debug_counter CFLAGS_SAI = -I /usr/include/sai @@ -25,6 +25,7 @@ endif orchagent_SOURCES = \ main.cpp \ + $(top_srcdir)/lib/gearboxutils.cpp \ orchdaemon.cpp \ orch.cpp \ notifications.cpp \ diff --git a/orchagent/main.cpp b/orchagent/main.cpp index d373c1120a..9da230bfb6 100644 --- a/orchagent/main.cpp +++ b/orchagent/main.cpp @@ -23,10 +23,12 @@ extern "C" { #include #include "orchdaemon.h" +#include "sai_serialize.h" #include "saihelper.h" #include "notifications.h" #include #include "warm_restart.h" +#include "gearboxutils.h" using namespace std; using namespace swss; @@ -99,7 +101,43 @@ void syncd_apply_view() { SWSS_LOG_ERROR("Failed to notify syncd APPLY_VIEW %d", status); exit(EXIT_FAILURE); + } +} + +/* + * If Gearbox is enabled... + * Create and initialize the external Gearbox PHYs. Upon success, store the + * new PHY OID in the database to be used later when creating the Gearbox + * ports. +*/ +void init_gearbox_phys(DBConnector *applDb) +{ + Table* tmpGearboxTable = new Table(applDb, "_GEARBOX_TABLE"); + map gearboxPhyMap; + GearboxUtils gearbox; + + if (gearbox.isGearboxEnabled(tmpGearboxTable)) + { + gearboxPhyMap = gearbox.loadPhyMap(tmpGearboxTable); + SWSS_LOG_DEBUG("BOX: gearboxPhyMap size = %d.", (int) gearboxPhyMap.size()); + + for (auto it = gearboxPhyMap.begin(); it != gearboxPhyMap.end(); ++it) + { + SWSS_LOG_NOTICE("BOX: Initialize PHY %d.", it->first); + + if (initSaiPhyApi(&it->second) != SAI_STATUS_SUCCESS) + { + SWSS_LOG_ERROR("BOX: Failed to initialize PHY %d.", it->first); + } + else + { + SWSS_LOG_NOTICE("BOX: Created new PHY phy_id:%d phy_oid:%s.", it->second.phy_id, it->second.phy_oid.c_str()); + tmpGearboxTable->hset("phy:"+to_string(it->second.phy_id), "phy_oid", it->second.phy_oid.c_str()); + tmpGearboxTable->hset("phy:"+to_string(it->second.phy_id), "firmware_major_version", it->second.firmware_major_version.c_str()); + } + } } + delete tmpGearboxTable; } int main(int argc, char **argv) @@ -224,6 +262,11 @@ int main(int argc, char **argv) attrs.push_back(attr); } + /* Must be last Attribute */ + attr.id = SAI_REDIS_SWITCH_ATTR_CONTEXT; + attr.value.u64 = gSwitchId; + attrs.push_back(attr); + // SAI_REDIS_SWITCH_ATTR_SYNC_MODE attribute only setBuffer and g_syncMode to true // since it is not using ASIC_DB, we can execute it before create_switch // when g_syncMode is set to true here, create_switch will wait the response from syncd @@ -326,6 +369,8 @@ int main(int argc, char **argv) DBConnector config_db("CONFIG_DB", 0); DBConnector state_db("STATE_DB", 0); + init_gearbox_phys(&appl_db); + auto orchDaemon = make_shared(&appl_db, &config_db, &state_db); if (!orchDaemon->init()) diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index cdd28e4999..d41ae931ab 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -2,6 +2,7 @@ #include "intfsorch.h" #include "bufferorch.h" #include "neighorch.h" +#include "gearboxutils.h" #include #include @@ -74,6 +75,32 @@ static map learn_mode_map = { "notification", SAI_BRIDGE_PORT_FDB_LEARNING_MODE_FDB_NOTIFICATION} }; +static map media_type_map = +{ + { "fiber", SAI_PORT_MEDIA_TYPE_FIBER }, + { "copper", SAI_PORT_MEDIA_TYPE_COPPER } +}; + +static map loopback_mode_map = +{ + { "none", SAI_PORT_INTERNAL_LOOPBACK_MODE_NONE }, + { "phy", SAI_PORT_INTERNAL_LOOPBACK_MODE_PHY }, + { "mac", SAI_PORT_INTERNAL_LOOPBACK_MODE_MAC } +}; + +static map interface_type_map = +{ + { "none", SAI_PORT_INTERFACE_TYPE_NONE }, + { "cr", SAI_PORT_INTERFACE_TYPE_CR }, + { "cr4", SAI_PORT_INTERFACE_TYPE_CR4 }, + { "sr", SAI_PORT_INTERFACE_TYPE_SR }, + { "sr4", SAI_PORT_INTERFACE_TYPE_SR4 }, + { "lr", SAI_PORT_INTERFACE_TYPE_LR }, + { "lr4", SAI_PORT_INTERFACE_TYPE_LR4 }, + { "kr", SAI_PORT_INTERFACE_TYPE_KR }, + { "kr4", SAI_PORT_INTERFACE_TYPE_KR4 } +}; + const vector port_stat_ids = { SAI_PORT_STAT_IF_IN_OCTETS, @@ -143,14 +170,16 @@ static char* hostif_vlan_tag[] = { }; /* * Initialize PortsOrch - * 0) By default, a switch has one CPU port, one 802.1Q bridge, and one default + * 0) If Gearbox is enabled, then initialize the external PHYs as defined in + * the GEARBOX_TABLE. + * 1) By default, a switch has one CPU port, one 802.1Q bridge, and one default * VLAN. All ports are in .1Q bridge as bridge ports, and all bridge ports * are in default VLAN as VLAN members. - * 1) Query switch CPU port. - * 2) Query ports associated with lane mappings - * 3) Query switch .1Q bridge and all its bridge ports. - * 4) Query switch default VLAN and all its VLAN members. - * 5) Remove each VLAN member from default VLAN and each bridge port from .1Q + * 2) Query switch CPU port. + * 3) Query ports associated with lane mappings + * 4) Query switch .1Q bridge and all its bridge ports. + * 5) Query switch default VLAN and all its VLAN members. + * 6) Remove each VLAN member from default VLAN and each bridge port from .1Q * bridge. By design, SONiC switch starts with all bridge ports removed from * default VLAN and all ports removed from .1Q bridge. */ @@ -174,6 +203,9 @@ PortsOrch::PortsOrch(DBConnector *db, vector &tableNames) /* Initialize port table */ m_portTable = unique_ptr(new Table(db, APP_PORT_TABLE_NAME)); + /* Initialize gearbox */ + m_gearboxTable = unique_ptr
(new Table(db, "_GEARBOX_TABLE")); + /* Initialize queue tables */ m_queueTable = unique_ptr
(new Table(m_counter_db.get(), COUNTERS_QUEUE_NAME_MAP)); m_queuePortTable = unique_ptr
(new Table(m_counter_db.get(), COUNTERS_QUEUE_PORT_MAP)); @@ -189,6 +221,8 @@ PortsOrch::PortsOrch(DBConnector *db, vector &tableNames) m_flexCounterTable = unique_ptr(new ProducerTable(m_flex_db.get(), FLEX_COUNTER_TABLE)); m_flexCounterGroupTable = unique_ptr(new ProducerTable(m_flex_db.get(), FLEX_COUNTER_GROUP_TABLE)); + initGearbox(); + string queueWmSha, pgWmSha; string queueWmPluginName = "watermark_queue.lua"; string pgWmPluginName = "watermark_pg.lua"; @@ -425,6 +459,38 @@ bool PortsOrch::isConfigDone() return m_portConfigState == PORT_CONFIG_DONE; } +/* Use this method to retrieve the desired port if the destination port is a Gearbox port. + * For example, if Gearbox is enabled on a specific physical interface, + * the destination port may be the PHY or LINE side of the external PHY. + * The original port id is returned if it's not a Gearbox configured port. + */ +bool PortsOrch::getDestPortId(sai_object_id_t src_port_id, dest_port_type_t port_type, sai_object_id_t &des_port_id) +{ + bool status = false; + des_port_id = src_port_id; + + if (m_gearboxEnabled) + { + if (m_gearboxPortListLaneMap.find(src_port_id) != m_gearboxPortListLaneMap.end()) + { + if (PHY_PORT_TYPE == port_type) + { + des_port_id = get<0>(m_gearboxPortListLaneMap[src_port_id]); + SWSS_LOG_DEBUG("BOX: port id:%" PRIx64 " has a phy-side port id:%" PRIx64, src_port_id, des_port_id); + status = true; + } + else if (LINE_PORT_TYPE == port_type) + { + des_port_id = get<1>(m_gearboxPortListLaneMap[src_port_id]); + SWSS_LOG_DEBUG("BOX: port id:%" PRIx64 " has a line-side port id:%" PRIx64, src_port_id, des_port_id); + status = true; + } + } + } + + return status; +} + bool PortsOrch::isPortAdminUp(const string &alias) { auto it = m_portList.find(alias); @@ -679,23 +745,26 @@ void PortsOrch::getCpuPort(Port &port) port = m_cpuPort; } -bool PortsOrch::setPortAdminStatus(sai_object_id_t id, bool up) +bool PortsOrch::setPortAdminStatus(Port &port, bool state) { SWSS_LOG_ENTER(); sai_attribute_t attr; attr.id = SAI_PORT_ATTR_ADMIN_STATE; - attr.value.booldata = up; + attr.value.booldata = state; - sai_status_t status = sai_port_api->set_port_attribute(id, &attr); - if (status != SAI_STATUS_SUCCESS) + if (sai_port_api->set_port_attribute(port.m_port_id, &attr) != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to set admin status %s to port pid:%" PRIx64, - up ? "UP" : "DOWN", id); + state ? "UP" : "DOWN", port.m_port_id); return false; } + SWSS_LOG_INFO("Set admin status %s to port pid:%" PRIx64, - up ? "UP" : "DOWN", id); + state ? "UP" : "DOWN", port.m_port_id); + + setGearboxPortsAttr(port, SAI_PORT_ATTR_ADMIN_STATE, &state); + return true; } @@ -703,6 +772,8 @@ bool PortsOrch::getPortAdminStatus(sai_object_id_t id, bool &up) { SWSS_LOG_ENTER(); + getDestPortId(id, LINE_PORT_TYPE, id); + sai_attribute_t attr; attr.id = SAI_PORT_ATTR_ADMIN_STATE; @@ -738,7 +809,7 @@ bool PortsOrch::setPortMtu(sai_object_id_t id, sai_uint32_t mtu) return true; } -bool PortsOrch::setPortFec(sai_object_id_t id, sai_port_fec_mode_t mode) +bool PortsOrch::setPortFec(Port &port, sai_port_fec_mode_t mode) { SWSS_LOG_ENTER(); @@ -746,15 +817,16 @@ bool PortsOrch::setPortFec(sai_object_id_t id, sai_port_fec_mode_t mode) attr.id = SAI_PORT_ATTR_FEC_MODE; attr.value.s32 = mode; - sai_status_t status = sai_port_api->set_port_attribute(id, &attr); - if (status != SAI_STATUS_SUCCESS) + if (sai_port_api->set_port_attribute(port.m_port_id, &attr) != SAI_STATUS_SUCCESS) { - SWSS_LOG_ERROR("Failed to set fec mode %d to port pid:%" PRIx64, - mode, id); + SWSS_LOG_ERROR("Failed to set fec mode %d to port pid:%" PRIx64, mode, port.m_port_id); return false; } - SWSS_LOG_INFO("Set fec mode %d to port pid:%" PRIx64, - mode, id); + + SWSS_LOG_INFO("Set fec mode %d to port pid:%" PRIx64, mode, port.m_port_id); + + setGearboxPortsAttr(port, SAI_PORT_ATTR_FEC_MODE, &mode); + return true; } @@ -1386,31 +1458,147 @@ bool PortsOrch::isSpeedSupported(const std::string& alias, sai_object_id_t port_ return std::find(supp_speeds.begin(), supp_speeds.end(), speed) != supp_speeds.end(); } -bool PortsOrch::setPortSpeed(sai_object_id_t port_id, sai_uint32_t speed) +/* + * If Gearbox is enabled and this is a Gearbox port then set the attributes accordingly. + */ +bool PortsOrch::setGearboxPortsAttr(Port &port, sai_port_attr_t id, void *value) { + bool status; + + status = setGearboxPortAttr(port, PHY_PORT_TYPE, id, value); + + if (status == true) + { + status = setGearboxPortAttr(port, LINE_PORT_TYPE, id, value); + } + + return status; +} + +/* + * If Gearbox is enabled and this is a Gearbox port then set the specific lane attribute. + * Note: the appl_db is also updated (Gearbox config_db tables are TBA). + */ +bool PortsOrch::setGearboxPortAttr(Port &port, dest_port_type_t port_type, sai_port_attr_t id, void *value) +{ + sai_status_t status = SAI_STATUS_SUCCESS; + sai_object_id_t dest_port_id; + sai_attribute_t attr; + string speed_attr; + uint32_t lane_speed = 0; + sai_uint32_t speed = 0; + uint32_t lanes = 0; + SWSS_LOG_ENTER(); + + if (m_gearboxEnabled) + { + if (getDestPortId(port.m_port_id, port_type, dest_port_id) == true) + { + switch (id) + { + case SAI_PORT_ATTR_FEC_MODE: + attr.id = id; + attr.value.s32 = *static_cast(value); + SWSS_LOG_NOTICE("BOX: Set %s FEC_MODE %d", port.m_alias.c_str(), attr.value.s32); + break; + case SAI_PORT_ATTR_ADMIN_STATE: + attr.id = id; + attr.value.booldata = *static_cast(value); + SWSS_LOG_NOTICE("BOX: Set %s ADMIN_STATE %d", port.m_alias.c_str(), attr.value.booldata); + break; + case SAI_PORT_ATTR_SPEED: + switch (port_type) + { + case PHY_PORT_TYPE: + lanes = static_cast(m_gearboxInterfaceMap[port.m_index].system_lanes.size()); + speed_attr = "system_speed"; + break; + case LINE_PORT_TYPE: + lanes = static_cast(m_gearboxInterfaceMap[port.m_index].line_lanes.size()); + speed_attr = "line_speed"; + break; + default: + return false; + } + + // Gearbox expects speed per lane + speed = *static_cast(value); + if (speed % lanes == 0) + { + lane_speed = speed / lanes; + } + if (isSpeedSupported(port.m_alias, dest_port_id, lane_speed)) + { + // Gearbox may not implement speed check, so + // invalidate speed if it doesn't make sense. + if (to_string(lane_speed).size() < 5) + { + lane_speed = 0; + } + + attr.id = SAI_PORT_ATTR_SPEED; + attr.value.u32 = lane_speed; + } + SWSS_LOG_NOTICE("BOX: Set %s lane %s %d", port.m_alias.c_str(), speed_attr.c_str(), lane_speed); + break; + default: + return false; + } + + status = sai_port_api->set_port_attribute(dest_port_id, &attr); + if (status == SAI_STATUS_SUCCESS) + { + if (id == SAI_PORT_ATTR_SPEED) + { + string key = "phy:"+to_string(m_gearboxInterfaceMap[port.m_index].phy_id)+":ports:"+to_string(port.m_index); + m_gearboxTable->hset(key, speed_attr, to_string(lane_speed)); + SWSS_LOG_NOTICE("BOX: Updated APPL_DB key:%s %s %d", key.c_str(), speed_attr.c_str(), lane_speed); + } + } + else + { + SWSS_LOG_ERROR("BOX: Failed to set %s port attribute %d", port.m_alias.c_str(), id); + } + } + } + + return status == SAI_STATUS_SUCCESS; +} + +bool PortsOrch::setPortSpeed(Port &port, sai_uint32_t speed) +{ sai_attribute_t attr; sai_status_t status; + SWSS_LOG_ENTER(); + attr.id = SAI_PORT_ATTR_SPEED; attr.value.u32 = speed; - status = sai_port_api->set_port_attribute(port_id, &attr); + status = sai_port_api->set_port_attribute(port.m_port_id, &attr); + + if (status == SAI_STATUS_SUCCESS) + { + setGearboxPortsAttr(port, SAI_PORT_ATTR_SPEED, &speed); + } return status == SAI_STATUS_SUCCESS; } -bool PortsOrch::getPortSpeed(sai_object_id_t port_id, sai_uint32_t &speed) +bool PortsOrch::getPortSpeed(sai_object_id_t id, sai_uint32_t &speed) { SWSS_LOG_ENTER(); + getDestPortId(id, LINE_PORT_TYPE, id); + sai_attribute_t attr; sai_status_t status; attr.id = SAI_PORT_ATTR_SPEED; attr.value.u32 = 0; - status = sai_port_api->get_port_attribute(port_id, 1, &attr); + status = sai_port_api->get_port_attribute(id, 1, &attr); if (status == SAI_STATUS_SUCCESS) speed = attr.value.u32; @@ -1602,7 +1790,7 @@ string PortsOrch::getPriorityGroupWatermarkFlexCounterTableKey(string key) return string(PG_WATERMARK_STAT_COUNTER_FLEX_COUNTER_GROUP) + ":" + key; } -bool PortsOrch::initPort(const string &alias, const set &lane_set) +bool PortsOrch::initPort(const string &alias, const int index, const set &lane_set) { SWSS_LOG_ENTER(); @@ -1620,15 +1808,20 @@ bool PortsOrch::initPort(const string &alias, const set &lane_set) { Port p(alias, Port::PHY); - p.m_index = static_cast(m_portList.size()); // TODO: Assume no deletion of physical port + p.m_index = index; p.m_port_id = id; /* Initialize the port and create corresponding host interface */ if (initializePort(p)) { + /* Create associated Gearbox lane mapping */ + initGearboxPort(p); + /* Add port to port list */ m_portList[alias] = p; m_port_ref_count[alias] = 0; + m_portOidToIndex[id] = index; + /* Add port name map to counter table */ FieldValueTuple tuple(p.m_alias, sai_serialize_object_id(p.m_port_id)); vector fields; @@ -1648,7 +1841,7 @@ bool PortsOrch::initPort(const string &alias, const set &lane_set) m_portList[alias].m_init = true; - SWSS_LOG_NOTICE("Initialized port %s", alias.c_str()); + SWSS_LOG_ERROR("Initialized port %s", alias.c_str()); } else { @@ -1847,9 +2040,16 @@ void PortsOrch::doPortTask(Consumer &consumer) uint32_t speed = 0; string learn_mode; int an = -1; + int index = -1; for (auto i : kfvFieldsValues(t)) { + /* Set interface index */ + if (fvField(i) == "index") + { + index = (int)stoul(fvValue(i)); + } + /* Get lane information of a physical port and initialize the port */ if (fvField(i) == "lanes") { @@ -1926,7 +2126,7 @@ void PortsOrch::doPortTask(Consumer &consumer) /* Collect information about all received ports */ if (lane_set.size()) { - m_lanesAliasSpeedMap[lane_set] = make_tuple(alias, speed, an, fec_mode); + m_lanesAliasSpeedMap[lane_set] = make_tuple(alias, speed, an, fec_mode, index); } // TODO: @@ -1968,7 +2168,7 @@ void PortsOrch::doPortTask(Consumer &consumer) } } - if (!initPort(get<0>(it->second), it->first)) + if (!initPort(get<0>(it->second), get<4>(it->second), it->first)) { throw runtime_error("PortsOrch initialization failure."); } @@ -2051,65 +2251,75 @@ void PortsOrch::doPortTask(Consumer &consumer) * 3. Set port admin status to DOWN before changing the speed * 4. Set port speed */ - if (speed != 0 && speed != p.m_speed) - { - m_portList[alias] = p; - if (p.m_autoneg) - { - if (setPortAdvSpeed(p.m_port_id, speed)) - { - SWSS_LOG_NOTICE("Set port %s advertised speed to %u", alias.c_str(), speed); - } - else - { - SWSS_LOG_ERROR("Failed to set port %s advertised speed to %u", alias.c_str(), speed); - it++; - continue; - } - } - else + SWSS_LOG_DEBUG("Set port %s speed to %u -> %u", alias.c_str(), p.m_speed, speed); + if (speed != 0) + { + if (speed != p.m_speed) { - if (!isSpeedSupported(alias, p.m_port_id, speed)) - { - it++; - continue; - } + m_portList[alias] = p; - if (p.m_admin_state_up) + if (p.m_autoneg) { - /* Bring port down before applying speed */ - if (!setPortAdminStatus(p.m_port_id, false)) + if (setPortAdvSpeed(p.m_port_id, speed)) { - SWSS_LOG_ERROR("Failed to set port %s admin status DOWN to set speed", alias.c_str()); - it++; - continue; + SWSS_LOG_NOTICE("Set port %s advertised speed to %u", alias.c_str(), speed); } - - p.m_admin_state_up = false; - m_portList[alias] = p; - - if (!setPortSpeed(p.m_port_id, speed)) + else { - SWSS_LOG_ERROR("Failed to set port %s speed to %u", alias.c_str(), speed); + SWSS_LOG_ERROR("Failed to set port %s advertised speed to %u", alias.c_str(), speed); it++; continue; } } else { - /* Port is already down, setting speed */ - if (!setPortSpeed(p.m_port_id, speed)) + if (!isSpeedSupported(alias, p.m_port_id, speed)) { - SWSS_LOG_ERROR("Failed to set port %s speed to %u", alias.c_str(), speed); it++; continue; } + + if (p.m_admin_state_up) + { + /* Bring port down before applying speed */ + if (!setPortAdminStatus(p, false)) + { + SWSS_LOG_ERROR("Failed to set port %s admin status DOWN to set speed", alias.c_str()); + it++; + continue; + } + + p.m_admin_state_up = false; + m_portList[alias] = p; + + if (!setPortSpeed(p, speed)) + { + SWSS_LOG_ERROR("Failed to set port %s speed to %u", alias.c_str(), speed); + it++; + continue; + } + } + else + { + /* Port is already down, setting speed */ + if (!setPortSpeed(p, speed)) + { + SWSS_LOG_ERROR("Failed to set port %s speed to %u", alias.c_str(), speed); + it++; + continue; + } + } + SWSS_LOG_NOTICE("Set port %s speed to %u", alias.c_str(), speed); } - SWSS_LOG_NOTICE("Set port %s speed to %u", alias.c_str(), speed); + p.m_speed = speed; + m_portList[alias] = p; + } + else + { + /* Always update Gearbox speed on Gearbox ports */ + setGearboxPortsAttr(p, SAI_PORT_ATTR_SPEED, &speed); } - p.m_speed = speed; - m_portList[alias] = p; } if (mtu != 0 && mtu != p.m_mtu) @@ -2140,7 +2350,7 @@ void PortsOrch::doPortTask(Consumer &consumer) if (p.m_fec_mode != fec_mode_map[fec_mode]) { p.m_fec_mode = fec_mode_map[fec_mode]; - if (setPortFec(p.m_port_id, p.m_fec_mode)) + if (setPortFec(p, p.m_fec_mode)) { m_portList[alias] = p; SWSS_LOG_NOTICE("Set port %s fec to %s", alias.c_str(), fec_mode.c_str()); @@ -2247,7 +2457,7 @@ void PortsOrch::doPortTask(Consumer &consumer) /* Last step set port admin status */ if (!admin_status.empty() && (p.m_admin_state_up != (admin_status == "up"))) { - if (setPortAdminStatus(p.m_port_id, admin_status == "up")) + if (setPortAdminStatus(p, admin_status == "up")) { p.m_admin_state_up = (admin_status == "up"); m_portList[alias] = p; @@ -4005,3 +4215,226 @@ void PortsOrch::getPortSerdesVal(const std::string& val_str, lane_values.push_back(lane_val); } } + +/* + * If Gearbox is enabled (wait for GearboxConfigDone), + * then initialize global storage maps + */ +void PortsOrch::initGearbox() +{ + GearboxUtils gearbox; + Table* tmpGearboxTable = m_gearboxTable.get(); + m_gearboxEnabled = gearbox.isGearboxEnabled(tmpGearboxTable); + + SWSS_LOG_ENTER(); + + if (m_gearboxEnabled) + { + m_gearboxPhyMap = gearbox.loadPhyMap(tmpGearboxTable); + m_gearboxInterfaceMap = gearbox.loadInterfaceMap(tmpGearboxTable); + m_gearboxLaneMap = gearbox.loadLaneMap(tmpGearboxTable); + m_gearboxPortMap = gearbox.loadPortMap(tmpGearboxTable); + + SWSS_LOG_NOTICE("BOX: m_gearboxPhyMap size = %d.", (int) m_gearboxPhyMap.size()); + SWSS_LOG_NOTICE("BOX: m_gearboxInterfaceMap size = %d.", (int) m_gearboxInterfaceMap.size()); + SWSS_LOG_NOTICE("BOX: m_gearboxLaneMap size = %d.", (int) m_gearboxLaneMap.size()); + SWSS_LOG_NOTICE("BOX: m_gearboxPortMap size = %d.", (int) m_gearboxPortMap.size()); + } +} + +/* + * Create both the system-side and line-side gearbox ports for the associated + * PHY and connect the ports. + * + */ +bool PortsOrch::initGearboxPort(Port &port) +{ + vector attrs; + vector lanes; + vector vals; + sai_attribute_t attr; + sai_object_id_t systemPort; + sai_object_id_t linePort; + sai_object_id_t connector; + sai_object_id_t phyOid; + sai_status_t status; + string phyOidStr; + int phy_id; + + SWSS_LOG_ENTER(); + + if (m_gearboxEnabled) + { + if (m_gearboxInterfaceMap.find(port.m_index) != m_gearboxInterfaceMap.end()) + { + SWSS_LOG_NOTICE("BOX: port_id:0x%lx index:%d alias:%s", port.m_port_id, port.m_index, port.m_alias.c_str()); + + phy_id = m_gearboxInterfaceMap[port.m_index].phy_id; + phyOidStr = m_gearboxPhyMap[phy_id].phy_oid; + + if (phyOidStr.size() == 0) + { + SWSS_LOG_ERROR("BOX: Gearbox PHY phy_id:%d has an invalid phy_oid", phy_id); + return false; + } + + sai_deserialize_object_id(phyOidStr, phyOid); + + /* Create SYSTEM-SIDE port */ + attrs.clear(); + + attr.id = SAI_PORT_ATTR_ADMIN_STATE; + attr.value.booldata = port.m_admin_state_up; + attrs.push_back(attr); + + attr.id = SAI_PORT_ATTR_SPEED; + attr.value.u32 = (uint32_t) m_gearboxPortMap[port.m_index].system_speed; + if (isSpeedSupported(port.m_alias, port.m_port_id, attr.value.u32)) + { + attrs.push_back(attr); + } + + attr.id = SAI_PORT_ATTR_AUTO_NEG_MODE; + attr.value.booldata = m_gearboxPortMap[port.m_index].system_auto_neg; + attrs.push_back(attr); + + attr.id = SAI_PORT_ATTR_FEC_MODE; + attr.value.s32 = fec_mode_map[m_gearboxPortMap[port.m_index].system_fec]; + attrs.push_back(attr); + + attr.id = SAI_PORT_ATTR_INTERNAL_LOOPBACK_MODE; + attr.value.u32 = loopback_mode_map[m_gearboxPortMap[port.m_index].system_loopback]; + attrs.push_back(attr); + + attr.id = SAI_PORT_ATTR_LINK_TRAINING_ENABLE; + attr.value.booldata = m_gearboxPortMap[port.m_index].system_training; + attrs.push_back(attr); + + attr.id = SAI_PORT_ATTR_HW_LANE_LIST; + lanes.assign(m_gearboxInterfaceMap[port.m_index].system_lanes.begin(), m_gearboxInterfaceMap[port.m_index].system_lanes.end()); + attr.value.u32list.list = lanes.data(); + attr.value.u32list.count = static_cast(lanes.size()); + attrs.push_back(attr); + + for (uint32_t i = 0; i < attr.value.u32list.count; i++) + { + SWSS_LOG_DEBUG("BOX: list[%d] = %d", i, attr.value.u32list.list[i]); + } + + status = sai_port_api->create_port(&systemPort, phyOid, static_cast(attrs.size()), attrs.data()); + if (status != SAI_STATUS_SUCCESS) + { + SWSS_LOG_ERROR("BOX: Failed to create Gearbox system-side port for alias:%s port_id:0x%lx index:%d status:%d", + port.m_alias.c_str(), port.m_port_id, port.m_index, status); + return false; + } + SWSS_LOG_NOTICE("BOX: Created Gearbox system-side port 0x%lx for alias:%s index:%d", + systemPort, port.m_alias.c_str(), port.m_index); + + /* Create LINE-SIDE port */ + attrs.clear(); + + attr.id = SAI_PORT_ATTR_ADMIN_STATE; + attr.value.booldata = port.m_admin_state_up; + attrs.push_back(attr); + + attr.id = SAI_PORT_ATTR_SPEED; + attr.value.u32 = (uint32_t) m_gearboxPortMap[port.m_index].line_speed; + if (isSpeedSupported(port.m_alias, port.m_port_id, attr.value.u32)) + { + attrs.push_back(attr); + } + + attr.id = SAI_PORT_ATTR_AUTO_NEG_MODE; + attr.value.booldata = m_gearboxPortMap[port.m_index].line_auto_neg; + attrs.push_back(attr); + + attr.id = SAI_PORT_ATTR_FEC_MODE; + attr.value.s32 = fec_mode_map[m_gearboxPortMap[port.m_index].line_fec]; + attrs.push_back(attr); + + attr.id = SAI_PORT_ATTR_MEDIA_TYPE; + attr.value.u32 = media_type_map[m_gearboxPortMap[port.m_index].line_media_type]; + attrs.push_back(attr); + + attr.id = SAI_PORT_ATTR_INTERNAL_LOOPBACK_MODE; + attr.value.u32 = loopback_mode_map[m_gearboxPortMap[port.m_index].line_loopback]; + attrs.push_back(attr); + + attr.id = SAI_PORT_ATTR_LINK_TRAINING_ENABLE; + attr.value.booldata = m_gearboxPortMap[port.m_index].line_training; + attrs.push_back(attr); + + attr.id = SAI_PORT_ATTR_INTERFACE_TYPE; + attr.value.u32 = interface_type_map[m_gearboxPortMap[port.m_index].line_intf_type]; + attrs.push_back(attr); + + attr.id = SAI_PORT_ATTR_ADVERTISED_SPEED; + vals.assign(m_gearboxPortMap[port.m_index].line_adver_speed.begin(), m_gearboxPortMap[port.m_index].line_adver_speed.end()); + attr.value.u32list.list = vals.data(); + attr.value.u32list.count = static_cast(vals.size()); + attrs.push_back(attr); + + attr.id = SAI_PORT_ATTR_ADVERTISED_FEC_MODE; + vals.assign(m_gearboxPortMap[port.m_index].line_adver_fec.begin(), m_gearboxPortMap[port.m_index].line_adver_fec.end()); + attr.value.u32list.list = vals.data(); + attr.value.u32list.count = static_cast(vals.size()); + attrs.push_back(attr); + + attr.id = SAI_PORT_ATTR_ADVERTISED_AUTO_NEG_MODE; + attr.value.booldata = m_gearboxPortMap[port.m_index].line_adver_auto_neg; + attrs.push_back(attr); + + attr.id = SAI_PORT_ATTR_ADVERTISED_ASYMMETRIC_PAUSE_MODE; + attr.value.booldata = m_gearboxPortMap[port.m_index].line_adver_asym_pause; + attrs.push_back(attr); + + attr.id = SAI_PORT_ATTR_ADVERTISED_MEDIA_TYPE; + attr.value.u32 = media_type_map[m_gearboxPortMap[port.m_index].line_adver_media_type]; + attrs.push_back(attr); + + attr.id = SAI_PORT_ATTR_HW_LANE_LIST; + lanes.assign(m_gearboxInterfaceMap[port.m_index].line_lanes.begin(), m_gearboxInterfaceMap[port.m_index].line_lanes.end()); + attr.value.u32list.list = lanes.data(); + attr.value.u32list.count = static_cast(lanes.size()); + attrs.push_back(attr); + + for (uint32_t i = 0; i < attr.value.u32list.count; i++) + { + SWSS_LOG_DEBUG("BOX: list[%d] = %d", i, attr.value.u32list.list[i]); + } + + status = sai_port_api->create_port(&linePort, phyOid, static_cast(attrs.size()), attrs.data()); + if (status != SAI_STATUS_SUCCESS) + { + SWSS_LOG_ERROR("BOX: Failed to create Gearbox line-side port for alias:%s port_id:0x%lx index:%d status:%d", + port.m_alias.c_str(), port.m_port_id, port.m_index, status); + return false; + } + SWSS_LOG_NOTICE("BOX: Created Gearbox line-side port 0x%lx for alias:%s index:%d", + linePort, port.m_alias.c_str(), port.m_index); + + /* Connect SYSTEM-SIDE to LINE-SIDE */ + attrs.clear(); + + attr.id = SAI_PORT_CONNECTOR_ATTR_SYSTEM_SIDE_PORT_ID; + attr.value.oid = systemPort; + attrs.push_back(attr); + attr.id = SAI_PORT_CONNECTOR_ATTR_LINE_SIDE_PORT_ID; + attr.value.oid = linePort; + attrs.push_back(attr); + + status = sai_port_api->create_port_connector(&connector, phyOid, static_cast(attrs.size()), attrs.data()); + if (status != SAI_STATUS_SUCCESS) + { + SWSS_LOG_ERROR("BOX: Failed to connect Gearbox system-side:0x%lx to line-side:0x%lx; status:%d", systemPort, linePort, status); + return false; + } + + SWSS_LOG_NOTICE("BOX: Connected Gearbox ports; system-side:0x%lx to line-side:0x%lx", systemPort, linePort); + m_gearboxPortListLaneMap[port.m_port_id] = make_tuple(systemPort, linePort); + } + } + return true; +} + diff --git a/orchagent/portsorch.h b/orchagent/portsorch.h index 62584da250..d4d3236f22 100755 --- a/orchagent/portsorch.h +++ b/orchagent/portsorch.h @@ -10,6 +10,9 @@ #include "macaddress.h" #include "producertable.h" #include "flex_counter_manager.h" +#include "gearboxutils.h" +#include "saihelper.h" + #define FCS_LEN 4 #define VLAN_TAG_LEN 4 @@ -126,6 +129,7 @@ class PortsOrch : public Orch, public Subject unique_ptr
m_counterTable; unique_ptr
m_counterLagTable; unique_ptr
m_portTable; + unique_ptr
m_gearboxTable; unique_ptr
m_queueTable; unique_ptr
m_queuePortTable; unique_ptr
m_queueIndexTable; @@ -160,11 +164,26 @@ class PortsOrch : public Orch, public Subject PORT_CONFIG_DONE, } port_config_state_t; + typedef enum + { + MAC_PORT_TYPE, + PHY_PORT_TYPE, + LINE_PORT_TYPE, + } dest_port_type_t; + + bool m_gearboxEnabled = false; + map m_gearboxPhyMap; + map m_gearboxInterfaceMap; + map m_gearboxLaneMap; + map m_gearboxPortMap; + map> m_gearboxPortListLaneMap; + port_config_state_t m_portConfigState = PORT_CONFIG_MISSING; sai_uint32_t m_portCount; map, sai_object_id_t> m_portListLaneMap; - map, tuple> m_lanesAliasSpeedMap; + map, tuple> m_lanesAliasSpeedMap; map m_portList; + unordered_map m_portOidToIndex; map m_port_ref_count; unordered_set m_pendingPortSet; @@ -210,22 +229,25 @@ class PortsOrch : public Orch, public Subject bool addPort(const set &lane_set, uint32_t speed, int an=0, string fec=""); sai_status_t removePort(sai_object_id_t port_id); - bool initPort(const string &alias, const set &lane_set); + bool initPort(const string &alias, const int index, const set &lane_set); void deInitPort(string alias, sai_object_id_t port_id); - bool setPortAdminStatus(sai_object_id_t id, bool up); + bool setPortAdminStatus(Port &port, bool up); bool getPortAdminStatus(sai_object_id_t id, bool& up); bool setPortMtu(sai_object_id_t id, sai_uint32_t mtu); bool setPortPvid (Port &port, sai_uint32_t pvid); bool getPortPvid(Port &port, sai_uint32_t &pvid); - bool setPortFec(sai_object_id_t id, sai_port_fec_mode_t mode); + bool setPortFec(Port &port, sai_port_fec_mode_t mode); bool setPortPfcAsym(Port &port, string pfc_asym); + bool getDestPortId(sai_object_id_t src_port_id, dest_port_type_t port_type, sai_object_id_t &des_port_id); bool setBridgePortAdminStatus(sai_object_id_t id, bool up); bool isSpeedSupported(const std::string& alias, sai_object_id_t port_id, sai_uint32_t speed); - bool setPortSpeed(sai_object_id_t port_id, sai_uint32_t speed); - bool getPortSpeed(sai_object_id_t port_id, sai_uint32_t &speed); + bool setPortSpeed(Port &port, sai_uint32_t speed); + bool getPortSpeed(sai_object_id_t id, sai_uint32_t &speed); + bool setGearboxPortsAttr(Port &port, sai_port_attr_t id, void *value); + bool setGearboxPortAttr(Port &port, dest_port_type_t port_type, sai_port_attr_t id, void *value); bool setPortAdvSpeed(sai_object_id_t port_id, sai_uint32_t speed); @@ -249,6 +271,8 @@ class PortsOrch : public Orch, public Subject vector &serdes_val); bool getSaiAclBindPointType(Port::Type type, sai_acl_bind_point_type_t &sai_acl_bind_type); + void initGearbox(); + bool initGearboxPort(Port &port); }; #endif /* SWSS_PORTSORCH_H */ diff --git a/orchagent/saihelper.cpp b/orchagent/saihelper.cpp index ec990d605e..a776ca701d 100644 --- a/orchagent/saihelper.cpp +++ b/orchagent/saihelper.cpp @@ -5,16 +5,23 @@ extern "C" { #include "saiextensions.h" } +#include #include #include #include #include +#include +#include +#include #include "timestamp.h" +#include "sai_serialize.h" #include "saihelper.h" using namespace std; using namespace swss; +#define CONTEXT_CFG_FILE "/usr/share/sonic/hwsku/context_config.json" + /* Initialize all global api pointers */ sai_switch_api_t* sai_switch_api; sai_bridge_api_t* sai_bridge_api; @@ -51,8 +58,29 @@ extern bool gSwssRecord; extern ofstream gRecordOfs; extern string gRecordFile; +static map hardware_access_map = +{ + { "mdio", SAI_SWITCH_HARDWARE_ACCESS_BUS_MDIO }, + { "i2c", SAI_SWITCH_HARDWARE_ACCESS_BUS_I2C }, + { "cpld", SAI_SWITCH_HARDWARE_ACCESS_BUS_CPLD } +}; + map gProfileMap; +sai_status_t mdio_read(uint64_t platform_context, + uint32_t mdio_addr, uint32_t reg_addr, + uint32_t number_of_registers, uint32_t *data) +{ + return SAI_STATUS_NOT_IMPLEMENTED; +} + +sai_status_t mdio_write(uint64_t platform_context, + uint32_t mdio_addr, uint32_t reg_addr, + uint32_t number_of_registers, uint32_t *data) +{ + return SAI_STATUS_NOT_IMPLEMENTED; +} + const char *test_profile_get_value ( _In_ sai_switch_profile_id_t profile_id, _In_ const char *variable) @@ -106,6 +134,12 @@ void initSaiApi() { SWSS_LOG_ENTER(); + if (ifstream(CONTEXT_CFG_FILE)) + { + SWSS_LOG_NOTICE("Context config file %s exists", CONTEXT_CFG_FILE); + gProfileMap[SAI_REDIS_KEY_CONTEXT_CONFIG] = CONTEXT_CFG_FILE; + } + sai_api_initialize(0, (const sai_service_method_table_t *)&test_services); sai_api_query(SAI_API_SWITCH, (void **)&sai_switch_api); @@ -225,8 +259,85 @@ void initSaiRedis(const string &record_location) if (status != SAI_STATUS_SUCCESS) { - SWSS_LOG_ERROR("Failed to notify syncd INIT_VIEW, rv:%d", status); + SWSS_LOG_ERROR("Failed to notify syncd INIT_VIEW, rv:%d gSwitchId %lx", status, gSwitchId); exit(EXIT_FAILURE); } SWSS_LOG_NOTICE("Notify syncd INIT_VIEW"); } + +sai_status_t initSaiPhyApi(swss::gearbox_phy_t *phy) +{ + sai_object_id_t phyOid; + sai_attribute_t attr; + vector attrs; + sai_status_t status; + + SWSS_LOG_ENTER(); + + attr.id = SAI_SWITCH_ATTR_INIT_SWITCH; + attr.value.booldata = true; + attrs.push_back(attr); + + attr.id = SAI_SWITCH_ATTR_TYPE; + attr.value.u32 = SAI_SWITCH_TYPE_PHY; + attrs.push_back(attr); + + attr.id = SAI_SWITCH_ATTR_SWITCH_PROFILE_ID; + attr.value.u32 = 0; + attrs.push_back(attr); + + attr.id = SAI_SWITCH_ATTR_SWITCH_HARDWARE_INFO; + attr.value.s8list.count = 0; + attr.value.s8list.list = 0; + attrs.push_back(attr); + + attr.id = SAI_SWITCH_ATTR_FIRMWARE_LOAD_METHOD; + attr.value.u32 = SAI_SWITCH_FIRMWARE_LOAD_METHOD_NONE; + attrs.push_back(attr); + + attr.id = SAI_SWITCH_ATTR_REGISTER_READ; + attr.value.ptr = (void *) mdio_read; + attrs.push_back(attr); + + attr.id = SAI_SWITCH_ATTR_REGISTER_WRITE; + attr.value.ptr = (void *) mdio_write; + attrs.push_back(attr); + + attr.id = SAI_SWITCH_ATTR_HARDWARE_ACCESS_BUS; + attr.value.u32 = hardware_access_map[phy->access]; + attrs.push_back(attr); + + attr.id = SAI_SWITCH_ATTR_PLATFROM_CONTEXT; + attr.value.u64 = phy->address; + attrs.push_back(attr); + + /* Must be last Attribute */ + attr.id = SAI_REDIS_SWITCH_ATTR_CONTEXT; + attr.value.u64 = phy->phy_id; + attrs.push_back(attr); + + status = sai_switch_api->create_switch(&phyOid, (uint32_t)attrs.size(), attrs.data()); + + if (status != SAI_STATUS_SUCCESS) + { + SWSS_LOG_ERROR("BOX: Failed to create PHY:%d rtn:%d", phy->phy_id, status); + return status; + } + SWSS_LOG_NOTICE("BOX: Created PHY:%d Oid:0x%lx", phy->phy_id, phyOid); + + phy->phy_oid = sai_serialize_object_id(phyOid); + + attr.id = SAI_SWITCH_ATTR_FIRMWARE_MAJOR_VERSION; + status = sai_switch_api->get_switch_attribute(phyOid, 1, &attr); + if (status != SAI_STATUS_SUCCESS) + { + SWSS_LOG_ERROR("BOX: Failed to get firmware major version:%d rtn:%d", phy->phy_id, status); + return status; + } + else + { + phy->firmware_major_version = string(attr.value.chardata); + } + + return status; +} diff --git a/orchagent/saihelper.h b/orchagent/saihelper.h index 8e733ef558..34bef06a67 100644 --- a/orchagent/saihelper.h +++ b/orchagent/saihelper.h @@ -1,6 +1,9 @@ #pragma once +#include "gearboxutils.h" + #include void initSaiApi(); -void initSaiRedis(const std::string &record_location); \ No newline at end of file +void initSaiRedis(const std::string &record_location); +sai_status_t initSaiPhyApi(swss::gearbox_phy_t *phy); diff --git a/portsyncd/Makefile.am b/portsyncd/Makefile.am index 430eadf882..96865e2887 100644 --- a/portsyncd/Makefile.am +++ b/portsyncd/Makefile.am @@ -1,4 +1,4 @@ -INCLUDES = -I $(top_srcdir) -I $(top_srcdir)/warmrestart -I $(top_srcdir)/cfgmgr +INCLUDES = -I $(top_srcdir)/lib -I $(top_srcdir) -I $(top_srcdir)/warmrestart -I $(top_srcdir)/cfgmgr bin_PROGRAMS = portsyncd @@ -8,7 +8,7 @@ else DBGFLAGS = -g endif -portsyncd_SOURCES = portsyncd.cpp linksync.cpp $(top_srcdir)/cfgmgr/shellcmd.h +portsyncd_SOURCES = $(top_srcdir)/lib/gearboxutils.cpp portsyncd.cpp linksync.cpp $(top_srcdir)/cfgmgr/shellcmd.h portsyncd_CFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) portsyncd_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) diff --git a/tests/mock_tests/Makefile.am b/tests/mock_tests/Makefile.am index a7f89475a6..d8a8036fb1 100644 --- a/tests/mock_tests/Makefile.am +++ b/tests/mock_tests/Makefile.am @@ -1,7 +1,7 @@ FLEX_CTR_DIR = $(top_srcdir)/orchagent/flex_counter DEBUG_CTR_DIR = $(top_srcdir)/orchagent/debug_counter -INCLUDES = -I $(FLEX_CTR_DIR) -I $(DEBUG_CTR_DIR) +INCLUDES = -I $(FLEX_CTR_DIR) -I $(DEBUG_CTR_DIR) -I $(top_srcdir)/lib CFLAGS_SAI = -I /usr/include/sai @@ -31,6 +31,7 @@ tests_SOURCES = aclorch_ut.cpp \ mock_table.cpp \ mock_hiredis.cpp \ mock_redisreply.cpp \ + $(top_srcdir)/lib/gearboxutils.cpp \ $(top_srcdir)/orchagent/orchdaemon.cpp \ $(top_srcdir)/orchagent/orch.cpp \ $(top_srcdir)/orchagent/notifications.cpp \