Skip to content

Commit 803bef8

Browse files
jacob-kellerPaolo Abeni
authored andcommitted
ice: factor out ice_ptp_rebuild_owner()
The ice_ptp_reset() function uses a goto to skip past clock owner operations if performing a PF reset or if the device is not the clock owner. This is a bit confusing. Factor this out into ice_ptp_rebuild_owner() instead. The ice_ptp_reset() function is called by ice_rebuild() to restore PTP functionality after a device reset. Follow the convention set by the ice_main.c file and rename this function to ice_ptp_rebuild(), in the same way that we have ice_prepare_for_reset() and ice_ptp_prepare_for_reset(). Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Signed-off-by: Karol Kolacinski <karol.kolacinski@intel.com> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> 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: Paolo Abeni <pabeni@redhat.com>
1 parent 1abefdc commit 803bef8

File tree

3 files changed

+42
-28
lines changed

3 files changed

+42
-28
lines changed

drivers/net/ethernet/intel/ice/ice_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7548,7 +7548,7 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type)
75487548
* fail.
75497549
*/
75507550
if (test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags))
7551-
ice_ptp_reset(pf, reset_type);
7551+
ice_ptp_rebuild(pf, reset_type);
75527552

75537553
if (ice_is_feature_supported(pf, ICE_F_GNSS))
75547554
ice_gnss_init(pf);

drivers/net/ethernet/intel/ice/ice_ptp.c

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2665,44 +2665,35 @@ void ice_ptp_prepare_for_reset(struct ice_pf *pf, enum ice_reset_req reset_type)
26652665
}
26662666

26672667
/**
2668-
* ice_ptp_reset - Initialize PTP hardware clock support after reset
2668+
* ice_ptp_rebuild_owner - Initialize PTP clock owner after reset
26692669
* @pf: Board private structure
2670-
* @reset_type: the reset type being performed
2670+
*
2671+
* Companion function for ice_ptp_rebuild() which handles tasks that only the
2672+
* PTP clock owner instance should perform.
26712673
*/
2672-
void ice_ptp_reset(struct ice_pf *pf, enum ice_reset_req reset_type)
2674+
static int ice_ptp_rebuild_owner(struct ice_pf *pf)
26732675
{
26742676
struct ice_ptp *ptp = &pf->ptp;
26752677
struct ice_hw *hw = &pf->hw;
26762678
struct timespec64 ts;
26772679
u64 time_diff;
26782680
int err;
26792681

2680-
if (ptp->state == ICE_PTP_READY) {
2681-
ice_ptp_prepare_for_reset(pf, reset_type);
2682-
} else if (ptp->state != ICE_PTP_RESETTING) {
2683-
err = -EINVAL;
2684-
dev_err(ice_pf_to_dev(pf), "PTP was not initialized\n");
2685-
goto err;
2686-
}
2687-
2688-
if (reset_type == ICE_RESET_PFR || !ice_pf_src_tmr_owned(pf))
2689-
goto pfr;
2690-
26912682
err = ice_ptp_init_phc(hw);
26922683
if (err)
2693-
goto err;
2684+
return err;
26942685

26952686
/* Acquire the global hardware lock */
26962687
if (!ice_ptp_lock(hw)) {
26972688
err = -EBUSY;
2698-
goto err;
2689+
return err;
26992690
}
27002691

27012692
/* Write the increment time value to PHY and LAN */
27022693
err = ice_ptp_write_incval(hw, ice_base_incval(pf));
27032694
if (err) {
27042695
ice_ptp_unlock(hw);
2705-
goto err;
2696+
return err;
27062697
}
27072698

27082699
/* Write the initial Time value to PHY and LAN using the cached PHC
@@ -2718,7 +2709,7 @@ void ice_ptp_reset(struct ice_pf *pf, enum ice_reset_req reset_type)
27182709
err = ice_ptp_write_init(pf, &ts);
27192710
if (err) {
27202711
ice_ptp_unlock(hw);
2721-
goto err;
2712+
return err;
27222713
}
27232714

27242715
/* Release the global hardware lock */
@@ -2727,11 +2718,39 @@ void ice_ptp_reset(struct ice_pf *pf, enum ice_reset_req reset_type)
27272718
if (!ice_is_e810(hw)) {
27282719
/* Enable quad interrupts */
27292720
err = ice_ptp_cfg_phy_interrupt(pf, true, 1);
2721+
if (err)
2722+
return err;
2723+
2724+
ice_ptp_restart_all_phy(pf);
2725+
}
2726+
2727+
return 0;
2728+
}
2729+
2730+
/**
2731+
* ice_ptp_rebuild - Initialize PTP hardware clock support after reset
2732+
* @pf: Board private structure
2733+
* @reset_type: the reset type being performed
2734+
*/
2735+
void ice_ptp_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type)
2736+
{
2737+
struct ice_ptp *ptp = &pf->ptp;
2738+
int err;
2739+
2740+
if (ptp->state == ICE_PTP_READY) {
2741+
ice_ptp_prepare_for_reset(pf, reset_type);
2742+
} else if (ptp->state != ICE_PTP_RESETTING) {
2743+
err = -EINVAL;
2744+
dev_err(ice_pf_to_dev(pf), "PTP was not initialized\n");
2745+
goto err;
2746+
}
2747+
2748+
if (ice_pf_src_tmr_owned(pf) && reset_type != ICE_RESET_PFR) {
2749+
err = ice_ptp_rebuild_owner(pf);
27302750
if (err)
27312751
goto err;
27322752
}
27332753

2734-
pfr:
27352754
/* Init Tx structures */
27362755
if (ice_is_e810(&pf->hw)) {
27372756
err = ice_ptp_init_tx_e810(pf, &ptp->port.tx);
@@ -2746,11 +2765,6 @@ void ice_ptp_reset(struct ice_pf *pf, enum ice_reset_req reset_type)
27462765

27472766
ptp->state = ICE_PTP_READY;
27482767

2749-
/* Restart the PHY timestamping block */
2750-
if (!test_bit(ICE_PFR_REQ, pf->state) &&
2751-
ice_pf_src_tmr_owned(pf))
2752-
ice_ptp_restart_all_phy(pf);
2753-
27542768
/* Start periodic work going */
27552769
kthread_queue_delayed_work(ptp->kworker, &ptp->work, 0);
27562770

drivers/net/ethernet/intel/ice/ice_ptp.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ enum ice_tx_tstamp_work ice_ptp_process_ts(struct ice_pf *pf);
316316

317317
u64 ice_ptp_get_rx_hwts(const union ice_32b_rx_flex_desc *rx_desc,
318318
const struct ice_pkt_ctx *pkt_ctx);
319-
void ice_ptp_reset(struct ice_pf *pf, enum ice_reset_req reset_type);
319+
void ice_ptp_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type);
320320
void ice_ptp_prepare_for_reset(struct ice_pf *pf,
321321
enum ice_reset_req reset_type);
322322
void ice_ptp_init(struct ice_pf *pf);
@@ -358,8 +358,8 @@ ice_ptp_get_rx_hwts(const union ice_32b_rx_flex_desc *rx_desc,
358358
return 0;
359359
}
360360

361-
static inline void ice_ptp_reset(struct ice_pf *pf,
362-
enum ice_reset_req reset_type)
361+
static inline void ice_ptp_rebuild(struct ice_pf *pf,
362+
enum ice_reset_req reset_type)
363363
{
364364
}
365365

0 commit comments

Comments
 (0)