Commit 06c16d89 authored by Jacob Keller's avatar Jacob Keller Committed by Tony Nguyen

ice: register 1588 PTP clock device object for E810 devices

Add a new ice_ptp.c file for holding the basic PTP clock interface
functions. If the device supports PTP, call the new ice_ptp_init and
ice_ptp_release functions where appropriate.

If the function owns the hardware resource associated with the PTP
hardware clock, register with the PTP_1588_CLOCK infrastructure to
allocate a new clock object that represents the device hardware clock.

Implement basic functionality for reading and setting the clock time,
performing clock adjustments, and adjusting the clock frequency.

Future changes will introduce functionality for handling related
features including Tx and Rx timestamps.
Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
Tested-by: default avatarTony Brelinski <tonyx.brelinski@intel.com>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent 03cb4473
...@@ -299,6 +299,7 @@ config ICE ...@@ -299,6 +299,7 @@ config ICE
select DIMLIB select DIMLIB
select NET_DEVLINK select NET_DEVLINK
select PLDMFW select PLDMFW
imply PTP_1588_CLOCK
help help
This driver supports Intel(R) Ethernet Connection E800 Series of This driver supports Intel(R) Ethernet Connection E800 Series of
devices. For more information on how to identify your adapter, go devices. For more information on how to identify your adapter, go
......
...@@ -29,6 +29,7 @@ ice-y := ice_main.o \ ...@@ -29,6 +29,7 @@ ice-y := ice_main.o \
ice_ethtool.o ice_ethtool.o
ice-$(CONFIG_PCI_IOV) += ice_virtchnl_allowlist.o ice-$(CONFIG_PCI_IOV) += ice_virtchnl_allowlist.o
ice-$(CONFIG_PCI_IOV) += ice_virtchnl_pf.o ice_sriov.o ice_virtchnl_fdir.o ice-$(CONFIG_PCI_IOV) += ice_virtchnl_pf.o ice_sriov.o ice_virtchnl_fdir.o
ice-$(CONFIG_PTP_1588_CLOCK) += ice_ptp.o ice_ptp_hw.o
ice-$(CONFIG_DCB) += ice_dcb.o ice_dcb_nl.o ice_dcb_lib.o ice-$(CONFIG_DCB) += ice_dcb.o ice_dcb_nl.o ice_dcb_lib.o
ice-$(CONFIG_RFS_ACCEL) += ice_arfs.o ice-$(CONFIG_RFS_ACCEL) += ice_arfs.o
ice-$(CONFIG_XDP_SOCKETS) += ice_xsk.o ice-$(CONFIG_XDP_SOCKETS) += ice_xsk.o
...@@ -59,6 +59,7 @@ ...@@ -59,6 +59,7 @@
#include "ice_idc_int.h" #include "ice_idc_int.h"
#include "ice_virtchnl_pf.h" #include "ice_virtchnl_pf.h"
#include "ice_sriov.h" #include "ice_sriov.h"
#include "ice_ptp.h"
#include "ice_fdir.h" #include "ice_fdir.h"
#include "ice_xsk.h" #include "ice_xsk.h"
#include "ice_arfs.h" #include "ice_arfs.h"
...@@ -389,6 +390,8 @@ enum ice_pf_flags { ...@@ -389,6 +390,8 @@ enum ice_pf_flags {
ICE_FLAG_DCB_CAPABLE, ICE_FLAG_DCB_CAPABLE,
ICE_FLAG_DCB_ENA, ICE_FLAG_DCB_ENA,
ICE_FLAG_FD_ENA, ICE_FLAG_FD_ENA,
ICE_FLAG_PTP_SUPPORTED, /* PTP is supported by NVM */
ICE_FLAG_PTP, /* PTP is enabled by software */
ICE_FLAG_AUX_ENA, ICE_FLAG_AUX_ENA,
ICE_FLAG_ADV_FEATURES, ICE_FLAG_ADV_FEATURES,
ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA, ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA,
...@@ -451,6 +454,7 @@ struct ice_pf { ...@@ -451,6 +454,7 @@ struct ice_pf {
struct mutex sw_mutex; /* lock for protecting VSI alloc flow */ struct mutex sw_mutex; /* lock for protecting VSI alloc flow */
struct mutex tc_mutex; /* lock to protect TC changes */ struct mutex tc_mutex; /* lock to protect TC changes */
u32 msg_enable; u32 msg_enable;
struct ice_ptp ptp;
u16 num_rdma_msix; /* Total MSIX vectors for RDMA driver */ u16 num_rdma_msix; /* Total MSIX vectors for RDMA driver */
u16 rdma_base_vector; u16 rdma_base_vector;
......
...@@ -58,6 +58,17 @@ static enum ice_status ice_set_mac_type(struct ice_hw *hw) ...@@ -58,6 +58,17 @@ static enum ice_status ice_set_mac_type(struct ice_hw *hw)
return 0; return 0;
} }
/**
* ice_is_e810
* @hw: pointer to the hardware structure
*
* returns true if the device is E810 based, false if not.
*/
bool ice_is_e810(struct ice_hw *hw)
{
return hw->mac_type == ICE_MAC_E810;
}
/** /**
* ice_clear_pf_cfg - Clear PF configuration * ice_clear_pf_cfg - Clear PF configuration
* @hw: pointer to the hardware structure * @hw: pointer to the hardware structure
......
...@@ -99,6 +99,7 @@ ice_update_phy_type(u64 *phy_type_low, u64 *phy_type_high, ...@@ -99,6 +99,7 @@ ice_update_phy_type(u64 *phy_type_low, u64 *phy_type_high,
enum ice_status enum ice_status
ice_aq_manage_mac_write(struct ice_hw *hw, const u8 *mac_addr, u8 flags, ice_aq_manage_mac_write(struct ice_hw *hw, const u8 *mac_addr, u8 flags,
struct ice_sq_cd *cd); struct ice_sq_cd *cd);
bool ice_is_e810(struct ice_hw *hw);
enum ice_status ice_clear_pf_cfg(struct ice_hw *hw); enum ice_status ice_clear_pf_cfg(struct ice_hw *hw);
enum ice_status enum ice_status
ice_aq_set_phy_cfg(struct ice_hw *hw, struct ice_port_info *pi, ice_aq_set_phy_cfg(struct ice_hw *hw, struct ice_port_info *pi,
......
...@@ -471,6 +471,9 @@ ice_prepare_for_reset(struct ice_pf *pf) ...@@ -471,6 +471,9 @@ ice_prepare_for_reset(struct ice_pf *pf)
/* disable the VSIs and their queues that are not already DOWN */ /* disable the VSIs and their queues that are not already DOWN */
ice_pf_dis_all_vsi(pf, false); ice_pf_dis_all_vsi(pf, false);
if (test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags))
ice_ptp_release(pf);
if (hw->port_info) if (hw->port_info)
ice_sched_clear_port(hw->port_info); ice_sched_clear_port(hw->port_info);
...@@ -3364,6 +3367,9 @@ static void ice_deinit_pf(struct ice_pf *pf) ...@@ -3364,6 +3367,9 @@ static void ice_deinit_pf(struct ice_pf *pf)
bitmap_free(pf->avail_rxqs); bitmap_free(pf->avail_rxqs);
pf->avail_rxqs = NULL; pf->avail_rxqs = NULL;
} }
if (pf->ptp.clock)
ptp_clock_unregister(pf->ptp.clock);
} }
/** /**
...@@ -3410,6 +3416,10 @@ static void ice_set_pf_caps(struct ice_pf *pf) ...@@ -3410,6 +3416,10 @@ static void ice_set_pf_caps(struct ice_pf *pf)
func_caps->fd_fltr_best_effort); func_caps->fd_fltr_best_effort);
} }
clear_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags);
if (func_caps->common_cap.ieee_1588)
set_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags);
pf->max_pf_txqs = func_caps->common_cap.num_txq; pf->max_pf_txqs = func_caps->common_cap.num_txq;
pf->max_pf_rxqs = func_caps->common_cap.num_rxq; pf->max_pf_rxqs = func_caps->common_cap.num_rxq;
} }
...@@ -4392,6 +4402,8 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent) ...@@ -4392,6 +4402,8 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)
} }
/* initialize DDP driven features */ /* initialize DDP driven features */
if (test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags))
ice_ptp_init(pf);
/* Note: Flow director init failure is non-fatal to load */ /* Note: Flow director init failure is non-fatal to load */
if (ice_init_fdir(pf)) if (ice_init_fdir(pf))
...@@ -4559,6 +4571,8 @@ static void ice_remove(struct pci_dev *pdev) ...@@ -4559,6 +4571,8 @@ static void ice_remove(struct pci_dev *pdev)
mutex_destroy(&(&pf->hw)->fdir_fltr_lock); mutex_destroy(&(&pf->hw)->fdir_fltr_lock);
ice_deinit_lag(pf); ice_deinit_lag(pf);
if (test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags))
ice_ptp_release(pf);
if (!ice_is_safe_mode(pf)) if (!ice_is_safe_mode(pf))
ice_remove_arfs(pf); ice_remove_arfs(pf);
ice_setup_mc_magic_wake(pf); ice_setup_mc_magic_wake(pf);
...@@ -6350,6 +6364,13 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type) ...@@ -6350,6 +6364,13 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type)
if (test_bit(ICE_FLAG_DCB_ENA, pf->flags)) if (test_bit(ICE_FLAG_DCB_ENA, pf->flags))
ice_dcb_rebuild(pf); ice_dcb_rebuild(pf);
/* If the PF previously had enabled PTP, PTP init needs to happen before
* the VSI rebuild. If not, this causes the PTP link status events to
* fail.
*/
if (test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags))
ice_ptp_init(pf);
/* rebuild PF VSI */ /* rebuild PF VSI */
err = ice_vsi_rebuild_by_type(pf, ICE_VSI_PF); err = ice_vsi_rebuild_by_type(pf, ICE_VSI_PF);
if (err) { if (err) {
......
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (C) 2021, Intel Corporation. */
#ifndef _ICE_PTP_H_
#define _ICE_PTP_H_
#include <linux/ptp_clock_kernel.h>
#include "ice_ptp_hw.h"
/**
* struct ice_ptp - data used for integrating with CONFIG_PTP_1588_CLOCK
* @info: structure defining PTP hardware capabilities
* @clock: pointer to registered PTP clock device
*/
struct ice_ptp {
struct ptp_clock_info info;
struct ptp_clock *clock;
};
#define __ptp_info_to_ptp(i) \
container_of((i), struct ice_ptp, info)
#define ptp_info_to_pf(i) \
container_of(__ptp_info_to_ptp((i)), struct ice_pf, ptp)
#define PTP_SHARED_CLK_IDX_VALID BIT(31)
#if IS_ENABLED(CONFIG_PTP_1588_CLOCK)
struct ice_pf;
void ice_ptp_init(struct ice_pf *pf);
void ice_ptp_release(struct ice_pf *pf);
#else /* IS_ENABLED(CONFIG_PTP_1588_CLOCK) */
static inline void ice_ptp_init(struct ice_pf *pf) { }
static inline void ice_ptp_release(struct ice_pf *pf) { }
#endif /* IS_ENABLED(CONFIG_PTP_1588_CLOCK) */
#endif /* _ICE_PTP_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment