Skip to content

Commit

Permalink
Add flag to enalbe SwitchDev mode in SriovNetworkNodePolicy CRD
Browse files Browse the repository at this point in the history
1. Add 'eSwitchMode' flag in CRD SriovNetworkNodePoliy can SriovNetworkNodeState.
2. Make config daemon to be able to detect the eswitch mode of NIC, when switchedv
is enabled.

The VF and switchdev configuration shall be done with a systemd service on host. That
will be covered in a separate PR.
  • Loading branch information
pliurh committed Nov 16, 2020
1 parent 5155e7f commit 2ca3d54
Show file tree
Hide file tree
Showing 30 changed files with 518 additions and 252 deletions.
15 changes: 9 additions & 6 deletions api/v1/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ import (
)

const (
LASTNETWORKNAMESPACE = "operator.sriovnetwork.openshift.io/last-network-namespace"
FINALIZERNAME = "netattdef.finalizers.sriovnetwork.openshift.io"
LASTNETWORKNAMESPACE = "operator.sriovnetwork.openshift.io/last-network-namespace"
FINALIZERNAME = "netattdef.finalizers.sriovnetwork.openshift.io"
ESWITCHMODE_LEGACY = "legacy"
ESWITCHMODE_SWITCHDEV = "switchdev"
)

const invalidVfIndex = -1
Expand Down Expand Up @@ -164,10 +166,11 @@ func (p *SriovNetworkNodePolicy) Apply(state *SriovNetworkNodeState, merge bool)
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,
PciAddress: iface.PciAddress,
Mtu: p.Spec.Mtu,
Name: iface.Name,
LinkType: p.Spec.LinkType,
EswitchMode: p.Spec.EswitchMode,
}
var group *VfGroup
if p.Spec.NumVfs > 0 {
Expand Down
3 changes: 3 additions & 0 deletions api/v1/sriovnetworknodepolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ type SriovNetworkNodePolicySpec struct {
// +kubebuilder:validation:Enum=eth;ETH;ib;IB
// NIC Link Type. Allowed value "eth", "ETH", "ib", and "IB".
LinkType string `json:"linkType,omitempty"`
// +kubebuilder:validation:Enum=legacy;switchdev
// NIC Device Mode. Allowed value "legacy","switchdev".
EswitchMode string `json:"eSwitchMode,omitempty"`
}

// +k8s:openapi-gen=false
Expand Down
38 changes: 20 additions & 18 deletions api/v1/sriovnetworknodestate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ type SriovNetworkNodeStateSpec struct {
}

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"`
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"`
}

type VfGroup struct {
Expand All @@ -33,18 +34,19 @@ type VfGroup struct {
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"`
Mtu int `json:"mtu,omitempty"`
NumVfs int `json:"numVfs,omitempty"`
LinkSpeed string `json:"linkSpeed,omitempty"`
LinkType string `json:"linkType,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"`
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"`
}
type InterfaceExts []InterfaceExt

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ spec:
- netdevice
- vfio-pci
type: string
eSwitchMode:
description: NIC Device Mode. Allowed value "legacy","switchdev".
enum:
- legacy
- switchdev
type: string
isRdma:
description: RDMA mode. Defaults to false.
type: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ spec:
interfaces:
items:
properties:
eSwitchMode:
type: string
linkType:
type: string
mtu:
Expand Down Expand Up @@ -109,6 +111,8 @@ spec:
type: string
driver:
type: string
eSwitchMode:
type: string
linkSpeed:
type: string
linkType:
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/openshift/sriov-network-operator
go 1.13

require (
cloud.google.com/go v0.53.0 // indirect
cloud.google.com/go v0.58.0 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Masterminds/sprig v2.22.0+incompatible
github.com/blang/semver v3.5.0+incompatible
Expand All @@ -28,7 +28,8 @@ require (
github.com/vishvananda/netlink v1.1.0
golang.org/x/net v0.0.0-20200625001655-4c5254603344 // indirect
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae // indirect
golang.org/x/time v0.0.0-20190921001708-c4c64cad1fd0
golang.org/x/time v0.0.0-20191024005414-555d28b269f0
google.golang.org/genproto v0.0.0-20200610104632-a5b850bcf112 // indirect
google.golang.org/protobuf v1.25.0 // indirect
k8s.io/api v0.18.8
k8s.io/apiextensions-apiserver v0.18.8 // indirect
Expand Down
Loading

0 comments on commit 2ca3d54

Please sign in to comment.