History

ethtool: add timestamping related string sets

Add three string sets related to timestamping information: ETH_SS_SOF_TIMESTAMPING: SOF_TIMESTAMPING_* flags ETH_SS_TS_TX_TYPES: timestamping Tx types ETH_SS_TS_RX_FILTERS: timestamping Rx filters These will be used for TIMESTAMP_GET request. v2: avoid compiler warning ("enumeration value not handled in switch") in net_hwtstamp_validate() v3: omit dash in Tx type names ("one-step-*" -> "onestep-*"), suggested by Richard Cochran

Michal Kubecek committed 6 years ago

Commit f76510b1 parent 6c5bc8f6 files · +87 −0Browse files

Unified · Split

6 files
  1. include/uapi/linux/ethtool.h +6 −0
  2. include/uapi/linux/net_tstamp.h +6 −0
  3. net/core/dev_ioctl.c +6 −0
  4. net/ethtool/common.c +49 −0
  5. net/ethtool/common.h +5 −0
  6. net/ethtool/strset.c +15 −0
include/uapi/linux/ethtool.h+6−0
@@ -596,6 +596,9 @@ struct ethtool_pauseparam { · 595 unmodified lines
596596 * @ETH_SS_LINK_MODES: link mode names
597597 * @ETH_SS_MSG_CLASSES: debug message class names
598598 * @ETH_SS_WOL_MODES: wake-on-lan modes
599+ * @ETH_SS_SOF_TIMESTAMPING: SOF_TIMESTAMPING_* flags
600+ * @ETH_SS_TS_TX_TYPES: timestamping Tx types
601+ * @ETH_SS_TS_RX_FILTERS: timestamping Rx filters
599602 */
600603 enum ethtool_stringset {
601604 ETH_SS_TEST = 0,
@@ -610,6 +613,9 @@ enum ethtool_stringset { · 8 unmodified lines
610613 ETH_SS_LINK_MODES,
611614 ETH_SS_MSG_CLASSES,
612615 ETH_SS_WOL_MODES,
616+ ETH_SS_SOF_TIMESTAMPING,
617+ ETH_SS_TS_TX_TYPES,
618+ ETH_SS_TS_RX_FILTERS,
613619
614620 /* add new constants above here */
615621 ETH_SS_COUNT
include/uapi/linux/net_tstamp.h+6−0
@@ -98,6 +98,9 @@ enum hwtstamp_tx_types { · 97 unmodified lines
9898 * receive a time stamp via the socket error queue.
9999 */
100100 HWTSTAMP_TX_ONESTEP_P2P,
101+
102+ /* add new constants above here */
103+ __HWTSTAMP_TX_CNT
101104 };
102105
103106 /* possible values for hwtstamp_config->rx_filter */
@@ -140,6 +143,9 @@ enum hwtstamp_rx_filters { · 36 unmodified lines
140143
141144 /* NTP, UDP, all versions and packet modes */
142145 HWTSTAMP_FILTER_NTP_ALL,
146+
147+ /* add new constants above here */
148+ __HWTSTAMP_FILTER_CNT
143149 };
144150
145151 /* SCM_TIMESTAMPING_PKTINFO control message */
net/core/dev_ioctl.c+6−0
@@ -190,6 +190,9 @@ static int net_hwtstamp_validate(struct ifreq *ifr) · 189 unmodified lines
190190 case HWTSTAMP_TX_ONESTEP_P2P:
191191 tx_type_valid = 1;
192192 break;
193+ case __HWTSTAMP_TX_CNT:
194+ /* not a real value */
195+ break;
193196 }
194197
195198 switch (rx_filter) {
@@ -211,6 +214,9 @@ static int net_hwtstamp_validate(struct ifreq *ifr) · 15 unmodified lines
211214 case HWTSTAMP_FILTER_NTP_ALL:
212215 rx_filter_valid = 1;
213216 break;
217+ case __HWTSTAMP_FILTER_CNT:
218+ /* not a real value */
219+ break;
214220 }
215221
216222 if (!tx_type_valid || !rx_filter_valid)
net/ethtool/common.c+49−0
@@ -1,5 +1,7 @@
11 // SPDX-License-Identifier: GPL-2.0-only
22
3+#include <linux/net_tstamp.h>
4+
35 #include "common.h"
46
57 const char netdev_features_strings[NETDEV_FEATURE_COUNT][ETH_GSTRING_LEN] = {
@@ -204,6 +206,53 @@ const char wol_mode_names[][ETH_GSTRING_LEN] = { · 198 unmodified lines
204206 };
205207 static_assert(ARRAY_SIZE(wol_mode_names) == WOL_MODE_COUNT);
206208
209+const char sof_timestamping_names[][ETH_GSTRING_LEN] = {
210+ [const_ilog2(SOF_TIMESTAMPING_TX_HARDWARE)] = "hardware-transmit",
211+ [const_ilog2(SOF_TIMESTAMPING_TX_SOFTWARE)] = "software-transmit",
212+ [const_ilog2(SOF_TIMESTAMPING_RX_HARDWARE)] = "hardware-receive",
213+ [const_ilog2(SOF_TIMESTAMPING_RX_SOFTWARE)] = "software-receive",
214+ [const_ilog2(SOF_TIMESTAMPING_SOFTWARE)] = "software-system-clock",
215+ [const_ilog2(SOF_TIMESTAMPING_SYS_HARDWARE)] = "hardware-legacy-clock",
216+ [const_ilog2(SOF_TIMESTAMPING_RAW_HARDWARE)] = "hardware-raw-clock",
217+ [const_ilog2(SOF_TIMESTAMPING_OPT_ID)] = "option-id",
218+ [const_ilog2(SOF_TIMESTAMPING_TX_SCHED)] = "sched-transmit",
219+ [const_ilog2(SOF_TIMESTAMPING_TX_ACK)] = "ack-transmit",
220+ [const_ilog2(SOF_TIMESTAMPING_OPT_CMSG)] = "option-cmsg",
221+ [const_ilog2(SOF_TIMESTAMPING_OPT_TSONLY)] = "option-tsonly",
222+ [const_ilog2(SOF_TIMESTAMPING_OPT_STATS)] = "option-stats",
223+ [const_ilog2(SOF_TIMESTAMPING_OPT_PKTINFO)] = "option-pktinfo",
224+ [const_ilog2(SOF_TIMESTAMPING_OPT_TX_SWHW)] = "option-tx-swhw",
225+};
226+static_assert(ARRAY_SIZE(sof_timestamping_names) == __SOF_TIMESTAMPING_CNT);
227+
228+const char ts_tx_type_names[][ETH_GSTRING_LEN] = {
229+ [HWTSTAMP_TX_OFF] = "off",
230+ [HWTSTAMP_TX_ON] = "on",
231+ [HWTSTAMP_TX_ONESTEP_SYNC] = "onestep-sync",
232+ [HWTSTAMP_TX_ONESTEP_P2P] = "onestep-p2p",
233+};
234+static_assert(ARRAY_SIZE(ts_tx_type_names) == __HWTSTAMP_TX_CNT);
235+
236+const char ts_rx_filter_names[][ETH_GSTRING_LEN] = {
237+ [HWTSTAMP_FILTER_NONE] = "none",
238+ [HWTSTAMP_FILTER_ALL] = "all",
239+ [HWTSTAMP_FILTER_SOME] = "some",
240+ [HWTSTAMP_FILTER_PTP_V1_L4_EVENT] = "ptpv1-l4-event",
241+ [HWTSTAMP_FILTER_PTP_V1_L4_SYNC] = "ptpv1-l4-sync",
242+ [HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ] = "ptpv1-l4-delay-req",
243+ [HWTSTAMP_FILTER_PTP_V2_L4_EVENT] = "ptpv2-l4-event",
244+ [HWTSTAMP_FILTER_PTP_V2_L4_SYNC] = "ptpv2-l4-sync",
245+ [HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ] = "ptpv2-l4-delay-req",
246+ [HWTSTAMP_FILTER_PTP_V2_L2_EVENT] = "ptpv2-l2-event",
247+ [HWTSTAMP_FILTER_PTP_V2_L2_SYNC] = "ptpv2-l2-sync",
248+ [HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ] = "ptpv2-l2-delay-req",
249+ [HWTSTAMP_FILTER_PTP_V2_EVENT] = "ptpv2-event",
250+ [HWTSTAMP_FILTER_PTP_V2_SYNC] = "ptpv2-sync",
251+ [HWTSTAMP_FILTER_PTP_V2_DELAY_REQ] = "ptpv2-delay-req",
252+ [HWTSTAMP_FILTER_NTP_ALL] = "ntp-all",
253+};
254+static_assert(ARRAY_SIZE(ts_rx_filter_names) == __HWTSTAMP_FILTER_CNT);
255+
207256 /* return false if legacy contained non-0 deprecated fields
208257 * maxtxpkt/maxrxpkt. rest of ksettings always updated
209258 */
net/ethtool/common.h+5−0
@@ -12,6 +12,8 @@ · 11 unmodified lines
1212 #define ETHTOOL_LINK_MODE(speed, type, duplex) \
1313 ETHTOOL_LINK_MODE_ ## speed ## base ## type ## _ ## duplex ## _BIT
1414
15+#define __SOF_TIMESTAMPING_CNT (const_ilog2(SOF_TIMESTAMPING_LAST) + 1)
16+
1517 extern const char
1618 netdev_features_strings[NETDEV_FEATURE_COUNT][ETH_GSTRING_LEN];
1719 extern const char
@@ -23,6 +25,9 @@ phy_tunable_strings[__ETHTOOL_PHY_TUNABLE_COUNT][ETH_GSTRING_LEN]; · 5 unmodified lines
2325 extern const char link_mode_names[][ETH_GSTRING_LEN];
2426 extern const char netif_msg_class_names[][ETH_GSTRING_LEN];
2527 extern const char wol_mode_names[][ETH_GSTRING_LEN];
28+extern const char sof_timestamping_names[][ETH_GSTRING_LEN];
29+extern const char ts_tx_type_names[][ETH_GSTRING_LEN];
30+extern const char ts_rx_filter_names[][ETH_GSTRING_LEN];
2631
2732 int __ethtool_get_link(struct net_device *dev);
2833
net/ethtool/strset.c+15−0
@@ -60,6 +60,21 @@ static const struct strset_info info_template[] = { · 59 unmodified lines
6060 .count = WOL_MODE_COUNT,
6161 .strings = wol_mode_names,
6262 },
63+ [ETH_SS_SOF_TIMESTAMPING] = {
64+ .per_dev = false,
65+ .count = __SOF_TIMESTAMPING_CNT,
66+ .strings = sof_timestamping_names,
67+ },
68+ [ETH_SS_TS_TX_TYPES] = {
69+ .per_dev = false,
70+ .count = __HWTSTAMP_TX_CNT,
71+ .strings = ts_tx_type_names,
72+ },
73+ [ETH_SS_TS_RX_FILTERS] = {
74+ .per_dev = false,
75+ .count = __HWTSTAMP_FILTER_CNT,
76+ .strings = ts_rx_filter_names,
77+ },
6378 };
6479
6580 struct strset_req_info {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t