Skip to content

Commit f6f629d

Browse files
committed
Fix comments for aws
Signed-off-by: Sebastian Sch <[email protected]>
1 parent 25d4f1f commit f6f629d

File tree

15 files changed

+295
-165
lines changed

15 files changed

+295
-165
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ manifests: controller-gen
109109
check-manifests: manifests
110110
@set +e; git diff --quiet config; \
111111
if [ $$? -eq 1 ]; \
112-
then echo -e "\n`config` folder is out of date. Please run `make manifests` and commit your changes"; \
112+
then echo -e "'config' folder is out of date. Please run 'make manifests' and commit your changes"; \
113113
exit 1; fi
114114

115115
sync-manifests-%: manifests

api/v1/helper.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,7 @@ var NicIDMap = []string{}
5555

5656
var InitialState SriovNetworkNodeState
5757

58-
// NetFilterType Represents the NetFilter tags to be used
59-
type NetFilterType int
60-
6158
const (
62-
// OpenstackNetworkID network UUID
63-
OpenstackNetworkID NetFilterType = iota
64-
6559
SupportedNicIDConfigmap = "supported-nic-ids"
6660
)
6761

@@ -72,15 +66,6 @@ const (
7266
SystemdConfigurationMode ConfigurationModeType = "systemd"
7367
)
7468

