@@ -754,29 +754,32 @@ ice_read_phy_tstamp_e822(struct ice_hw *hw, u8 quad, u8 idx, u64 *tstamp)
754754 * @quad: the quad to read from
755755 * @idx: the timestamp index to reset
756756 *
757- * Clear a timestamp, resetting its valid bit, from the PHY quad block that is
758- * shared between the internal PHYs on the E822 devices.
757+ * Read the timestamp out of the quad to clear its timestamp status bit from
758+ * the PHY quad block that is shared between the internal PHYs of the E822
759+ * devices.
760+ *
761+ * Note that unlike E810, software cannot directly write to the quad memory
762+ * bank registers. E822 relies on the ice_get_phy_tx_tstamp_ready() function
763+ * to determine which timestamps are valid. Reading a timestamp auto-clears
764+ * the valid bit.
765+ *
766+ * To directly clear the contents of the timestamp block entirely, discarding
767+ * all timestamp data at once, software should instead use
768+ * ice_ptp_reset_ts_memory_quad_e822().
769+ *
770+ * This function should only be called on an idx whose bit is set according to
771+ * ice_get_phy_tx_tstamp_ready().
759772 */
760773static int
761774ice_clear_phy_tstamp_e822 (struct ice_hw * hw , u8 quad , u8 idx )
762775{
763- u16 lo_addr , hi_addr ;
776+ u64 unused_tstamp ;
764777 int err ;
765778
766- lo_addr = (u16 )TS_L (Q_REG_TX_MEMORY_BANK_START , idx );
767- hi_addr = (u16 )TS_H (Q_REG_TX_MEMORY_BANK_START , idx );
768-
769- err = ice_write_quad_reg_e822 (hw , quad , lo_addr , 0 );
770- if (err ) {
771- ice_debug (hw , ICE_DBG_PTP , "Failed to clear low PTP timestamp register, err %d\n" ,
772- err );
773- return err ;
774- }
775-
776- err = ice_write_quad_reg_e822 (hw , quad , hi_addr , 0 );
779+ err = ice_read_phy_tstamp_e822 (hw , quad , idx , & unused_tstamp );
777780 if (err ) {
778- ice_debug (hw , ICE_DBG_PTP , "Failed to clear high PTP timestamp register, err %d\n" ,
779- err );
781+ ice_debug (hw , ICE_DBG_PTP , "Failed to read the timestamp register for quad %u, idx %u , err %d\n" ,
782+ quad , idx , err );
780783 return err ;
781784 }
782785
@@ -2812,28 +2815,39 @@ ice_read_phy_tstamp_e810(struct ice_hw *hw, u8 lport, u8 idx, u64 *tstamp)
28122815 * @lport: the lport to read from
28132816 * @idx: the timestamp index to reset
28142817 *
2815- * Clear a timestamp, resetting its valid bit, from the timestamp block of the
2816- * external PHY on the E810 device.
2818+ * Read the timestamp and then forcibly overwrite its value to clear the valid
2819+ * bit from the timestamp block of the external PHY on the E810 device.
2820+ *
2821+ * This function should only be called on an idx whose bit is set according to
2822+ * ice_get_phy_tx_tstamp_ready().
28172823 */
28182824static int ice_clear_phy_tstamp_e810 (struct ice_hw * hw , u8 lport , u8 idx )
28192825{
28202826 u32 lo_addr , hi_addr ;
2827+ u64 unused_tstamp ;
28212828 int err ;
28222829
2830+ err = ice_read_phy_tstamp_e810 (hw , lport , idx , & unused_tstamp );
2831+ if (err ) {
2832+ ice_debug (hw , ICE_DBG_PTP , "Failed to read the timestamp register for lport %u, idx %u, err %d\n" ,
2833+ lport , idx , err );
2834+ return err ;
2835+ }
2836+
28232837 lo_addr = TS_EXT (LOW_TX_MEMORY_BANK_START , lport , idx );
28242838 hi_addr = TS_EXT (HIGH_TX_MEMORY_BANK_START , lport , idx );
28252839
28262840 err = ice_write_phy_reg_e810 (hw , lo_addr , 0 );
28272841 if (err ) {
2828- ice_debug (hw , ICE_DBG_PTP , "Failed to clear low PTP timestamp register, err %d\n" ,
2829- err );
2842+ ice_debug (hw , ICE_DBG_PTP , "Failed to clear low PTP timestamp register for lport %u, idx %u , err %d\n" ,
2843+ lport , idx , err );
28302844 return err ;
28312845 }
28322846
28332847 err = ice_write_phy_reg_e810 (hw , hi_addr , 0 );
28342848 if (err ) {
2835- ice_debug (hw , ICE_DBG_PTP , "Failed to clear high PTP timestamp register, err %d\n" ,
2836- err );
2849+ ice_debug (hw , ICE_DBG_PTP , "Failed to clear high PTP timestamp register for lport %u, idx %u , err %d\n" ,
2850+ lport , idx , err );
28372851 return err ;
28382852 }
28392853
@@ -3515,9 +3529,15 @@ int ice_read_phy_tstamp(struct ice_hw *hw, u8 block, u8 idx, u64 *tstamp)
35153529 * @block: the block to read from
35163530 * @idx: the timestamp index to reset
35173531 *
3518- * Clear a timestamp, resetting its valid bit, from the timestamp block. For
3519- * E822 devices, the block is the quad to clear from. For E810 devices, the
3520- * block is the logical port to clear from.
3532+ * Clear a timestamp from the timestamp block, discarding its value without
3533+ * returning it. This resets the memory status bit for the timestamp index
3534+ * allowing it to be reused for another timestamp in the future.
3535+ *
3536+ * For E822 devices, the block number is the PHY quad to clear from. For E810
3537+ * devices, the block number is the logical port to clear from.
3538+ *
3539+ * This function must only be called on a timestamp index whose valid bit is
3540+ * set according to ice_get_phy_tx_tstamp_ready().
35213541 */
35223542int ice_clear_phy_tstamp (struct ice_hw * hw , u8 block , u8 idx )
35233543{
0 commit comments