From f11ec23f4c6df5f034eb019daab62abf02d3d79d Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Fri, 30 Jul 2021 19:56:31 +0700 Subject: [PATCH 1/3] Add SR-IOV token ID mechanism parameter for kernel, VFIO mechanisms Signed-off-by: Vladimir Popov --- .../networkservice/mechanisms/common/constants.go | 6 ++++++ .../networkservice/mechanisms/kernel/constants.go | 5 +++++ pkg/api/networkservice/mechanisms/kernel/helpers.go | 12 ++++++++++++ pkg/api/networkservice/mechanisms/vfio/constants.go | 6 +++++- pkg/api/networkservice/mechanisms/vfio/helpers.go | 13 ++++++++++++- 5 files changed, 40 insertions(+), 2 deletions(-) diff --git a/pkg/api/networkservice/mechanisms/common/constants.go b/pkg/api/networkservice/mechanisms/common/constants.go index 599baf6..f4d2297 100644 --- a/pkg/api/networkservice/mechanisms/common/constants.go +++ b/pkg/api/networkservice/mechanisms/common/constants.go @@ -1,5 +1,7 @@ // Copyright (c) 2020-2021 Cisco Systems, Inc. // +// Copyright (c) 2021 Doc.ai and/or its affiliates. +// // SPDX-License-Identifier: Apache-2.0 // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -46,6 +48,10 @@ const ( // PCIAddressKey - PCI address of the device for the SR-IOV supported mechanisms PCIAddressKey = "pciAddress" + // SRIOVTokenIDKey - Client/Endpoint SR-IOV token ID + // nolint:gosec + SRIOVTokenIDKey = "sriovTokenID" + // MTU - Maximum Transmission Unit MTU = "MTU" ) diff --git a/pkg/api/networkservice/mechanisms/kernel/constants.go b/pkg/api/networkservice/mechanisms/kernel/constants.go index 8e3817e..a63360f 100644 --- a/pkg/api/networkservice/mechanisms/kernel/constants.go +++ b/pkg/api/networkservice/mechanisms/kernel/constants.go @@ -1,5 +1,7 @@ // Copyright (c) 2020-2021 Cisco Systems, Inc. // +// Copyright (c) 2021 Doc.ai and/or its affiliates. +// // SPDX-License-Identifier: Apache-2.0 // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -33,6 +35,9 @@ const ( // PCIAddressKey - device PCI address property key PCIAddressKey = common.PCIAddressKey + // SRIOVTokenIDKey is a SR-IOV token ID property key + SRIOVTokenIDKey = common.SRIOVTokenIDKey + // NetNSInodeKey - netns inode mechanism property key NetNSInodeKey = common.NetNSInodeKey diff --git a/pkg/api/networkservice/mechanisms/kernel/helpers.go b/pkg/api/networkservice/mechanisms/kernel/helpers.go index 9ef2237..bf3ba11 100644 --- a/pkg/api/networkservice/mechanisms/kernel/helpers.go +++ b/pkg/api/networkservice/mechanisms/kernel/helpers.go @@ -1,5 +1,7 @@ // Copyright (c) 2019-2021 Cisco Systems, Inc and/or its affiliates. // +// Copyright (c) 2021 Doc.ai and/or its affiliates. +// // SPDX-License-Identifier: Apache-2.0 // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -86,6 +88,16 @@ func (m *Mechanism) IsPCIDevice() bool { return m.GetPCIAddress() != "" } +// GetSRIOVTokenID returns SR-IOV token ID +func (m *Mechanism) GetSRIOVTokenID() string { + return m.Parameters[SRIOVTokenIDKey] +} + +// SetSRIOVTokenID sets SR-IOV token ID +func (m *Mechanism) SetSRIOVTokenID(tokenID string) { + m.Parameters[SRIOVTokenIDKey] = tokenID +} + // GetInterfaceName returns the Kernel Interface Name func (m *Mechanism) GetInterfaceName() string { return m.GetParameters()[InterfaceNameKey] diff --git a/pkg/api/networkservice/mechanisms/vfio/constants.go b/pkg/api/networkservice/mechanisms/vfio/constants.go index d834676..58abdd0 100644 --- a/pkg/api/networkservice/mechanisms/vfio/constants.go +++ b/pkg/api/networkservice/mechanisms/vfio/constants.go @@ -1,5 +1,6 @@ // Copyright (c) 2020 Intel Corporation. All Rights Reserved. -// Copyright (c) 2020 Doc.ai and/or its affiliates. +// +// Copyright (c) 2020-2021 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -35,6 +36,9 @@ const ( // PCIAddressKey is a PCI address property key PCIAddressKey = common.PCIAddressKey + // SRIOVTokenIDKey is a SR-IOV token ID property key + SRIOVTokenIDKey = common.SRIOVTokenIDKey + // VfioMajorKey is a /dev/vfio major number property key VfioMajorKey = "vfioMajor" diff --git a/pkg/api/networkservice/mechanisms/vfio/helpers.go b/pkg/api/networkservice/mechanisms/vfio/helpers.go index 9b015f3..da153f2 100644 --- a/pkg/api/networkservice/mechanisms/vfio/helpers.go +++ b/pkg/api/networkservice/mechanisms/vfio/helpers.go @@ -1,5 +1,6 @@ // Copyright (c) 2020 Intel Corporation. All Rights Reserved. -// Copyright (c) 2020 Doc.ai and/or its affiliates. +// +// Copyright (c) 2020-2021 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -91,6 +92,16 @@ func (m *Mechanism) SetPCIAddress(pciAddress string) { m.GetParameters()[PCIAddressKey] = pciAddress } +// GetSRIOVTokenID returns SR-IOV token ID +func (m *Mechanism) GetSRIOVTokenID() string { + return m.Parameters[SRIOVTokenIDKey] +} + +// SetSRIOVTokenID sets SR-IOV token ID +func (m *Mechanism) SetSRIOVTokenID(tokenID string) { + m.Parameters[SRIOVTokenIDKey] = tokenID +} + // GetVfioMajor returns /dev/vfio major number func (m *Mechanism) GetVfioMajor() uint32 { return atou32(m.GetParameters()[VfioMajorKey]) From e396b4c0ac87ca6e85e49b61a5ce5a5a0564f3e3 Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Fri, 3 Sep 2021 13:01:18 +0700 Subject: [PATCH 2/3] Renam SR-IOV token ID to just token ID Signed-off-by: Vladimir Popov --- .../networkservice/mechanisms/common/constants.go | 4 ++-- .../networkservice/mechanisms/kernel/constants.go | 4 ++-- pkg/api/networkservice/mechanisms/kernel/helpers.go | 12 ++++++------ pkg/api/networkservice/mechanisms/vfio/constants.go | 4 ++-- pkg/api/networkservice/mechanisms/vfio/helpers.go | 12 ++++++------ 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/pkg/api/networkservice/mechanisms/common/constants.go b/pkg/api/networkservice/mechanisms/common/constants.go index f4d2297..9f32be5 100644 --- a/pkg/api/networkservice/mechanisms/common/constants.go +++ b/pkg/api/networkservice/mechanisms/common/constants.go @@ -48,9 +48,9 @@ const ( // PCIAddressKey - PCI address of the device for the SR-IOV supported mechanisms PCIAddressKey = "pciAddress" - // SRIOVTokenIDKey - Client/Endpoint SR-IOV token ID + // TokenIDKey - Client/Endpoint token ID // nolint:gosec - SRIOVTokenIDKey = "sriovTokenID" + TokenIDKey = "tokenID" // MTU - Maximum Transmission Unit MTU = "MTU" diff --git a/pkg/api/networkservice/mechanisms/kernel/constants.go b/pkg/api/networkservice/mechanisms/kernel/constants.go index a63360f..e288420 100644 --- a/pkg/api/networkservice/mechanisms/kernel/constants.go +++ b/pkg/api/networkservice/mechanisms/kernel/constants.go @@ -35,8 +35,8 @@ const ( // PCIAddressKey - device PCI address property key PCIAddressKey = common.PCIAddressKey - // SRIOVTokenIDKey is a SR-IOV token ID property key - SRIOVTokenIDKey = common.SRIOVTokenIDKey + // TokenIDKey is a token ID property key + TokenIDKey = common.TokenIDKey // NetNSInodeKey - netns inode mechanism property key NetNSInodeKey = common.NetNSInodeKey diff --git a/pkg/api/networkservice/mechanisms/kernel/helpers.go b/pkg/api/networkservice/mechanisms/kernel/helpers.go index bf3ba11..5707179 100644 --- a/pkg/api/networkservice/mechanisms/kernel/helpers.go +++ b/pkg/api/networkservice/mechanisms/kernel/helpers.go @@ -88,14 +88,14 @@ func (m *Mechanism) IsPCIDevice() bool { return m.GetPCIAddress() != "" } -// GetSRIOVTokenID returns SR-IOV token ID -func (m *Mechanism) GetSRIOVTokenID() string { - return m.Parameters[SRIOVTokenIDKey] +// GetTokenID returns token ID +func (m *Mechanism) GetTokenID() string { + return m.Parameters[TokenIDKey] } -// SetSRIOVTokenID sets SR-IOV token ID -func (m *Mechanism) SetSRIOVTokenID(tokenID string) { - m.Parameters[SRIOVTokenIDKey] = tokenID +// SetTokenID sets token ID +func (m *Mechanism) SetTokenID(tokenID string) { + m.Parameters[TokenIDKey] = tokenID } // GetInterfaceName returns the Kernel Interface Name diff --git a/pkg/api/networkservice/mechanisms/vfio/constants.go b/pkg/api/networkservice/mechanisms/vfio/constants.go index 58abdd0..213f1b6 100644 --- a/pkg/api/networkservice/mechanisms/vfio/constants.go +++ b/pkg/api/networkservice/mechanisms/vfio/constants.go @@ -36,8 +36,8 @@ const ( // PCIAddressKey is a PCI address property key PCIAddressKey = common.PCIAddressKey - // SRIOVTokenIDKey is a SR-IOV token ID property key - SRIOVTokenIDKey = common.SRIOVTokenIDKey + // TokenIDKey is a token ID property key + TokenIDKey = common.TokenIDKey // VfioMajorKey is a /dev/vfio major number property key VfioMajorKey = "vfioMajor" diff --git a/pkg/api/networkservice/mechanisms/vfio/helpers.go b/pkg/api/networkservice/mechanisms/vfio/helpers.go index da153f2..fd5235b 100644 --- a/pkg/api/networkservice/mechanisms/vfio/helpers.go +++ b/pkg/api/networkservice/mechanisms/vfio/helpers.go @@ -92,14 +92,14 @@ func (m *Mechanism) SetPCIAddress(pciAddress string) { m.GetParameters()[PCIAddressKey] = pciAddress } -// GetSRIOVTokenID returns SR-IOV token ID -func (m *Mechanism) GetSRIOVTokenID() string { - return m.Parameters[SRIOVTokenIDKey] +// GetTokenID returns token ID +func (m *Mechanism) GetTokenID() string { + return m.Parameters[TokenIDKey] } -// SetSRIOVTokenID sets SR-IOV token ID -func (m *Mechanism) SetSRIOVTokenID(tokenID string) { - m.Parameters[SRIOVTokenIDKey] = tokenID +// SetTokenID sets token ID +func (m *Mechanism) SetTokenID(tokenID string) { + m.Parameters[TokenIDKey] = tokenID } // GetVfioMajor returns /dev/vfio major number From cf2bef5ed32e5790dd315d22b37234ea352a7326 Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Mon, 6 Sep 2021 11:29:34 +0700 Subject: [PATCH 3/3] Rename token ID to device token ID Signed-off-by: Vladimir Popov --- .../networkservice/mechanisms/common/constants.go | 4 ++-- .../networkservice/mechanisms/kernel/constants.go | 4 ++-- pkg/api/networkservice/mechanisms/kernel/helpers.go | 12 ++++++------ pkg/api/networkservice/mechanisms/vfio/constants.go | 4 ++-- pkg/api/networkservice/mechanisms/vfio/helpers.go | 12 ++++++------ 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/pkg/api/networkservice/mechanisms/common/constants.go b/pkg/api/networkservice/mechanisms/common/constants.go index 9f32be5..c3e1986 100644 --- a/pkg/api/networkservice/mechanisms/common/constants.go +++ b/pkg/api/networkservice/mechanisms/common/constants.go @@ -48,9 +48,9 @@ const ( // PCIAddressKey - PCI address of the device for the SR-IOV supported mechanisms PCIAddressKey = "pciAddress" - // TokenIDKey - Client/Endpoint token ID + // DeviceTokenIDKey - Client/Endpoint device token ID // nolint:gosec - TokenIDKey = "tokenID" + DeviceTokenIDKey = "tokenID" // MTU - Maximum Transmission Unit MTU = "MTU" diff --git a/pkg/api/networkservice/mechanisms/kernel/constants.go b/pkg/api/networkservice/mechanisms/kernel/constants.go index e288420..72ebbd4 100644 --- a/pkg/api/networkservice/mechanisms/kernel/constants.go +++ b/pkg/api/networkservice/mechanisms/kernel/constants.go @@ -35,8 +35,8 @@ const ( // PCIAddressKey - device PCI address property key PCIAddressKey = common.PCIAddressKey - // TokenIDKey is a token ID property key - TokenIDKey = common.TokenIDKey + // DeviceTokenIDKey is a device token ID property key + DeviceTokenIDKey = common.DeviceTokenIDKey // NetNSInodeKey - netns inode mechanism property key NetNSInodeKey = common.NetNSInodeKey diff --git a/pkg/api/networkservice/mechanisms/kernel/helpers.go b/pkg/api/networkservice/mechanisms/kernel/helpers.go index 5707179..8250c50 100644 --- a/pkg/api/networkservice/mechanisms/kernel/helpers.go +++ b/pkg/api/networkservice/mechanisms/kernel/helpers.go @@ -88,14 +88,14 @@ func (m *Mechanism) IsPCIDevice() bool { return m.GetPCIAddress() != "" } -// GetTokenID returns token ID -func (m *Mechanism) GetTokenID() string { - return m.Parameters[TokenIDKey] +// GetDeviceTokenID returns device token ID +func (m *Mechanism) GetDeviceTokenID() string { + return m.Parameters[DeviceTokenIDKey] } -// SetTokenID sets token ID -func (m *Mechanism) SetTokenID(tokenID string) { - m.Parameters[TokenIDKey] = tokenID +// SetDeviceTokenID sets device token ID +func (m *Mechanism) SetDeviceTokenID(tokenID string) { + m.Parameters[DeviceTokenIDKey] = tokenID } // GetInterfaceName returns the Kernel Interface Name diff --git a/pkg/api/networkservice/mechanisms/vfio/constants.go b/pkg/api/networkservice/mechanisms/vfio/constants.go index 213f1b6..e426dc2 100644 --- a/pkg/api/networkservice/mechanisms/vfio/constants.go +++ b/pkg/api/networkservice/mechanisms/vfio/constants.go @@ -36,8 +36,8 @@ const ( // PCIAddressKey is a PCI address property key PCIAddressKey = common.PCIAddressKey - // TokenIDKey is a token ID property key - TokenIDKey = common.TokenIDKey + // DeviceTokenIDKey is a device token ID property key + DeviceTokenIDKey = common.DeviceTokenIDKey // VfioMajorKey is a /dev/vfio major number property key VfioMajorKey = "vfioMajor" diff --git a/pkg/api/networkservice/mechanisms/vfio/helpers.go b/pkg/api/networkservice/mechanisms/vfio/helpers.go index fd5235b..fae2515 100644 --- a/pkg/api/networkservice/mechanisms/vfio/helpers.go +++ b/pkg/api/networkservice/mechanisms/vfio/helpers.go @@ -92,14 +92,14 @@ func (m *Mechanism) SetPCIAddress(pciAddress string) { m.GetParameters()[PCIAddressKey] = pciAddress } -// GetTokenID returns token ID -func (m *Mechanism) GetTokenID() string { - return m.Parameters[TokenIDKey] +// GetDeviceTokenID returns device token ID +func (m *Mechanism) GetDeviceTokenID() string { + return m.Parameters[DeviceTokenIDKey] } -// SetTokenID sets token ID -func (m *Mechanism) SetTokenID(tokenID string) { - m.Parameters[TokenIDKey] = tokenID +// SetDeviceTokenID sets device token ID +func (m *Mechanism) SetDeviceTokenID(tokenID string) { + m.Parameters[DeviceTokenIDKey] = tokenID } // GetVfioMajor returns /dev/vfio major number