diff options
author | Laurence Evans <levans@solarflare.com> | 2013-02-11 08:55:08 -0500 |
---|---|---|
committer | Ben Hutchings <bhutchings@solarflare.com> | 2013-03-07 15:21:56 -0500 |
commit | 9230451af9efcf5e3d60ce7f4fec2468e8ce54b1 (patch) | |
tree | ddcf80cf7822df913091a6f6b357186cb079d0b7 | |
parent | c939a316459783e5cd6c6bd9dc90ea11b18ecd7f (diff) |
sfc: tidy up PTP synchronize function efx_ptp_process_times()
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
-rw-r--r-- | drivers/net/ethernet/sfc/ptp.c | 35 |
1 files changed, 7 insertions, 28 deletions
diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c index 2b40cbd6667b..d1858c0e0827 100644 --- a/drivers/net/ethernet/sfc/ptp.c +++ b/drivers/net/ethernet/sfc/ptp.c | |||
@@ -432,13 +432,10 @@ static int efx_ptp_process_times(struct efx_nic *efx, u8 *synch_buf, | |||
432 | unsigned number_readings = (response_length / | 432 | unsigned number_readings = (response_length / |
433 | MC_CMD_PTP_OUT_SYNCHRONIZE_TIMESET_LEN); | 433 | MC_CMD_PTP_OUT_SYNCHRONIZE_TIMESET_LEN); |
434 | unsigned i; | 434 | unsigned i; |
435 | unsigned min; | ||
436 | unsigned min_set = 0; | ||
437 | unsigned total; | 435 | unsigned total; |
438 | unsigned ngood = 0; | 436 | unsigned ngood = 0; |
439 | unsigned last_good = 0; | 437 | unsigned last_good = 0; |
440 | struct efx_ptp_data *ptp = efx->ptp_data; | 438 | struct efx_ptp_data *ptp = efx->ptp_data; |
441 | bool min_valid = false; | ||
442 | u32 last_sec; | 439 | u32 last_sec; |
443 | u32 start_sec; | 440 | u32 start_sec; |
444 | struct timespec delta; | 441 | struct timespec delta; |
@@ -446,35 +443,17 @@ static int efx_ptp_process_times(struct efx_nic *efx, u8 *synch_buf, | |||
446 | if (number_readings == 0) | 443 | if (number_readings == 0) |
447 | return -EAGAIN; | 444 | return -EAGAIN; |
448 | 445 | ||
449 | /* Find minimum value in this set of results, discarding clearly | 446 | /* Read the set of results and increment stats for any results that |
450 | * erroneous results. | 447 | * appera to be erroneous. |
451 | */ | 448 | */ |
452 | for (i = 0; i < number_readings; i++) { | 449 | for (i = 0; i < number_readings; i++) { |
453 | efx_ptp_read_timeset(synch_buf, &ptp->timeset[i]); | 450 | efx_ptp_read_timeset(synch_buf, &ptp->timeset[i]); |
454 | synch_buf += MC_CMD_PTP_OUT_SYNCHRONIZE_TIMESET_LEN; | 451 | synch_buf += MC_CMD_PTP_OUT_SYNCHRONIZE_TIMESET_LEN; |
455 | if (ptp->timeset[i].window > SYNCHRONISATION_GRANULARITY_NS) { | ||
456 | if (min_valid) { | ||
457 | if (ptp->timeset[i].window < min_set) | ||
458 | min_set = ptp->timeset[i].window; | ||
459 | } else { | ||
460 | min_valid = true; | ||
461 | min_set = ptp->timeset[i].window; | ||
462 | } | ||
463 | } | ||
464 | } | ||
465 | |||
466 | if (min_valid) { | ||
467 | if (ptp->base_sync_valid && (min_set > ptp->base_sync_ns)) | ||
468 | min = ptp->base_sync_ns; | ||
469 | else | ||
470 | min = min_set; | ||
471 | } else { | ||
472 | min = SYNCHRONISATION_GRANULARITY_NS; | ||
473 | } | 452 | } |
474 | 453 | ||
475 | /* Discard excessively long synchronise durations. The MC times | 454 | /* Find the last good host-MC synchronization result. The MC times |
476 | * when it finishes reading the host time so the corrected window | 455 | * when it finishes reading the host time so the corrected window time |
477 | * time should be fairly constant for a given platform. | 456 | * should be fairly constant for a given platform. |
478 | */ | 457 | */ |
479 | total = 0; | 458 | total = 0; |
480 | for (i = 0; i < number_readings; i++) | 459 | for (i = 0; i < number_readings; i++) |
@@ -492,8 +471,8 @@ static int efx_ptp_process_times(struct efx_nic *efx, u8 *synch_buf, | |||
492 | 471 | ||
493 | if (ngood == 0) { | 472 | if (ngood == 0) { |
494 | netif_warn(efx, drv, efx->net_dev, | 473 | netif_warn(efx, drv, efx->net_dev, |
495 | "PTP no suitable synchronisations %dns %dns\n", | 474 | "PTP no suitable synchronisations %dns\n", |
496 | ptp->base_sync_ns, min_set); | 475 | ptp->base_sync_ns); |
497 | return -EAGAIN; | 476 | return -EAGAIN; |
498 | } | 477 | } |
499 | 478 | ||