75-
func (e NetFilterType) String() string {
76-
switch e {
77-
case OpenstackNetworkID:
78-
return "openstack/NetworkID"
79-
default:
80-
return fmt.Sprintf("%d", int(e))
81-
}
82-
}
83-
8469
func InitNicIDMapFromConfigMap(client kubernetes.Interface, namespace string) error {
8570
cm, err := client.CoreV1().ConfigMaps(namespace).Get(
8671
context.Background(),

api/v1/sriovnetworknodepolicy_types.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ type SriovNetworkNicSelector struct {
7676
RootDevices []string `json:"rootDevices,omitempty"`
7777
// Name of SR-IoV PF.
7878
PfNames []string `json:"pfNames,omitempty"`
79-
// Infrastructure Networking selection filter. Allowed value "openstack/NetworkID:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
79+
// Infrastructure Networking selection filter.
80+
// Allowed values:
81+
// - "openstack/NetworkID:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
82+
// - "aws/NetworkID:xxxxxxxx"
8083
NetFilter string `json:"netFilter,omitempty"`
8184
}
8285

cmd/sriov-network-config-daemon/start.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,8 @@ func runStartCmd(cmd *cobra.Command, args []string) error {
244244
setupLog.Error(err, "failed to fetch node state, exiting", "node-name", startOpts.nodeName)
245245
return err
246246
}
247-
// check for a platform
248-
for key, pType := range vars.PlatformsMap {
249-
if strings.Contains(strings.ToLower(nodeInfo.Spec.ProviderID), strings.ToLower(key)) {
250-
vars.PlatformType = pType
251-
}
252-
}
247+
// set the platform type
248+
vars.PlatformType = vars.GetPlatformType(nodeInfo.Spec.ProviderID)
253249
setupLog.Info("Running on", "platform", vars.PlatformType)
254250

255251
// create helpers

config/crd/bases/sriovnetwork.openshift.io_sriovnetworknodepolicies.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,11 @@ spec:
161161
"0d58", "1572", "158b", "1013", "1015", "1017", "101b".
162162
type: string
163163
netFilter:
164-
description: Infrastructure Networking selection filter. Allowed
165-
value "openstack/NetworkID:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
164+
description: |-
165+
Infrastructure Networking selection filter.
166+
Allowed values:
167+
- "openstack/NetworkID:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
168+
- "aws/NetworkID:xxxxxxxx"
166169
type: string
167170
pfNames:
168171
description: Name of SR-IoV PF.

deployment/sriov-network-operator-chart/crds/sriovnetwork.openshift.io_sriovnetworknodepolicies.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,11 @@ spec:
161161
"0d58", "1572", "158b", "1013", "1015", "1017", "101b".
162162
type: string
163163
netFilter:
164-
description: Infrastructure Networking selection filter. Allowed
165-
value "openstack/NetworkID:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
164+
description: |-
165+
Infrastructure Networking selection filter.
166+
Allowed values:
167+
- "openstack/NetworkID:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
168+
- "aws/NetworkID:xxxxxxxx"
166169
type: string
167170
pfNames:
168171
description: Name of SR-IoV PF.

pkg/host/internal/sriov/sriov.go

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,15 @@ func (s *sriov) SetVfAdminMac(vfAddr string, pfLink, vfLink netlink.Link) error
208208
return nil
209209
}
210210

211+
// getDeviceClass parses the device class from the device
212+
func getDeviceClass(device *ghw.PCIDevice) (int64, error) {
213+
devClass, err := strconv.ParseInt(device.Class.ID, 16, 64)
214+
if err != nil {
215+
return 0, fmt.Errorf("unable to parse device class: %v", err)
216+
}
217+
return devClass, nil
218+
}
219+
211220
func (s *sriov) DiscoverSriovDevices(storeManager store.ManagerInterface) ([]sriovnetworkv1.InterfaceExt, error) {
212221
log.Log.V(2).Info("DiscoverSriovDevices")
213222
pfList := []sriovnetworkv1.InterfaceExt{}
@@ -223,7 +232,7 @@ func (s *sriov) DiscoverSriovDevices(storeManager store.ManagerInterface) ([]sri
223232
}
224233

225234
for _, device := range devices {
226-
devClass, err := strconv.ParseInt(device.Class.ID, 16, 64)
235+
devClass, err := getDeviceClass(device)
227236
if err != nil {
228237
log.Log.Error(err, "DiscoverSriovDevices(): unable to parse device class, skipping",
229238
"device", device)
@@ -326,7 +335,7 @@ func (s *sriov) DiscoverSriovVirtualDevices() ([]sriovnetworkv1.InterfaceExt, er
326335
}
327336

328337
for _, device := range devices {
329-
devClass, err := strconv.ParseInt(device.Class.ID, 16, 64)
338+
devClass, err := getDeviceClass(device)
330339
if err != nil {
331340
log.Log.Error(err, "DiscoverSriovVirtualDevices(): unable to parse device class for device, skipping",
332341
"device", device)
@@ -915,25 +924,30 @@ func (s *sriov) ConfigSriovDevicesVirtual(storeManager store.ManagerInterface, i
915924
"numVfs", ifaceToConfigure.Iface.NumVfs)
916925
return errors.New("NumVfs > 1")
917926
}
927+
// Validate the VFGroups we need to have only one VFGroup
918928
if len(ifaceToConfigure.Iface.VfGroups) != 1 {
919-
log.Log.Error(nil, "ConfigSriovDeviceVirtual(): missing VFGroup")
920-
return errors.New("NumVfs != 1")
929+
log.Log.Error(nil, "ConfigSriovDeviceVirtual(): unexpected number of VFGroups", "vfGroups", ifaceToConfigure.Iface.VfGroups)
930+
return errors.New("unexpected number of VFGroups")
921931
}
932+
922933
addr := ifaceToConfigure.Iface.PciAddress
923-
log.Log.V(2).Info("ConfigSriovDeviceVirtual()", "address", addr)
934+
log.Log.V(2).Info("ConfigSriovDeviceVirtual()", "pciAddress", addr)
924935
driver := ""
925936
vfID := 0
926-
for _, group := range ifaceToConfigure.Iface.VfGroups {
927-
log.Log.V(2).Info("ConfigSriovDeviceVirtual()", "group", group)
928-
if sriovnetworkv1.IndexInRange(vfID, group.VfRange) {
929-
log.Log.V(2).Info("ConfigSriovDeviceVirtual()", "indexInRange", vfID)
930-
if sriovnetworkv1.StringInArray(group.DeviceType, vars.DpdkDrivers) {
931-
log.Log.V(2).Info("ConfigSriovDeviceVirtual()", "driver", group.DeviceType)
932-
driver = group.DeviceType
933-
}
934-
break
935-
}
937+
938+
group := ifaceToConfigure.Iface.VfGroups[0]
939+
// Validate the VF ID is in the range for the VFGroup
940+
if !sriovnetworkv1.IndexInRange(vfID, group.VfRange) {
941+
log.Log.Error(nil, "ConfigSriovDeviceVirtual(): VF ID is not in the range", "vfID", vfID, "vfRange", group.VfRange)
942+
return errors.New("VF ID is not in the range")
936943
}
944+
945+
// check if we need to bind to a DPDK driver
946+
if sriovnetworkv1.StringInArray(group.DeviceType, vars.DpdkDrivers) {
947+
log.Log.V(2).Info("ConfigSriovDeviceVirtual()", "driver", group.DeviceType)
948+
driver = group.DeviceType
949+
}
950+
937951
if driver == "" {
938952
log.Log.V(2).Info("ConfigSriovDeviceVirtual(): bind default")
939953
if err := s.kernelHelper.BindDefaultDriver(addr); err != nil {

pkg/host/internal/sriov/sriov_test.go

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ var _ = Describe("SRIOV", func() {
11711171
LinkAdminState: "down",
11721172
}})
11731173
Expect(err).To(HaveOccurred())
1174-
Expect(err.Error()).To(ContainSubstring("NumVfs != 1"))
1174+
Expect(err.Error()).To(ContainSubstring("unexpected number of VFGroups"))
11751175
})
11761176

11771177
It("should fail when BindDefaultDriver fails", func() {
@@ -1423,10 +1423,7 @@ var _ = Describe("SRIOV", func() {
14231423
}})).NotTo(HaveOccurred())
14241424
})
14251425

1426-
It("should configure with default driver when VfRange doesn't include vfID 0", func() {
1427-
hostMock.EXPECT().BindDefaultDriver("0000:d8:00.0").Return(nil)
1428-
storeManagerMode.EXPECT().SaveLastPfAppliedStatus(gomock.Any()).Return(nil)
1429-
1426+
It("should return error when VfRange doesn't include vfID 0", func() {
14301427
Expect(s.ConfigSriovDevicesVirtual(storeManagerMode,
14311428
[]sriovnetworkv1.Interface{{
14321429
Name: "enp216s0f0np0",
@@ -1443,7 +1440,7 @@ var _ = Describe("SRIOV", func() {
14431440
PciAddress: "0000:d8:00.0",
14441441
NumVfs: 1,
14451442
LinkAdminState: "down",
1446-
}})).NotTo(HaveOccurred())
1443+
}})).To(HaveOccurred())
14471444
})
14481445

14491446
It("should configure with default driver when DeviceType is not a DPDK driver", func() {
@@ -1492,30 +1489,6 @@ var _ = Describe("SRIOV", func() {
14921489
}})).NotTo(HaveOccurred())
14931490
})
14941491

1495-
It("should configure when EswitchMode needs update", func() {
1496-
hostMock.EXPECT().BindDpdkDriver("0000:d8:00.0", "vfio-pci").Return(nil)
1497-
storeManagerMode.EXPECT().SaveLastPfAppliedStatus(gomock.Any()).Return(nil)
1498-
1499-
Expect(s.ConfigSriovDevicesVirtual(storeManagerMode,
1500-
[]sriovnetworkv1.Interface{{
1501-
Name: "enp216s0f0np0",
1502-
PciAddress: "0000:d8:00.0",
1503-
NumVfs: 1,
1504-
EswitchMode: "switchdev",
1505-
VfGroups: []sriovnetworkv1.VfGroup{{
1506-
VfRange: "0-0",
1507-
ResourceName: "test-resource0",
1508-
PolicyName: "test-policy0",
1509-
DeviceType: "vfio-pci",
1510-
}},
1511-
}},
1512-
[]sriovnetworkv1.InterfaceExt{{
1513-
PciAddress: "0000:d8:00.0",
1514-
NumVfs: 1,
1515-
EswitchMode: "legacy",
1516-
}})).NotTo(HaveOccurred())
1517-
})
1518-
15191492
It("should configure when LinkAdminState is down", func() {
15201493
hostMock.EXPECT().BindDefaultDriver("0000:d8:00.0").Return(nil)
15211494
storeManagerMode.EXPECT().SaveLastPfAppliedStatus(gomock.Any()).Return(nil)

0 commit comments

Comments
 (0)