Skip to content

Commit

Permalink
SRIOV-FEC Operator Release 22.38
Browse files Browse the repository at this point in the history
  • Loading branch information
sunil-parida committed Sep 28, 2022
1 parent 046e4f9 commit 7eec69b
Show file tree
Hide file tree
Showing 77 changed files with 1,311 additions and 955 deletions.
2 changes: 1 addition & 1 deletion COPYRIGHT
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2020-2021 Intel Corporation
# Copyright (c) 2020-2022 Intel Corporation
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## SPDX-License-Identifier: Apache-2.0
## Copyright (c) 2020-2021 Intel Corporation
## Copyright (c) 2020-2022 Intel Corporation

# Build the manager binary
FROM golang:1.18.3 as builder
Expand All @@ -22,7 +22,7 @@ COPY controllers/ controllers/
# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go

FROM registry.access.redhat.com/ubi8/ubi-minimal:8.6-751
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.6-941

ARG VERSION
### Required OpenShift Labels
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile.daemon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2020-2021 Intel Corporation
# Copyright (c) 2020-2022 Intel Corporation

FROM golang:1.18.3 as builder

Expand All @@ -10,11 +10,11 @@ RUN git clone --depth 1 --branch r44 https://github.com/benhoyt/inih && \
make -f Makefile.static && \
cp libinih.a ../

RUN git clone --depth 1 --branch v22.03 https://github.com/intel/pf-bb-config && \
RUN git clone --depth 1 --branch v22.07 https://github.com/intel/pf-bb-config && \
cd pf-bb-config && \
VERSION_STRING=$(git describe --tags --long) && \
sed -i "s/#VERSION_STRING#/${VERSION_STRING}/g" config_app.c && \
make CFLAGS="-D_FORTIFY_SOURCE=2 -fstack-protector-strong -fPIE -z relro -z now -z noexecstack -s -O1"
make


WORKDIR /workspace-go
Expand All @@ -29,7 +29,7 @@ COPY api api/

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o sriov_fec_daemon cmd/daemon/main.go

FROM registry.access.redhat.com/ubi8:8.6-754
FROM registry.access.redhat.com/ubi8:8.6-943

ARG VERSION
### Required OpenShift Labels
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.labeler
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ COPY pkg/ pkg/

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o node_labeler cmd/labeler/main.go

FROM registry.access.redhat.com/ubi8:8.6-754
FROM registry.access.redhat.com/ubi8:8.6-943

ARG VERSION
### Required OpenShift Labels
Expand Down
24 changes: 13 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export CLI_EXEC?=oc
# Container format for podman. Required to build containers with "ManifestType": "application/vnd.oci.image.manifest.v2+json",
export BUILDAH_FORMAT=docker
# Current Operator version
VERSION ?= 2.4.0
VERSION ?= 2.5.0
# Supported channels
CHANNELS ?= stable
# Default channel
Expand All @@ -25,7 +25,7 @@ endif
# tls verify flag for pushing images
TLS_VERIFY ?= false

REQUIRED_OPERATOR_SDK_VERSION ?= v1.20.1
REQUIRED_OPERATOR_SDK_VERSION ?= v1.22.2

IMAGE_TAG_BASE ?= $(IMAGE_REGISTRY)sriov-fec
BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:v$(VERSION)
Expand All @@ -50,11 +50,11 @@ export SRIOV_FEC_DAEMON_IMAGE ?= $(IMAGE_REGISTRY)sriov-fec-daemon:$(IMG_VERSION
export SRIOV_FEC_LABELER_IMAGE ?= $(IMAGE_REGISTRY)n3000-labeler:$(IMG_VERSION)

ifeq ($(CONTAINER_TOOL),podman)
export SRIOV_FEC_NETWORK_DEVICE_PLUGIN_IMAGE ?= registry.redhat.io/openshift4/ose-sriov-network-device-plugin:v4.10
export KUBE_RBAC_PROXY_IMAGE ?= registry.redhat.io/openshift4/ose-kube-rbac-proxy@sha256:86e5fa1fa294987114be200890c2e516501e424aee0fb98ece25c95e7716295b
export SRIOV_FEC_NETWORK_DEVICE_PLUGIN_IMAGE ?= registry.redhat.io/openshift4/ose-sriov-network-device-plugin:v4.10 #TBD
export KUBE_RBAC_PROXY_IMAGE ?= registry.redhat.io/openshift4/ose-kube-rbac-proxy@sha256:b5786bbbef725badf3dfcc2c2c7a86ead5ebb584c978c47aae8b9a62e241b80d
else
export SRIOV_FEC_NETWORK_DEVICE_PLUGIN_IMAGE ?= quay.io/openshift/origin-sriov-network-device-plugin:4.10
export KUBE_RBAC_PROXY_IMAGE ?= gcr.io/kubebuilder/kube-rbac-proxy:v0.5.0
export SRIOV_FEC_NETWORK_DEVICE_PLUGIN_IMAGE ?= quay.io/openshift/origin-sriov-network-device-plugin:4.11
export KUBE_RBAC_PROXY_IMAGE ?= gcr.io/kubebuilder/kube-rbac-proxy:v0.11.0
endif

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
Expand All @@ -74,11 +74,11 @@ SHELL = /usr/bin/env bash -o pipefail
all: manager daemon labeler

# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.23
ENVTEST_K8S_VERSION = 1.24
ENVTEST = $(shell pwd)/bin/setup-envtest
.PHONY: envtest
envtest: ## Download envtest-setup locally if necessary.
echo $(ENVTEST)
rm -f $(ENVTEST)
$(call go-get-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@latest)

.PHONY: test
Expand Down Expand Up @@ -160,7 +160,7 @@ vet:
generate: controller-gen
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

# go-get-tool will 'go get' any package $2 and install it to $1.
# go-get-tool will 'go install' any package $2 and install it to $1.
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))

