netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Stefan Sørensen" <stefan.sorensen@spectralink.com>
To: <davem@davemloft.net>
Cc: netdev@vger.kernel.org, richardcochran@gmail.com,
	"Stefan Sørensen" <stefan.sorensen@spectralink.com>
Subject: [PATCH net-next 5/5] dp83640: Only wait for timestamps for packets with timestamping enabled.
Date: Fri, 30 Oct 2015 13:14:04 +0100	[thread overview]
Message-ID: <1446207244-2206-6-git-send-email-stefan.sorensen@spectralink.com> (raw)
In-Reply-To: <1446207244-2206-1-git-send-email-stefan.sorensen@spectralink.com>

In the packet timestamping function, check that the ptp version and
protocol of the packet matches what we have configured the hardware to
actually generate timestamps for, before looking/waiting for a timestamp.

Signed-off-by: Stefan Sørensen <stefan.sorensen@spectralink.com>
---
 drivers/net/phy/dp83640.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c
index c1f70b7..30bfeb1 100644
--- a/drivers/net/phy/dp83640.c
+++ b/drivers/net/phy/dp83640.c
@@ -37,8 +37,6 @@
 
 #define DP83640_PHY_ID	0x20005ce1
 #define PAGESEL		0x13
-#define LAYER4		0x02
-#define LAYER2		0x01
 #define MAX_RXTS	64
 #define N_EXT_TS	6
 #define N_PER_OUT	7
@@ -1292,29 +1290,29 @@ static int dp83640_hwtstamp(struct phy_device *phydev, struct ifreq *ifr)
 	case HWTSTAMP_FILTER_PTP_V1_L4_SYNC:
 	case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:
 		dp83640->hwts_rx_en = 1;
-		dp83640->layer = LAYER4;
-		dp83640->version = 1;
+		dp83640->layer = PTP_CLASS_L4;
+		dp83640->version = PTP_CLASS_V1;
 		break;
 	case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
 	case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
 	case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
 		dp83640->hwts_rx_en = 1;
-		dp83640->layer = LAYER4;
-		dp83640->version = 2;
+		dp83640->layer = PTP_CLASS_L4;
+		dp83640->version = PTP_CLASS_V2;
 		break;
 	case HWTSTAMP_FILTER_PTP_V2_L2_EVENT:
 	case HWTSTAMP_FILTER_PTP_V2_L2_SYNC:
 	case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ:
 		dp83640->hwts_rx_en = 1;
-		dp83640->layer = LAYER2;
-		dp83640->version = 2;
+		dp83640->layer = PTP_CLASS_L2;
+		dp83640->version = PTP_CLASS_V2;
 		break;
 	case HWTSTAMP_FILTER_PTP_V2_EVENT:
 	case HWTSTAMP_FILTER_PTP_V2_SYNC:
 	case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
 		dp83640->hwts_rx_en = 1;
-		dp83640->layer = LAYER4|LAYER2;
-		dp83640->version = 2;
+		dp83640->layer = PTP_CLASS_L4 | PTP_CLASS_L2;
+		dp83640->version = PTP_CLASS_V2;
 		break;
 	default:
 		return -ERANGE;
@@ -1323,11 +1321,11 @@ static int dp83640_hwtstamp(struct phy_device *phydev, struct ifreq *ifr)
 	txcfg0 = (dp83640->version & TX_PTP_VER_MASK) << TX_PTP_VER_SHIFT;
 	rxcfg0 = (dp83640->version & TX_PTP_VER_MASK) << TX_PTP_VER_SHIFT;
 
-	if (dp83640->layer & LAYER2) {
+	if (dp83640->layer & PTP_CLASS_L2) {
 		txcfg0 |= TX_L2_EN;
 		rxcfg0 |= RX_L2_EN;
 	}
-	if (dp83640->layer & LAYER4) {
+	if (dp83640->layer & PTP_CLASS_L4) {
 		txcfg0 |= TX_IPV6_EN | TX_IPV4_EN;
 		rxcfg0 |= RX_IPV6_EN | RX_IPV4_EN;
 	}
@@ -1393,6 +1391,9 @@ static bool dp83640_rxtstamp(struct phy_device *phydev,
 	if (!dp83640->hwts_rx_en)
 		return false;
 
+	if ((type & dp83640->version) == 0 || (type & dp83640->layer) == 0)
+		return false;
+
 	spin_lock_irqsave(&dp83640->rx_lock, flags);
 	prune_rx_ts(dp83640);
 	list_for_each_safe(this, next, &dp83640->rxts) {
-- 
2.5.0

  parent reply	other threads:[~2015-10-30 12:15 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-30 12:13 [PATCH net-next 0/5] dp83640 driver fixes Stefan Sørensen
2015-10-30 12:14 ` [PATCH net-next 1/5] dp83640: Include hash in timestamp/packet matching Stefan Sørensen
2015-10-30 20:32   ` Richard Cochran
2015-10-30 12:14 ` [PATCH net-next 2/5] dp83640: Delay scheduled work Stefan Sørensen
2015-10-30 20:37   ` Richard Cochran
2015-11-02  7:23     ` Sørensen, Stefan
2015-11-02  9:59       ` Richard Cochran
2015-10-30 12:14 ` [PATCH net-next 3/5] dp83640: Prune rx timestamp list before reading from it Stefan Sørensen
2015-10-30 20:38   ` Richard Cochran
2015-10-30 12:14 ` [PATCH net-next 4/5] ptp: Change ptp_class to a proper bitmask Stefan Sørensen
2015-10-30 20:39   ` Richard Cochran
2015-10-30 12:14 ` Stefan Sørensen [this message]
2015-10-30 20:40   ` [PATCH net-next 5/5] dp83640: Only wait for timestamps for packets with timestamping enabled Richard Cochran
2015-11-02 20:13 ` [PATCH net-next 0/5] dp83640 driver fixes David Miller
2015-11-03  8:42   ` Richard Cochran

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=1446207244-2206-6-git-send-email-stefan.sorensen@spectralink.com \
    --to=stefan.sorensen@spectralink.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.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;
as well as URLs for NNTP newsgroup(s).