From patchwork Tue Sep 27 13:06:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zulkifli, Muhammad Husaini" X-Patchwork-Id: 1683248 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=PYMSwvNP; dkim-atps=neutral Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4McKgD3KCFz1yq7 for ; Tue, 27 Sep 2022 23:08:08 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 962E94179C; Tue, 27 Sep 2022 13:08:06 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 962E94179C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1664284086; bh=MjcGTKsmy0VAJOWsA1GRoDSdpQ79IAiC9PbW8wPAeos=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=PYMSwvNP6lZvpVrYVqJvP/G/1A0nL7U7Sp+S49Brgs3IHVIDnQbJ8pEKSs8NINxiY OSScbdgfku9En9DORUwAHlaGCKH/jouy/6Er5E4ZDQ2bnQVNBSZAMOEslFL6bprhOK QK8X8xlLdeAYdL21dRP2a8PwleqwVPJnX1/nv93CYtwMUMEgbQAe62hZ7OZfshwwJe Yv9rzt4sKTTy2XHAvOxt7SXKUgglyO5d6laWJv95UtIRfnz8oRMx3jlp8LglYVW5Xl Fct+P35poIL8tmAgm5GyyKpQsgAgHR7WZc8/qrXdo97deNDoixYrtaVd78VDQS5lGs DSomiQaJNiyiw== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CDbge-JSPkow; Tue, 27 Sep 2022 13:08:05 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp4.osuosl.org (Postfix) with ESMTP id 149B4401DA; Tue, 27 Sep 2022 13:08:05 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 149B4401DA X-Original-To: intel-wired-lan@osuosl.org Delivered-To: intel-wired-lan@osuosl.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id CB06F1BF47A for ; Tue, 27 Sep 2022 13:07:59 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id B3F00826BF for ; Tue, 27 Sep 2022 13:07:59 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org B3F00826BF X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ru3nuTIsT4yo for ; Tue, 27 Sep 2022 13:07:59 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org D8E02825B9 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by smtp1.osuosl.org (Postfix) with ESMTPS id D8E02825B9 for ; Tue, 27 Sep 2022 13:07:58 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6500,9779,10483"; a="327667753" X-IronPort-AV: E=Sophos;i="5.93,349,1654585200"; d="scan'208";a="327667753" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2022 06:07:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10483"; a="689984904" X-IronPort-AV: E=Sophos;i="5.93,349,1654585200"; d="scan'208";a="689984904" Received: from zulkifl3-ilbpg0.png.intel.com ([10.88.229.82]) by fmsmga004.fm.intel.com with ESMTP; 27 Sep 2022 06:07:56 -0700 From: Muhammad Husaini Zulkifli To: intel-wired-lan@osuosl.org Date: Tue, 27 Sep 2022 21:06:53 +0800 Message-Id: <20220927130656.32567-2-muhammad.husaini.zulkifli@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220927130656.32567-1-muhammad.husaini.zulkifli@intel.com> References: <20220927130656.32567-1-muhammad.husaini.zulkifli@intel.com> X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664284078; x=1695820078; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=Xg8TGzJPc/gD3Zjd5Ai+lcmvIcXQRlW43GVPymtwnPc=; b=dMh2QnQhvSF6YxYqz75ocv6jpJB4qYHzrqmrgpZ+zqtvQNZGO5OzMukx VY6pgsyGC90eUDUJFimubIDAkNctF2EoPdo+mwbD1j2qV8yYPSulIj5RD dSCfuGlaBR4KNBJr5KFaPyV0LEC/81s8ESw3AxMy1hGEhPCSHWxniA5Zz lEiV4S1zDi5KiKArfOPgVBuprd6Mlxg6vmVImc9Ll7Y9GhH28Gqbo4t/r 56KHQQn2IsCYyNexPyyBKJqqTPGWvc3iH91xjC7+PyW1tApp309uhUC8h 0uqX8yEmo6SkYM22jpxMZmVfUOj6cEUUqrMGerknBLfzK2n9mjB8Ui+88 A==; X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=dMh2QnQh Subject: [Intel-wired-lan] [PATCH v1 1/4] ethtool: Add new hwtstamp flag X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, edumazet@google.com, noor.azura.ahmad.tarmizi@intel.com, kuba@kernel.org, muhammad.husaini.zulkifli@intel.com, davem@davemloft.net MIME-Version: 1.0 Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" 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 Signed-off-by: Muhammad Husaini Zulkifli --- 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(-) diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h index fe9893d1485d..07ca8d496e1a 100644 --- a/include/uapi/linux/ethtool.h +++ b/include/uapi/linux/ethtool.h @@ -675,6 +675,7 @@ enum ethtool_link_ext_substate_module { * @ETH_SS_MSG_CLASSES: debug message class names * @ETH_SS_WOL_MODES: wake-on-lan modes * @ETH_SS_SOF_TIMESTAMPING: SOF_TIMESTAMPING_* flags + * @ETH_SS_HWTSTAMP_FLAG: timestamping flags * @ETH_SS_TS_TX_TYPES: timestamping Tx types * @ETH_SS_TS_RX_FILTERS: timestamping Rx filters * @ETH_SS_UDP_TUNNEL_TYPES: UDP tunnel types @@ -700,6 +701,7 @@ enum ethtool_stringset { ETH_SS_MSG_CLASSES, ETH_SS_WOL_MODES, ETH_SS_SOF_TIMESTAMPING, + ETH_SS_HWTSTAMP_FLAG, ETH_SS_TS_TX_TYPES, ETH_SS_TS_RX_FILTERS, ETH_SS_UDP_TUNNEL_TYPES, @@ -1367,6 +1369,7 @@ struct ethtool_ts_info { __u32 cmd; __u32 so_timestamping; __s32 phc_index; + __u32 flag; __u32 tx_types; __u32 tx_reserved[3]; __u32 rx_filters; diff --git a/include/uapi/linux/ethtool_netlink.h b/include/uapi/linux/ethtool_netlink.h index 408a664fad59..58d073b5a6d2 100644 --- a/include/uapi/linux/ethtool_netlink.h +++ b/include/uapi/linux/ethtool_netlink.h @@ -452,6 +452,7 @@ enum { ETHTOOL_A_TSINFO_UNSPEC, ETHTOOL_A_TSINFO_HEADER, /* nest - _A_HEADER_* */ ETHTOOL_A_TSINFO_TIMESTAMPING, /* bitset */ + ETHTOOL_A_TSINFO_FLAG, /* bitset */ ETHTOOL_A_TSINFO_TX_TYPES, /* bitset */ ETHTOOL_A_TSINFO_RX_FILTERS, /* bitset */ ETHTOOL_A_TSINFO_PHC_INDEX, /* u32 */ diff --git a/include/uapi/linux/net_tstamp.h b/include/uapi/linux/net_tstamp.h index 55501e5e7ac8..4966d5ca521f 100644 --- a/include/uapi/linux/net_tstamp.h +++ b/include/uapi/linux/net_tstamp.h @@ -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 }; diff --git a/net/ethtool/common.c b/net/ethtool/common.c index 566adf85e658..f2a178d162ef 100644 --- a/net/ethtool/common.c +++ b/net/ethtool/common.c @@ -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", diff --git a/net/ethtool/common.h b/net/ethtool/common.h index 2dc2b80aea5f..39fedceb82ca 100644 --- a/net/ethtool/common.h +++ b/net/ethtool/common.h @@ -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; @@ -33,6 +34,7 @@ extern const struct link_mode_info link_mode_params[]; extern const char netif_msg_class_names[][ETH_GSTRING_LEN]; extern const char wol_mode_names[][ETH_GSTRING_LEN]; extern const char sof_timestamping_names[][ETH_GSTRING_LEN]; +extern const char ts_flag_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]; diff --git a/net/ethtool/strset.c b/net/ethtool/strset.c index 3f7de54d85fb..2c26cfece494 100644 --- a/net/ethtool/strset.c +++ b/net/ethtool/strset.c @@ -65,6 +65,11 @@ static const struct strset_info info_template[] = { .count = __SOF_TIMESTAMPING_CNT, .strings = sof_timestamping_names, }, + [ETH_SS_HWTSTAMP_FLAG] = { + .per_dev = false, + .count = __HWTSTAMP_FLAG_CNT, + .strings = ts_flag_names, + }, [ETH_SS_TS_TX_TYPES] = { .per_dev = false, .count = __HWTSTAMP_TX_CNT, diff --git a/net/ethtool/tsinfo.c b/net/ethtool/tsinfo.c index 63b5814bd460..84aa15445944 100644 --- a/net/ethtool/tsinfo.c +++ b/net/ethtool/tsinfo.c @@ -50,6 +50,7 @@ static int tsinfo_reply_size(const struct ethnl_req_info *req_base, int ret; BUILD_BUG_ON(__SOF_TIMESTAMPING_CNT > 32); + BUILD_BUG_ON(__HWTSTAMP_FLAG_CNT > 32); BUILD_BUG_ON(__HWTSTAMP_TX_CNT > 32); BUILD_BUG_ON(__HWTSTAMP_FILTER_CNT > 32); @@ -61,6 +62,14 @@ static int tsinfo_reply_size(const struct ethnl_req_info *req_base, return ret; len += ret; /* _TSINFO_TIMESTAMPING */ } + 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 */ + } if (ts_info->tx_types) { ret = ethnl_bitset32_size(&ts_info->tx_types, NULL, __HWTSTAMP_TX_CNT, @@ -100,6 +109,14 @@ static int tsinfo_fill_reply(struct sk_buff *skb, if (ret < 0) return ret; } + 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; + } if (ts_info->tx_types) { ret = ethnl_put_bitset32(skb, ETHTOOL_A_TSINFO_TX_TYPES, &ts_info->tx_types, NULL, From patchwork Tue Sep 27 13:06:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zulkifli, Muhammad Husaini" X-Patchwork-Id: 1683249 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=0qn+VRl9; dkim-atps=neutral Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4McKgJ5snyz1yq7 for ; Tue, 27 Sep 2022 23:08:12 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id D784F606ED; Tue, 27 Sep 2022 13:08:10 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org D784F606ED DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1664284090; bh=l7SpiaJNhstmrboJkav7nxYUSwN6Pe/Q/ge4V7VbXAI=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=0qn+VRl9wIQyQ4Tu+gVgHzefky0EvErfFD5QFLG3JLRJ4TkPZF946U7oImtRfQG0o jiwnyt5lL1aQa51Hedii3vvhvEIkwXldEmioTe0YcKTngI7AJCcmiq9xfOEfMQilJg hhgkzb8WZziXfJWvMSOEa6uoPI1f1EBnMz6VICZcwgyPwJv0l5gtvb7rUUjAwWGYNP p3k4JW4ZBR0zj50pa08MunnK+m51Nr/aL87jFkLx6VwUTwpDTWX/yMLxZ0jsWf/fIl c8gK45Q3P+MZFMCPXPxh1VZATyBbOdmFLL4d57ZIMpJRVUII2so226zHnRFHl98LQj 2xTci4Seg8fng== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FHcxZ0iEJG4C; Tue, 27 Sep 2022 13:08:10 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id D042060A75; Tue, 27 Sep 2022 13:08:09 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org D042060A75 X-Original-To: intel-wired-lan@osuosl.org Delivered-To: intel-wired-lan@osuosl.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 091F91BF47A for ; Tue, 27 Sep 2022 13:08:02 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id D8F768283D for ; Tue, 27 Sep 2022 13:08:01 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org D8F768283D X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id umjD1YgYmGGP for ; Tue, 27 Sep 2022 13:08:01 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 3A48F826BF Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by smtp1.osuosl.org (Postfix) with ESMTPS id 3A48F826BF for ; Tue, 27 Sep 2022 13:08:01 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6500,9779,10483"; a="327667759" X-IronPort-AV: E=Sophos;i="5.93,349,1654585200"; d="scan'208";a="327667759" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2022 06:08:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10483"; a="689984913" X-IronPort-AV: E=Sophos;i="5.93,349,1654585200"; d="scan'208";a="689984913" Received: from zulkifl3-ilbpg0.png.intel.com ([10.88.229.82]) by fmsmga004.fm.intel.com with ESMTP; 27 Sep 2022 06:07:58 -0700 From: Muhammad Husaini Zulkifli To: intel-wired-lan@osuosl.org Date: Tue, 27 Sep 2022 21:06:54 +0800 Message-Id: <20220927130656.32567-3-muhammad.husaini.zulkifli@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220927130656.32567-1-muhammad.husaini.zulkifli@intel.com> References: <20220927130656.32567-1-muhammad.husaini.zulkifli@intel.com> X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664284081; x=1695820081; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=Kog0xSd26qPd6cwbA++KQY6QqoIoX9anF6dCmsdaD68=; b=Lx543zx7GGD94HupvrRLRLwEkAVumG1aQTUFLpbC9ePnM6VTGDoUNoPF uKHkTnpdNhRN8Q4uBcwSWFt1XHkyQGX/BW7f0wl+844irtdO6XSlcrSd7 fJ4utBE8HaIgQ0dOb1poV/WviWguxybzVZ8Utc2V6IJ5znWrXDDo+qsBi MBB1iuF1nfJQM6Nth+yHUzofFMtjCLLtJi1l7hTj11X8KDxL5PivL3j0G SKchOFQT5n03TjnFn7oru94om9TxHWpjQjB6p6A0JY2O1jOQpMfQ2YU/B XZl7fzkcCmmtWz3USW5p2hYnBxZkSler5/pfVQaqfDugnfEML4SkUvBdI w==; X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Lx543zx7 Subject: [Intel-wired-lan] [PATCH v1 2/4] net-timestamp: Increase the size of tsflags X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, edumazet@google.com, noor.azura.ahmad.tarmizi@intel.com, kuba@kernel.org, muhammad.husaini.zulkifli@intel.com, davem@davemloft.net MIME-Version: 1.0 Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Increase the size of tsflags to support more SOF_TIMESTAMPING flags. Current flag size can only support up to 16 flags only. Suggested-by: Vinicius Costa Gomes Signed-off-by: Muhammad Husaini Zulkifli --- include/net/sock.h | 12 ++++++------ net/socket.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/net/sock.h b/include/net/sock.h index 96a31026e35d..6be4d768d7dd 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -503,7 +503,7 @@ struct sock { #if BITS_PER_LONG==32 seqlock_t sk_stamp_seq; #endif - u16 sk_tsflags; + u32 sk_tsflags; u8 sk_shutdown; atomic_t sk_tskey; atomic_t sk_zckey; @@ -1897,7 +1897,7 @@ void sk_send_sigurg(struct sock *sk); struct sockcm_cookie { u64 transmit_time; u32 mark; - u16 tsflags; + u32 tsflags; }; static inline void sockcm_init(struct sockcm_cookie *sockc, @@ -2728,7 +2728,7 @@ static inline void sock_recv_cmsgs(struct msghdr *msg, struct sock *sk, sock_write_timestamp(sk, 0); } -void __sock_tx_timestamp(__u16 tsflags, __u8 *tx_flags); +void __sock_tx_timestamp(__u32 tsflags, __u8 *tx_flags); /** * _sock_tx_timestamp - checks whether the outgoing packet is to be time stamped @@ -2739,7 +2739,7 @@ void __sock_tx_timestamp(__u16 tsflags, __u8 *tx_flags); * * Note: callers should take care of initial ``*tx_flags`` value (usually 0) */ -static inline void _sock_tx_timestamp(struct sock *sk, __u16 tsflags, +static inline void _sock_tx_timestamp(struct sock *sk, __u32 tsflags, __u8 *tx_flags, __u32 *tskey) { if (unlikely(tsflags)) { @@ -2752,13 +2752,13 @@ static inline void _sock_tx_timestamp(struct sock *sk, __u16 tsflags, *tx_flags |= SKBTX_WIFI_STATUS; } -static inline void sock_tx_timestamp(struct sock *sk, __u16 tsflags, +static inline void sock_tx_timestamp(struct sock *sk, __u32 tsflags, __u8 *tx_flags) { _sock_tx_timestamp(sk, tsflags, tx_flags, NULL); } -static inline void skb_setup_tx_timestamp(struct sk_buff *skb, __u16 tsflags) +static inline void skb_setup_tx_timestamp(struct sk_buff *skb, __u32 tsflags) { _sock_tx_timestamp(skb->sk, tsflags, &skb_shinfo(skb)->tx_flags, &skb_shinfo(skb)->tskey); diff --git a/net/socket.c b/net/socket.c index 7378375d3a5b..34ddb5d6889e 100644 --- a/net/socket.c +++ b/net/socket.c @@ -679,7 +679,7 @@ void sock_release(struct socket *sock) } EXPORT_SYMBOL(sock_release); -void __sock_tx_timestamp(__u16 tsflags, __u8 *tx_flags) +void __sock_tx_timestamp(__u32 tsflags, __u8 *tx_flags) { u8 flags = *tx_flags; From patchwork Tue Sep 27 13:06:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zulkifli, Muhammad Husaini" X-Patchwork-Id: 1683250 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.133; helo=smtp2.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=QXn+5GXp; dkim-atps=neutral Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4McKgP5Jx0z1yq7 for ; Tue, 27 Sep 2022 23:08:17 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id EE2F440121; Tue, 27 Sep 2022 13:08:15 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org EE2F440121 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1664284096; bh=N6Yeblg0/NK3AfqWSSXSFLcdZtpHet6vrzuL4XUjHq4=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=QXn+5GXpgbm/U4wJF+Ig2zCeRUxWbaRfT5ZjZYcKrnhpMK2eMCEHKF/SC/+4JkN5O xmOiqPLvh9vZi30nNDFHZkb3as9453jcDtqNbgjTdMr9/T82h//k3nAEZNCtmMb6qn Oeaw0htc1cJPgB80Fnxqh76B6lQLdkdqDfjvY/pXwYme93N3yNB3FHbMqFWkTqM1yd nHJDdTQXvlen/wlnMEl4v//qCeWj2lr2ZT4pZYEe33FRcFu2n2feudGkfyWvN+aJnx mB4cqiJ6bkPsDatPgfqCA6ZyzlLhRBApZoLBQRILRVuvXlc0nzH44SnrhgRYuUiRfd xnQm448w4VGUQ== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VSHXzeHhdGPu; Tue, 27 Sep 2022 13:08:14 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp2.osuosl.org (Postfix) with ESMTP id E51954048B; Tue, 27 Sep 2022 13:08:13 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org E51954048B X-Original-To: intel-wired-lan@osuosl.org Delivered-To: intel-wired-lan@osuosl.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 7EC641BF47A for ; Tue, 27 Sep 2022 13:08:04 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 67E2A826BF for ; Tue, 27 Sep 2022 13:08:04 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 67E2A826BF X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5Rtnfoe_R8jC for ; Tue, 27 Sep 2022 13:08:03 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org BFBE0825B9 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by smtp1.osuosl.org (Postfix) with ESMTPS id BFBE0825B9 for ; Tue, 27 Sep 2022 13:08:03 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6500,9779,10483"; a="327667769" X-IronPort-AV: E=Sophos;i="5.93,349,1654585200"; d="scan'208";a="327667769" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2022 06:08:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10483"; a="689984934" X-IronPort-AV: E=Sophos;i="5.93,349,1654585200"; d="scan'208";a="689984934" Received: from zulkifl3-ilbpg0.png.intel.com ([10.88.229.82]) by fmsmga004.fm.intel.com with ESMTP; 27 Sep 2022 06:08:01 -0700 From: Muhammad Husaini Zulkifli To: intel-wired-lan@osuosl.org Date: Tue, 27 Sep 2022 21:06:55 +0800 Message-Id: <20220927130656.32567-4-muhammad.husaini.zulkifli@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220927130656.32567-1-muhammad.husaini.zulkifli@intel.com> References: <20220927130656.32567-1-muhammad.husaini.zulkifli@intel.com> X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664284083; x=1695820083; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=DZNjweI9TdozcGmRC02pghiJtsrhevsDJXl1aTUhKCY=; b=aagn1U3fSS8hGzCUHKYGKpqYtvcZvFbVIf/+vgWDhPVvWyTP0iVDK0uD upOQpuY9KBruJuGNf3jBtqDd6wOKLmMDX/RC7TenfmZyBiKPJpp33eeyi OV+wKbecIOhTOmcliWxmHp5DMW/fU6t6UJN1ib2neHBbDCxKSAOfsbtoz bS60V2+X49gXAg+Jlymdk7BvEt8egsaPQ5oJgblrSFu2YWr+V5S210RIB EKq/UzvUx44z1HpctbRNEGcVJGyJw6Mq9z2BPsXy3wm5sLURo4V/IpeHe 7mc1QAF4uh9eYz86yP6O04djGhKT5sTTxxkWPotRvpZsgm/CzCJOmgmuw g==; X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=aagn1U3f Subject: [Intel-wired-lan] [PATCH v1 3/4] net: sock: extend SO_TIMESTAMPING for DMA Fetch X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, edumazet@google.com, noor.azura.ahmad.tarmizi@intel.com, kuba@kernel.org, muhammad.husaini.zulkifli@intel.com, davem@davemloft.net MIME-Version: 1.0 Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" This patch is to extend SO_TIMESTAMPING API to support the DMA Time Stamp by adding a new flag SOF_TIMESTAMPING_TX_HARDWARE_DMA_FETCH. User space application can configure this flag into hwtstamp_config flag if require to use the DMA Time Stamp for that socket application. Suggested-by: Vinicius Costa Gomes Signed-off-by: Muhammad Husaini Zulkifli --- include/linux/skbuff.h | 3 +++ include/uapi/linux/net_tstamp.h | 6 ++++-- net/ethtool/common.c | 1 + net/socket.c | 3 +++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index f15d5b62539b..7a79ffa7799d 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -485,6 +485,9 @@ enum { /* generate software time stamp when entering packet scheduling */ SKBTX_SCHED_TSTAMP = 1 << 6, + + /* generate hardware DMA time stamp */ + SKBTX_HW_DMA_TSTAMP = 1 << 7, }; #define SKBTX_ANY_SW_TSTAMP (SKBTX_SW_TSTAMP | \ diff --git a/include/uapi/linux/net_tstamp.h b/include/uapi/linux/net_tstamp.h index 4966d5ca521f..c9e113cea883 100644 --- a/include/uapi/linux/net_tstamp.h +++ b/include/uapi/linux/net_tstamp.h @@ -31,8 +31,9 @@ enum { SOF_TIMESTAMPING_OPT_PKTINFO = (1<<13), SOF_TIMESTAMPING_OPT_TX_SWHW = (1<<14), SOF_TIMESTAMPING_BIND_PHC = (1 << 15), + SOF_TIMESTAMPING_TX_HARDWARE_DMA_FETCH = (1 << 16), - SOF_TIMESTAMPING_LAST = SOF_TIMESTAMPING_BIND_PHC, + SOF_TIMESTAMPING_LAST = SOF_TIMESTAMPING_TX_HARDWARE_DMA_FETCH, SOF_TIMESTAMPING_MASK = (SOF_TIMESTAMPING_LAST - 1) | SOF_TIMESTAMPING_LAST }; @@ -45,7 +46,8 @@ enum { #define SOF_TIMESTAMPING_TX_RECORD_MASK (SOF_TIMESTAMPING_TX_HARDWARE | \ SOF_TIMESTAMPING_TX_SOFTWARE | \ SOF_TIMESTAMPING_TX_SCHED | \ - SOF_TIMESTAMPING_TX_ACK) + SOF_TIMESTAMPING_TX_ACK | \ + SOF_TIMESTAMPING_TX_HARDWARE_DMA_FETCH) /** * struct so_timestamping - SO_TIMESTAMPING parameter diff --git a/net/ethtool/common.c b/net/ethtool/common.c index f2a178d162ef..24f8e7f9b4a5 100644 --- a/net/ethtool/common.c +++ b/net/ethtool/common.c @@ -403,6 +403,7 @@ const char sof_timestamping_names[][ETH_GSTRING_LEN] = { [const_ilog2(SOF_TIMESTAMPING_OPT_PKTINFO)] = "option-pktinfo", [const_ilog2(SOF_TIMESTAMPING_OPT_TX_SWHW)] = "option-tx-swhw", [const_ilog2(SOF_TIMESTAMPING_BIND_PHC)] = "bind-phc", + [const_ilog2(SOF_TIMESTAMPING_TX_HARDWARE_DMA_FETCH)] = "hardware-dma-transmit", }; static_assert(ARRAY_SIZE(sof_timestamping_names) == __SOF_TIMESTAMPING_CNT); diff --git a/net/socket.c b/net/socket.c index 34ddb5d6889e..dfb9fa693a11 100644 --- a/net/socket.c +++ b/net/socket.c @@ -695,6 +695,9 @@ void __sock_tx_timestamp(__u32 tsflags, __u8 *tx_flags) flags |= SKBTX_HW_TSTAMP_USE_CYCLES; } + if (tsflags & SOF_TIMESTAMPING_TX_HARDWARE_DMA_FETCH) + flags |= SKBTX_HW_DMA_TSTAMP; + if (tsflags & SOF_TIMESTAMPING_TX_SOFTWARE) flags |= SKBTX_SW_TSTAMP; From patchwork Tue Sep 27 13:06:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zulkifli, Muhammad Husaini" X-Patchwork-Id: 1683251 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=63glRze+; dkim-atps=neutral Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4McKgW6spZz1yq7 for ; Tue, 27 Sep 2022 23:08:23 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 36E3B60A87; Tue, 27 Sep 2022 13:08:22 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 36E3B60A87 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1664284102; bh=Qiiqmcv5RlxThc6sk0Mj0Tw2UmW6P5HpkQ1/OdtBrSs=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=63glRze+0wr5hdKv6CaTdz77VK69kZZpotcsf+/fEk93utBBci/Q5afw8C19Im6cb cmRLQheVuqy6MQcMAvDCyaZkKq4+h8Pc1Krgtg4cSv1mv8my+HZbR9o5W+wGkf0Jp5 2nmgJK/zdubRZZ+yLLBoyFHL8Re3MCjQs6XYQ/+qonFs9fCpxjR2Bj85WmnqwYnEQe ITKNOLBhsm0AfgdTYlbKNRwSN6hFiAOWUDVF1p6aFpwyDuS3JGL4DsyPbMILx8LhH3 XrYrSEJqyCIf8T2UwIGXpzI53TmUOwX97uqiNtYb2F9HBEHJKHoe8UHC7gD/VACmoA gSqW1nAIg7dOw== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8kXIsyXl_wKp; Tue, 27 Sep 2022 13:08:18 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id 1804D60ADB; Tue, 27 Sep 2022 13:08:18 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 1804D60ADB X-Original-To: intel-wired-lan@osuosl.org Delivered-To: intel-wired-lan@osuosl.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id E5E031BF47A for ; Tue, 27 Sep 2022 13:08:07 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id C18AE826BF for ; Tue, 27 Sep 2022 13:08:07 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org C18AE826BF X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id F8Nl0A1JCupL for ; Tue, 27 Sep 2022 13:08:06 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org A5835825B9 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by smtp1.osuosl.org (Postfix) with ESMTPS id A5835825B9 for ; Tue, 27 Sep 2022 13:08:06 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6500,9779,10483"; a="327667777" X-IronPort-AV: E=Sophos;i="5.93,349,1654585200"; d="scan'208";a="327667777" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2022 06:08:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10483"; a="689984956" X-IronPort-AV: E=Sophos;i="5.93,349,1654585200"; d="scan'208";a="689984956" Received: from zulkifl3-ilbpg0.png.intel.com ([10.88.229.82]) by fmsmga004.fm.intel.com with ESMTP; 27 Sep 2022 06:08:03 -0700 From: Muhammad Husaini Zulkifli To: intel-wired-lan@osuosl.org Date: Tue, 27 Sep 2022 21:06:56 +0800 Message-Id: <20220927130656.32567-5-muhammad.husaini.zulkifli@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220927130656.32567-1-muhammad.husaini.zulkifli@intel.com> References: <20220927130656.32567-1-muhammad.husaini.zulkifli@intel.com> X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664284086; x=1695820086; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=c3+msq/2FisQRAngg7DD893rNAxDf1zOzNzJekBmVuo=; b=WF+NJgXwqJ+MsybrHdwUIh6Qj+sEDPdlCD+KIAVKGw9mZwtqEZ96yYN0 LaQ8+hiNktSJmxZkiYvZyp0bHKMVf9UcxrraIzGT5nX8tCUtjwanV/GLR g+VPUYjcbFwcHmuMBoJXBdfrya5XCpTA+zWkTUxH8ZH1PAuOvnrr+9S0R RWjT3WmDoGf3Clm7rL0ObCMDWq1ZU0iZvOgNVsk/pvhJLogAmsHqSkraq +sGBVeM8ufIKHw4W41BFmnTgCH0aXhTIB9+JSOtWfm5TLQqwgLV8RioCX uVP1fiytMAJlIxhO3tHK+SOlNvViLtrjcVX/lV/aOQTBgXP9WuwBf4bCi g==; X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=WF+NJgXw Subject: [Intel-wired-lan] [PATCH v1 4/4] igc: Add support for DMA timestamp for non-PTP packets X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, edumazet@google.com, noor.azura.ahmad.tarmizi@intel.com, kuba@kernel.org, muhammad.husaini.zulkifli@intel.com, davem@davemloft.net MIME-Version: 1.0 Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Vinicius Costa Gomes For PTP traffic, timestamp is retrieved from TXSTMP register. For all other packets, DMA time stamp field of the Transmit Descriptor Write-back is used. If the TXSTAMPO register is used for both PTP and non-PTP packets, there is a significant possibility that the time stamp for a PTP packet will be lost when there is a lot of traffic. This patch introduce to use the DMA Time Stamp for non PTP packet to solve the current issue. User application can add new SOF_TIMESTAMPING flag SOF_TIMESTAMPING_TX_HARDWARE_DMA_FETCH when configure the hwtstamp_config for the socket option if require DMA Time Stamp. Before: ptp4l: rms 2 max 5 freq -3404 +/- 3 delay 1 +/- 0 ptp4l: rms 3 max 6 freq -3400 +/- 3 delay 1 +/- 0 ptp4l: rms 2 max 4 freq -3400 +/- 3 delay 1 +/- 0 ptp4l: timed out while polling for tx timestamp ptp4l: increasing tx_timestamp_timeout may correct this issue, but it is likely caused by a driver bug ptp4l: port 1 (enp170s0.vlan): send peer delay response failed ptp4l: port 1 (enp170s0.vlan): SLAVE to FAULTY on FAULT_DETECTED ptp4l: port 1 (enp170s0.vlan): FAULTY to LISTENING on INIT_COMPLETE ptp4l: port 1 (enp170s0.vlan): LISTENING to MASTER on ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES ptp4l: selected local clock aa00aa.fffe.00aa00 as best master ptp4l: port 1 (enp170s0.vlan): assuming the grand master role ptp4l: port 1 (enp170s0.vlan): new foreign master 22bb22.fffe.bb22bb-1 ptp4l: selected best master clock 22bb22.fffe.bb22bb ptp4l: port 1 (enp170s0.vlan): MASTER to UNCALIBRATED on RS_SLAVE ptp4l: port 1 (enp170s0.vlan): UNCALIBRATED to SLAVE on MASTER_CLOCK_SELECTED ptp4l: rms 39 max 66 freq -3355 +/- 45 delay 1 +/- 0 ptp4l: rms 20 max 36 freq -3339 +/- 12 delay 1 +/- 0 ptp4l: rms 11 max 18 freq -3371 +/- 11 delay 1 +/- 0 ptp4l: rms 10 max 16 freq -3384 +/- 2 delay 1 +/- 0 ptp4l: rms 1 max 2 freq -3375 +/- 2 delay 1 +/- 0 ptp4l: rms 3 max 6 freq -3373 +/- 4 delay 0 +/- 0 After: ptp4l: rms 3 max 4 freq -3386 +/- 4 delay 0 +/- 0 ptp4l: rms 3 max 7 freq -3380 +/- 3 delay 0 +/- 0 ptp4l: rms 3 max 6 freq -3380 +/- 3 delay 0 +/- 0 ptp4l: rms 1 max 3 freq -3381 +/- 2 delay 0 +/- 0 ptp4l: rms 3 max 5 freq -3377 +/- 2 delay 0 +/- 0 ptp4l: rms 2 max 3 freq -3377 +/- 2 delay 0 +/- 0 ptp4l: rms 3 max 6 freq -3375 +/- 4 delay 0 +/- 0 ptp4l: rms 2 max 4 freq -3380 +/- 2 delay 1 +/- 0 ptp4l: rms 4 max 7 freq -3385 +/- 3 delay 0 +/- 0 ptp4l: rms 2 max 3 freq -3384 +/- 2 delay 0 +/- 0 ptp4l: rms 4 max 7 freq -3376 +/- 2 delay 0 +/- 0 ptp4l: rms 3 max 5 freq -3376 +/- 4 delay 0 +/- 0 ptp4l: rms 3 max 5 freq -3382 +/- 2 delay 0 +/- 0 ptp4l: rms 5 max 7 freq -3389 +/- 2 delay 0 +/- 0 ptp4l: rms 3 max 4 freq -3388 +/- 3 delay 1 +/- 0 ptp4l: rms 3 max 5 freq -3387 +/- 4 delay 1 +/- 0 ptp4l: rms 5 max 8 freq -3395 +/- 3 delay 1 +/- 0 ptp4l: rms 5 max 8 freq -3399 +/- 4 delay 0 +/- 0 ptp4l: rms 2 max 5 freq -3397 +/- 3 delay 1 +/- 0 ptp4l: rms 2 max 4 freq -3397 +/- 3 delay 1 +/- 0 ptp4l: rms 2 max 3 freq -3397 +/- 2 delay 1 +/- 0 ptp4l: rms 3 max 5 freq -3391 +/- 2 delay 2 +/- 0 Test Setup: back-to-back communication between Host and DUT. Host will act as transmitter and DUT will become receiver. Host will generate the packet using sample application with timestamping_flag of SOF_TIMESTAMPING_TX_HARDWARE_DMA_FETCH and hwtstamp_config flag of HWTSTAMP_FLAG_DMA_TIMESTAMP. Signed-off-by: Vinicius Costa Gomes Co-developed-by: Muhammad Husaini Zulkifli Signed-off-by: Muhammad Husaini Zulkifli Co-developed-by: Aravindhan Gunasekaran Signed-off-by: Aravindhan Gunasekaran Signed-off-by: Muhammad Husaini Zulkifli --- drivers/net/ethernet/intel/igc/igc.h | 10 +++ drivers/net/ethernet/intel/igc/igc_base.h | 2 +- drivers/net/ethernet/intel/igc/igc_defines.h | 2 + drivers/net/ethernet/intel/igc/igc_ethtool.c | 5 +- drivers/net/ethernet/intel/igc/igc_main.c | 24 ++++-- drivers/net/ethernet/intel/igc/igc_ptp.c | 83 ++++++++++++++++++++ 6 files changed, 119 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc.h b/drivers/net/ethernet/intel/igc/igc.h index 1e7e7071f64d..38a24b5260d1 100644 --- a/drivers/net/ethernet/intel/igc/igc.h +++ b/drivers/net/ethernet/intel/igc/igc.h @@ -348,6 +348,12 @@ extern char igc_driver_name[]; #define IGC_I225_RX_LATENCY_1000 300 #define IGC_I225_RX_LATENCY_2500 1485 +/* Transmit latency (for DMA timestamps) in nanosecond */ +#define IGC_I225_TX_DMA_LATENCY_10 13100 +#define IGC_I225_TX_DMA_LATENCY_100 1410 +#define IGC_I225_TX_DMA_LATENCY_1000 285 +#define IGC_I225_TX_DMA_LATENCY_2500 1485 + /* RX and TX descriptor control thresholds. * PTHRESH - MAC will consider prefetch if it has fewer than this number of * descriptors available in its onboard memory. @@ -410,6 +416,8 @@ enum igc_tx_flags { /* olinfo flags */ IGC_TX_FLAGS_IPV4 = 0x10, IGC_TX_FLAGS_CSUM = 0x20, + + IGC_TX_FLAGS_DMA_TSTAMP = 0x200, }; enum igc_boards { @@ -627,6 +635,8 @@ void igc_ptp_reset(struct igc_adapter *adapter); void igc_ptp_suspend(struct igc_adapter *adapter); void igc_ptp_stop(struct igc_adapter *adapter); ktime_t igc_ptp_rx_pktstamp(struct igc_adapter *adapter, __le32 *buf); +void igc_ptp_tx_dma_tstamp(struct igc_adapter *adapter, + struct sk_buff *skb, u64 tstamp); int igc_ptp_set_ts_config(struct net_device *netdev, struct ifreq *ifr); int igc_ptp_get_ts_config(struct net_device *netdev, struct ifreq *ifr); void igc_ptp_tx_hang(struct igc_adapter *adapter); diff --git a/drivers/net/ethernet/intel/igc/igc_base.h b/drivers/net/ethernet/intel/igc/igc_base.h index ce530f5fd7bd..672cf2d92165 100644 --- a/drivers/net/ethernet/intel/igc/igc_base.h +++ b/drivers/net/ethernet/intel/igc/igc_base.h @@ -16,7 +16,7 @@ union igc_adv_tx_desc { __le32 olinfo_status; } read; struct { - __le64 rsvd; /* Reserved */ + __le64 dma_tstamp; __le32 nxtseq_seed; __le32 status; } wb; diff --git a/drivers/net/ethernet/intel/igc/igc_defines.h b/drivers/net/ethernet/intel/igc/igc_defines.h index f7311aeb293b..baedf48b4e2e 100644 --- a/drivers/net/ethernet/intel/igc/igc_defines.h +++ b/drivers/net/ethernet/intel/igc/igc_defines.h @@ -312,6 +312,7 @@ #define IGC_TXD_CMD_DEXT 0x20000000 /* Desc extension (0 = legacy) */ #define IGC_TXD_CMD_VLE 0x40000000 /* Add VLAN tag */ #define IGC_TXD_STAT_DD 0x00000001 /* Descriptor Done */ +#define IGC_TXD_STAT_TS_STAT 0x00000002 /* DMA Timestamp in packet */ #define IGC_TXD_CMD_TCP 0x01000000 /* TCP packet */ #define IGC_TXD_CMD_IP 0x02000000 /* IP packet */ #define IGC_TXD_CMD_TSE 0x04000000 /* TCP Seg enable */ @@ -520,6 +521,7 @@ /* Transmit Scheduling */ #define IGC_TQAVCTRL_TRANSMIT_MODE_TSN 0x00000001 #define IGC_TQAVCTRL_ENHANCED_QAV 0x00000008 +#define IGC_TQAVCTRL_1588_STAT_EN 0x00000004 #define IGC_TXQCTL_QUEUE_MODE_LAUNCHT 0x00000001 #define IGC_TXQCTL_STRICT_CYCLE 0x00000002 diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c index 8cc077b712ad..7d198fb6d619 100644 --- a/drivers/net/ethernet/intel/igc/igc_ethtool.c +++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c @@ -1532,7 +1532,8 @@ static int igc_ethtool_get_ts_info(struct net_device *dev, SOF_TIMESTAMPING_SOFTWARE | SOF_TIMESTAMPING_TX_HARDWARE | SOF_TIMESTAMPING_RX_HARDWARE | - SOF_TIMESTAMPING_RAW_HARDWARE; + SOF_TIMESTAMPING_RAW_HARDWARE | + SOF_TIMESTAMPING_TX_HARDWARE_DMA_FETCH; info->tx_types = BIT(HWTSTAMP_TX_OFF) | @@ -1541,6 +1542,8 @@ static int igc_ethtool_get_ts_info(struct net_device *dev, info->rx_filters = BIT(HWTSTAMP_FILTER_NONE); info->rx_filters |= BIT(HWTSTAMP_FILTER_ALL); + info->flag = HWTSTAMP_FLAG_DMA_TIMESTAMP; + return 0; default: return -EOPNOTSUPP; diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index 97b9edb5153e..afcf98cd6117 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -1415,6 +1415,7 @@ static int igc_tso(struct igc_ring *tx_ring, static netdev_tx_t igc_xmit_frame_ring(struct sk_buff *skb, struct igc_ring *tx_ring) { + struct igc_adapter *adapter = netdev_priv(tx_ring->netdev); u16 count = TXD_USE_COUNT(skb_headlen(skb)); __be16 protocol = vlan_get_protocol(skb); struct igc_tx_buffer *first; @@ -1445,16 +1446,14 @@ static netdev_tx_t igc_xmit_frame_ring(struct sk_buff *skb, first->bytecount = skb->len; first->gso_segs = 1; - if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) { - struct igc_adapter *adapter = netdev_priv(tx_ring->netdev); - + if (unlikely((skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) && + !(skb_shinfo(skb)->tx_flags & SKBTX_HW_DMA_TSTAMP))) { /* FIXME: add support for retrieving timestamps from * the other timer registers before skipping the * timestamping request. */ if (adapter->tstamp_config.tx_type == HWTSTAMP_TX_ON && - !test_and_set_bit_lock(__IGC_PTP_TX_IN_PROGRESS, - &adapter->state)) { + !test_and_set_bit_lock(__IGC_PTP_TX_IN_PROGRESS, &adapter->state)) { skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; tx_flags |= IGC_TX_FLAGS_TSTAMP; @@ -1463,6 +1462,14 @@ static netdev_tx_t igc_xmit_frame_ring(struct sk_buff *skb, } else { adapter->tx_hwtstamp_skipped++; } + } else if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_DMA_TSTAMP)) { + if (adapter->tstamp_config.tx_type == HWTSTAMP_TX_ON && + adapter->tstamp_config.flags == HWTSTAMP_FLAG_DMA_TIMESTAMP) { + skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; + tx_flags |= IGC_TX_FLAGS_DMA_TSTAMP; + } else { + adapter->tx_hwtstamp_skipped++; + } } if (skb_vlan_tag_present(skb)) { @@ -2741,6 +2748,13 @@ static bool igc_clean_tx_irq(struct igc_q_vector *q_vector, int napi_budget) if (!(eop_desc->wb.status & cpu_to_le32(IGC_TXD_STAT_DD))) break; + if (eop_desc->wb.status & cpu_to_le32(IGC_TXD_STAT_TS_STAT) && + tx_buffer->tx_flags & IGC_TX_FLAGS_DMA_TSTAMP) { + u64 tstamp = le64_to_cpu(eop_desc->wb.dma_tstamp); + + igc_ptp_tx_dma_tstamp(adapter, tx_buffer->skb, tstamp); + } + /* clear next_to_watch to prevent false hangs */ tx_buffer->next_to_watch = NULL; diff --git a/drivers/net/ethernet/intel/igc/igc_ptp.c b/drivers/net/ethernet/intel/igc/igc_ptp.c index 8dbb9f903ca7..631972d7e97b 100644 --- a/drivers/net/ethernet/intel/igc/igc_ptp.c +++ b/drivers/net/ethernet/intel/igc/igc_ptp.c @@ -432,6 +432,29 @@ static void igc_ptp_systim_to_hwtstamp(struct igc_adapter *adapter, } } +static void igc_ptp_dma_time_to_hwtstamp(struct igc_adapter *adapter, + struct skb_shared_hwtstamps *hwtstamps, + u64 systim) +{ + struct igc_hw *hw = &adapter->hw; + u32 sec, nsec; + + nsec = rd32(IGC_SYSTIML); + sec = rd32(IGC_SYSTIMH); + + if (unlikely(nsec < (systim & 0xFFFFFFFF))) + --sec; + + switch (adapter->hw.mac.type) { + case igc_i225: + memset(hwtstamps, 0, sizeof(*hwtstamps)); + hwtstamps->hwtstamp = ktime_set(sec, systim & 0xFFFFFFFF); + break; + default: + break; + } +} + /** * igc_ptp_rx_pktstamp - Retrieve timestamp from Rx packet buffer * @adapter: Pointer to adapter the packet buffer belongs to @@ -549,6 +572,28 @@ static void igc_ptp_enable_tx_timestamp(struct igc_adapter *adapter) rd32(IGC_TXSTMPH); } +static void igc_ptp_disable_dma_timestamp(struct igc_adapter *adapter) +{ + struct igc_hw *hw = &adapter->hw; + u32 tqavctrl; + + tqavctrl = rd32(IGC_TQAVCTRL); + tqavctrl &= ~IGC_TQAVCTRL_1588_STAT_EN; + + wr32(IGC_TQAVCTRL, tqavctrl); +} + +static void igc_ptp_enable_dma_timestamp(struct igc_adapter *adapter) +{ + struct igc_hw *hw = &adapter->hw; + u32 tqavctrl; + + tqavctrl = rd32(IGC_TQAVCTRL); + tqavctrl |= IGC_TQAVCTRL_1588_STAT_EN; + + wr32(IGC_TQAVCTRL, tqavctrl); +} + /** * igc_ptp_set_timestamp_mode - setup hardware for timestamping * @adapter: networking device structure @@ -562,9 +607,14 @@ static int igc_ptp_set_timestamp_mode(struct igc_adapter *adapter, switch (config->tx_type) { case HWTSTAMP_TX_OFF: igc_ptp_disable_tx_timestamp(adapter); + igc_ptp_disable_dma_timestamp(adapter); break; case HWTSTAMP_TX_ON: igc_ptp_enable_tx_timestamp(adapter); + + /* Ensure that flag only can be used during HWTSTAMP_TX_ON */ + if (config->flags == HWTSTAMP_FLAG_DMA_TIMESTAMP) + igc_ptp_enable_dma_timestamp(adapter); break; default: return -ERANGE; @@ -683,6 +733,39 @@ static void igc_ptp_tx_hwtstamp(struct igc_adapter *adapter) dev_kfree_skb_any(skb); } +void igc_ptp_tx_dma_tstamp(struct igc_adapter *adapter, + struct sk_buff *skb, u64 tstamp) +{ + struct skb_shared_hwtstamps shhwtstamps; + int adjust = 0; + + if (!(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS)) + return; + + igc_ptp_dma_time_to_hwtstamp(adapter, &shhwtstamps, tstamp); + + switch (adapter->link_speed) { + case SPEED_10: + adjust = IGC_I225_TX_DMA_LATENCY_10; + break; + case SPEED_100: + adjust = IGC_I225_TX_DMA_LATENCY_100; + break; + case SPEED_1000: + adjust = IGC_I225_TX_DMA_LATENCY_1000; + break; + case SPEED_2500: + adjust = IGC_I225_TX_DMA_LATENCY_2500; + break; + } + + shhwtstamps.hwtstamp = + ktime_add_ns(shhwtstamps.hwtstamp, adjust); + + /* Notify the stack and free the skb after we've unlocked */ + skb_tstamp_tx(skb, &shhwtstamps); +} + /** * igc_ptp_tx_work * @work: pointer to work struct