From e19311096c68639149384e199be8e2627d7bd6db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jarom=C3=ADr=20Smr=C4=8Dek?= <4plague@gmail.com> Date: Wed, 2 Oct 2024 17:57:18 +0200 Subject: [PATCH] Get multiport-eswitch mode from metalnet rundir --- Dockerfile | 2 +- docs/README.md | 22 ++++++++++++++++++++++ main.go | 9 ++++++++- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8f358e7..d561e7d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Build the manager binary -FROM --platform=$BUILDPLATFORM golang:1.23 as builder +FROM --platform=$BUILDPLATFORM golang:1.23 AS builder ARG GOARCH='' diff --git a/docs/README.md b/docs/README.md index 9175395..e677db5 100644 --- a/docs/README.md +++ b/docs/README.md @@ -10,3 +10,25 @@ ## CRD usage * [Usage](./usage/crd_usage.md) + +## Multiport-eswitch mode +When running dpservice with Mellanox in multiport-eswitch mode, it is important to tell metalnet about it: +``` +metalnet --multiport-eswitch +``` +or +``` +echo -n "eswitch" > /var/run/metalnet/mode +``` +This changes the way metalnet generates identifiers for virtual function representors that are sent over to dpservice. + +If pf1-proxy is also in use, it is important to mark it as used in the metalnet VF database: +``` +mkdir -p /var/lib/metalnet/netfns/claims +echo -n "$pf1_proxy_vf_pci" > /var/lib/metalnet/netfns/claims/00000001-0000-4000-0000-000000000000 +``` +Where the `$pf1_proxy_vf_pci` is the PCI address of the VF representor for pf1-proxy. This should be the only VF using `mlx5_core` driver instead of the `vfio-pci` driver. One of many ways to retrieve such address is as follows: +``` +pf1_proxy_vf_name=$(/opt/local/bin/dpdk-devbind.py -s | grep "mlx5Gen Virtual Function" | grep "drv=mlx5_core" | awk -F'if=' '{print $2}' | awk '{print $1}') +pf1_proxy_vf_pci=$(/opt/local/bin/dpdk-devbind.py -s | grep "mlx5Gen Virtual Function" | grep $pf1_proxy_vf_name | awk '{print $1}') +``` diff --git a/main.go b/main.go index 9f44594..5174c65 100644 --- a/main.go +++ b/main.go @@ -104,7 +104,7 @@ func main() { flag.BoolVar(&enableIPv6Support, "enable-ipv6", false, "Enable IPv6 support") flag.IntVar(&publicVNI, "public-vni", 100, "Virtual network identifier used for public routing announcements.") flag.IPVar(&routerAddress, "router-address", net.IP{}, "The address of the next router.") - flag.BoolVar(&multiportEswitchMode, "multiport-eswitch", false, "Enable multiport eswitch support") + flag.BoolVar(&multiportEswitchMode, "multiport-eswitch", false, "Enable multiport eswitch support (unless specified in metalnet-dir)") flag.BoolVar(&enableLeaderElection, "leader-elect", false, "Enable leader election for controller manager. "+ "Enabling this will ensure there is only one active controller manager.") @@ -125,6 +125,13 @@ func main() { log.SetLevel(log.DebugLevel) } + // detect multiport-eswitch mode automatically (overrides command-line) + // Usage example: 'echo -n "eswitch" > /var/run/metalnet/mode' + modeFilePath := filepath.Join(metalnetDir, "mode") + content, err := os.ReadFile(modeFilePath) + multiportEswitchMode = err == nil && string(content) == "eswitch" + setupLog.Info(fmt.Sprintf("Multiport Eswitch mode set to: %v", multiportEswitchMode)) + defaultRouterAddr.PublicVNI = uint32(publicVNI) defaultRouterAddr.SetBySubsciption = false