mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dong Zhu <bluezhudong@gmail.com>
To: Richard Cochran <richardcochran@gmail.com>
Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>,
	Jeff Kirsher <jeffrey.t.kirsher@intel.com>,
	Jesse Brandeburg <jesse.brandeburg@intel.com>,
	Bruce Allan <bruce.w.allan@intel.com>,
	Carolyn Wyborny <carolyn.wyborny@intel.com>,
	Don Skidmore <donald.c.skidmore@intel.com>,
	Greg Rose <gregory.v.rose@intel.com>,
	Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com>,
	Alex Duyck <alexander.h.duyck@intel.com>,
	John Ronciak <john.ronciak@intel.com>,
	Tushar Dave <tushar.n.dave@intel.com>,
	Matthew Vick <matthew.vick@intel.com>,
	Jacob Keller <Jacob.e.keller@intel.com>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	David Howells <dhowells@redhat.com>,
	Dave Jones <davej@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-kernel@vger.kernel.org, e1000-devel@lists.sourceforge.net,
	netdev@vger.kernel.org
Subject: Re: [PATCH] igb: add a method to get the nic hw time stamping policy
Date: Mon, 13 May 2013 18:07:42 +0800	[thread overview]
Message-ID: <20130513100742.GM8399@zhudong.nay.redhat.com> (raw)
In-Reply-To: <20130513043140.GA2567@netboy>

> You could use the flags field, as it has no definition yet.
> 
> But you still need to explain why this new functionality is needed in
> the first place:
> 
> - You can query an interface's time stamping capabilities with the
>   GET_TS_INFO ethtool command.
> 

Hi,

I modified this patch and added the method to igb_get_ts_info function.
For 82576 nic, through this method we can easily check which type of packets
are time stamped now, such as (HWTSTAMP_FILTER_PTP_V1_L4_SYNC and
HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ), then change or disable it up to your requests.
I think it is convenient.The origial GET_TS_INFO method can only show the device’s
time stamping capabilities which nics supported.

I use the tx_reserved[0] and rx_reserved[0] to restore the hwtstamp_tx_types and
hwtstamp_rx_filters enumeration values.

Due to the limitation of 80 characters one line, I have to move the
switch out of else judegment.

I test it on I350 and 82576NS nics and it works as expect.

Could help reviewing it again ? Any comments would be appreciated.


>From 8a12932fd2a3bb5ca904bc72b20140247a5d81be Mon Sep 17 00:00:00 2001
From: Dong Zhu <bluezhudong@gmail.com>
Date: Mon, 13 May 2013 17:27:59 +0800

Currently kernel only support setting the hw time stamping policy
through ioctl,now add a method to check which packets(Outgoing and
Incoming) are time stamped by nic.

Add this to igb_get_ts_info, we can query this by using the GET_TS_INFO
ethtool command. Testing on I350 and 82576NS it seems work well.

Signed-off-by: Dong Zhu <bluezhudong@gmail.com>
---
 drivers/net/ethernet/intel/igb/igb_ethtool.c | 78 +++++++++++++++++++++++++++-
 include/uapi/linux/ethtool.h                 |  3 ++
 2 files changed, 79 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c
