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 2 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"

// TokenIDKey - Client/Endpoint token ID
// nolint:gosec
TokenIDKey = "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

// TokenIDKey is a token ID property key
TokenIDKey = common.TokenIDKey
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the Token we are getting from DevicePlugin in an ENV variable? If so, could we call it DeviceToken or DeviceTokenID?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sure. Fixed.


// 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() != ""
}

// GetTokenID returns token ID
func (m *Mechanism) GetTokenID() string {
return m.Parameters[TokenIDKey]
}

// SetTokenID sets token ID
func (m *Mechanism) SetTokenID(tokenID string) {
m.Parameters[TokenIDKey] = 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

// TokenIDKey is a token ID property key
TokenIDKey = common.TokenIDKey

// 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
}

// GetTokenID returns token ID
func (m *Mechanism) GetTokenID() string {
return m.Parameters[TokenIDKey]
}

// SetTokenID sets token ID
func (m *Mechanism) SetTokenID(tokenID string) {
m.Parameters[TokenIDKey] = tokenID
}

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