Skip to content

Commit

Permalink
Support externally created virtual functions
Browse files Browse the repository at this point in the history
this commit add the new API allow the operator to use virtual functions
that the user configure manually on the system

this will allow new use-cases like using a VF as the SDN primary nic.
the nic will be created before the operator start by the user, for
example using nmstate or NetworkManager and the operator will allocate
all the remaining vfs to pods.

Signed-off-by: Sebastian Sch <[email protected]>
  • Loading branch information
SchSeba committed Jul 3, 2023
1 parent 109c2c2 commit bd7fae5
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 29 deletions.
13 changes: 7 additions & 6 deletions api/v1/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,13 @@ func (p *SriovNetworkNodePolicy) Apply(state *SriovNetworkNodeState, equalPriori
if s.Selected(&iface) {
log.Info("Update interface", "name:", iface.Name)
result := Interface{
PciAddress: iface.PciAddress,
Mtu: p.Spec.Mtu,
Name: iface.Name,
LinkType: p.Spec.LinkType,
EswitchMode: p.Spec.EswitchMode,
NumVfs: p.Spec.NumVfs,
PciAddress: iface.PciAddress,
Mtu: p.Spec.Mtu,
Name: iface.Name,
LinkType: p.Spec.LinkType,
EswitchMode: p.Spec.EswitchMode,
NumVfs: p.Spec.NumVfs,
ExternallyCreated: p.Spec.ExternallyCreated,
}
if p.Spec.NumVfs > 0 {
group, err := p.generateVfGroup(&iface)
Expand Down
2 changes: 2 additions & 0 deletions api/v1/sriovnetworknodepolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ type SriovNetworkNodePolicySpec struct {
VdpaType string `json:"vdpaType,omitempty"`
// Exclude device's NUMA node when advertising this resource by SRIOV network device plugin. Default to false.
ExcludeTopology bool `json:"excludeTopology,omitempty"`
// don't create the virtual function only allocated them to the device plugin. Defaults to false.
ExternallyCreated bool `json:"externallyCreated,omitempty"`
}

type SriovNetworkNicSelector struct {
Expand Down
48 changes: 25 additions & 23 deletions api/v1/sriovnetworknodestate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@ type SriovNetworkNodeStateSpec struct {
Interfaces Interfaces `json:"interfaces,omitempty"`
}

type Interfaces []Interface

type Interface struct {
PciAddress string `json:"pciAddress"`
NumVfs int `json:"numVfs,omitempty"`
Mtu int `json:"mtu,omitempty"`
Name string `json:"name,omitempty"`
LinkType string `json:"linkType,omitempty"`
EswitchMode string `json:"eSwitchMode,omitempty"`
VfGroups []VfGroup `json:"vfGroups,omitempty"`
PciAddress string `json:"pciAddress"`
NumVfs int `json:"numVfs,omitempty"`
Mtu int `json:"mtu,omitempty"`
Name string `json:"name,omitempty"`
LinkType string `json:"linkType,omitempty"`
EswitchMode string `json:"eSwitchMode,omitempty"`
VfGroups []VfGroup `json:"vfGroups,omitempty"`
ExternallyCreated bool `json:"externallyCreated,omitempty"`
}

type VfGroup struct {
Expand All @@ -49,23 +52,22 @@ type VfGroup struct {
VdpaType string `json:"vdpaType,omitempty"`
}

type Interfaces []Interface

type InterfaceExt struct {
Name string `json:"name,omitempty"`
Mac string `json:"mac,omitempty"`
Driver string `json:"driver,omitempty"`
PciAddress string `json:"pciAddress"`
Vendor string `json:"vendor,omitempty"`
DeviceID string `json:"deviceID,omitempty"`
NetFilter string `json:"netFilter,omitempty"`
Mtu int `json:"mtu,omitempty"`
NumVfs int `json:"numVfs,omitempty"`
LinkSpeed string `json:"linkSpeed,omitempty"`
LinkType string `json:"linkType,omitempty"`
EswitchMode string `json:"eSwitchMode,omitempty"`
TotalVfs int `json:"totalvfs,omitempty"`
VFs []VirtualFunction `json:"Vfs,omitempty"`
Name string `json:"name,omitempty"`
Mac string `json:"mac,omitempty"`
Driver string `json:"driver,omitempty"`
PciAddress string `json:"pciAddress"`
Vendor string `json:"vendor,omitempty"`
DeviceID string `json:"deviceID,omitempty"`
NetFilter string `json:"netFilter,omitempty"`
Mtu int `json:"mtu,omitempty"`
NumVfs int `json:"numVfs,omitempty"`
LinkSpeed string `json:"linkSpeed,omitempty"`
LinkType string `json:"linkType,omitempty"`
EswitchMode string `json:"eSwitchMode,omitempty"`
ExternallyCreated bool `json:"externallyCreated,omitempty"`
TotalVfs int `json:"totalvfs,omitempty"`
VFs []VirtualFunction `json:"Vfs,omitempty"`
}
type InterfaceExts []InterfaceExt

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ spec:
description: Exclude device's NUMA node when advertising this resource
by SRIOV network device plugin. Default to false.
type: boolean
externallyCreated:
description: don't create the virtual function only allocated them
to the device plugin. Defaults to false.
type: boolean
isRdma:
description: RDMA mode. Defaults to false.
type: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ spec:
properties:
eSwitchMode:
type: string
externallyCreated:
type: boolean
linkType:
type: string
mtu:
Expand Down Expand Up @@ -125,6 +127,8 @@ spec:
type: string
eSwitchMode:
type: string
externallyCreated:
type: boolean
linkSpeed:
type: string
linkType:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ spec:
description: Exclude device's NUMA node when advertising this resource
by SRIOV network device plugin. Default to false.
type: boolean
externallyCreated:
description: don't create the virtual function only allocated them
to the device plugin. Defaults to false.
type: boolean
isRdma:
description: RDMA mode. Defaults to false.
type: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ spec:
properties:
eSwitchMode:
type: string
externallyCreated:
type: boolean
linkType:
type: string
mtu:
Expand Down Expand Up @@ -125,6 +127,8 @@ spec:
type: string
eSwitchMode:
type: string
externallyCreated:
type: boolean
linkSpeed:
type: string
linkType:
Expand Down

0 comments on commit bd7fae5

Please sign in to comment.