Skip to content

Commit 06c16d8

Browse files
jacob-kelleranguy11
authored andcommitted
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: Jacob Keller <[email protected]> Tested-by: Tony Brelinski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 03cb447 commit 06c16d8

File tree

8 files changed

+513
-0
lines changed

8 files changed

+513
-0
lines changed

drivers/net/ethernet/intel/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ config ICE
299299
select DIMLIB
300300
select NET_DEVLINK
301301
select PLDMFW
302+
imply PTP_1588_CLOCK
302303
help
303304
This driver supports Intel(R) Ethernet Connection E800 Series of
304305
devices. For more information on how to identify your adapter, go

drivers/net/ethernet/intel/ice/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ ice-y := ice_main.o \
2929
ice_ethtool.o
3030
ice-$(CONFIG_PCI_IOV) += ice_virtchnl_allowlist.o
3131
ice-$(CONFIG_PCI_IOV) += ice_virtchnl_pf.o ice_sriov.o ice_virtchnl_fdir.o
32+
ice-$(CONFIG_PTP_1588_CLOCK) += ice_ptp.o ice_ptp_hw.o
3233
ice-$(CONFIG_DCB) += ice_dcb.o ice_dcb_nl.o ice_dcb_lib.o
3334
ice-$(CONFIG_RFS_ACCEL) += ice_arfs.o
3435
ice-$(CONFIG_XDP_SOCKETS) += ice_xsk.o

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
#include "ice_idc_int.h"
6060
#include "ice_virtchnl_pf.h"
6161
#include "ice_sriov.h"
62+
#include "ice_ptp.h"
6263
#include "ice_fdir.h"
6364
#include "ice_xsk.h"
6465
#include "ice_arfs.h"
@@ -389,6 +390,8 @@ enum ice_pf_flags {
389390
ICE_FLAG_DCB_CAPABLE,
390391
ICE_FLAG_DCB_ENA,
391392
ICE_FLAG_FD_ENA,
393+
ICE_FLAG_PTP_SUPPORTED, /* PTP is supported by NVM */
394+
ICE_FLAG_PTP, /* PTP is enabled by software */
392395
ICE_FLAG_AUX_ENA,
393396
ICE_FLAG_ADV_FEATURES,
394397
ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA,
@@ -451,6 +454,7 @@ struct ice_pf {
451454
struct mutex sw_mutex; /* lock for protecting VSI alloc flow */
452455
struct mutex tc_mutex; /* lock to protect TC changes */
453456
u32 msg_enable;
457+
struct ice_ptp ptp;
454458
u16 num_rdma_msix; /* Total MSIX vectors for RDMA driver */
455459
u16 rdma_base_vector;
456460

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ static enum ice_status ice_set_mac_type(struct ice_hw *hw)
5858
return 0;
5959
}
6060

61+
/**
62+
* ice_is_e810
63+
* @hw: pointer to the hardware structure
64+
*
65+
* returns true if the device is E810 based, false if not.
66+
*/
67+
bool ice_is_e810(struct ice_hw *hw)
68+
{
69+
return hw->mac_type == ICE_MAC_E810;
70+
}
71+
6172
/**
6273
* ice_clear_pf_cfg - Clear PF configuration
6374
* @hw: pointer to the hardware structure

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ ice_update_phy_type(u64 *phy_type_low, u64 *phy_type_high,
9999
enum ice_status
100100
ice_aq_manage_mac_write(struct ice_hw *hw, const u8 *mac_addr, u8 flags,
101101
struct ice_sq_cd *cd);
102+
bool ice_is_e810(struct ice_hw *hw);
102103
enum ice_status ice_clear_pf_cfg(struct ice_hw *hw);
103104
enum ice_status
104105
ice_aq_set_phy_cfg(struct ice_hw *hw, struct ice_port_info *pi,

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,9 @@ ice_prepare_for_reset(struct ice_pf *pf)
471471
/* disable the VSIs and their queues that are not already DOWN */
472472
ice_pf_dis_all_vsi(pf, false);
473473

474+
if (test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags))
475+
ice_ptp_release(pf);
476+
474477
if (hw->port_info)
475478
ice_sched_clear_port(hw->port_info);
476479

@@ -3364,6 +3367,9 @@ static void ice_deinit_pf(struct ice_pf *pf)
33643367
bitmap_free(pf->avail_rxqs);
33653368
pf->avail_rxqs = NULL;
33663369
}
3370+
3371+
if (pf->ptp.clock)
3372+
ptp_clock_unregister(pf->ptp.clock);
33673373
}
33683374

33693375
/**
@@ -3410,6 +3416,10 @@ static void ice_set_pf_caps(struct ice_pf *pf)
34103416
func_caps->fd_fltr_best_effort);
34113417
}
34123418

3419+
clear_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags);
3420+
if (func_caps->common_cap.ieee_1588)
3421+
set_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags);
3422+
34133423
pf->max_pf_txqs = func_caps->common_cap.num_txq;
34143424
pf->max_pf_rxqs = func_caps->common_cap.num_rxq;
34153425
}
@@ -4392,6 +4402,8 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)
43924402
}
43934403

43944404
/* initialize DDP driven features */
4405+
if (test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags))
4406+
ice_ptp_init(pf);
43954407

43964408
/* Note: Flow director init failure is non-fatal to load */
43974409
if (ice_init_fdir(pf))
@@ -4559,6 +4571,8 @@ static void ice_remove(struct pci_dev *pdev)
45594571

45604572
mutex_destroy(&(&pf->hw)->fdir_fltr_lock);
45614573
ice_deinit_lag(pf);
4574+
if (test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags))
4575+
ice_ptp_release(pf);
45624576
if (!ice_is_safe_mode(pf))
45634577
ice_remove_arfs(pf);
45644578
ice_setup_mc_magic_wake(pf);
@@ -6350,6 +6364,13 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type)
63506364
if (test_bit(ICE_FLAG_DCB_ENA, pf->flags))
63516365
ice_dcb_rebuild(pf);
63526366

6367+
/* If the PF previously had enabled PTP, PTP init needs to happen before
6368+
* the VSI rebuild. If not, this causes the PTP link status events to
6369+
* fail.
6370+
*/
6371+
if (test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags))
6372+
ice_ptp_init(pf);
6373+
63536374
/* rebuild PF VSI */
63546375
err = ice_vsi_rebuild_by_type(pf, ICE_VSI_PF);
63556376
if (err) {

0 commit comments

Comments
 (0)