On 7/18/2024 3:52 AM, Sergey Temerkhanov wrote:
> Use struct ice_adapter to hold shared PTP data and control PTP
> related actions instead of auxbus. This allows significant code
> simplification and faster access to the container fields used in
> the PTP support code.
> 
> Move the PTP port list to the ice_adapter container to simplify
> the code and avoid race conditions which could occur due to the
> synchronous nature of the initialization/access and
> certain memory saving can be achieved by moving PTP data into
> the ice_adapter itself.
> 
> Signed-off-by: Sergey Temerkhanov <[email protected]>
> Reviewed-by: Przemek Kitszel <[email protected]>
> Reviewed-by: Simon Horman <[email protected]>
> ---
>  drivers/net/ethernet/intel/ice/ice_adapter.c |   6 +
>  drivers/net/ethernet/intel/ice/ice_adapter.h |  17 +++
>  drivers/net/ethernet/intel/ice/ice_ptp.c     | 115 ++++++++++++-------
>  drivers/net/ethernet/intel/ice/ice_ptp.h     |   5 +-
>  drivers/net/ethernet/intel/ice/ice_ptp_hw.h  |   5 +
>  5 files changed, 105 insertions(+), 43 deletions(-)
> 

Reviewed-by: Jacob Keller <[email protected]>

> diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c 
> b/drivers/net/ethernet/intel/ice/ice_ptp.c
> index 1cf620eebc2e..48bc29182cb8 100644
> --- a/drivers/net/ethernet/intel/ice/ice_ptp.c
> +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
> @@ -1514,10 +1514,10 @@ static void ice_ptp_restart_all_phy(struct ice_pf *pf)
>  {
>       struct list_head *entry;
>  
> -     list_for_each(entry, &pf->ptp.ports_owner.ports) {
> +     list_for_each(entry, &pf->adapter->ports.ports) {
>               struct ice_ptp_port *port = list_entry(entry,
>                                                      struct ice_ptp_port,
> -                                                    list_member);
> +                                                    list_node);
>  
>               if (port->link_up)
>                       ice_ptp_port_phy_restart(port);
> @@ -2967,6 +2967,50 @@ void ice_ptp_rebuild(struct ice_pf *pf, enum 
> ice_reset_req reset_type)
>       dev_err(ice_pf_to_dev(pf), "PTP reset failed %d\n", err);
>  }
>  
> +static inline bool ice_is_primary(struct ice_hw *hw)
> +{
> +     return ice_is_e825c(hw) && ice_is_dual(hw) ?
> +             !!(hw->dev_caps.nac_topo.mode & ICE_NAC_TOPO_PRIMARY_M) : true;
> +}
> +

The use of ice_adapter should also make it easier to handle the primary
vs secondary PF issues as well. Nice.


> +static int ice_ptp_setup_adapter(struct ice_pf *pf)
> +{
> +     if (!ice_pf_src_tmr_owned(pf) || !ice_is_primary(&pf->hw))
> +             return -EPERM;
> +
> +     pf->adapter->ctrl_pf = pf;
> +
> +     return 0;
> +}

Reply via email to