Skip to content

Commit

Permalink
Merge pull request #74 from gizmoguy/set-coalesce
Browse files Browse the repository at this point in the history
Add support for setting coalesce configuration.
  • Loading branch information
safchain authored Dec 13, 2023
2 parents 83e5e00 + 9f24ce2 commit 1127ba9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions ethtool.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const (
* physical port (if there is one) are up (ethtool_value). */
ETHTOOL_GLINK = 0x0000000a
ETHTOOL_GCOALESCE = 0x0000000e /* Get coalesce config */
ETHTOOL_SCOALESCE = 0x0000000f /* Set coalesce config */
ETHTOOL_GRINGPARAM = 0x00000010 /* Get ring parameters */
ETHTOOL_SRINGPARAM = 0x00000011 /* Set ring parameters. */
ETHTOOL_GPAUSEPARAM = 0x00000012 /* Get pause parameters */
Expand Down Expand Up @@ -484,6 +485,15 @@ func (e *Ethtool) GetCoalesce(intf string) (Coalesce, error) {
return coalesce, nil
}

// SetCoalesce sets the coalesce config for the given interface name.
func (e *Ethtool) SetCoalesce(intf string, coalesce Coalesce) (Coalesce, error) {
coalesce, err := e.setCoalesce(intf, coalesce)
if err != nil {
return Coalesce{}, err
}
return coalesce, nil
}

// GetTimestampingInformation returns the PTP timestamping information for the given interface name.
func (e *Ethtool) GetTimestampingInformation(intf string) (TimestampingInformation, error) {
ts, err := e.getTimestampingInformation(intf)
Expand Down Expand Up @@ -579,6 +589,16 @@ func (e *Ethtool) getCoalesce(intf string) (Coalesce, error) {
return coalesce, nil
}

func (e *Ethtool) setCoalesce(intf string, coalesce Coalesce) (Coalesce, error) {
coalesce.Cmd = ETHTOOL_SCOALESCE

if err := e.ioctl(intf, uintptr(unsafe.Pointer(&coalesce))); err != nil {
return Coalesce{}, err
}

return coalesce, nil
}

func (e *Ethtool) getTimestampingInformation(intf string) (TimestampingInformation, error) {
ts := TimestampingInformation{
Cmd: ETHTOOL_GET_TS_INFO,
Expand Down

0 comments on commit 1127ba9

Please sign in to comment.