Commit a1f8723f authored by Stefan Sørensen's avatar Stefan Sørensen Committed by David S. Miller

dp83640: Only wait for timestamps for packets with timestamping enabled.

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: default avatarStefan Sørensen <stefan.sorensen@spectralink.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5f94c943
...@@ -37,8 +37,6 @@ ...@@ -37,8 +37,6 @@
#define DP83640_PHY_ID 0x20005ce1 #define DP83640_PHY_ID 0x20005ce1
#define PAGESEL 0x13 #define PAGESEL 0x13
#define LAYER4 0x02
#define LAYER2 0x01
#define MAX_RXTS 64 #define MAX_RXTS 64
#define N_EXT_TS 6 #define N_EXT_TS 6
#define N_PER_OUT 7 #define N_PER_OUT 7
...@@ -1296,29 +1294,29 @@ static int dp83640_hwtstamp(struct phy_device *phydev, struct ifreq *ifr) ...@@ -1296,29 +1294,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_SYNC:
case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ: case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:
dp83640->hwts_rx_en = 1; dp83640->hwts_rx_en = 1;
dp83640->layer = LAYER4; dp83640->layer = PTP_CLASS_L4;
dp83640->version = 1; dp83640->version = PTP_CLASS_V1;
break; break;
case HWTSTAMP_FILTER_PTP_V2_L4_EVENT: case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
case HWTSTAMP_FILTER_PTP_V2_L4_SYNC: case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ: case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
dp83640->hwts_rx_en = 1; dp83640->hwts_rx_en = 1;
dp83640->layer = LAYER4; dp83640->layer = PTP_CLASS_L4;
dp83640->version = 2; dp83640->version = PTP_CLASS_V2;
break; break;
case HWTSTAMP_FILTER_PTP_V2_L2_EVENT: case HWTSTAMP_FILTER_PTP_V2_L2_EVENT:
case HWTSTAMP_FILTER_PTP_V2_L2_SYNC: case HWTSTAMP_FILTER_PTP_V2_L2_SYNC:
case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ: case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ:
dp83640->hwts_rx_en = 1; dp83640->hwts_rx_en = 1;
dp83640->layer = LAYER2; dp83640->layer = PTP_CLASS_L2;
dp83640->version = 2; dp83640->version = PTP_CLASS_V2;
break; break;
case HWTSTAMP_FILTER_PTP_V2_EVENT: case HWTSTAMP_FILTER_PTP_V2_EVENT:
case HWTSTAMP_FILTER_PTP_V2_SYNC: case HWTSTAMP_FILTER_PTP_V2_SYNC:
case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ: case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
dp83640->hwts_rx_en = 1; dp83640->hwts_rx_en = 1;
dp83640->layer = LAYER4|LAYER2; dp83640->layer = PTP_CLASS_L4 | PTP_CLASS_L2;
dp83640->version = 2; dp83640->version = PTP_CLASS_V2;
break; break;
default: default:
return -ERANGE; return -ERANGE;
...@@ -1327,11 +1325,11 @@ static int dp83640_hwtstamp(struct phy_device *phydev, struct ifreq *ifr) ...@@ -1327,11 +1325,11 @@ static int dp83640_hwtstamp(struct phy_device *phydev, struct ifreq *ifr)
txcfg0 = (dp83640->version & TX_PTP_VER_MASK) << TX_PTP_VER_SHIFT; txcfg0 = (dp83640->version & TX_PTP_VER_MASK) << TX_PTP_VER_SHIFT;
rxcfg0 = (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; txcfg0 |= TX_L2_EN;
rxcfg0 |= RX_L2_EN; rxcfg0 |= RX_L2_EN;
} }
if (dp83640->layer & LAYER4) { if (dp83640->layer & PTP_CLASS_L4) {
txcfg0 |= TX_IPV6_EN | TX_IPV4_EN; txcfg0 |= TX_IPV6_EN | TX_IPV4_EN;
rxcfg0 |= RX_IPV6_EN | RX_IPV4_EN; rxcfg0 |= RX_IPV6_EN | RX_IPV4_EN;
} }
...@@ -1397,6 +1395,9 @@ static bool dp83640_rxtstamp(struct phy_device *phydev, ...@@ -1397,6 +1395,9 @@ static bool dp83640_rxtstamp(struct phy_device *phydev,
if (!dp83640->hwts_rx_en) if (!dp83640->hwts_rx_en)
return false; return false;
if ((type & dp83640->version) == 0 || (type & dp83640->layer) == 0)
return false;
spin_lock_irqsave(&dp83640->rx_lock, flags); spin_lock_irqsave(&dp83640->rx_lock, flags);
prune_rx_ts(dp83640); prune_rx_ts(dp83640);
list_for_each_safe(this, next, &dp83640->rxts) { list_for_each_safe(this, next, &dp83640->rxts) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment