@@ -239,6 +239,54 @@ static void igc_ptp_enable_tstamp_all_rxqueues(struct igc_adapter *adapter,
239
239
}
240
240
}
241
241
242
+ static void igc_ptp_disable_rx_timestamp (struct igc_adapter * adapter )
243
+ {
244
+ struct igc_hw * hw = & adapter -> hw ;
245
+ u32 val ;
246
+
247
+ wr32 (IGC_TSYNCRXCTL , 0 );
248
+
249
+ val = rd32 (IGC_RXPBS );
250
+ val &= ~IGC_RXPBS_CFG_TS_EN ;
251
+ wr32 (IGC_RXPBS , val );
252
+ }
253
+
254
+ static void igc_ptp_enable_rx_timestamp (struct igc_adapter * adapter )
255
+ {
256
+ struct igc_hw * hw = & adapter -> hw ;
257
+ u32 val ;
258
+
259
+ val = rd32 (IGC_RXPBS );
260
+ val |= IGC_RXPBS_CFG_TS_EN ;
261
+ wr32 (IGC_RXPBS , val );
262
+
263
+ /* FIXME: For now, only support retrieving RX timestamps from timer 0
264
+ */
265
+ igc_ptp_enable_tstamp_all_rxqueues (adapter , 0 );
266
+
267
+ val = IGC_TSYNCRXCTL_ENABLED | IGC_TSYNCRXCTL_TYPE_ALL |
268
+ IGC_TSYNCRXCTL_RXSYNSIG ;
269
+ wr32 (IGC_TSYNCRXCTL , val );
270
+ }
271
+
272
+ static void igc_ptp_disable_tx_timestamp (struct igc_adapter * adapter )
273
+ {
274
+ struct igc_hw * hw = & adapter -> hw ;
275
+
276
+ wr32 (IGC_TSYNCTXCTL , 0 );
277
+ }
278
+
279
+ static void igc_ptp_enable_tx_timestamp (struct igc_adapter * adapter )
280
+ {
281
+ struct igc_hw * hw = & adapter -> hw ;
282
+
283
+ wr32 (IGC_TSYNCTXCTL , IGC_TSYNCTXCTL_ENABLED | IGC_TSYNCTXCTL_TXSYNSIG );
284
+
285
+ /* Read TXSTMP registers to discard any timestamp previously stored. */
286
+ rd32 (IGC_TXSTMPL );
287
+ rd32 (IGC_TXSTMPH );
288
+ }
289
+
242
290
/**
243
291
* igc_ptp_set_timestamp_mode - setup hardware for timestamping
244
292
* @adapter: networking device structure
@@ -249,27 +297,24 @@ static void igc_ptp_enable_tstamp_all_rxqueues(struct igc_adapter *adapter,
249
297
static int igc_ptp_set_timestamp_mode (struct igc_adapter * adapter ,
250
298
struct hwtstamp_config * config )
251
299
{
252
- u32 tsync_tx_ctl = IGC_TSYNCTXCTL_ENABLED ;
253
- u32 tsync_rx_ctl = IGC_TSYNCRXCTL_ENABLED ;
254
- struct igc_hw * hw = & adapter -> hw ;
255
- u32 regval ;
256
-
257
300
/* reserved for future extensions */
258
301
if (config -> flags )
259
302
return - EINVAL ;
260
303
261
304
switch (config -> tx_type ) {
262
305
case HWTSTAMP_TX_OFF :
263
- tsync_tx_ctl = 0 ;
306
+ igc_ptp_disable_tx_timestamp (adapter );
307
+ break ;
264
308
case HWTSTAMP_TX_ON :
309
+ igc_ptp_enable_tx_timestamp (adapter );
265
310
break ;
266
311
default :
267
312
return - ERANGE ;
268
313
}
269
314
270
315
switch (config -> rx_filter ) {
271
316
case HWTSTAMP_FILTER_NONE :
272
- tsync_rx_ctl = 0 ;
317
+ igc_ptp_disable_rx_timestamp ( adapter ) ;
273
318
break ;
274
319
case HWTSTAMP_FILTER_PTP_V1_L4_SYNC :
275
320
case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ :
@@ -285,55 +330,13 @@ static int igc_ptp_set_timestamp_mode(struct igc_adapter *adapter,
285
330
case HWTSTAMP_FILTER_PTP_V1_L4_EVENT :
286
331
case HWTSTAMP_FILTER_NTP_ALL :
287
332
case HWTSTAMP_FILTER_ALL :
288
- tsync_rx_ctl |= IGC_TSYNCRXCTL_TYPE_ALL ;
333
+ igc_ptp_enable_rx_timestamp ( adapter ) ;
289
334
config -> rx_filter = HWTSTAMP_FILTER_ALL ;
290
335
break ;
291
336
default :
292
- config -> rx_filter = HWTSTAMP_FILTER_NONE ;
293
337
return - ERANGE ;
294
338
}
295
339
296
- if (tsync_rx_ctl ) {
297
- tsync_rx_ctl = IGC_TSYNCRXCTL_ENABLED ;
298
- tsync_rx_ctl |= IGC_TSYNCRXCTL_TYPE_ALL ;
299
- tsync_rx_ctl |= IGC_TSYNCRXCTL_RXSYNSIG ;
300
- config -> rx_filter = HWTSTAMP_FILTER_ALL ;
301
-
302
- if (hw -> mac .type == igc_i225 ) {
303
- regval = rd32 (IGC_RXPBS );
304
- regval |= IGC_RXPBS_CFG_TS_EN ;
305
- wr32 (IGC_RXPBS , regval );
306
-
307
- /* FIXME: For now, only support retrieving RX
308
- * timestamps from timer 0
309
- */
310
- igc_ptp_enable_tstamp_all_rxqueues (adapter , 0 );
311
- }
312
- }
313
-
314
- if (tsync_tx_ctl ) {
315
- tsync_tx_ctl = IGC_TSYNCTXCTL_ENABLED ;
316
- tsync_tx_ctl |= IGC_TSYNCTXCTL_TXSYNSIG ;
317
- }
318
-
319
- /* enable/disable TX */
320
- regval = rd32 (IGC_TSYNCTXCTL );
321
- regval &= ~IGC_TSYNCTXCTL_ENABLED ;
322
- regval |= tsync_tx_ctl ;
323
- wr32 (IGC_TSYNCTXCTL , regval );
324
-
325
- /* enable/disable RX */
326
- regval = rd32 (IGC_TSYNCRXCTL );
327
- regval &= ~(IGC_TSYNCRXCTL_ENABLED | IGC_TSYNCRXCTL_TYPE_MASK );
328
- regval |= tsync_rx_ctl ;
329
- wr32 (IGC_TSYNCRXCTL , regval );
330
-
331
- wrfl ();
332
-
333
- /* clear TX time stamp registers, just to be sure */
334
- regval = rd32 (IGC_TXSTMPL );
335
- regval = rd32 (IGC_TXSTMPH );
336
-
337
340
return 0 ;
338
341
}
339
342
0 commit comments