Skip to content

Commit

Permalink
Add SR-IOV token ID mechanism parameter for kernel, VFIO mechanisms
Browse files Browse the repository at this point in the history
Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>
  • Loading branch information
Vladimir Popov committed Jul 30, 2021
1 parent 6e4a0f8 commit 0cca414
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 2 deletions.
5 changes: 5 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,9 @@ const (
// PCIAddressKey - PCI address of the device for the SR-IOV supported mechanisms
PCIAddressKey = "pciAddress"

// SRIOVTokenIDKey - Client/Endpoint SR-IOV token ID
SRIOVTokenIDKey = "sriovTokenID"

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

// SRIOVTokenIDKey is a SR-IOV token ID property key
SRIOVTokenIDKey = common.SRIOVTokenIDKey

// 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 @@ -84,6 +86,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]
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

// SRIOVTokenIDKey is a SR-IOV token ID property key
SRIOVTokenIDKey = common.SRIOVTokenIDKey

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

// 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])
Expand Down

0 comments on commit 0cca414

Please sign in to comment.