Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for ETHTOOL_MSG_TSINFO_GET and ETHTOOL_MSG_TSINFO_GET_REPLY #9

Open
blainsmith opened this issue Mar 7, 2022 · 1 comment

Comments

@blainsmith
Copy link

It looks like ethtool can support querying a link to find out what kind of time-stamping capabilities it has with the -T option.

> ethtool -T enp1s0
Time stamping parameters for enp1s0:
Capabilities:
        hardware-transmit     (SOF_TIMESTAMPING_TX_HARDWARE)
        software-transmit     (SOF_TIMESTAMPING_TX_SOFTWARE)
        hardware-receive      (SOF_TIMESTAMPING_RX_HARDWARE)
        software-receive      (SOF_TIMESTAMPING_RX_SOFTWARE)
        software-system-clock (SOF_TIMESTAMPING_SOFTWARE)
        hardware-raw-clock    (SOF_TIMESTAMPING_RAW_HARDWARE)
PTP Hardware Clock: 0
Hardware Transmit Timestamp Modes:
        off                   (HWTSTAMP_TX_OFF)
        on                    (HWTSTAMP_TX_ON)
Hardware Receive Filter Modes:
        none                  (HWTSTAMP_FILTER_NONE)
        all                   (HWTSTAMP_FILTER_ALL)

The results of this query could then be used in setsockopt to enable these capabilities when using sendmsg and recvmsg and then parsing the control message that gets returned to get timestamps of userspace, kernel, and hardware. Enabling these options would work with https://pkg.go.dev/github.com/mdlayher/socket as long as Recvmsg and Sendmsg are used and there is a utility function for assisting in parsing the control message, but this is outside the scope of this issue.

Would you be open to adding support for this query? I propose something along the lines of:

// TimestampInfo holds the decoded response from `ethtool -T`
// NOTE: I am not suggesting that this is the struct we should use, but
// it is similar to how I have a working version already.
type TimestampInfo struct {
  HardwareRx bool
  HardwareTx bool

  SoftwareRx bool
  SoftwareTx bool

  SoftwareSystem bool
  HardwareRaw bool

  PTPClockIndex int
}

// TimestampingInfo essentiall does `ethtool -T DEV` and decodes the response into *TimestampInfo
func (c *Client) TimestampingInfo(ifi Interface) (*TimestampInfo, error) {
  // TBD
}

Additional References:

@mdlayher
Copy link
Owner

mdlayher commented Mar 8, 2022

Looks good to me, yeah! Feel free to send over a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants