Skip to content

Commit 3c44191

Browse files
Vadim Fedorenkodavem330
authored andcommitted
ixgbe: fix timestamp configuration code
The commit in fixes introduced flags to control the status of hardware configuration while processing packets. At the same time another structure is used to provide configuration of timestamper to user-space applications. The way it was coded makes this structures go out of sync easily. The repro is easy for 82599 chips: [root@hostname ~]# hwstamp_ctl -i eth0 -r 12 -t 1 current settings: tx_type 0 rx_filter 0 new settings: tx_type 1 rx_filter 12 The eth0 device is properly configured to timestamp any PTPv2 events. [root@hostname ~]# hwstamp_ctl -i eth0 -r 1 -t 1 current settings: tx_type 1 rx_filter 12 SIOCSHWTSTAMP failed: Numerical result out of range The requested time stamping mode is not supported by the hardware. The error is properly returned because HW doesn't support all packets timestamping. But the adapter->flags is cleared of timestamp flags even though no HW configuration was done. From that point no RX timestamps are received by user-space application. But configuration shows good values: [root@hostname ~]# hwstamp_ctl -i eth0 current settings: tx_type 1 rx_filter 12 Fix the issue by applying new flags only when the HW was actually configured. Fixes: a9763f3 ("ixgbe: Update PTP to support X550EM_x devices") Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev> Reviewed-by: Simon Horman <horms@kernel.org> Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ab6c4ec commit 3c44191

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,7 @@ static int ixgbe_ptp_set_timestamp_mode(struct ixgbe_adapter *adapter,
979979
u32 tsync_tx_ctl = IXGBE_TSYNCTXCTL_ENABLED;
980980
u32 tsync_rx_ctl = IXGBE_TSYNCRXCTL_ENABLED;
981981
u32 tsync_rx_mtrl = PTP_EV_PORT << 16;
982+
u32 aflags = adapter->flags;
982983
bool is_l2 = false;
983984
u32 regval;
984985

@@ -996,20 +997,20 @@ static int ixgbe_ptp_set_timestamp_mode(struct ixgbe_adapter *adapter,
996997
case HWTSTAMP_FILTER_NONE:
997998
tsync_rx_ctl = 0;
998999
tsync_rx_mtrl = 0;
999-
adapter->flags &= ~(IXGBE_FLAG_RX_HWTSTAMP_ENABLED |
1000-
IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER);
1000+
aflags &= ~(IXGBE_FLAG_RX_HWTSTAMP_ENABLED |
1001+
IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER);
10011002
break;
10021003
case HWTSTAMP_FILTER_PTP_V1_L4_SYNC:
10031004
tsync_rx_ctl |= IXGBE_TSYNCRXCTL_TYPE_L4_V1;
10041005
tsync_rx_mtrl |= IXGBE_RXMTRL_V1_SYNC_MSG;
1005-
adapter->flags |= (IXGBE_FLAG_RX_HWTSTAMP_ENABLED |
1006-
IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER);
1006+
aflags |= (IXGBE_FLAG_RX_HWTSTAMP_ENABLED |
1007+
IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER);
10071008
break;
10081009
case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:
10091010
tsync_rx_ctl |= IXGBE_TSYNCRXCTL_TYPE_L4_V1;
10101011
tsync_rx_mtrl |= IXGBE_RXMTRL_V1_DELAY_REQ_MSG;
1011-
adapter->flags |= (IXGBE_FLAG_RX_HWTSTAMP_ENABLED |
1012-
IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER);
1012+
aflags |= (IXGBE_FLAG_RX_HWTSTAMP_ENABLED |
1013+
IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER);
10131014
break;
10141015
case HWTSTAMP_FILTER_PTP_V2_EVENT:
10151016
case HWTSTAMP_FILTER_PTP_V2_L2_EVENT:
@@ -1023,8 +1024,8 @@ static int ixgbe_ptp_set_timestamp_mode(struct ixgbe_adapter *adapter,
10231024
tsync_rx_ctl |= IXGBE_TSYNCRXCTL_TYPE_EVENT_V2;
10241025
is_l2 = true;
10251026
config->rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT;
1026-
adapter->flags |= (IXGBE_FLAG_RX_HWTSTAMP_ENABLED |
1027-
IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER);
1027+
aflags |= (IXGBE_FLAG_RX_HWTSTAMP_ENABLED |
1028+
IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER);
10281029
break;
10291030
case HWTSTAMP_FILTER_PTP_V1_L4_EVENT:
10301031
case HWTSTAMP_FILTER_NTP_ALL:
@@ -1035,7 +1036,7 @@ static int ixgbe_ptp_set_timestamp_mode(struct ixgbe_adapter *adapter,
10351036
if (hw->mac.type >= ixgbe_mac_X550) {
10361037
tsync_rx_ctl |= IXGBE_TSYNCRXCTL_TYPE_ALL;
10371038
config->rx_filter = HWTSTAMP_FILTER_ALL;
1038-
adapter->flags |= IXGBE_FLAG_RX_HWTSTAMP_ENABLED;
1039+
aflags |= IXGBE_FLAG_RX_HWTSTAMP_ENABLED;
10391040
break;
10401041
}
10411042
fallthrough;
@@ -1046,8 +1047,6 @@ static int ixgbe_ptp_set_timestamp_mode(struct ixgbe_adapter *adapter,
10461047
* Delay_Req messages and hardware does not support
10471048
* timestamping all packets => return error
10481049
*/
1049-
adapter->flags &= ~(IXGBE_FLAG_RX_HWTSTAMP_ENABLED |
1050-
IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER);
10511050
config->rx_filter = HWTSTAMP_FILTER_NONE;
10521051
return -ERANGE;
10531052
}
@@ -1079,8 +1078,8 @@ static int ixgbe_ptp_set_timestamp_mode(struct ixgbe_adapter *adapter,
10791078
IXGBE_TSYNCRXCTL_TYPE_ALL |
10801079
IXGBE_TSYNCRXCTL_TSIP_UT_EN;
10811080
config->rx_filter = HWTSTAMP_FILTER_ALL;
1082-
adapter->flags |= IXGBE_FLAG_RX_HWTSTAMP_ENABLED;
1083-
adapter->flags &= ~IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER;
1081+
aflags |= IXGBE_FLAG_RX_HWTSTAMP_ENABLED;
1082+
aflags &= ~IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER;
10841083
is_l2 = true;
10851084
break;
10861085
default:
@@ -1113,6 +1112,9 @@ static int ixgbe_ptp_set_timestamp_mode(struct ixgbe_adapter *adapter,
11131112

11141113
IXGBE_WRITE_FLUSH(hw);
11151114

1115+
/* configure adapter flags only when HW is actually configured */
1116+
adapter->flags = aflags;
1117+
11161118
/* clear TX/RX time stamp registers, just to be sure */
11171119
ixgbe_ptp_clear_tx_timestamp(adapter);
11181120
IXGBE_READ_REG(hw, IXGBE_RXSTMPH);

0 commit comments

Comments
 (0)