@@ -683,6 +683,7 @@ enum ethtool_link_ext_substate_module {
* @ETH_SS_STATS_ETH_MAC: names of IEEE 802.3 MAC statistics
* @ETH_SS_STATS_ETH_CTRL: names of IEEE 802.3 MAC Control statistics
* @ETH_SS_STATS_RMON: names of RMON statistics
+ * @ETH_SS_HWTSTAMP_FLAG: timestamping flags
*
* @ETH_SS_COUNT: number of defined string sets
*/
@@ -708,6 +709,7 @@ enum ethtool_stringset {
ETH_SS_STATS_ETH_MAC,
ETH_SS_STATS_ETH_CTRL,
ETH_SS_STATS_RMON,
+ ETH_SS_HWTSTAMP_FLAG,
/* add new constants above here */
ETH_SS_COUNT
@@ -1416,6 +1418,7 @@ struct ethtool_ts_info {
__u32 tx_reserved[3];
__u32 rx_filters;
__u32 rx_reserved[3];
+ __u32 flag;
};
/*
@@ -458,6 +458,7 @@ enum {
ETHTOOL_A_TSINFO_TX_TYPES, /* bitset */
ETHTOOL_A_TSINFO_RX_FILTERS, /* bitset */
ETHTOOL_A_TSINFO_PHC_INDEX, /* u32 */
+ ETHTOOL_A_TSINFO_FLAG, /* bitset */
/* add new constants above here */
__ETHTOOL_A_TSINFO_CNT,
@@ -89,7 +89,10 @@ enum hwtstamp_flags {
HWTSTAMP_FLAG_BONDED_PHC_INDEX = (1<<0),
#define HWTSTAMP_FLAG_BONDED_PHC_INDEX HWTSTAMP_FLAG_BONDED_PHC_INDEX
- HWTSTAMP_FLAG_LAST = HWTSTAMP_FLAG_BONDED_PHC_INDEX,
+ HWTSTAMP_FLAG_DMA_TIMESTAMP = (1<<1),
+#define HWTSTAMP_FLAG_DMA_TIMESTAMP HWTSTAMP_FLAG_DMA_TIMESTAMP
+
+ HWTSTAMP_FLAG_LAST = HWTSTAMP_FLAG_DMA_TIMESTAMP,
HWTSTAMP_FLAG_MASK = (HWTSTAMP_FLAG_LAST - 1) | HWTSTAMP_FLAG_LAST
};
@@ -406,6 +406,12 @@ const char sof_timestamping_names[][ETH_GSTRING_LEN] = {
};
static_assert(ARRAY_SIZE(sof_timestamping_names) == __SOF_TIMESTAMPING_CNT);
+const char ts_flag_names[][ETH_GSTRING_LEN] = {
+ [const_ilog2(HWTSTAMP_FLAG_BONDED_PHC_INDEX)] = "bonded-phc-index",
+ [const_ilog2(HWTSTAMP_FLAG_DMA_TIMESTAMP)] = "dma-time-stamp",
+};
+static_assert(ARRAY_SIZE(ts_flag_names) == __HWTSTAMP_FLAG_CNT);
+
const char ts_tx_type_names[][ETH_GSTRING_LEN] = {
[HWTSTAMP_TX_OFF] = "off",
[HWTSTAMP_TX_ON] = "on",
@@ -13,6 +13,7 @@
ETHTOOL_LINK_MODE_ ## speed ## base ## type ## _ ## duplex ## _BIT
#define __SOF_TIMESTAMPING_CNT (const_ilog2(SOF_TIMESTAMPING_LAST) + 1)
+#define __HWTSTAMP_FLAG_CNT (const_ilog2(HWTSTAMP_FLAG_LAST) + 1)
struct link_mode_info {
int speed;
@@ -36,6 +37,7 @@ extern const char sof_timestamping_names[][ETH_GSTRING_LEN];
extern const char ts_tx_type_names[][ETH_GSTRING_LEN];
extern const char ts_rx_filter_names[][ETH_GSTRING_LEN];
extern const char udp_tunnel_type_names[][ETH_GSTRING_LEN];
+extern const char ts_flag_names[][ETH_GSTRING_LEN];
int __ethtool_get_link(struct net_device *dev);
@@ -105,6 +105,11 @@ static const struct strset_info info_template[] = {
.count = __ETHTOOL_A_STATS_RMON_CNT,
.strings = stats_rmon_names,
},
+ [ETH_SS_HWTSTAMP_FLAG] = {
+ .per_dev = false,
+ .count = __HWTSTAMP_FLAG_CNT,
+ .strings = ts_flag_names,
+ },
};
struct strset_req_info {
@@ -52,6 +52,7 @@ static int tsinfo_reply_size(const struct ethnl_req_info *req_base,
BUILD_BUG_ON(__SOF_TIMESTAMPING_CNT > 32);
BUILD_BUG_ON(__HWTSTAMP_TX_CNT > 32);
BUILD_BUG_ON(__HWTSTAMP_FILTER_CNT > 32);
+ BUILD_BUG_ON(__HWTSTAMP_FLAG_CNT > 32);
if (ts_info->so_timestamping) {
ret = ethnl_bitset32_size(&ts_info->so_timestamping, NULL,
@@ -79,6 +80,14 @@ static int tsinfo_reply_size(const struct ethnl_req_info *req_base,
}
if (ts_info->phc_index >= 0)
len += nla_total_size(sizeof(u32)); /* _TSINFO_PHC_INDEX */
+ if (ts_info->flag) {
+ ret = ethnl_bitset32_size(&ts_info->flag, NULL,
+ __HWTSTAMP_FLAG_CNT,
+ ts_flag_names, compact);
+ if (ret < 0)
+ return ret;
+ len += ret; /* _TSINFO_FLAG */
+ }
return len;
}
@@ -119,6 +128,14 @@ static int tsinfo_fill_reply(struct sk_buff *skb,
if (ts_info->phc_index >= 0 &&
nla_put_u32(skb, ETHTOOL_A_TSINFO_PHC_INDEX, ts_info->phc_index))
return -EMSGSIZE;
+ if (ts_info->flag) {
+ ret = ethnl_put_bitset32(skb, ETHTOOL_A_TSINFO_FLAG,
+ &ts_info->flag, NULL,
+ __HWTSTAMP_FLAG_CNT,
+ ts_flag_names, compact);
+ if (ret < 0)
+ return ret;
+ }
return 0;
}
This add patch add a new DMA Time Stamp flag. User can configure hwtstamp_config with this flag if they want to use DMA time stamp. Suggested-by: Vinicius Costa Gomes <vinicius.gomes@intel.com> Signed-off-by: Muhammad Husaini Zulkifli <muhammad.husaini.zulkifli@intel.com> --- include/uapi/linux/ethtool.h | 3 +++ include/uapi/linux/ethtool_netlink.h | 1 + include/uapi/linux/net_tstamp.h | 5 ++++- net/ethtool/common.c | 6 ++++++ net/ethtool/common.h | 2 ++ net/ethtool/strset.c | 5 +++++ net/ethtool/tsinfo.c | 17 +++++++++++++++++ 7 files changed, 38 insertions(+), 1 deletion(-)