sriov

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExecQuantumMax = 64
	// Name of the profile in Profiles that resets VF to fair-share provisioning.
	FairShareProfile = "fairShare"
)

Variables

View Source
var PerDeviceIdDefaultProfiles = map[string]string{

	"0x56c0": "flex170_m8",

	"0x56c1": "flex140_m6",

	"0x0b69": "max_128g_c16",

	"0x0bd0": "max_128g_c16",

	"0x0bd5": "max_128g_c16",

	"0x0bd6": "max_128g_c16",

	"0x0bd9": "max_48g_c8",

	"0x0bda": "max_48g_c8",

	"0x0bdb": "max_48g_c8",
}

PerDeviceIdDefaultProfiles specifies name of default profile that should be used for particular PCI deviceId.

View Source
var PerDeviceIdProfiles = map[string][]string{

	"0x56c0": {"flex170_m1", "flex170_m2", "flex170_m4", "flex170_m5", "flex170_m8", "flex170_m16"},

	"0x56c1": {"flex140_m1", "flex140_m3", "flex140_m6", "flex140_m12"},

	"0x0b69": {"max_128g_c1", "max_128g_c2", "max_128g_c4", "max_128g_c8", "max_128g_c16", "max_128g_c32", "max_128g_c62"},

	"0x0bd0": {"max_128g_c1", "max_128g_c2", "max_128g_c4", "max_128g_c8", "max_128g_c16", "max_128g_c32", "max_128g_c62"},

	"0x0bd5": {"max_128g_c1", "max_128g_c2", "max_128g_c4", "max_128g_c8", "max_128g_c16", "max_128g_c32", "max_128g_c62"},

	"0x0bd6": {"max_128g_c1", "max_128g_c2", "max_128g_c4", "max_128g_c8", "max_128g_c16", "max_128g_c32", "max_128g_c62"},

	"0x0bd9": {"max_48g_c1", "max_48g_c2", "max_48g_c4", "max_48g_c8", "max_48g_c16", "max_48g_c32", "max_48g_c63"},

	"0x0bda": {"max_48g_c1", "max_48g_c2", "max_48g_c4", "max_48g_c8", "max_48g_c16", "max_48g_c32", "max_48g_c63"},

	"0x0bdb": {"max_48g_c1", "max_48g_c2", "max_48g_c4", "max_48g_c8", "max_48g_c16", "max_48g_c32", "max_48g_c63"},
}

PerDeviceIdProfiles has to be ordered descending by size, the profile picking logic relies on this.