define go-get-tool
Expand All @@ -180,11 +180,13 @@ endef
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
.PHONY: controller-gen
controller-gen: ## Download controller-gen locally if necessary.
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.8.0)
rm -f $(CONTROLLER_GEN)
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.9.2)

KUSTOMIZE = $(shell pwd)/bin/kustomize
.PHONY: kustomize
kustomize: ## Download kustomize locally if necessary.
rm -f $(KUSTOMIZE)
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v4@v4.5.5)

# Build/Push daemon image
Expand Down Expand Up @@ -339,7 +341,7 @@ build_all: build
.PHONY: build_index
build_index:
opm index add --bundles $(BUNDLE_IMG) --tag localhost/sriov-fec-index:$(VERSION) $(if ifeq $(TLS_VERIFY) false, --skip-tls) -c $(CONTAINER_TOOL) --mode=semver
$(MAKE) VERSION=$(VERSION) IMAGE_REGISTRY=$(IMAGE_REGISTRY) TLS_VERIFY=$(TLS_VERIFY) $(CONTAINER_TOOL)_push_index
$(MAKE) VERSION=$(VERSION) IMAGE_REGISTRY=$(IMAGE_REGISTRY) TLS_VERIFY=$(TLS_VERIFY) $(CONTAINER_TOOL)_push_index

.PHONY: podman_push_index
podman_push_index:
Expand Down
2 changes: 1 addition & 1 deletion api/v1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (c) 2020-2021 Intel Corporation
// Copyright (c) 2020-2022 Intel Corporation

