ice: Implement PTP support for E830 devices
Subsystems (3)
v6 cover ice: Implement PTP support for E830 devices
Add specific functions and definitions for E830 devices to enable PTP support.
Refactor processing of timestamping interrupt and cross timestamp to avoid code redundancy.
Jacob Keller (1):
ice: combine cross timestamp functions for E82x and E830
Karol Kolacinski (4):
ice: Remove unncecessary ice_is_e8xx() functions
ice: Use FIELD_PREP for timestamp values
ice: Process TSYN IRQ in a separate function
ice: Add timestamp ready bitmap for E830 products
Michal Michalik (1):
ice: Implement PTP support for E830 devices
drivers/net/ethernet/intel/Kconfig | 2 +- drivers/net/ethernet/intel/ice/ice_common.c | 128 +---- drivers/net/ethernet/intel/ice/ice_common.h | 19 +- drivers/net/ethernet/intel/ice/ice_ddp.c | 4 +- drivers/net/ethernet/intel/ice/ice_gnss.c | 23 +- .../net/ethernet/intel/ice/ice_hw_autogen.h | 12 + drivers/net/ethernet/intel/ice/ice_main.c | 25 +- drivers/net/ethernet/intel/ice/ice_ptp.c | 469 ++++++++++++------ drivers/net/ethernet/intel/ice/ice_ptp.h | 9 +- drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 289 ++++++++--- drivers/net/ethernet/intel/ice/ice_ptp_hw.h | 41 +- drivers/net/ethernet/intel/ice/ice_type.h | 9 - 12 files changed, 614 insertions(+), 416 deletions(-)
V5 -> V6: Fixed minor compilation issue in "ice: Use FIELD_PREP for timestamp
values"
V4 -> V5: Added 2 patches: "ice: Remove unncecessary ice_is_e8xx()
functions" and "ice: Use FIELD_PREP for timestamp values". Edited return values "ice: Implement PTP support for E830 devices".
V3 -> V4: Further kdoc fixes in "ice: Implement PTP support for
E830 devices"
V2 -> V3: Rebased and fixed kdoc in "ice: Implement PTP support for
E830 devices"
V1 -> V2: Fixed compilation issue in "ice: Implement PTP support for
E830 devices"base-commit: 1dc36a5700fae7c147c5a78da10930a36729d14a
Signature · 1 line
2.46.0
PATCH v6 1/6 ice: Remove unncecessary ice_is_e8xx() functions
Remove unnecessary ice_is_e8xx() functions and PHY model. Instead, use MAC type where applicable.
--- drivers/net/ethernet/intel/ice/ice_common.c | 128 +------------------- drivers/net/ethernet/intel/ice/ice_common.h | 19 ++- drivers/net/ethernet/intel/ice/ice_ddp.c | 4 +- drivers/net/ethernet/intel/ice/ice_gnss.c | 23 ++-- drivers/net/ethernet/intel/ice/ice_ptp.c | 99 ++++++++------- drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 108 ++++++++--------- drivers/net/ethernet/intel/ice/ice_ptp_hw.h | 16 +-- drivers/net/ethernet/intel/ice/ice_type.h | 9 -- 8 files changed, 139 insertions(+), 267 deletions(-)
drivers/net/ethernet/intel/ice/ice_common.c +1 -127
@@ -181,132 +181,6 @@ static int ice_set_mac_type(struct ice_hw *hw)return 0 ; } -/** -* ice_is_generic_mac - check if device's mac_type is generic -* @hw: pointer to the hardware structure -* -* Return: true if mac_type is generic (with SBQ support), false if not -*/ -bool ice_is_generic_mac (struct ice_hw *hw) -{ -return (hw->mac_type ==ICE_MAC_GENERIC || - hw->mac_type ==ICE_MAC_GENERIC_3K_E825 ); -} - -/** -* 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_is_e810t -* @hw: pointer to the hardware structure -* -* returns true if the device is E810T based, false if not. -*/ -bool ice_is_e810t (struct ice_hw *hw) -{ -switch (hw->device_id) { -case ICE_DEV_ID_E810C_SFP : -switch (hw->subsystem_device_id) { -case ICE_SUBDEV_ID_E810T : -case ICE_SUBDEV_ID_E810T2 : -case ICE_SUBDEV_ID_E810T3 : -case ICE_SUBDEV_ID_E810T4 : -case ICE_SUBDEV_ID_E810T6 : -case ICE_SUBDEV_ID_E810T7 : -return true; - } -break ; -case ICE_DEV_ID_E810C_QSFP : -switch (hw->subsystem_device_id) { -case ICE_SUBDEV_ID_E810T2 : -case ICE_SUBDEV_ID_E810T3 : -case ICE_SUBDEV_ID_E810T5 : -return true; - } -break ; -default : -break ; - } - -return false; -} - -/** -* ice_is_e822 - Check if a device is E822 family device -* @hw: pointer to the hardware structure -* -* Return: true if the device is E822 based, false if not. -*/ -bool ice_is_e822 (struct ice_hw *hw) -{ -switch (hw->device_id) { -case ICE_DEV_ID_E822C_BACKPLANE : -case ICE_DEV_ID_E822C_QSFP : -case ICE_DEV_ID_E822C_SFP : -case ICE_DEV_ID_E822C_10G_BASE_T : -case ICE_DEV_ID_E822C_SGMII : -case ICE_DEV_ID_E822L_BACKPLANE : -case ICE_DEV_ID_E822L_SFP : -case ICE_DEV_ID_E822L_10G_BASE_T : -case ICE_DEV_ID_E822L_SGMII : -return true; -default : -return false; - } -} - -/** -* ice_is_e823 -* @hw: pointer to the hardware structure -* -* returns true if the device is E823-L or E823-C based, false if not. -*/ -bool ice_is_e823 (struct ice_hw *hw) -{ -switch (hw->device_id) { -case ICE_DEV_ID_E823L_BACKPLANE : -case ICE_DEV_ID_E823L_SFP : -case ICE_DEV_ID_E823L_10G_BASE_T : -case ICE_DEV_ID_E823L_1GBE : -case ICE_DEV_ID_E823L_QSFP : -case ICE_DEV_ID_E823C_BACKPLANE : -case ICE_DEV_ID_E823C_QSFP : -case ICE_DEV_ID_E823C_SFP : -case ICE_DEV_ID_E823C_10G_BASE_T : -case ICE_DEV_ID_E823C_SGMII : -return true; -default : -return false; - } -} - -/** -* ice_is_e825c - Check if a device is E825C family device -* @hw: pointer to the hardware structure -* -* Return: true if the device is E825-C based, false if not. -*/ -bool ice_is_e825c (struct ice_hw *hw) -{ -switch (hw->device_id) { -case ICE_DEV_ID_E825C_BACKPLANE : -case ICE_DEV_ID_E825C_QSFP : -case ICE_DEV_ID_E825C_SFP : -case ICE_DEV_ID_E825C_SGMII : -return true; -default : -return false; - } -} -/** * ice_clear_pf_cfg - Clear PF configuration * @hw: pointer to the hardware structure
@@ -2311,7 +2185,7 @@ ice_parse_1588_func_caps(struct ice_hw *hw, struct ice_hw_func_caps *func_p, info->tmr_index_owned = ((number &ICE_TS_TMR_IDX_OWND_M ) !=0 ); info->tmr_index_assoc = ((number &ICE_TS_TMR_IDX_ASSOC_M ) !=0 ); -if (!ice_is_e825c (hw)) { +if (hw->mac_type ==ICE_MAC_GENERIC_3K_E825 ) { info->clk_freq =FIELD_GET (ICE_TS_CLK_FREQ_M , number); info->clk_src = ((number &ICE_TS_CLK_SRC_M ) !=0 ); }else {
drivers/net/ethernet/intel/ice/ice_common.h +13 -6
@@ -132,8 +132,6 @@ ice_update_phy_type(u64 *phy_type_low, u64 *phy_type_high,int ice_aq_manage_mac_write (struct ice_hw *hw,const u8 *mac_addr,u8 flags,struct ice_sq_cd *cd); -bool ice_is_generic_mac (struct ice_hw *hw); -bool ice_is_e810 (struct ice_hw *hw);int ice_clear_pf_cfg (struct ice_hw *hw); int ice_aq_set_phy_cfg(struct ice_hw *hw, struct ice_port_info *pi,
@@ -275,10 +273,6 @@ ice_stat_update40(struct ice_hw *hw, u32 reg, bool prev_stat_loaded,void ice_stat_update32 (struct ice_hw *hw,u32 reg,bool prev_stat_loaded,u64 *prev_stat,u64 *cur_stat); -bool ice_is_e810t (struct ice_hw *hw); -bool ice_is_e822 (struct ice_hw *hw); -bool ice_is_e823 (struct ice_hw *hw); -bool ice_is_e825c (struct ice_hw *hw);int ice_sched_query_elem (struct ice_hw *hw,u32 node_teid,struct ice_aqc_txsched_elem_data *buf);
@@ -306,4 +300,17 @@ ice_aq_write_i2c(struct ice_hw *hw, struct ice_aqc_link_topo_addr topo_addr, u16 bus_addr, __le16 addr, u8 params, const u8 *data, struct ice_sq_cd *cd);bool ice_fw_supports_report_dflt_cfg (struct ice_hw *hw); + +/** +* ice_is_generic_mac - check if device's mac_type is generic +* @hw: pointer to the hardware structure +* +* Return: true if mac_type is generic (with SBQ support), false if not +*/ +static inline bool ice_is_generic_mac (const struct ice_hw *hw) +{ +return (hw->mac_type ==ICE_MAC_GENERIC || + hw->mac_type ==ICE_MAC_GENERIC_3K_E825 ); +} +#endif /* _ICE_COMMON_H_ */
drivers/net/ethernet/intel/ice/ice_ddp.c +2 -2
@@ -2323,14 +2323,14 @@ ice_get_set_tx_topo(struct ice_hw *hw, u8 *buf, u16 buf_size, cmd->set_flags |=ICE_AQC_TX_TOPO_FLAGS_SRC_RAM |ICE_AQC_TX_TOPO_FLAGS_LOAD_NEW ; -if (ice_is_e825c (hw)) +if (hw->mac_type ==ICE_MAC_GENERIC_3K_E825 ) desc.flags |=cpu_to_le16 (ICE_AQ_FLAG_RD ); }else {ice_fill_dflt_direct_cmd_desc (&desc, ice_aqc_opc_get_tx_topo); cmd->get_flags =ICE_AQC_TX_TOPO_GET_RAM ; } -if (!ice_is_e825c (hw)) +if (hw->mac_type !=ICE_MAC_GENERIC_3K_E825 ) desc.flags |=cpu_to_le16 (ICE_AQ_FLAG_RD ); status =ice_aq_send_cmd (hw, &desc, buf, buf_size, cd);
drivers/net/ethernet/intel/ice/ice_gnss.c +9 -14
@@ -386,27 +386,22 @@ void ice_gnss_exit(struct ice_pf *pf)*/ bool ice_gnss_is_gps_present (struct ice_hw *hw) { +#if IS_ENABLED (CONFIG_PTP_1588_CLOCK ) +int err; +u8 data; +if (!hw->func_caps.ts_func_info.src_tmr_owned)return false;if (!ice_is_gps_in_netlist (hw))return false; -#if IS_ENABLED (CONFIG_PTP_1588_CLOCK ) -if (ice_is_e810t (hw)) { -int err; -u8 data; - - err =ice_read_pca9575_reg (hw,ICE_PCA9575_P0_IN , &data); -if (err || !!(data &ICE_P0_GNSS_PRSNT_N )) -return false; - }else { + err =ice_read_pca9575_reg (hw,ICE_PCA9575_P0_IN , &data); +if (err || !!(data &ICE_P0_GNSS_PRSNT_N ))return false; - } -#else -if (!ice_is_e810t (hw)) -return false; -#endif /* IS_ENABLED(CONFIG_PTP_1588_CLOCK) */ return true; +#else +return false; +#endif /* IS_ENABLED(CONFIG_PTP_1588_CLOCK) */ }
drivers/net/ethernet/intel/ice/ice_ptp.c +52 -47
237 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_ptp_hw.c +54 -54
252 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_ptp_hw.h +8 -8
@@ -436,12 +436,12 @@ int ice_phy_cfg_ptp_1step_eth56g(struct ice_hw *hw, u8 port);static inline u64 ice_prop_delay (const struct ice_hw *hw) { -switch (hw->ptp.phy_model) { -case ICE_PHY_ETH56G : +switch (hw->mac_type) { +case ICE_MAC_GENERIC_3K_E825 :return ICE_E825C_OUT_PROP_DELAY_NS ; -case ICE_PHY_E810 : +case ICE_MAC_E810 :return ICE_E810_OUT_PROP_DELAY_NS ; -case ICE_PHY_E82X : +case ICE_MAC_GENERIC :return ice_e82x_pps_delay (ice_e82x_time_ref (hw));default :return 0 ;
@@ -456,12 +456,12 @@ static inline u64 ice_prop_delay(const struct ice_hw *hw)*/ static inline u64 ice_get_base_incval (struct ice_hw *hw) { -switch (hw->ptp.phy_model) { -case ICE_PHY_ETH56G : +switch (hw->mac_type) { +case ICE_MAC_GENERIC_3K_E825 :return ICE_ETH56G_NOMINAL_INCVAL ; -case ICE_PHY_E810 : +case ICE_MAC_E810 :return ICE_PTP_NOMINAL_INCVAL_E810 ; -case ICE_PHY_E82X : +case ICE_MAC_GENERIC :return ice_e82x_nominal_incval (ice_e82x_time_ref (hw));default :return 0 ;
drivers/net/ethernet/intel/ice/ice_type.h +0 -9
@@ -860,14 +860,6 @@ union ice_phy_params {struct ice_eth56g_params eth56g; }; -/* PHY model */ -enum ice_phy_model { -ICE_PHY_UNSUP =-1 , -ICE_PHY_E810 =1 , -ICE_PHY_E82X , -ICE_PHY_ETH56G , -}; -/* Global Link Topology */ enum ice_global_link_topo {ICE_LINK_TOPO_UP_TO_2_LINKS ,
@@ -877,7 +869,6 @@ enum ice_global_link_topo { };struct ice_ptp_hw { -enum ice_phy_model phy_model;union ice_phy_params phy;u8 num_lports;u8 ports_per_phy;
Signature · 1 line
2.46.0
PATCH v6 2/6 ice: Use FIELD_PREP for timestamp values
In reply to Karol KolacinskiInstead of using shifts and casts, use FIELD_PREP after reading 40b timestamp values.
---
V5 -> V6: Replaced removed macros with the new ones
drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 9 ++++++--- drivers/net/ethernet/intel/ice/ice_ptp_hw.h | 13 +++++-------- 2 files changed, 11 insertions(+), 11 deletions(-)
drivers/net/ethernet/intel/ice/ice_ptp_hw.c +6 -3
@@ -1520,7 +1520,8 @@ static int ice_read_ptp_tstamp_eth56g(struct ice_hw *hw, u8 port, u8 idx,* lower 8 bits in the low register, and the upper 32 bits in the high * register. */ - *tstamp = ((u64 )hi) <<TS_PHY_HIGH_S | ((u64 )lo &TS_PHY_LOW_M ); + *tstamp =FIELD_PREP (PHY_40B_HIGH_M , hi) | +FIELD_PREP (PHY_40B_LOW_M , lo);return 0 ; }
@@ -3199,7 +3200,8 @@ ice_read_phy_tstamp_e82x(struct ice_hw *hw, u8 quad, u8 idx, u64 *tstamp)* lower 8 bits in the low register, and the upper 32 bits in the high * register. */ - *tstamp =FIELD_PREP (TS_PHY_HIGH_M , hi) |FIELD_PREP (TS_PHY_LOW_M , lo); + *tstamp =FIELD_PREP (PHY_40B_HIGH_M , hi) | +FIELD_PREP (PHY_40B_LOW_M , lo);return 0 ; }
@@ -4952,7 +4954,8 @@ ice_read_phy_tstamp_e810(struct ice_hw *hw, u8 lport, u8 idx, u64 *tstamp)/* For E810 devices, the timestamp is reported with the lower 32 bits * in the low register, and the upper 8 bits in the high register. */ - *tstamp = ((u64 )hi) <<TS_HIGH_S | ((u64 )lo &TS_LOW_M ); + *tstamp =FIELD_PREP (PHY_EXT_40B_HIGH_M , hi) | +FIELD_PREP (PHY_EXT_40B_LOW_M , lo);return 0 ; }
drivers/net/ethernet/intel/ice/ice_ptp_hw.h +5 -8
@@ -673,15 +673,12 @@ static inline u64 ice_get_base_incval(struct ice_hw *hw)/* Source timer incval macros */ #define INCVAL_HIGH_M 0xFF -/* Timestamp block macros */ +/* PHY 40b registers macros */ +#define PHY_EXT_40B_LOW_M GENMASK(31, 0) +#define PHY_EXT_40B_HIGH_M GENMASK_ULL(39, 32) +#define PHY_40B_LOW_M GENMASK(7, 0) +#define PHY_40B_HIGH_M GENMASK_ULL(39, 8)#define TS_VALID BIT(0) -#define TS_LOW_M 0xFFFFFFFF -#define TS_HIGH_M 0xFF -#define TS_HIGH_S 32 - -#define TS_PHY_LOW_M 0xFF -#define TS_PHY_HIGH_M 0xFFFFFFFF -#define TS_PHY_HIGH_S 8#define BYTES_PER_IDX_ADDR_L_U 8#define BYTES_PER_IDX_ADDR_L 4
Signature · 1 line
2.46.0
PATCH v6 3/6 ice: Implement PTP support for E830 devices
In reply to Karol KolacinskiFrom: Michal Michalik <[email protected]>
Add specific functions and definitions for E830 devices to enable PTP support.
Introduce new PHY model ICE_PHY_E830.
E830 devices support direct write to GLTSYN_ registers without shadow registers and 64 bit read of PHC time.
---
V4 -> V5: Edited return values
V3 -> V4: Fixed kdoc for other ice_is_e***() and other _e830() functions in
ice_ptp_hw.c
V2 -> V3: Fixed kdoc for ice_is_e***() and ice_ptp_init_phy_e830() V1 -> V2: Fixed compilation issue with GENMASK bits higher than 32
.../net/ethernet/intel/ice/ice_hw_autogen.h | 4 + drivers/net/ethernet/intel/ice/ice_ptp.c | 25 ++- drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 178 +++++++++++++++++- drivers/net/ethernet/intel/ice/ice_ptp_hw.h | 12 ++ 4 files changed, 204 insertions(+), 15 deletions(-)
drivers/net/ethernet/intel/ice/ice_hw_autogen.h +4 -0
@@ -533,10 +533,14 @@#define PFPM_WUS_MAG_M BIT(1)#define PFPM_WUS_MNG_M BIT(3)#define PFPM_WUS_FW_RST_WK_M BIT(31) +#define E830_PRTMAC_TS_TX_MEM_VALID_H 0x001E2020 +#define E830_PRTMAC_TS_TX_MEM_VALID_L 0x001E2000#define E830_PRTMAC_CL01_PS_QNT 0x001E32A0#define E830_PRTMAC_CL01_PS_QNT_CL0_M GENMASK(15, 0)#define E830_PRTMAC_CL01_QNT_THR 0x001E3320#define E830_PRTMAC_CL01_QNT_THR_CL0_M GENMASK(15, 0) +#define E830_PRTTSYN_TXTIME_H (_i) (0x001E5800 + ((_i) * 32)) +#define E830_PRTTSYN_TXTIME_L (_i) (0x001E5000 + ((_i) * 32))#define VFINT_DYN_CTLN (_i) (0x00003800 + ((_i) * 4))#define VFINT_DYN_CTLN_CLEARPBA_M BIT(1)
drivers/net/ethernet/intel/ice/ice_ptp.c +20 -5
@@ -298,6 +298,15 @@ ice_ptp_read_src_clk_reg(struct ice_pf *pf, struct ptp_system_timestamp *sts)/* Read the system timestamp pre PHC read */ ptp_read_system_prets (sts); +if (hw->mac_type ==ICE_MAC_E830 ) { +u64 clk_time =rd64 (hw,E830_GLTSYN_TIME_L (tmr_idx)); + +/* Read the system timestamp post PHC read */ +ptp_read_system_postts (sts); + +return clk_time; + } + lo =rd32 (hw,GLTSYN_TIME_L (tmr_idx));/* Read the system timestamp post PHC read */
@@ -1284,6 +1293,7 @@ ice_ptp_port_phy_stop(struct ice_ptp_port *ptp_port)switch (hw->mac_type) {case ICE_MAC_E810 : +case ICE_MAC_E830 : err =0 ;break ;case ICE_MAC_GENERIC :
@@ -1330,6 +1340,7 @@ ice_ptp_port_phy_restart(struct ice_ptp_port *ptp_port)switch (hw->mac_type) {case ICE_MAC_E810 : +case ICE_MAC_E830 : err =0 ;break ;case ICE_MAC_GENERIC :
@@ -1405,10 +1416,11 @@ void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup)switch (hw->mac_type) {case ICE_MAC_E810 : -/* Do not reconfigure E810 PHY */ +case ICE_MAC_E830 : +/* Do not reconfigure E810 or E830 PHY */ return ; -case ICE_MAC_GENERIC_3K_E825 :case ICE_MAC_GENERIC : +case ICE_MAC_GENERIC_3K_E825 :ice_ptp_port_phy_restart (ptp_port);return ;default :
@@ -1471,6 +1483,7 @@ static int ice_ptp_cfg_phy_interrupt(struct ice_pf *pf, bool ena, u32 threshold)return 0 ; }case ICE_MAC_E810 : +case ICE_MAC_E830 :return 0 ;case ICE_MAC_UNKNOWN :default :
@@ -2628,6 +2641,7 @@ static void ice_ptp_set_caps(struct ice_pf *pf)switch (pf->hw.mac_type) {case ICE_MAC_E810 : +case ICE_MAC_E830 :ice_ptp_set_funcs_e810 (pf);return ;case ICE_MAC_GENERIC :
@@ -3271,10 +3285,8 @@ static int ice_ptp_init_port(struct ice_pf *pf, struct ice_ptp_port *ptp_port)mutex_init (&ptp_port->ps_lock);switch (hw->mac_type) { -case ICE_MAC_GENERIC_3K_E825 : -return ice_ptp_init_tx_eth56g (pf, &ptp_port->tx, - ptp_port->port_num);case ICE_MAC_E810 : +case ICE_MAC_E830 :return ice_ptp_init_tx_e810 (pf, &ptp_port->tx);case ICE_MAC_GENERIC : kthread_init_delayed_work(&ptp_port->ov_work,
@@ -3282,6 +3294,9 @@ static int ice_ptp_init_port(struct ice_pf *pf, struct ice_ptp_port *ptp_port)return ice_ptp_init_tx_e82x (pf, &ptp_port->tx, ptp_port->port_num); +case ICE_MAC_GENERIC_3K_E825 : +return ice_ptp_init_tx_eth56g (pf, &ptp_port->tx, + ptp_port->port_num);default :return -ENODEV ; }
drivers/net/ethernet/intel/ice/ice_ptp_hw.c +168 -10
252 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_ptp_hw.h +12 -0
@@ -327,6 +327,7 @@ extern const struct ice_vernier_info_e82x e822_vernier[NUM_ICE_PTP_LNK_SPD];#define ICE_E810_PLL_FREQ 812500000#define ICE_PTP_NOMINAL_INCVAL_E810 0x13b13b13bULL#define ICE_E810_OUT_PROP_DELAY_NS 1 +#define ICE_E810_E830_SYNC_DELAY 0#define ICE_E825C_OUT_PROP_DELAY_NS 11/* Device agnostic functions */
@@ -670,6 +671,12 @@ static inline u64 ice_get_base_incval(struct ice_hw *hw)/* E810 timer command register */ #define E810_ETH_GLTSYN_CMD 0x03000344 +/* E830 timer command register */ +#define E830_ETH_GLTSYN_CMD 0x00088814 + +/* E810 PHC time register */ +#define E830_GLTSYN_TIME_L (_tmr_idx) (0x0008A000 + 0x1000 * (_tmr_idx)) +/* Source timer incval macros */ #define INCVAL_HIGH_M 0xFF
@@ -702,6 +709,11 @@ static inline u64 ice_get_base_incval(struct ice_hw *hw)#define LOW_TX_MEMORY_BANK_START 0x03090000#define HIGH_TX_MEMORY_BANK_START 0x03090004 +#define E830_LOW_TX_MEMORY_BANK (slot, port) \ + (E830_PRTTSYN_TXTIME_L(slot) + 0x8 * (port)) +#define E830_HIGH_TX_MEMORY_BANK (slot, port) \ + (E830_PRTTSYN_TXTIME_H(slot) + 0x8 * (port)) +/* SMA controller pin control */ #define ICE_SMA1_DIR_EN BIT(4)#define ICE_SMA1_TX_EN BIT(5)
Signature · 1 line
2.46.0
PATCH v6 4/6 ice: Process TSYN IRQ in a separate function
In reply to Karol KolacinskiSimplify TSYN IRQ processing by moving it to a separate function and having appropriate behavior per PHY model, instead of multiple conditions not related to HW, but to specific timestamping modes.
--- drivers/net/ethernet/intel/ice/ice_main.c | 18 +------ drivers/net/ethernet/intel/ice/ice_ptp.c | 59 +++++++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_ptp.h | 6 +++ 3 files changed, 67 insertions(+), 16 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +2 -16
@@ -3257,22 +3257,8 @@ static irqreturn_t ice_misc_intr(int __always_unused irq, void *data)if (oicr &PFINT_OICR_TSYN_TX_M ) { ena_mask &= ~PFINT_OICR_TSYN_TX_M ; -if (ice_pf_state_is_nominal (pf) && - pf->hw.dev_caps.ts_dev_info.ts_ll_int_read) { -struct ice_ptp_tx *tx = &pf->ptp.port.tx; -unsigned long flags; -u8 idx; - -spin_lock_irqsave (&tx->lock, flags); - idx =find_next_bit_wrap (tx->in_use, tx->len, - tx->last_ll_ts_idx_read +1 ); -if (idx != tx->len) -ice_ptp_req_tx_single_tstamp (tx, idx); -spin_unlock_irqrestore (&tx->lock, flags); - }else if (ice_ptp_pf_handles_tx_interrupt (pf)) { -set_bit (ICE_MISC_THREAD_TX_TSTAMP , pf->misc_thread); - ret =IRQ_WAKE_THREAD ; - } + + ret =ice_ptp_ts_irq (pf); }if (oicr &PFINT_OICR_TSYN_EVNT_M ) {
drivers/net/ethernet/intel/ice/ice_ptp.c +59 -0
65 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_ptp.h +6 -0
@@ -322,6 +322,7 @@ s8 ice_ptp_request_ts(struct ice_ptp_tx *tx, struct sk_buff *skb);void ice_ptp_req_tx_single_tstamp (struct ice_ptp_tx *tx,u8 idx);void ice_ptp_complete_tx_single_tstamp (struct ice_ptp_tx *tx);enum ice_tx_tstamp_work ice_ptp_process_ts (struct ice_pf *pf); +irqreturn_t ice_ptp_ts_irq (struct ice_pf *pf);u64 ice_ptp_get_rx_hwts (const union ice_32b_rx_flex_desc *rx_desc,const struct ice_pkt_ctx *pkt_ctx);
@@ -360,6 +361,11 @@ static inline bool ice_ptp_process_ts(struct ice_pf *pf)return true; } +static inline irqreturn_t ice_ptp_ts_irq (struct ice_pf *pf) +{ +return IRQ_HANDLED ; +} +static inline u64 ice_ptp_get_rx_hwts (const union ice_32b_rx_flex_desc *rx_desc,const struct ice_pkt_ctx *pkt_ctx)
Signature · 1 line
2.46.0
PATCH v6 5/6 ice: Add timestamp ready bitmap for E830 products
In reply to Karol KolacinskiE830 PHY supports timestamp ready bitmap. Enable the bitmap by refactoring tx init function.
--- drivers/net/ethernet/intel/ice/ice_ptp.c | 56 +++++++----------------- drivers/net/ethernet/intel/ice/ice_ptp.h | 3 +- 2 files changed, 17 insertions(+), 42 deletions(-)
drivers/net/ethernet/intel/ice/ice_ptp.c +16 -40
@@ -942,28 +942,6 @@ ice_ptp_release_tx_tracker(struct ice_pf *pf, struct ice_ptp_tx *tx) tx->len =0 ; } -/** -* ice_ptp_init_tx_eth56g - Initialize tracking for Tx timestamps -* @pf: Board private structure -* @tx: the Tx tracking structure to initialize -* @port: the port this structure tracks -* -* Initialize the Tx timestamp tracker for this port. ETH56G PHYs -* have independent memory blocks for all ports. -* -* Return: 0 for success, -ENOMEM when failed to allocate Tx tracker -*/ -static int ice_ptp_init_tx_eth56g (struct ice_pf *pf,struct ice_ptp_tx *tx, -u8 port) -{ - tx->block = port; - tx->offset =0 ; - tx->len =INDEX_PER_PORT_ETH56G ; - tx->has_ready_bitmap =1 ; - -return ice_ptp_alloc_tx_tracker (tx); -} -/** * ice_ptp_init_tx_e82x - Initialize tracking for Tx timestamps * @pf: Board private structure
@@ -974,9 +952,11 @@ static int ice_ptp_init_tx_eth56g(struct ice_pf *pf, struct ice_ptp_tx *tx,* the timestamp block is shared for all ports in the same quad. To avoid * ports using the same timestamp index, logically break the block of * registers into chunks based on the port number. +* +* Return: 0 on success, -ENOMEM when out of memory */ -static int -ice_ptp_init_tx_e82x (struct ice_pf *pf,struct ice_ptp_tx *tx,u8 port) +static int ice_ptp_init_tx_e82x (struct ice_pf *pf,struct ice_ptp_tx *tx, +u8 port) { tx->block =ICE_GET_QUAD_NUM (port); tx->offset = (port %ICE_PORTS_PER_QUAD ) *INDEX_PER_PORT_E82X ;
@@ -987,24 +967,27 @@ ice_ptp_init_tx_e82x(struct ice_pf *pf, struct ice_ptp_tx *tx, u8 port) }/** -* ice_ptp_init_tx_e810 - Initialize tracking for Tx timestamps +* ice_ptp_init_tx - Initialize tracking for Tx timestamps * @pf: Board private structure * @tx: the Tx tracking structure to initialize +* @port: the port this structure tracks * -* Initialize the Tx timestamp tracker for this PF. For E810 devices, each -* port has its own block of timestamps, independent of the other ports. +* Initialize the Tx timestamp tracker for this PF. For all PHYs except E82X, +* each port has its own block of timestamps, independent of the other ports. +* +* Return: 0 on success, -ENOMEM when out of memory */ -static int -ice_ptp_init_tx_e810 (struct ice_pf *pf,struct ice_ptp_tx *tx) +static int ice_ptp_init_tx (struct ice_pf *pf,struct ice_ptp_tx *tx,u8 port) { - tx->block = pf->hw.port_info->lport; + tx->block = port; tx->offset =0 ; - tx->len =INDEX_PER_PORT_E810 ; + tx->len =INDEX_PER_PORT ; +/* The E810 PHY does not provide a timestamp ready bitmap. Instead, * verify new timestamps against cached copy of the last read * timestamp. */ - tx->has_ready_bitmap =0 ; + tx->has_ready_bitmap = pf->hw.mac_type !=ICE_MAC_E810 ;return ice_ptp_alloc_tx_tracker (tx); }
@@ -3344,20 +3327,13 @@ static int ice_ptp_init_port(struct ice_pf *pf, struct ice_ptp_port *ptp_port)mutex_init (&ptp_port->ps_lock);switch (hw->mac_type) { -case ICE_MAC_E810 : -case ICE_MAC_E830 : -return ice_ptp_init_tx_e810 (pf, &ptp_port->tx);case ICE_MAC_GENERIC :kthread_init_delayed_work (&ptp_port->ov_work, ice_ptp_wait_for_offsets); -return ice_ptp_init_tx_e82x (pf, &ptp_port->tx, ptp_port->port_num); -case ICE_MAC_GENERIC_3K_E825 : -return ice_ptp_init_tx_eth56g (pf, &ptp_port->tx, - ptp_port->port_num);default : -return -ENODEV ; +return ice_ptp_init_tx (pf, &ptp_port->tx, ptp_port->port_num); } }
drivers/net/ethernet/intel/ice/ice_ptp.h +1 -2
@@ -128,8 +128,7 @@ struct ice_ptp_tx {/* Quad and port information for initializing timestamp blocks */ #define INDEX_PER_QUAD 64#define INDEX_PER_PORT_E82X 16 -#define INDEX_PER_PORT_E810 64 -#define INDEX_PER_PORT_ETH56G 64 +#define INDEX_PER_PORT 64/** * struct ice_ptp_port - data used to initialize an external port for PTP
Signature · 1 line
2.46.0
PATCH v6 6/6 ice: combine cross timestamp functions for E82x and E830
In reply to Karol KolacinskiFrom: Jacob Keller <[email protected]>
The E830 and E82x devices use essentially the same logic for performing a crosstimestamp. The only difference is that E830 hardware has different offsets. Instead of having two implementations, combine them into a single ice_capture_crosststamp() function.
Also combine the wrapper functions which call get_device_system_crosststamp() into a single ice_ptp_getcrosststamp() function.
To support both hardware types, the ice_capture_crosststamp function must be able to determine the appropriate registers to access. To handle this, pass a custom context structure instead of the PF pointer. This structure, ice_crosststamp_ctx, contains a pointer to the PF, and a pointer to the device configuration structure. This new structure also will make it easier to implement historic snapshot support in a future commit.
The device configuration structure is a static const data which defines the offsets and flags for the various registers. This includes the lock register, the cross timestamp control register, the upper and lower ART system time capture registers, and the upper and lower device time capture registers for each timer index.
This does add extra data to the .text of the module (and thus kernel), but it also removes 2 near duplicate functions for enabling E830 support.
Use the configuration structure to access all of the registers in ice_capture_crosststamp(). Ensure that we don't over-run the device time array by checking that the timer index is 0 or 1. Previously this was simply assumed, and it would cause the device to read an incorrect and likely garbage register.
It does feel like there should be a kernel interface for managing register offsets like this, but the closest thing I saw was <linux/regmap.h> which is interesting but not quite what we're looking for...
---
V4 -> V5: Removed unnecessary CPU features check for SoCs (E82X) and
X86_FEATURE_TSC_KNOWN_FREQ check for E830
drivers/net/ethernet/intel/Kconfig | 2 +- .../net/ethernet/intel/ice/ice_hw_autogen.h | 8 + drivers/net/ethernet/intel/ice/ice_main.c | 7 + drivers/net/ethernet/intel/ice/ice_ptp.c | 246 ++++++++++++------ 4 files changed, 187 insertions(+), 76 deletions(-)
drivers/net/ethernet/intel/Kconfig +1 -1
@@ -334,7 +334,7 @@ config ICE_SWITCHDEV config ICE_HWTS bool "Support HW cross-timestamp on platforms with PTM support" default y - depends on ICE && X86 + depends on ICE && X86 && PCIE_PTM help Say Y to enable hardware supported cross-timestamping on platforms with PCIe PTM support. The cross-timestamp is available through
drivers/net/ethernet/intel/ice/ice_hw_autogen.h +8 -0
@@ -541,6 +541,14 @@#define E830_PRTMAC_CL01_QNT_THR_CL0_M GENMASK(15, 0)#define E830_PRTTSYN_TXTIME_H (_i) (0x001E5800 + ((_i) * 32))#define E830_PRTTSYN_TXTIME_L (_i) (0x001E5000 + ((_i) * 32)) +#define E830_GLPTM_ART_CTL 0x00088B50 +#define E830_GLPTM_ART_CTL_ACTIVE_M BIT(0) +#define E830_GLPTM_ART_TIME_H 0x00088B54 +#define E830_GLPTM_ART_TIME_L 0x00088B58 +#define E830_GLTSYN_PTMTIME_H (_i) (0x00088B48 + ((_i) * 4)) +#define E830_GLTSYN_PTMTIME_L (_i) (0x00088B40 + ((_i) * 4)) +#define E830_PFPTM_SEM 0x00088B00 +#define E830_PFPTM_SEM_BUSY_M BIT(0)#define VFINT_DYN_CTLN (_i) (0x00003800 + ((_i) * 4))#define VFINT_DYN_CTLN_CLEARPBA_M BIT(1)
drivers/net/ethernet/intel/ice/ice_main.c +7 -0
@@ -5042,6 +5042,12 @@ static int ice_init(struct ice_pf *pf)if (err)return err; +if (pf->hw.mac_type ==ICE_MAC_E830 ) { + err =pci_enable_ptm (pf->pdev,NULL ); +if (err) +dev_dbg (ice_pf_to_dev (pf),"PCIe PTM not supported by PCIe bus/controller\n" ); + } + err =ice_alloc_vsis (pf);if (err) goto err_alloc_vsis;
@@ -5272,6 +5278,7 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent) hw->subsystem_device_id = pdev->subsystem_device; hw->bus.device =PCI_SLOT (pdev->devfn); hw->bus.func =PCI_FUNC (pdev->devfn); +ice_set_ctrlq_len (hw); pf->msg_enable =netif_msg_init (debug,ICE_DFLT_NETIF_M );
drivers/net/ethernet/intel/ice/ice_ptp.c +171 -75
313 lines not on this page · raw message
Signature · 1 line
2.46.0