Categorygithub.com/safchain/ethtool
modulepackage
0.5.10
Repository: https://github.com/safchain/ethtool.git
Documentation: pkg.go.dev

# README

ethtool go package

Build Status GoDoc

The ethtool package aims to provide a library that provides easy access to the Linux SIOCETHTOOL ioctl operations. It can be used to retrieve information from a network device such as statistics, driver related information or even the peer of a VETH interface.

Installation

go get github.com/safchain/ethtool

How to use

package main

import (
	"fmt"

	"github.com/safchain/ethtool"
)

func main() {
	ethHandle, err := ethtool.NewEthtool()
	if err != nil {
		panic(err.Error())
	}
	defer ethHandle.Close()

	// Retrieve tx from eth0
	stats, err := ethHandle.Stats("eth0")
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("TX: %d\n", stats["tx_bytes"])

	// Retrieve peer index of a veth interface
	stats, err = ethHandle.Stats("veth0")
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("Peer Index: %d\n", stats["peer_ifindex"])
}

LICENSE

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

# Packages

No description provided by the author

# Functions

BusInfo returns bus information of the given interface name.
CmdGetMapped returns the interface settings in a map.
DriverName returns the driver name of the given interface name.
MsglvlGet returns the msglvl of the given interface.
MsglvlSet returns the read-msglvl, post-set-msglvl of the given interface.
NewEthtool returns a new ethtool handler.
PermAddr returns permanent address of the given interface name.
Stats retrieves stats of the given interface name.
SupportedLinkModes returns the names of the link modes supported by the interface.
SupportedSpeed returns the maximum capacity of this interface.

# Constants

MAX_GSTRINGS maximum number of stats entries that ethtool can retrieve currently.
ethtool stats related constants.
ethtool stats related constants.
ethtool stats related constants.
ethtool stats related constants.
Get no of channels */.
Get coalesce config */.
Get driver info.
Get time stamping and PHC info */.
Get device offload settings */.
Get flags bitmap(ethtool_value) */.
Get link status for host, i.e.
Get plug-in module eeprom */.
Get plug-in module information */.
Get driver message level */.
Get pause parameters */.
Get permanent hardware address */.
Get driver-private flags bitmap */.
Get ring parameters */.
Get settings.
Get string set info */.
Get NIC-specific statistics */.
Get specified string set */.
Get wake-on-lan options.
Set no of channels */.
Set coalesce config */.
Change device offload settings */.
Set driver msg level.
Set pause parameters.
Set driver-private flags bitmap */.
Set ring parameters.
Set settings.
Set wake-on-lan options.
time stamp any incoming packet */.
time stamp no incoming packet at all */.
NTP, UDP, all versions and packet modes */.
PTP v1, UDP, Delay_req packet */.
PTP v1, UDP, any kind of event packet */.
PTP v1, UDP, Sync packet */.
PTP v2/802.AS1, any layer, Delay_req packet */.
PTP v2/802.AS1, any layer, any kind of event packet */.
802.AS1, Ethernet, Delay_req packet */.
802.AS1, Ethernet, any kind of event packet */.
802.AS1, Ethernet, Sync packet */.
PTP v2, UDP, Delay_req packet */.
PTP v2, UDP, any kind of event packet */.
PTP v2, UDP, Sync packet */.
PTP v2/802.AS1, any layer, Sync packet */.
return value: time stamp all packets requested plus some others */.
* No outgoing packet will need hardware time stamping; * should a packet arrive which asks for it, no hardware * time stamping will be done.
* Enables hardware time stamping for outgoing packets; * the sender of the packet decides which are to be * time stamped by setting %SOF_TIMESTAMPING_TX_SOFTWARE * before sending the packet.
* Same as HWTSTAMP_TX_ONESTEP_SYNC, but also enables time * stamp insertion directly into PDelay_Resp packets.
* Enables time stamping for outgoing packets just as * HWTSTAMP_TX_ON does, but also enables time stamp insertion * directly into Sync packets.
Maximum size of an interface name.
MAX_GSTRINGS maximum number of stats entries that ethtool can retrieve currently.
MAX_GSTRINGS maximum number of stats entries that ethtool can retrieve currently.
ethtool sset_info related constants.
MAX_GSTRINGS maximum number of stats entries that ethtool can retrieve currently.
ioctl ethtool request.
Bind the socket to a specific PTP Hardware Clock.
Support recv() cmsg for all timestamped packets.
Generate a unique identifier along with each packet.
Enable the SCM_TIMESTAMPING_PKTINFO control message for incoming packets with hardware timestamps.
Optional stats that are obtained along with the transmit timestamps.
Applies to transmit timestamps only.
Request both hardware and software timestamps for outgoing packets when SOF_TIMESTAMPING_TX_HARDWARE and SOF_TIMESTAMPING_TX_SOFTWARE are enabled at the same time.
Report hardware timestamps.
Request rx timestamps generated by the network adapter.
Request rx timestamps when data enters the kernel.
Report any software timestamps when available.
This option is deprecated and ignored.
Request tx timestamps when all data in the send buffer has been acknowledged.
Request tx timestamps generated by the network adapter.
Request tx timestamps prior to entering the packet scheduler.
Request tx timestamps when data leaves the kernel.
WoL options.
WoL options.
WoL options.
only meaningful if WAKE_MAGIC.
WoL options.
WoL options.
WoL options.

# Variables

No description provided by the author

# Structs

Channels contains the number of channels for a given interface.
Coalesce is a coalesce config for an interface.
DrvInfo contains driver information ethtool.h v3.5: struct ethtool_drvinfo.
Ethtool is a struct that contains the file descriptor for the ethtool.
EthtoolCmd is the Go version of the Linux kerne ethtool_cmd struct see ethtool.c.
FeatureState contains the state of a feature.
Pause is a pause config for an interface.
Ring is a ring config for an interface.
TimestampingInformation contains PTP timetstapming information.
WakeOnLan contains WoL config for an interface.