Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sdk-vpp#314] Add SR-IOV token ID mechanism parameter for kernel, VFIO mechanisms #110

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/api/networkservice/mechanisms/common/constants.go
Original file line number Diff line number Diff line change
@@ -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");
Expand Down Expand Up @@ -46,6 +48,10 @@ const (
// PCIAddressKey - PCI address of the device for the SR-IOV supported mechanisms
PCIAddressKey = "pciAddress"

// DeviceTokenIDKey - Client/Endpoint device token ID
// nolint:gosec
DeviceTokenIDKey = "tokenID"

// MTU - Maximum Transmission Unit
MTU = "MTU"
)
5 changes: 5 additions & 0 deletions pkg/api/networkservice/mechanisms/kernel/constants.go
Original file line number Diff line number Diff line change
@@ -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");
Expand Down Expand Up @@ -33,6 +35,9 @@ const (
// PCIAddressKey - device PCI address property key
PCIAddressKey = common.PCIAddressKey

// DeviceTokenIDKey is a device token ID property key
DeviceTokenIDKey = common.DeviceTokenIDKey

// NetNSInodeKey - netns inode mechanism property key
NetNSInodeKey = common.NetNSInodeKey

Expand Down
12 changes: 12 additions & 0 deletions pkg/api/networkservice/mechanisms/kernel/helpers.go
Original file line number Diff line number Diff line change
@@ -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");
Expand Down Expand Up @@ -86,6 +88,16 @@ func (m *Mechanism) IsPCIDevice() bool {
return m.GetPCIAddress() != ""
}

// GetDeviceTokenID returns device token ID
func (m *Mechanism) GetDeviceTokenID() string {
return m.Parameters[DeviceTokenIDKey]
}

// SetDeviceTokenID sets device token ID
func (m *Mechanism) SetDeviceTokenID(tokenID string) {
m.Parameters[DeviceTokenIDKey] = tokenID
}

// GetInterfaceName returns the Kernel Interface Name
func (m *Mechanism) GetInterfaceName() string {
return m.GetParameters()[InterfaceNameKey]
Expand Down
6 changes: 5 additions & 1 deletion pkg/api/networkservice/mechanisms/vfio/constants.go
Original file line number Diff line number Diff line change
@@ -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
//
Expand Down Expand Up @@ -35,6 +36,9 @@ const (
// PCIAddressKey is a PCI address property key
PCIAddressKey = common.PCIAddressKey

// DeviceTokenIDKey is a device token ID property key
DeviceTokenIDKey = common.DeviceTokenIDKey

// VfioMajorKey is a /dev/vfio major number property key
VfioMajorKey = "vfioMajor"

Expand Down
13 changes: 12 additions & 1 deletion pkg/api/networkservice/mechanisms/vfio/helpers.go
Original file line number Diff line number Diff line change
@@ -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
//
Expand Down Expand Up @@ -91,6 +92,16 @@ func (m *Mechanism) SetPCIAddress(pciAddress string) {
m.GetParameters()[PCIAddressKey] = pciAddress
}

// GetDeviceTokenID returns device token ID
func (m *Mechanism) GetDeviceTokenID() string {
return m.Parameters[DeviceTokenIDKey]
}

// SetDeviceTokenID sets device token ID
func (m *Mechanism) SetDeviceTokenID(tokenID string) {
m.Parameters[DeviceTokenIDKey] = tokenID
}

// GetVfioMajor returns /dev/vfio major number
func (m *Mechanism) GetVfioMajor() uint32 {
return atou32(m.GetParameters()[VfioMajorKey])
Expand Down