/*
Expand Down
2 changes: 1 addition & 1 deletion api/v1/sriovfecclusterconfig_types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (c) 2020-2021 Intel Corporation
// Copyright (c) 2020-2022 Intel Corporation

package v1

Expand Down
2 changes: 1 addition & 1 deletion api/v1/sriovfecnodeconfig_types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (c) 2020-2021 Intel Corporation
// Copyright (c) 2020-2022 Intel Corporation

package v1

Expand Down
2 changes: 1 addition & 1 deletion api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/v2/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (c) 2020-2021 Intel Corporation
// Copyright (c) 2020-2022 Intel Corporation

// Package v2 contains API Schema definitions for the sriovfec v2 API group
// +kubebuilder:object:generate=true
Expand Down
44 changes: 27 additions & 17 deletions api/v2/helper.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (c) 2020-2021 Intel Corporation
// Copyright (c) 2020-2022 Intel Corporation

package v2

import (
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"reflect"
)

type ByPriority []SriovFecClusterConfig
Expand All @@ -26,25 +27,34 @@ func (a ByPriority) Swap(i, j int) {
}

func (s AcceleratorSelector) Matches(a SriovAccelerator) bool {
if s.VendorID != "" && s.VendorID != a.VendorID {
return false
}
if s.PCIAddress != "" && s.PCIAddress != a.PCIAddress {
return false
}
if s.PFDriver != "" && s.PFDriver != a.PFDriver {
return false
}
if s.MaxVFs != 0 && s.MaxVFs != a.MaxVFs {
return false
}
if s.DeviceID != "" && s.DeviceID != a.DeviceID {
return false
}
return s.isVendorMatching(a) && s.isPciAddressMatching(a) &&
s.isPFDriverMatching(a) && s.isMaxVFsMatching(a) && s.isDeviceIDMatching(a)
}

func (s AcceleratorSelector) isVendorMatching(a SriovAccelerator) bool {
return s.VendorID == "" || s.VendorID == a.VendorID
}

return true
func (s AcceleratorSelector) isPciAddressMatching(a SriovAccelerator) bool {
return s.PCIAddress == "" || s.PCIAddress == a.PCIAddress
}

func (s AcceleratorSelector) isPFDriverMatching(a SriovAccelerator) bool {
return s.PFDriver == "" || s.PFDriver == a.PFDriver
}

func (s AcceleratorSelector) isMaxVFsMatching(a SriovAccelerator) bool {
return s.MaxVFs == 0 || s.MaxVFs == a.MaxVFs
}

func (s AcceleratorSelector) isDeviceIDMatching(a SriovAccelerator) bool {
return s.DeviceID == "" || s.DeviceID == a.DeviceID
}

func (in *SriovFecNodeConfig) FindCondition(conditionType string) *metav1.Condition {
return meta.FindStatusCondition(in.Status.Conditions, conditionType)
}

func isNil(v interface{}) bool {
return v == nil || (reflect.ValueOf(v).Kind() == reflect.Ptr && reflect.ValueOf(v).IsNil())
}
54 changes: 51 additions & 3 deletions api/v2/sriovfecclusterconfig_types.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (c) 2020-2021 Intel Corporation
// Copyright (c) 2020-2022 Intel Corporation

package v2

import (
"fmt"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type SyncStatus string

const (
acc100maxQueueGroups = 8
acc200maxQueueGroups = 16
)

var (
// InProgressSync indicates that the synchronization of the CR is in progress
InProgressSync SyncStatus = "InProgress"
Expand Down Expand Up @@ -108,10 +112,54 @@ type ACC100BBDevConfig struct {
Downlink5G QueueGroupConfig `json:"downlink5G"`
}

func (in *ACC100BBDevConfig) Validate() error {
totalQueueGroups := in.Uplink4G.NumQueueGroups + in.Downlink4G.NumQueueGroups + in.Uplink5G.NumQueueGroups + in.Downlink5G.NumQueueGroups
if totalQueueGroups > acc100maxQueueGroups {
return fmt.Errorf("total number of requested queue groups (4G/5G) %v exceeds the maximum (%d)", totalQueueGroups, acc100maxQueueGroups)
}
return nil
}

// ACC200BBDevConfig specifies variables to configure ACC200 with
type ACC200BBDevConfig struct {
ACC100BBDevConfig `json:",inline"`
QFFT QueueGroupConfig `json:"qfft"`
}

func (in *ACC200BBDevConfig) Validate() error {
totalQueueGroups := in.Uplink4G.NumQueueGroups + in.Downlink4G.NumQueueGroups + in.Uplink5G.NumQueueGroups + in.Downlink5G.NumQueueGroups + in.QFFT.NumQueueGroups
if totalQueueGroups > acc200maxQueueGroups {
return fmt.Errorf("total number of requested queue groups (4G/5G/QFFT) %v exceeds the maximum (%d)", totalQueueGroups, acc200maxQueueGroups)
}
return nil
}

// BBDevConfig is a struct containing configuration for various FEC cards
type BBDevConfig struct {
N3000 *N3000BBDevConfig `json:"n3000,omitempty"`
ACC100 *ACC100BBDevConfig `json:"acc100,omitempty"`
ACC200 *ACC200BBDevConfig `json:"acc200,omitempty"`
}

type validator interface {
Validate() error
}

func (in *BBDevConfig) Validate() error {

if err := hasAmbiguousBBDevConfigs(*in); err != nil {
return err
}

for _, config := range []interface{}{in.ACC200, in.ACC100, in.N3000} {
if !isNil(config) {
if validator, ok := config.(validator); ok {
return validator.Validate()
}
}
}

return nil
}

// PhysicalFunctionConfig defines a possible configuration of a single Physical Function (PF), i.e. card
Expand All @@ -122,7 +170,7 @@ type PhysicalFunctionConfig struct {
// VFDriver to bound the VFs to
VFDriver string `json:"vfDriver"`
// VFAmount is an amount of VFs to be created
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Minimum=1
VFAmount int `json:"vfAmount"`
// BBDevConfig is a config for PF's queues
BBDevConfig BBDevConfig `json:"bbDevConfig"`
Expand Down
Loading

0 comments on commit 7eec69b

Please sign in to comment.