View Source
var Profiles = map[string]map[string]uint64{

	"flex170_m1": {
		"contexts_quota":     1024,
		"doorbells_quota":    240,
		"exec_quantum_ms":    64,
		"ggtt_quota":         4026531840,
		"lmem_quota":         16911433728,
		"lmem_quota_ecc_on":  14334453350,
		"preempt_timeout_us": 128000,
		"numvfs":             1,
	},
	"flex170_m2": {
		"contexts_quota":     1024,
		"doorbells_quota":    120,
		"exec_quantum_ms":    32,
		"ggtt_quota":         2013265920,
		"lmem_quota":         8455716864,
		"lmem_quota_ecc_on":  7167226675,
		"preempt_timeout_us": 64000,
		"numvfs":             2,
	},
	"flex170_m4": {
		"contexts_quota":     1024,
		"doorbells_quota":    60,
		"exec_quantum_ms":    16,
		"ggtt_quota":         1006632960,
		"lmem_quota":         4227858432,
		"lmem_quota_ecc_on":  3583613337,
		"preempt_timeout_us": 32000,
		"numvfs":             4,
	},
	"flex170_m5": {
		"contexts_quota":     1024,
		"doorbells_quota":    48,
		"exec_quantum_ms":    12,
		"ggtt_quota":         805306368,
		"lmem_quota":         3380609024,
		"lmem_quota_ecc_on":  2866890670,
		"preempt_timeout_us": 24000,
		"numvfs":             5,
	},
	"flex170_m8": {
		"contexts_quota":     1024,
		"doorbells_quota":    30,
		"exec_quantum_ms":    8,
		"ggtt_quota":         503316480,
		"lmem_quota":         2113929216,
		"lmem_quota_ecc_on":  1791806668,
		"preempt_timeout_us": 16000,
		"numvfs":             8,
	},
	"flex170_m16": {
		"contexts_quota":     1024,
		"doorbells_quota":    15,
		"exec_quantum_ms":    4,
		"ggtt_quota":         251658240,
		"lmem_quota":         1056964608,
		"lmem_quota_ecc_on":  895903334,
		"preempt_timeout_us": 8000,
		"numvfs":             16,
	},

	"flex140_m1": {
		"contexts_quota":     1024,
		"doorbells_quota":    240,
		"exec_quantum_ms":    64,
		"ggtt_quota":         4026531840,
		"lmem_quota":         6174015488,
		"lmem_quota_ecc_on":  5014290432,
		"preempt_timeout_us": 128000,
		"numvfs":             1,
	},
	"flex140_m3": {
		"contexts_quota":     1024,
		"doorbells_quota":    80,
		"exec_quantum_ms":    22,
		"ggtt_quota":         1342177280,
		"lmem_quota":         2057306112,
		"lmem_quota_ecc_on":  1671430144,
		"preempt_timeout_us": 44000,
		"numvfs":             3,
	},
	"flex140_m6": {
		"contexts_quota":     1024,
		"doorbells_quota":    40,
		"exec_quantum_ms":    16,
		"ggtt_quota":         671088640,
		"lmem_quota":         1027604480,
		"lmem_quota_ecc_on":  834666496,
		"preempt_timeout_us": 32000,
		"numvfs":             6,
	},
	"flex140_m12": {
		"contexts_quota":     1024,
		"doorbells_quota":    20,
		"exec_quantum_ms":    8,
		"ggtt_quota":         335544320,
		"lmem_quota":         513802240,
		"lmem_quota_ecc_on":  417333248,
		"preempt_timeout_us": 16000,
		"numvfs":             12,
	},

	"max_128g_c1": {
		"contexts_quota":     1024,
		"doorbells_quota":    240,
		"exec_quantum_ms":    64,
		"ggtt_quota":         4026531840,
		"lmem_quota":         64424509440,
		"lmem_quota_ecc_on":  64424509440,
		"preempt_timeout_us": 128000,
		"numvfs":             1,
	},
	"max_128g_c2": {
		"contexts_quota":     1024,
		"doorbells_quota":    240,
		"exec_quantum_ms":    64,
		"ggtt_quota":         2013265920,
		"lmem_quota":         32212254720,
		"lmem_quota_ecc_on":  32212254720,
		"preempt_timeout_us": 128000,
		"numvfs":             2,
	},
	"max_128g_c4": {
		"contexts_quota":     1024,
		"doorbells_quota":    120,
		"exec_quantum_ms":    64,
		"ggtt_quota":         1006632960,
		"lmem_quota":         16106127360,
		"lmem_quota_ecc_on":  16106127360,
		"preempt_timeout_us": 128000,
		"numvfs":             4,
	},
	"max_128g_c8": {
		"contexts_quota":     1024,
		"doorbells_quota":    60,
		"exec_quantum_ms":    32,
		"ggtt_quota":         503316480,
		"lmem_quota":         8053063680,
		"lmem_quota_ecc_on":  8053063680,
		"preempt_timeout_us": 64000,
		"numvfs":             8,
	},
	"max_128g_c16": {
		"contexts_quota":     1024,
		"doorbells_quota":    30,
		"exec_quantum_ms":    16,
		"ggtt_quota":         251658240,
		"lmem_quota":         4026531840,
		"lmem_quota_ecc_on":  4026531840,
		"preempt_timeout_us": 32000,
		"numvfs":             16,
	},
	"max_128g_c32": {
		"contexts_quota":     1024,
		"doorbells_quota":    15,
		"exec_quantum_ms":    8,
		"ggtt_quota":         125829120,
		"lmem_quota":         2013265920,
		"lmem_quota_ecc_on":  2013265920,
		"preempt_timeout_us": 16000,
		"numvfs":             32,
	},
	"max_128g_c62": {
		"contexts_quota":     1024,
		"doorbells_quota":    7,
		"exec_quantum_ms":    4,
		"ggtt_quota":         64880640,
		"lmem_quota":         1038090240,
		"lmem_quota_ecc_on":  1038090240,
		"preempt_timeout_us": 8000,
		"numvfs":             62,
	},
	"max_48g_c1": {
		"contexts_quota":     1024,
		"doorbells_quota":    240,
		"exec_quantum_ms":    64,
		"ggtt_quota":         4026531840,
		"lmem_quota":         47244640256,
		"lmem_quota_ecc_on":  47244640256,
		"preempt_timeout_us": 128000,
		"numvfs":             1,
	},
	"max_48g_c2": {
		"contexts_quota":     1024,
		"doorbells_quota":    120,
		"exec_quantum_ms":    64,
		"ggtt_quota":         2013265920,
		"lmem_quota":         23622320128,
		"lmem_quota_ecc_on":  23622320128,
		"preempt_timeout_us": 128000,
		"numvfs":             2,
	},
	"max_48g_c4": {
		"contexts_quota":     1024,
		"doorbells_quota":    60,
		"exec_quantum_ms":    64,
		"ggtt_quota":         1006632960,
		"lmem_quota":         11811160064,
		"lmem_quota_ecc_on":  11811160064,
		"preempt_timeout_us": 128000,
		"numvfs":             4,
	},
	"max_48g_c8": {
		"contexts_quota":     1024,
		"doorbells_quota":    30,
		"exec_quantum_ms":    32,
		"ggtt_quota":         503316480,
		"lmem_quota":         5905580032,
		"lmem_quota_ecc_on":  5905580032,
		"preempt_timeout_us": 64000,
		"numvfs":             8,
	},
	"max_48g_c16": {
		"contexts_quota":     1024,
		"doorbells_quota":    15,
		"exec_quantum_ms":    16,
		"ggtt_quota":         251658240,
		"lmem_quota":         2952790016,
		"lmem_quota_ecc_on":  2952790016,
		"preempt_timeout_us": 32000,
		"numvfs":             16,
	},
	"max_48g_c32": {
		"contexts_quota":     1024,
		"doorbells_quota":    7,
		"exec_quantum_ms":    8,
		"ggtt_quota":         125829120,
		"lmem_quota":         1476395008,
		"lmem_quota_ecc_on":  1476395008,
		"preempt_timeout_us": 16000,
		"numvfs":             32,
	},
	"max_48g_c63": {
		"contexts_quota":     1024,
		"doorbells_quota":    3,
		"exec_quantum_ms":    4,
		"ggtt_quota":         63897600,
		"lmem_quota":         738197504,
		"lmem_quota_ecc_on":  738197504,
		"preempt_timeout_us": 8000,
		"numvfs":             63,
	},
	FairShareProfile: {
		"contexts_quota":     0,
		"doorbells_quota":    0,
		"exec_quantum_ms":    0,
		"ggtt_quota":         0,
		"lmem_quota":         0,
		"lmem_quota_ecc_on":  0,
		"preempt_timeout_us": 0,
		"numvfs":             0,
	},
}

Profiles is a set of all supported profiles and per-sysfs-file values.

View Source
var VfAttributeFiles = []string{
	"contexts_quota",
	"doorbells_quota",
	"exec_quantum_ms",
	"ggtt_quota",
	"lmem_quota",
	"preempt_timeout_us",
}

VfAttributeFiles is a list of filenames that needs to be configured for a VF profile to be applied.

Functions

func CleanupManualConfigurationMaybe

func CleanupManualConfigurationMaybe(sysfsVFsDir string, numVFs uint64, model string) error

CleanupManualConfigurationMaybe checks whether "pf/auto_provisioning" (under given sysfsVFsDir) is disabled before enabling it back. If numVfs is zero, it unconfigures all available VFs regardless whether they are enabled or configured.

func DeduceVFMillicores added in v0.3.0

func DeduceVFMillicores(parentI915Dir string, cardIdx uint64, pciVFIndex uint64, vfMemMiB uint64, deviceID string) (uint64, error)

DeduceVFMillicores returns relative amount of millicores based on either of: - number of provisioned VFs, if auto_provisioning is enabled; - memory allocated to the VF, if auto_provisioning is disabled.

func DeviceProfileExists

func DeviceProfileExists(deviceId string, profileName string) bool

DeviceProfileExists returns true if given profileName is found for deviceId in PerDeviceIdProfiles, or false.

