nic

package
v0.0.0-...-b79a0d8 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package nic allows enabling/disabling NICs, configuring XPS, RFS, and RSS, etc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisableByIndex

func DisableByIndex(i int, allowedPrefixes [][]uint8) bool

Disables the given nic until reboot.

WARNING: if multiple ports are to be disabled, disable the one with highest index first; otherwise the wrong port(s) will be disabled.

func DisabledNics

func DisabledNics() int

Returns number of nics that have been disabled. Note, only counts disables by this process, not by all processes on system.

func IrqName

func IrqName(i uint64) string

return name of irq

func IsQueueIrq

func IsQueueIrq(i uint64) bool

true if i appears to be the irq for a queue (based on irq name alone)

func NICsAlreadyConfigured

func NICsAlreadyConfigured() bool

return true if bans have already been written out for irqbalance

func WriteIRQBalanceBans

func WriteIRQBalanceBans(irqs []uint64)

write bans for irqbalance to systemd override file

func WriteMasks

func WriteMasks(qMasks map[string]uint64, suffix string) (errors int)

write masks for queues

func XpsConfig

func XpsConfig(qnames []string, cpuMask uint64, nrCpus uint16) (qMasks queueMasks)

Transmit Packet Scaling - set up cpumasks for the queues. We want a set of masks with no gaps or overlap. These IRQs must be excluded from the set irqbalance can change.

Suggested XPS Configuration

For a network device with a single transmission queue, XPS configuration has no effect, since there is no choice in this case. In a multi-queue system, XPS is preferably configured so that each CPU maps onto one queue. If there are as many queues as there are CPUs in the system, then each queue can also map onto one CPU, resulting in exclusive pairings that experience no contention. If there are fewer queues than CPUs, then the best CPUs to share a given queue are probably those that share the cache with the CPU that processes transmit completions for that queue (transmit interrupts).

/sys/class/net/<dev>/queues/tx-<n>/xps_cpus

Types

type FilterFn

type FilterFn func(int, Nic) bool

func IndexFilter

func IndexFilter(indexes []int) FilterFn

A filter for nics with the given indexes.

func NotFilter

func NotFilter(fn FilterFn) FilterFn

A filter that inverts the sense of the given filter.

type MACList

type MACList []umac

func SortableMacs

func SortableMacs(l []net.HardwareAddr) (s MACList)

func (MACList) Len

func (m MACList) Len() int

func (MACList) Less

func (m MACList) Less(i, j int) bool

func (MACList) Sequential

func (m MACList) Sequential() bool

func (MACList) Sort

func (m MACList) Sort()

func (MACList) Swap

func (m MACList) Swap(i, j int)

type Nic

type Nic struct {
	// contains filtered or unexported fields
}

func TestNic

func TestNic(device, mac string, irqs []uint64) (n Nic, err error)

used to create a Nic for testing

func (Nic) AllowedPrefix

func (n Nic) AllowedPrefix(allowed [][]byte) bool

func (Nic) AssignIRQs

func (nic Nic) AssignIRQs(cpus cpu.CpuSet)

assign device's IRQs to the specified CPUs

func (Nic) Disable

func (nic Nic) Disable() (success bool)

Sets nic state down and detaches from driver, causing the nic to disappear until reboot.

func (Nic) Down

func (nic Nic) Down()

Set nic state down

func (*Nic) FindIRQs

func (nic *Nic) FindIRQs() (num int, err error)

populate list of irqs which may fire on packet ingress, return number found on NICs without RSS, uses the main irq - otherwise, RxTx IRQs

func (Nic) GetAlias

func (nic Nic) GetAlias() string

Returns a network interface's IfAlias. Returns an empty string if an error occurs or there is no alias.

func (Nic) ListIRQs

func (nic Nic) ListIRQs() []uint64

return list of device IRQs

func (Nic) Mac

func (n Nic) Mac() net.HardwareAddr

func (Nic) MatchOUI

func (n Nic) MatchOUI() bool

func (*Nic) MaximizeQueues

func (nic *Nic) MaximizeQueues()

MaximizeQueues - enable any NIC queues that were't automatically enabled. * Must happen before other queue-related operations so that the configuration * will apply to these additional queues. Intel seems to configure the max * queues automatically while Broadcom doesn't.

func (Nic) Name

func (n Nic) Name() string

func (Nic) Queues

func (nic Nic) Queues(prefix string) (queues []string)

return array of paths to queues

func (Nic) RfsConfig

func (nic Nic) RfsConfig()

Receive Flow Scaling - set total number of RFS entries, as well as number per RSS queue

func (*Nic) RssConfig

func (nic *Nic) RssConfig()

Receive Side Scaling - set rx flow hashes. * Doesn't affect IRQ affinity - we handle that elsewhere * rather than letting irqbalance have its way. Irqbalance * seems to not be locality-aware; we let it shuffle other * interrupts while we focus on NICs.

func (Nic) SetAlias

func (nic Nic) SetAlias(alias string, overwrite bool) (changed bool)

Set IfAlias on a nic. Unless overwrite is true, first checks that no alias is set.

func (Nic) String

func (n Nic) String() string

func (Nic) Up

func (nic Nic) Up()

Set nic state up

type NicList

type NicList []Nic

func List

func List() (nics NicList)

return array of names of nics

func SortedList

func SortedList(allowedPrefixes [][]byte) NicList

Sort interfaces by mac, ascending. Filters out interfaces lacking an allowed prefix, if such are specified.

func (NicList) Filter

func (nl NicList) Filter(fn FilterFn) (filtered NicList)

func (NicList) FilterMACs

func (nl NicList) FilterMACs(allowedPrefixes [][]byte) (filtered NicList)

Return Nics whose MACs match allowedPrefixes. Return all Nics if list is empty.

func (NicList) Sort

func (nl NicList) Sort() (sorted NicList)

Jump to

Keyboard shortcuts

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