(fd int, ifname string)
| 96 | var rxFilter int32 |
| 97 | |
| 98 | hw, err := unix.IoctlGetEthtoolTsInfo(fd, ifname) |
| 99 | if err != nil { |
| 100 | return 0, fmt.Errorf("failed to run ioctl SIOCETHTOOL to see what is supported: (%w)", err) |
| 101 | } |
| 102 | |
| 103 | if hw.Tx_types&(1<<unix.HWTSTAMP_TX_ON) == 0 { |
| 104 | return 0, fmt.Errorf("hardware TX timestamping is not supported for the interface %s", ifname) |
| 105 | } |
| 106 | |
| 107 | if hw.Rx_filters&(1<<unix.HWTSTAMP_FILTER_PTP_V2_L4_EVENT) > 0 { |
| 108 | rxFilter = unix.HWTSTAMP_FILTER_PTP_V2_L4_EVENT |
| 109 | } else if hw.Rx_filters&(1<<unix.HWTSTAMP_FILTER_PTP_V2_EVENT) > 0 { |
| 110 | rxFilter = unix.HWTSTAMP_FILTER_PTP_V2_EVENT |
| 111 | } else if hw.Rx_filters&(1<<unix.HWTSTAMP_FILTER_ALL) > 0 { |
| 112 | rxFilter = unix.HWTSTAMP_FILTER_ALL |
| 113 | } |
| 114 | |
| 115 | if rxFilter == 0 { |
| 116 | return 0, fmt.Errorf("hardware RX timestamping is not supported for the interface %s", ifname) |
| 117 | } |
| 118 | return rxFilter, nil |
| 119 | } |
| 120 | |
| 121 | func ioctlTimestamp(fd int, ifname string, filter int32) error { |
| 122 | hw, err := unix.IoctlGetHwTstamp(fd, ifname) |
| 123 | if errors.Is(err, unix.ENOTSUP) { |
| 124 | // for the loopback interface |
| 125 | hw = &unix.HwTstampConfig{} |
no outgoing calls
searching dependent graphs…