func GetMaximumVFDoorbells

func GetMaximumVFDoorbells(deviceId string) uint64

GetMaximumVFDoorbells returns amount of doorbells the biggest profile for deviceId has.

func GetMaximumVFMemorySizeMiB

func GetMaximumVFMemorySizeMiB(deviceId string, eccOn bool) (uint64, error)

GetMaximumVFMemorySizeMiB returns amount of memory in MiB that the largest profile for deviceId has.

func GetMimimumVFDoorbells

func GetMimimumVFDoorbells(deviceId string) uint64

GetMinimumVFDoorbells returns amount of doorbells the smallest profile for deviceId has.

func GetMimimumVFMemorySizeMiB

func GetMimimumVFMemorySizeMiB(deviceId string, eccOn bool) (uint64, error)

GetMimimumVFMemorySizeMiB returns amount of memory in MiB that the smallest profile for deviceId has.

func GetProfileDoorbells

func GetProfileDoorbells(profileName string) uint64

GetProfileDoorbells returns amount of doorbells the profile has.

func GetVFDefaults

func GetVFDefaults(deviceId string, eccOn bool) (uint64, uint64, string, error)

GetVFDefaults returns default VF memory amount in MiB and profile name for a given deviceId.

func GtDirFromModel added in v0.3.0

func GtDirFromModel(model string) string

GtDirFromModel returns gt or gt0 for /sys/class/drm/cardXX/prelim_iov/vfYY/ depending on the GPU family. Family is determined based on the default VF profile prefix of the given GPU model.

func GtDirFromProfile added in v0.3.0

func GtDirFromProfile(profileName string) string

GtDirFromProfile returns gt or gt0 for /sys/class/drm/cardXX/prelim_iov/vfYY/ depending on the GPU family. Family is determined based on profile prefix.

func MaxFairVFs

func MaxFairVFs(deviceId string, vfs []int) (int, error)

MaxFairVFs returns the maximum number of VFs that PF resources can be split fairly into, for the requested VF combination. Example 1: 16 GiB GPU memory can be split into 4, 4, 4, 4 to serve two VFs that requested 2 and 4 GiB respectively. Four VFs can be provisioned by simple fair-share provisioning. Example 2: 16GiB GPU memory cannot be evenly split to server VFs that requested 8, 2, 2 GiB respectively because minimum fair-share split 16 / 3 would yield less memory (5.3 GiB) per VF than the biggest memory request (8).

func PickVFProfile

func PickVFProfile(deviceId string, requestMemoryMiB uint64, requestMillicores uint64, eccOn bool) (uint64, uint64, string, error)

PickVFProfile selects suitable VF profile based on memory request. Returns VF memory in MiB, profile name and error. Can be used in case fair share is not suitable.

func PreConfigureVF

func PreConfigureVF(vfAttrsDir string, drmVfIndex uint64, vfProfile string, eccOn bool) error

PreConfigureVF sets custom VF settings from profile for manual provisioning mode for cases when fair share is not suitable. pf/auto_provisioning will be automatically set to 0 by KMD in this case.

func ProfileMemoryMiB added in v0.3.0

func ProfileMemoryMiB(profileName string, eccOn bool) (uint64, error)

ProfileMemoryMiB returns amount of memory in MiB given profile provides if it exists, or error.

func SanitizeLmemQuotaMiB

func SanitizeLmemQuotaMiB(deviceId string, eccOn bool, lmemQuotaMiB uint64) bool

SanitizeLmemQuotaMiB returns true is requested amount of lmemQuota in MiB is supported by at least one profile for deviceId, otherwise false.

func UnConfigureAllVFs

func UnConfigureAllVFs(vfsDir string, model string) bool

UnconfigureAllVfs is taking full path to the driver's DRM VFs dir and loops through found VFs to write zeroes into all VFs' attributes. Returns true if all operations succeeded, false otherwise.

func UnConfigureVF

func UnConfigureVF(attrsDir string) error

UnConfigureVF unsets configuration of single VF to auto mode, writing 0 to all configuration files. It is important to manually set pf/auto_provisioning to 1 after all VFs are unconfigured.

Types

This section is empty.

Jump to

Keyboard shortcuts

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