sriovnet

package module
v0.5.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

README

sriovnet

Go library to configure SRIOV networking devices

Local build and test

You can use go get command:

go get github.com/Mellanox/sriovnet.git

Example:

package main

import (
    "fmt"
    "github.com/Mellanox/sriovnet"
)

func main() {
	var vfList[10] *sriovnet.VfObj

	err1 := sriovnet.EnableSriov("ib0")
	if err1 != nil {
		return
	}

	handle, err2 := sriovnet.GetPfNetdevHandle("ib0")
	if err2 != nil {
		return
	}
	err3 := sriovnet.ConfigVfs(handle, false)
	if err3 != nil {
		return
	}
	for i := 0; i < 10; i++ {
		vfList[i], _ = sriovnet.AllocateVf(handle)
	}
	for _, vf := range handle.List {
		fmt.Printf("after allocation vf = %v\n", vf)
	}
	for i := 0; i < 10; i++ {
		if vfList[i] == nil {
			continue
		}
		sriovnet.FreeVf(handle, vfList[i])
	}
	for _, vf := range handle.List {
		fmt.Printf("after free vf = %v\n", vf)
	}
}

Documentation

Index

Constants

View Source
const (
	NetSysDir = "/sys/class/net"
	PciSysDir = "/sys/bus/pci/devices"
)

Variables

This section is empty.

Functions

func BindVf

func BindVf(handle *PfNetdevHandle, vf *VfObj) error

func ConfigVfs

func ConfigVfs(handle *PfNetdevHandle, privileged bool) error

func DisableSriov

func DisableSriov(pfNetdevName string) error

func EnableSriov

func EnableSriov(pfNetdevName string) error

func FreeVf

func FreeVf(handle *PfNetdevHandle, vf *VfObj)

func FreeVfByNetdevName

func FreeVfByNetdevName(handle *PfNetdevHandle, vfIndex int) error

func GetAllRdmaSriovSupportedDevices

func GetAllRdmaSriovSupportedDevices() (devices []string)

GetAllRdmaSriovSupportedDevices returns a list of devices on a physical computer that have SRIOV enabled and the current VF count > 0. Also the infiniband directory must exist.

func GetAllSriovEnabledDevices

func GetAllSriovEnabledDevices() (devices []string)

GetAllSriovEnabledDevices returns a list of devices on a physical computer that have SRIOV enabled and the current VF count > 0. Note: this scans all the directories in NetSysDir variable, this should be used sparingly!!

func GetCurrentVfCount

func GetCurrentVfCount(pfNetdevName string) (int, error)

GetCurrentVfCount is a wrapper for the internal function

func GetNetDevicesFromPci

func GetNetDevicesFromPci(pciAddress string) ([]string, error)

GetNetDevicesFromPci gets a PCI address (e.g '0000:03:00.1') and returns the correlate list of netdevices

func GetPfMaxSendingRate

func GetPfMaxSendingRate(pfNetdevName string) (rate uint, err error)

GetPfMaxSendingRate gets the maximum sending rate of a given PF device name the rate returned is in Mb/second

func GetUplinkRepresentor

func GetUplinkRepresentor(vfPciAddress string) (string, error)

GetUplinkRepresentor gets a VF PCI address (e.g '0000:03:00.4') and returns the uplink represntor netdev name for that VF.

func GetVfDefaultMacAddr

func GetVfDefaultMacAddr(vfNetdevName string) (string, error)

func GetVfIndexByPciAddress

func GetVfIndexByPciAddress(vfPciAddress string) (int, error)

GetVfIndexByPciAddress gets a VF PCI address (e.g '0000:03:00.4') and returns the correlate VF index.

func GetVfNetdevName

func GetVfNetdevName(handle *PfNetdevHandle, vf *VfObj) string

func GetVfPciDevList

func GetVfPciDevList(pfNetdevName string) ([]string, error)

func GetVfRepresentor

func GetVfRepresentor(uplink string, vfIndex int) (string, error)

func IsSriovEnabled

func IsSriovEnabled(netdevName string) bool

func IsSriovSupported

func IsSriovSupported(netdevName string) bool

func SetPFLinkUp

func SetPFLinkUp(pfNetdevName string) error

func SetVfDefaultGUID

func SetVfDefaultGUID(handle *PfNetdevHandle, vf *VfObj) error

func SetVfDefaultMacAddress

func SetVfDefaultMacAddress(handle *PfNetdevHandle, vf *VfObj) error

func SetVfPrivileged

func SetVfPrivileged(handle *PfNetdevHandle, vf *VfObj, privileged bool) error

func SetVfVlan

func SetVfVlan(handle *PfNetdevHandle, vf *VfObj, vlan int) error

func UnbindVf

func UnbindVf(handle *PfNetdevHandle, vf *VfObj) error

Types

type PfNetdevHandle

type PfNetdevHandle struct {
	PfNetdevName string

	List []*VfObj
	// contains filtered or unexported fields
}

func GetPfNetdevHandle

func GetPfNetdevHandle(pfNetdevName string) (*PfNetdevHandle, error)

type VfObj

type VfObj struct {
	Index      int
	PciAddress string
	Bound      bool
	Allocated  bool
}

func AllocateVf

func AllocateVf(handle *PfNetdevHandle) (*VfObj, error)

func AllocateVfByMacAddress

func AllocateVfByMacAddress(handle *PfNetdevHandle, vfMacAddress string) (*VfObj, error)

type VfObject

type VfObject struct {
	NetdevName string
	PCIDevName string
}

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL