]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ice: Refactor ice_ptp_init_tx_*
authorKarol Kolacinski <karol.kolacinski@intel.com>
Mon, 30 Sep 2024 12:12:43 +0000 (14:12 +0200)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Mon, 10 Feb 2025 18:43:47 +0000 (10:43 -0800)
Unify ice_ptp_init_tx_* functions for most of the MAC types except E82X.
This simplifies the code for the future use with new MAC types.

Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Signed-off-by: Karol Kolacinski <karol.kolacinski@intel.com>
Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/ice/ice_ptp.c
drivers/net/ethernet/intel/ice/ice_ptp.h

index 6e1801285a5d65e4fac5c3d002e171dc8bddde34..79ec8727388b84bf9c0d64e0ba31f3fdfb5f83d8 100644 (file)
@@ -971,28 +971,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
@@ -1003,9 +981,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;
@@ -1016,24 +996,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 all PHYs except E82X,
+ * each port has its own block of timestamps, independent of the other ports.
  *
- * Initialize the Tx timestamp tracker for this PF. For E810 devices, 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);
 }
@@ -3235,6 +3218,8 @@ static int ice_ptp_init_work(struct ice_pf *pf, struct ice_ptp *ptp)
  * ice_ptp_init_port - Initialize PTP port structure
  * @pf: Board private structure
  * @ptp_port: PTP port structure
+ *
+ * Return: 0 on success, -ENODEV on invalid MAC type, -ENOMEM on failed alloc.
  */
 static int ice_ptp_init_port(struct ice_pf *pf, struct ice_ptp_port *ptp_port)
 {
@@ -3244,16 +3229,13 @@ static int ice_ptp_init_port(struct ice_pf *pf, struct ice_ptp_port *ptp_port)
 
        switch (hw->mac_type) {
        case ICE_MAC_E810:
-               return ice_ptp_init_tx_e810(pf, &ptp_port->tx);
+       case ICE_MAC_GENERIC_3K_E825:
+               return ice_ptp_init_tx(pf, &ptp_port->tx, ptp_port->port_num);
        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;
        }
index a3b27f7162825f3da3fc695785c3c2d7b15f36f9..783139de7f7419030bcd3c9bb3457bd334a5ba9b 100644 (file)
@@ -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