WedgePlatform::InitPortMap WedgePlatform::initPorts() { InitPortMap ports; auto add_port = [&](int num) { PortID portID(num); opennsl_port_t bcmPortNum = num; auto port = make_unique<WedgePort>(portID); ports.emplace(bcmPortNum, port.get()); ports_.emplace(portID, std::move(port)); }; // Wedge has 16 QSFPs, each mapping to 4 physical ports. int portNum = 0; auto add_ports = [&](int n_ports) { while (n_ports--) { ++portNum; add_port(portNum); } }; auto add_ports_stride = [&](int n_ports, int start, int stride) { int curr = start; while (n_ports--) { add_port(curr); curr += stride; } }; if (mode_ == WEDGE || mode_ == LC) { // Front panel are 16 4x10G ports add_ports(16 * 4); if (mode_ == LC) { // On LC, another 16 ports for back plane ports add_ports(16); } } else if (mode_ == FC) { // On FC, 32 40G ports add_ports(32); } else { add_ports_stride(8 * 4, 1, 1); add_ports_stride(8 * 4, 34, 1); add_ports_stride(8 * 4, 68, 1); add_ports_stride(8 * 4, 102, 1); } return ports; }
WedgePlatform::InitPortMap WedgePlatform::initPorts() { InitPortMap ports; enum { WEDGE, LC, FC, } mode; if (FLAGS_mode == "wedge") { mode = WEDGE; } else if (FLAGS_mode == "lc") { mode = LC; } else if (FLAGS_mode == "fc") { mode = FC; } else { throw std::runtime_error("invalide mode " + FLAGS_mode); } // Wedge has 16 QSFPs, each mapping to 4 physical ports. int portNum = 0; auto add_ports = [&](int n_ports) { while (n_ports--) { ++portNum; PortID portID(portNum); opennsl_port_t bcmPortNum = portNum; auto port = make_unique<WedgePort>(portID); ports.emplace(bcmPortNum, port.get()); ports_.emplace(portID, std::move(port)); } }; if (mode == WEDGE || mode == LC) { // Front panel are 16 4x10G ports add_ports(16 * 4); if (mode == LC) { // On LC, another 16 ports for back plane ports add_ports(16); } } else { // On FC, 32 40G ports add_ports(32); } return ports; }
WedgePlatform::InitPortMap WedgePlatform::initPorts() { InitPortMap ports; // Wedge has 16 QSFPs, each mapping to 4 physical ports. int portNum = 0; for (int mod = 0; mod < 16; ++mod) { // Eventually we should define objects for each of the QSFPs here. for (int channel = 0; channel < 4; ++channel) { ++portNum; PortID portID(portNum); opennsl_port_t bcmPortNum = portNum; auto port = make_unique<WedgePort>(portID); ports.emplace(bcmPortNum, port.get()); ports_.emplace(portID, std::move(port)); } } return ports; }
void ThriftConfigApplier::processVlanPorts() { // Build the Port --> Vlan mappings // // The config file has a separate list for this data, // but it is stored in the state tree as part of both the PortMap and the // VlanMap. for (const auto& vp : cfg_->vlanPorts) { PortID portID(vp.logicalPort); VlanID vlanID(vp.vlanID); auto ret1 = portVlans_[portID].insert( std::make_pair(vlanID, Port::VlanInfo(vp.emitTags))); if (!ret1.second) { throw FbossError("duplicate VlanPort for port ", portID, ", vlan ", vlanID); } auto ret2 = vlanPorts_[vlanID].insert( std::make_pair(portID, Vlan::PortInfo(vp.emitTags))); if (!ret2.second) { // This should never fail if the first insert succeeded above. throw FbossError("duplicate VlanPort for vlan ", vlanID, ", port ", portID); } } }