index 7876240..49486b8 100644
--- a/drivers/net/ethernet/intel/igb/igb_ethtool.c
+++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c
@@ -2327,6 +2327,8 @@ static int igb_get_ts_info(struct net_device *dev,
 			   struct ethtool_ts_info *info)
 {
 	struct igb_adapter *adapter = netdev_priv(dev);
+	struct e1000_hw *hw = &adapter->hw;
+	u32 regval;
 
 	switch (adapter->hw.mac.type) {
 	case e1000_82575:
@@ -2360,10 +2362,29 @@ static int igb_get_ts_info(struct net_device *dev,
 
 		info->rx_filters = 1 << HWTSTAMP_FILTER_NONE;
 
+		regval = rd32(E1000_TSYNCTXCTL);
+		if (regval & E1000_TSYNCTXCTL_ENABLED)
+			info->tx_reserved[0] = 1 << HWTSTAMP_TX_ON;
+		else
+			info->tx_reserved[0] = 1 << HWTSTAMP_TX_OFF;
+
+		regval = rd32(E1000_TSYNCRXCTL);
+
 		/* 82576 does not support timestamping all packets. */
-		if (adapter->hw.mac.type >= e1000_82580)
+		if (adapter->hw.mac.type >= e1000_82580) {
 			info->rx_filters |= 1 << HWTSTAMP_FILTER_ALL;
-		else
+
+			if (!(regval & E1000_TSYNCRXCTL_ENABLED))
+				info->rx_reserved[0] =
+					1 << HWTSTAMP_FILTER_NONE;
+			else if (E1000_TSYNCRXCTL_TYPE_ALL ==
+					(regval & E1000_TSYNCRXCTL_TYPE_MASK))
+				info->rx_reserved[0] = 1 << HWTSTAMP_FILTER_ALL;
+			else
+				return -ERANGE;
+
+			return 0;
+		} else {
 			info->rx_filters |=
 				(1 << HWTSTAMP_FILTER_PTP_V1_L4_SYNC) |
 				(1 << HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ) |
@@ -2373,6 +2394,59 @@ static int igb_get_ts_info(struct net_device *dev,
 				(1 << HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ) |
 				(1 << HWTSTAMP_FILTER_PTP_V2_EVENT);
 
+			if (!(regval & E1000_TSYNCRXCTL_ENABLED)) {
+				info->rx_reserved[0] =
+					1 << HWTSTAMP_FILTER_NONE;
+				return 0;
+			}
+		}
+
+		switch (regval & E1000_TSYNCRXCTL_TYPE_MASK) {
+		case E1000_TSYNCRXCTL_TYPE_L4_V1:
+			regval = rd32(E1000_TSYNCRXCFG);
+			if (E1000_TSYNCRXCFG_PTP_V1_SYNC_MESSAGE ==
+					(regval &
+					 E1000_TSYNCRXCFG_PTP_V1_CTRLT_MASK))
+				info->rx_reserved[0] =
+					(1 << HWTSTAMP_FILTER_PTP_V1_L4_SYNC);
+			else if (E1000_TSYNCRXCFG_PTP_V1_DELAY_REQ_MESSAGE
+					== (regval &
+					E1000_TSYNCRXCFG_PTP_V1_CTRLT_MASK))
+				info->rx_reserved[0] =
+					(1 <<
+					 HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ);
+			else
+				return -ERANGE;
+			break;
+		case E1000_TSYNCRXCTL_TYPE_L2_L4_V2:
+			regval = rd32(E1000_TSYNCRXCFG);
+			if (E1000_TSYNCRXCFG_PTP_V2_SYNC_MESSAGE ==
+					(regval &
+					 E1000_TSYNCRXCFG_PTP_V2_MSGID_MASK))
+				info->rx_reserved[0] =
+					(1 << HWTSTAMP_FILTER_PTP_V2_L2_SYNC) |
+					(1 << HWTSTAMP_FILTER_PTP_V2_L4_SYNC);
+			else if (E1000_TSYNCRXCFG_PTP_V2_DELAY_REQ_MESSAGE ==
+					(regval &
+					 E1000_TSYNCRXCFG_PTP_V2_MSGID_MASK))
+				info->rx_reserved[0] =
+					(1 <<
+					 HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ) |
+					(1 <<
+					 HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ);
+			else
+				return -ERANGE;
+			break;
+		case E1000_TSYNCRXCTL_TYPE_EVENT_V2:
+			info->rx_reserved[0] =
+				(1 << HWTSTAMP_FILTER_PTP_V2_EVENT) |
+				(1 << HWTSTAMP_FILTER_PTP_V2_SYNC) |
+				(1 << HWTSTAMP_FILTER_PTP_V2_DELAY_REQ);
+			break;
+		default:
+			return -ERANGE;
+		}
+
 		return 0;
 	default:
 		return -EOPNOTSUPP;
diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
index 0c9b448..06cdbc0 100644
--- a/include/uapi/linux/ethtool.h
+++ b/include/uapi/linux/ethtool.h
@@ -772,7 +772,10 @@ struct ethtool_sfeatures {
  * @so_timestamping: bit mask of the sum of the supported SO_TIMESTAMPING flags
  * @phc_index: device index of the associated PHC, or -1 if there is none
  * @tx_types: bit mask of the supported hwtstamp_tx_types enumeration values
+ * @tx_reserved[0]: bit mask of the in use hwtstamp_tx_types enumeration values
  * @rx_filters: bit mask of the supported hwtstamp_rx_filters enumeration values
+ * @rx_reserved[0]: bit mask of the in use hwtstamp_rx_filters enumeration
+ * values
  *
  * The bits in the 'tx_types' and 'rx_filters' fields correspond to
  * the 'hwtstamp_tx_types' and 'hwtstamp_rx_filters' enumeration values,
-- 
1.7.11.7


-- 
Best Regards,
Dong Zhu

  reply	other threads:[~2013-05-13 10:09 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-11 14:02 Dong Zhu
2013-05-11 15:31 ` Richard Cochran
2013-05-12 13:11   ` Dong Zhu
2013-05-11 16:51 ` Sergei Shtylyov
2013-05-12 14:25   ` Dong Zhu
2013-05-12 17:24     ` Richard Cochran
2013-05-13  2:12       ` Dong Zhu
2013-05-13  4:31         ` Richard Cochran
2013-05-13 10:07           ` Dong Zhu [this message]
2013-05-13 15:48             ` Vick, Matthew
2013-05-13 16:09               ` Ben Hutchings
2013-05-13 16:47             ` Keller, Jacob E
2013-05-14  9:51             ` Dong Zhu
2013-05-14 10:51               ` Peter P Waskiewicz Jr
2013-05-14 18:59               ` Keller, Jacob E

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130513100742.GM8399@zhudong.nay.redhat.com \
    --to=bluezhudong@gmail.com \
    --cc=Jacob.e.keller@intel.com \
    --cc=alexander.h.duyck@intel.com \
    --cc=bruce.w.allan@intel.com \
    --cc=carolyn.wyborny@intel.com \
    --cc=davej@redhat.com \
    --cc=dhowells@redhat.com \
    --cc=donald.c.skidmore@intel.com \
    --cc=e1000-devel@lists.sourceforge.net \
    --cc=gregory.v.rose@intel.com \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=jesse.brandeburg@intel.com \
    --cc=john.ronciak@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew.vick@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peter.p.waskiewicz.jr@intel.com \
    --cc=richardcochran@gmail.com \
    --cc=sergei.shtylyov@cogentembedded.com \
    --cc=tglx@linutronix.de \
    --cc=tushar.n.dave@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®