Documentation ¶
Overview ¶
Package nic allows enabling/disabling NICs, configuring XPS, RFS, and RSS, etc.
Index ¶
- func DisableByIndex(i int, allowedPrefixes [][]uint8) bool
- func DisabledNics() int
- func IrqName(i uint64) string
- func IsQueueIrq(i uint64) bool
- func NICsAlreadyConfigured() bool
- func WriteIRQBalanceBans(irqs []uint64)
- func WriteMasks(qMasks map[string]uint64, suffix string) (errors int)
- func XpsConfig(qnames []string, cpuMask uint64, nrCpus uint16) (qMasks queueMasks)
- type FilterFn
- type MACList
- type Nic
- func (n Nic) AllowedPrefix(allowed [][]byte) bool
- func (nic Nic) AssignIRQs(cpus cpu.CpuSet)
- func (nic Nic) Disable() (success bool)
- func (nic Nic) Down()
- func (nic *Nic) FindIRQs() (num int, err error)
- func (nic Nic) GetAlias() string
- func (nic Nic) ListIRQs() []uint64
- func (n Nic) Mac() net.HardwareAddr
- func (n Nic) MatchOUI() bool
- func (nic *Nic) MaximizeQueues()
- func (n Nic) Name() string
- func (nic Nic) Queues(prefix string) (queues []string)
- func (nic Nic) RfsConfig()
- func (nic *Nic) RssConfig()
- func (nic Nic) SetAlias(alias string, overwrite bool) (changed bool)
- func (n Nic) String() string
- func (nic Nic) Up()
- type NicList
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DisableByIndex ¶
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 IsQueueIrq ¶
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 ¶
write masks for queues
func XpsConfig ¶
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 ¶
func IndexFilter ¶
A filter for nics with the given indexes.
type MACList ¶
type MACList []umac
func SortableMacs ¶
func SortableMacs(l []net.HardwareAddr) (s MACList)
func (MACList) Sequential ¶
type Nic ¶
type Nic struct {
// contains filtered or unexported fields
}
func (Nic) AllowedPrefix ¶
func (Nic) AssignIRQs ¶
assign device's IRQs to the specified CPUs
func (Nic) Disable ¶
Sets nic state down and detaches from driver, causing the nic to disappear until reboot.
func (*Nic) FindIRQs ¶
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 ¶
Returns a network interface's IfAlias. Returns an empty string if an error occurs or there is no alias.
func (Nic) Mac ¶
func (n Nic) Mac() net.HardwareAddr
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) 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.
type NicList ¶
type NicList []Nic
func SortedList ¶
Sort interfaces by mac, ascending. Filters out interfaces lacking an allowed prefix, if such are specified.
func (NicList) FilterMACs ¶
Return Nics whose MACs match allowedPrefixes. Return all Nics if list is empty.