Commit 4b247477 authored by Ryan Goodfellow's avatar Ryan Goodfellow
Browse files

transitional package structure form v0.1 -> v0.2


Signed-off-by: Ryan Goodfellow's avatarRyan Goodfellow <rgoodfel@isi.edu>
parent acab5906
Pipeline #120188451 failed with stage
in 11 seconds
package hw
import (
"fmt"
"github.com/satori/go.uuid"
"gitlab.com/mergetb/xir/lang/go"
)
// CableKind defines the type of cable
type CableKind uint16
const (
// UnspecCable indicates the cable kind is not defined
UnspecCable CableKind = iota
// Cat5 indicates a category 5 copper cable
Cat5
// Cat5e indicates a category 5 enhanced copper cable
Cat5e
// Cat6 indicates a category 6 copper cable
Cat6
// DAC indicates a direct attach copper cable
DAC
// FiberLC indicates a fiber cable with LC type connectors
FiberLC
// FiberMPOTrunk indicates a fiber trunk cable with MPO connectors
FiberMPOTrunk
// FiberMPOBreakout indicates a fiber breakout cable with an MPO connector on
// the trunk side.
FiberMPOBreakout
)
// An End represents an end of a cable that may have 1 or many connectors
// (breakout cable).
type End []*Connector
// A Cable is a physical link between two hosts.
type Cable struct {
Base
Kind CableKind
Connectors [2]End
Length uint64 //meters
Props xir.Props
}
// Connect a simple straight cable. Breakouts require more detailed attention.
func (c *Cable) Connect(a, b *Port) {
c.Connectors[0][0].Connect(a)
c.Connectors[1][0].Connect(b)
}
// ConnectorKind defines the type of connector.
type ConnectorKind uint16
const (
// UnspecConnector indicates the connector kind is not defined
UnspecConnector ConnectorKind = iota
// RJ45 type twisted pair connector.
RJ45
// SFP type modular connector.
SFP
// QSFP type modular connector.
QSFP
// SFPP indicates SFP+ type modular connector
SFPP
// QSFPP indicates QSFP+ type modular connector
QSFPP
// SFP28 type modular connector
SFP28
// QSFP28 type modular connector
QSFP28
// CXP type modular connector
CXP
// LC type fiber connector
LC
// MPO type fiber connector
MPO
)
// A Connector couples a cable to a host.
type Connector struct {
Base
Kind ConnectorKind
Protocol Layer1
Capacity uint64
Port *Port `json:"-" yaml:"-"`
}
// Link creates an XIR parameterized link from a cable.
func (c *Cable) Link() *xir.Link {
lnk := &xir.Link{
Id: uuid.NewV4().String(),
Props: c.Props,
}
if lnk.Props == nil {
lnk.Props = make(xir.Props)
}
lnk.Props["model"] = c.Model
for _, end := range c.Connectors {
for _, cx := range end {
if cx.Port != nil && cx.Port.Endpoint != nil {
lnk.Endpoints = append(lnk.Endpoints, cx.Port.Endpoint)
}
}
}
return lnk
}
// Connect a connector to a port.
func (c *Connector) Connect(p *Port) {
p.Connector = c
c.Port = p
}
// Connect a cable end to a set of ports
func (e End) Connect(ps ...*Port) error {
if len(ps) > len(e) {
return fmt.Errorf(
"cannot connect %d ports to %d connectors", len(ps), len(e))
}
for _, p := range ps {
for _, c := range e {
p.Connector = c
c.Port = p
}
}
return nil
}
// Breakout connects a single port to multiple. This function assumes the first
// end is the trunk end of the cable.
func (c *Cable) Breakout(a *Port, b []*Port) {
c.Connectors[0][0].Connect(a)
c.Connectors[1].Connect(b...)
}
package cables
import (
"gitlab.com/mergetb/xir/lang/go/hw"
)
// FsDACBreakout40x10 is a 40 gbps to 4x10 gbps copper breakout direct attach
// cable.
func FsDACBreakout40x10() *hw.Cable {
return &hw.Cable{
Base: hw.Base{
Manufacturer: "Fiberstore",
Model: "FS 40x10 DAC Breakout",
},
Kind: hw.FiberMPOBreakout,
Connectors: [2]hw.End{
[]*hw.Connector{{
Base: hw.Base{Manufacturer: "Fiberstore", Model: "QSFP-CR4-40G"},
Kind: hw.QSFPP,
Capacity: 40e9,
Protocol: hw.GBase40CR4,
}},
[]*hw.Connector{
{
Base: hw.Base{Manufacturer: "Fiberstore", Model: "SFP-10GCR"},
Kind: hw.SFPP,
Capacity: 10e9,
Protocol: hw.GBase10CR,
},
{
Base: hw.Base{Manufacturer: "Fiberstore", Model: "SFP-10GCR"},
Kind: hw.SFPP,
Capacity: 10e9,
Protocol: hw.GBase10CR,
},
{
Base: hw.Base{Manufacturer: "Fiberstore", Model: "SFP-10GCR"},
Kind: hw.SFPP,
Capacity: 10e9,
Protocol: hw.GBase10CR,
},
{
Base: hw.Base{Manufacturer: "Fiberstore", Model: "SFP-10GSR-85"},
Kind: hw.SFPP,
Capacity: 10e9,
Protocol: hw.GBase10CR,
},
},
},
}
}
// Cat6 is a thing
func Cat6() *hw.Cable {
return &hw.Cable{
Kind: hw.Cat6,
Connectors: [2]hw.End{
[]*hw.Connector{{Kind: hw.RJ45, Capacity: 1e9, Protocol: hw.Base1000T}},
[]*hw.Connector{{Kind: hw.RJ45, Capacity: 1e9, Protocol: hw.Base1000T}},
},
}
}
package cables
import (
"gitlab.com/mergetb/xir/lang/go/hw"
)
// Fsoc100G is a Fiberstore 100 gbps optical cable composed of two SR4
// transcievers and an MPO fiber trunk.
func Fsoc100G() *hw.Cable {
return &hw.Cable{
Base: hw.Base{
Manufacturer: "Fiberstore",
Model: "FS-100G-Trunk-3m", //MPO trunk cable
},
Kind: hw.FiberMPOBreakout,
Connectors: [2]hw.End{
[]*hw.Connector{{
Base: hw.Base{Manufacturer: "Fiberstore", Model: "QSFP28-SR4-100G"},
Kind: hw.SFP28,
Capacity: 100e9,
Protocol: hw.GBase100SR4,
}},
[]*hw.Connector{
{
Base: hw.Base{Manufacturer: "Fiberstore", Model: "QSFP28-SR4-100G"},
Kind: hw.SFP28,
Capacity: 100e9,
Protocol: hw.GBase100SR4,
},
},
},
}
}
// Fsoc10G is a Fiberstore 10 gbps optical cable composed of two SR
// transcievers and an LC fiber.
func Fsoc10G() *hw.Cable {
return &hw.Cable{
Base: hw.Base{
Manufacturer: "Fiberstore",
Model: "FS-10G-Trunk-10m", //MPO trunk cable
},
Kind: hw.FiberMPOBreakout,
Connectors: [2]hw.End{
[]*hw.Connector{{
Base: hw.Base{Manufacturer: "Fiberstore", Model: "SFP+-SR-10G"},
Kind: hw.SFPP,
Capacity: 10e9,
Protocol: hw.GBase10SR,
}},
[]*hw.Connector{
{
Base: hw.Base{Manufacturer: "Fiberstore", Model: "SFP+-SR-10G"},
Kind: hw.SFPP,
Capacity: 10e9,
Protocol: hw.GBase10SR,
},
},
},
}
}
// Fsoc25G is a Fiberstore 25 gbps optical cable composed of two SR
// transceivers and an LC fiber.
func Fsoc25G() *hw.Cable {
return &hw.Cable{
Base: hw.Base{
Manufacturer: "Fiberstore",
Model: "FS-25G-Trunk-5m", //MPO trunk cable
},
Kind: hw.FiberMPOBreakout,
Connectors: [2]hw.End{
[]*hw.Connector{{
Base: hw.Base{Manufacturer: "Fiberstore", Model: "SFP28-25GSR-85"},
Kind: hw.SFP28,
Capacity: 25e9,
Protocol: hw.GBase25SR,
}},
[]*hw.Connector{
{
Base: hw.Base{Manufacturer: "Fiberstore", Model: "SFP28-25GSR-85"},
Kind: hw.SFP28,
Capacity: 25e9,
Protocol: hw.GBase25SR,
},
},
},
}
}
// FsMpoBreakout40x10 is a Fiberstore optical breakout cable composed of one 40
// gbps transceiver (MPO) and 4x10 gbps transceivers (LC) interconnected by an
// optical breakout cable.
func FsMpoBreakout40x10() *hw.Cable {
return &hw.Cable{
Base: hw.Base{
Manufacturer: "Fiberstore",
Model: "FS-40x10-MPO-Breakout",
},
Kind: hw.FiberMPOBreakout,
Connectors: [2]hw.End{
[]*hw.Connector{{
Base: hw.Base{Manufacturer: "Fiberstore", Model: "QSFP-SR4-40G"},
Kind: hw.QSFPP,
Capacity: 40e9,
Protocol: hw.GBase40SR4,
}},
[]*hw.Connector{
{
Base: hw.Base{Manufacturer: "Fiberstore", Model: "SFP-10GSR-85"},
Kind: hw.SFPP,
Capacity: 10e9,
Protocol: hw.GBase10SR,
},
{
Base: hw.Base{Manufacturer: "Fiberstore", Model: "SFP-10GSR-85"},
Kind: hw.SFPP,
Capacity: 10e9,
Protocol: hw.GBase10SR,
},
{
Base: hw.Base{Manufacturer: "Fiberstore", Model: "SFP-10GSR-85"},
Kind: hw.SFPP,
Capacity: 10e9,
Protocol: hw.GBase10SR,
},
{
Base: hw.Base{Manufacturer: "Fiberstore", Model: "SFP-10GSR-85"},
Kind: hw.SFPP,
Capacity: 10e9,
Protocol: hw.GBase10SR,
},
},
},
}
}
// FsMpoBreakout100x25 is a Fiberstore optical breakout cable composed of one
// 100 gbps transceiver (MPO) and 4x25 gbps transceivers (LC) interconnected by
// an optical breakout cable.
func FsMpoBreakout100x25() *hw.Cable {
return &hw.Cable{
Base: hw.Base{
Manufacturer: "Fiberstore",
Model: "FS 100Gx25G Optical Breakout",
},
Kind: hw.FiberMPOBreakout,
Connectors: [2]hw.End{
[]*hw.Connector{{
Base: hw.Base{Manufacturer: "Fiberstore", Model: "QSFP28-SR4-100G"},
Kind: hw.QSFP28,
Capacity: 100e9,
Protocol: hw.GBase100SR4,
}},
[]*hw.Connector{
{
Base: hw.Base{Manufacturer: "Fiberstore", Model: "SFP28-25GSR-85"},
Kind: hw.SFP28,
Capacity: 25e9,
Protocol: hw.GBase25SR,
},
{
Base: hw.Base{Manufacturer: "Fiberstore", Model: "SFP28-25GSR-85"},
Kind: hw.SFP28,
Capacity: 25e9,
Protocol: hw.GBase25SR,
},
{
Base: hw.Base{Manufacturer: "Fiberstore", Model: "SFP28-25GSR-85"},
Kind: hw.SFP28,
Capacity: 25e9,
Protocol: hw.GBase25SR,
},
{
Base: hw.Base{Manufacturer: "Fiberstore", Model: "SFP28-25GSR-85"},
Kind: hw.SFP28,
Capacity: 25e9,
Protocol: hw.GBase25SR,
},
},
},
}
}
package components
import (
"gitlab.com/mergetb/xir/lang/go/hw"
)
// XeonE52650v4 is described here https://ark.intel.com/content/www/us/en/ark/products/91767/intel-xeon-processor-e5-2650-v4-30m-cache-2-20-ghz.html
func XeonE52650v4() hw.Proc {
return hw.Proc{
Base: hw.Base{
Model: "E5 2650v4",
Manufacturer: "Intel",
},
ISA: hw.X86_64,
Family: "Xeon",
BaseFrequency: hw.Mhz(2200),
L2: hw.Mb(30),
Cores: 12,
Threads: 24,
Tdp: 105,
}
}
// Epyc7601 is a 32 core 2.2 Ghz first generation model AMD Epyc processor.
func Epyc7601() hw.Proc {
return hw.Proc{
Base: hw.Base{
Manufacturer: "AMD",
Model: "Epyc 7601",
},
ISA: hw.X86_64,
Family: "Epyc",
BaseFrequency: hw.Mhz(2200),
Cores: 32,
Threads: 64,
Tdp: 180,
}
}
// Epyc7551 is a 32 core 2.0 Ghz first generation model AMD Epyc processor.
func Epyc7551() hw.Proc {
return hw.Proc{
Base: hw.Base{
Manufacturer: "AMD",
Model: "Epyc 7551",
},
ISA: hw.X86_64,
Family: "Epyc",
BaseFrequency: hw.Mhz(2000),
Cores: 32,
Threads: 64,
Tdp: 180,
}
}
// Epyc7621 is an 8 core 2.5 Ghz first generation model AMD Epyc processor.
func Epyc7621() hw.Proc {
return hw.Proc{
Base: hw.Base{
Manufacturer: "AMD",
Model: "Epyc 7621",
},
ISA: hw.X86_64,
Family: "Epyc",
BaseFrequency: hw.Mhz(2500),
Cores: 8,
Threads: 16,
Tdp: 155,
}
}
// XeonGold6252N is a 24 core Xeon Gold processor specialized for network
// processing.
func XeonGold6252N() hw.Proc {
return hw.Proc{
Base: hw.Base{
Model: "Xeon Gold 6252N",
Manufacturer: "Intel",
},
ISA: hw.X86_64,
Family: "Xeon",
BaseFrequency: hw.Mhz(2300),
L2: hw.Mb(35),
Cores: 24,
Threads: 48,
Tdp: 150,
}
}
// XeonSilver4215 is an 8 core Xeon Silver series processor.
func XeonSilver4215() hw.Proc {
return hw.Proc{
Base: hw.Base{
Model: "Xeon Silver 4216",
Manufacturer: "Intel",
},
ISA: hw.X86_64,
Family: "Xeon",
BaseFrequency: hw.Mhz(2500),
L2: hw.Mb(11),
Cores: 8,
Threads: 16,
Tdp: 85,
}
}
// XeonSilver4216 is a 16 core Xeon Silver series processor.
func XeonSilver4216() hw.Proc {
return hw.Proc{
Base: hw.Base{
Model: "Xeon Silver 4216",
Manufacturer: "Intel",
},
ISA: hw.X86_64,
Family: "Xeon",
BaseFrequency: hw.Mhz(2200),
L2: hw.Mb(22),
Cores: 16,
Threads: 32,
Tdp: 100,
}
}
package components
import (
"gitlab.com/mergetb/xir/lang/go/hw"
)
// I350DA4 is a thing
func I350DA4() hw.Nic {
return hw.Nic{
Base: hw.Base{
Manufacturer: "Intel",
Model: "i350-DA4",
},
Kind: "eth",
Ports: []*hw.Port{
{Protocol: hw.Base1000T, Capacity: hw.Gbps(1)},
{Protocol: hw.Base1000T, Capacity: hw.Gbps(1)},
{Protocol: hw.Base1000T, Capacity: hw.Gbps(1)},
{Protocol: hw.Base1000T, Capacity: hw.Gbps(1)},
},
}
}
// XL710DA4 is a thing
func XL710DA4() hw.Nic {
return hw.Nic{
Base: hw.Base{