Skip to content

Commit

Permalink
Add physical port assignment for network device function (#291)
Browse files Browse the repository at this point in the history
  • Loading branch information
xflipped authored Nov 30, 2023
1 parent 22a60a7 commit af776b3
Show file tree
Hide file tree
Showing 4 changed files with 894 additions and 16 deletions.
23 changes: 18 additions & 5 deletions redfish/networkdevicefunction.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,12 @@ type NetworkDeviceFunction struct {
// PCIeFunction shall be a references of type PCIeFunction that represents
// the PCI-e Function associated with this Network Device Function.
pcieFunction string
// PhysicalPortAssignment shall be the physical port that this network
// Deprecated (v1.5): PhysicalPortAssignment shall be the physical port that this network
// device function is currently assigned to. This value shall be one of the
// AssignablePhysicalPorts array members.
physicalPortAssignment string
// (v1.5+) The physical port to which this network device function is currently assigned.
physicalNetworkPortAssignment string
// rawData holds the original serialized JSON so we can compare updates.
rawData []byte
}
Expand All @@ -296,10 +298,11 @@ type NetworkDeviceFunction struct {
func (networkdevicefunction *NetworkDeviceFunction) UnmarshalJSON(b []byte) error {
type temp NetworkDeviceFunction
type links struct {
Endpoints common.Links
EndpointsCount int `json:"Endpoints@odata.count"`
PCIeFunction common.Link
PhysicalPortAssignment common.Link
Endpoints common.Links
EndpointsCount int `json:"Endpoints@odata.count"`
PCIeFunction common.Link
PhysicalPortAssignment common.Link
PhysicalNetworkPortAssignment common.Link
}
var t struct {
temp
Expand All @@ -319,6 +322,7 @@ func (networkdevicefunction *NetworkDeviceFunction) UnmarshalJSON(b []byte) erro
networkdevicefunction.EndpointsCount = t.Links.EndpointsCount
networkdevicefunction.pcieFunction = t.Links.PCIeFunction.String()
networkdevicefunction.physicalPortAssignment = t.Links.PhysicalPortAssignment.String()
networkdevicefunction.physicalNetworkPortAssignment = t.Links.PhysicalNetworkPortAssignment.String()

// This is a read/write object, so we need to save the raw object data for later
networkdevicefunction.rawData = b
Expand Down Expand Up @@ -490,3 +494,12 @@ type ISCSIBoot struct {
// netmask should be obtained from DHCP.
TargetInfoViaDHCP bool
}

// PhysicalNetworkPortAssignment gets the physical port
// to which this network device function is currently assigned.
func (networkdevicefunction *NetworkDeviceFunction) PhysicalNetworkPortAssignment() (port *Port, err error) {
if networkdevicefunction.physicalNetworkPortAssignment == "" {
return
}
return GetPort(networkdevicefunction.GetClient(), networkdevicefunction.physicalNetworkPortAssignment)
}
47 changes: 36 additions & 11 deletions redfish/networkport.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,43 @@ const (
// FibreChannelLinkNetworkTechnology means the port is capable of connecting to
// a Fibre Channel network.
FibreChannelLinkNetworkTechnology LinkNetworkTechnology = "FibreChannel"

// The port is capable of connecting to a Gen-Z fabric.
GenZLinkNetworkTechnology LinkNetworkTechnology = "GenZ"
// (v1.8+) The port is capable of connecting to PCIe and CXL fabrics.
PCIeLinkNetworkTechnology LinkNetworkTechnology = "PCIe"
)

// PortConnectionType is
type PortConnectionType string

const (
// (v1.5+) This port connection type is a diagnostic port.
DPortPortConnectionType PortConnectionType = "DPort"
// (v1.5+) This port connection type is an extender fabric port.
EPortPortConnectionType PortConnectionType = "EPort"
// (v1.5+) This port connection type is an external fabric port.
EXPortPortConnectionType PortConnectionType = "EXPort"
// ExtenderFabricPortConnectionType means this port connection type is an
// extender fabric port.
ExtenderFabricPortConnectionType PortConnectionType = "ExtenderFabric"
// (v1.5+) This port connects in a fabric loop configuration.
FLPortPortConnectionType PortConnectionType = "FLPort"
// (v1.5+) This port connection type is a fabric port.
FPortPortConnectionType PortConnectionType = "FPort"
// (v1.5+) This port connection type is a generic fabric port.
GPortPortConnectionType PortConnectionType = "GPort"
// GenericPortConnectionType means this port connection type is a generic
// fabric port.
GenericPortConnectionType PortConnectionType = "Generic"
// (v1.5+) This port connects in a node loop configuration.
NLPortPortConnectionType PortConnectionType = "NLPort"
// NotConnectedPortConnectionType means this port is not connected.
NotConnectedPortConnectionType PortConnectionType = "NotConnected"
// NPortPortConnectionType means this port connects via an N-Port to a switch.
NPortPortConnectionType PortConnectionType = "NPort"
// (v1.5+) This port connection type is a proxy N port for N-Port virtualization.
NPPortPortConnectionType PortConnectionType = "NPPort"
// PointToPointPortConnectionType means this port connects in a Point-to-point
// configuration.
PointToPointPortConnectionType PortConnectionType = "PointToPoint"
Expand All @@ -60,12 +87,10 @@ const (
// PublicLoopPortConnectionType means this port connects in a public
// configuration.
PublicLoopPortConnectionType PortConnectionType = "PublicLoop"
// GenericPortConnectionType means this port connection type is a generic
// fabric port.
GenericPortConnectionType PortConnectionType = "Generic"
// ExtenderFabricPortConnectionType means this port connection type is an
// extender fabric port.
ExtenderFabricPortConnectionType PortConnectionType = "ExtenderFabric"
// (v1.5+) This port connection type is an trunking extender fabric port.
TEPortPortConnectionType PortConnectionType = "TEPort"
// (v1.5+) This port connection type is unassigned.
UPortPortConnectionType PortConnectionType = "UPort"
)

// SupportedEthernetCapabilities is
Expand Down Expand Up @@ -106,16 +131,16 @@ type NetDevFuncMinBWAlloc struct {
}

// PortLinkStatus is the port link status.
type PortLinkStatus string
type NetworkPortLinkStatus string

const (
// UpPortLinkStatus The port is enabled and link is good (up).
UpPortLinkStatus PortLinkStatus = "Up"
UpPortLinkStatus NetworkPortLinkStatus = "Up"
// DownPortLinkStatus The port is enabled but link is down.
DownPortLinkStatus PortLinkStatus = "Down"
DownPortLinkStatus NetworkPortLinkStatus = "Down"
)

// NetworkPort represents a discrete physical port capable of connecting to a
// Deprecated (v1.4+): NetworkPort represents a discrete physical port capable of connecting to a
// network.
type NetworkPort struct {
common.Entity
Expand Down Expand Up @@ -156,7 +181,7 @@ type NetworkPort struct {
FlowControlStatus FlowControl
// LinkStatus shall be the link status between this port and its link
// partner.
LinkStatus PortLinkStatus
LinkStatus NetworkPortLinkStatus
// MaxFrameSize shall be the maximum frame size supported by the port.
MaxFrameSize int
// NetDevFuncMaxBWAlloc shall be an array of maximum bandwidth allocation
Expand Down
Loading

0 comments on commit af776b3

Please sign in to comment.