Skip to contentSkip to conversation

ice: introduce hw->phy_model for handling PTP PHY differences

PATCH In review Jacob Keller 3 participants 4 messages Jul 17, 2023 – Jul 28, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ice: introduce hw->phy_model for handling PTP PHY differences

The ice driver has PTP support which works across a couple of different device families. The device families each have different PHY hardware which have unique requirements for programming.

Today, there is E810-based hardware, and E822-based hardware. To handle this, the driver checks the ice_is_e810() function to separate between the two existing families of hardware.

Future development is going to add new hardware designs which have further unique requirements. To make this easier, introduce a phy_model field to the HW structure. This field represents what PHY model the current device has, and is used to allow distinguishing which logic a particular device needs.

This will make supporting future upcoming hardware easier, by providing an obvious place to initialize the PHY model, and by already using switch/case statements instead of the previous if statements.

Astute reviewers may notice that there are a handful of remaining checks for ice_is_e810() left in ice_ptp.c These conflict with some other cleanup patches in development, and will be fixed in the near future.

---
 drivers/net/ethernet/intel/ice/ice_ptp.c    |  32 ++++--
 drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 104 ++++++++++++++++----
 drivers/net/ethernet/intel/ice/ice_ptp_hw.h |   2 +
 drivers/net/ethernet/intel/ice/ice_type.h   |   8 ++
 4 files changed, 120 insertions(+), 26 deletions(-)
drivers/net/ethernet/intel/ice/ice_ptp.c +25 -7
index db78bf156df4..8ac5afbbf9c2 100644
@@ -1366,6 +1366,7 @@ ice_ptp_port_phy_restart(struct ice_ptp_port *ptp_port)
 void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup)
 {
 	struct ice_ptp_port *ptp_port;
+	struct ice_hw *hw = &pf->hw;
 
 	if (!test_bit(ICE_FLAG_PTP, pf->flags))
 		return;
@@ -1380,11 +1381,18 @@ void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup)
 	/* Update cached link status for this port immediately */
 	ptp_port->link_up = linkup;
 
-	/* E810 devices do not need to reconfigure the PHY */
-	if (ice_is_e810(&pf->hw))
+	switch (hw->phy_model) {
+	case ICE_PHY_E810:
+		/* Do not reconfigure E810 PHY */
 		return;
+	case ICE_PHY_E822:
 
-	ice_ptp_port_phy_restart(ptp_port);
+		ice_ptp_port_phy_restart(ptp_port);
+
+		return;
+	default:
+		dev_warn(ice_pf_to_dev(pf), "%s: Unknown PHY type\n", __func__);
+	}
 }
 
 /**
@@ -2702,14 +2710,22 @@ static int ice_ptp_init_work(struct ice_pf *pf, struct ice_ptp *ptp)
  */
 static int ice_ptp_init_port(struct ice_pf *pf, struct ice_ptp_port *ptp_port)
 {
+	struct ice_hw *hw = &pf->hw;
+
 	mutex_init(&ptp_port->ps_lock);
 
-	if (ice_is_e810(&pf->hw))
+	switch (hw->phy_model) {
+	case ICE_PHY_E810:
 		return ice_ptp_init_tx_e810(pf, &ptp_port->tx);
+	case ICE_PHY_E822:
+		kthread_init_delayed_work(&ptp_port->ov_work,
+					  ice_ptp_wait_for_offsets);
 
-	kthread_init_delayed_work(&ptp_port->ov_work,
-				  ice_ptp_wait_for_offsets);
-	return ice_ptp_init_tx_e822(pf, &ptp_port->tx, ptp_port->port_num);
+		return ice_ptp_init_tx_e822(pf, &ptp_port->tx,
+					    ptp_port->port_num);
+	default:
+		return -ENODEV;
+	}
 }
 
 /**
@@ -2730,6 +2746,8 @@ void ice_ptp_init(struct ice_pf *pf)
 	struct ice_hw *hw = &pf->hw;
 	int err;
 
+	ice_ptp_init_phy_model(hw);
+
 	/* If this function owns the clock hardware, it must allocate and
 	 * configure the PTP clock device to represent it.
 	 */
drivers/net/ethernet/intel/ice/ice_ptp_hw.c +85 -19

181 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_ptp_hw.h +2 -0
index ba4ab96073e0..c17d9dcf96f2 100644
@@ -203,6 +203,8 @@ int ice_write_sma_ctrl_e810t(struct ice_hw *hw, u8 data);
 int ice_read_pca9575_reg_e810t(struct ice_hw *hw, u8 offset, u8 *data);
 bool ice_is_pca9575_present(struct ice_hw *hw);
 
+int ice_ptp_init_phy_model(struct ice_hw *hw);
+
 #define PFTSYN_SEM_BYTES	4
 
 #define ICE_PTP_CLOCK_INDEX_0	0x00
drivers/net/ethernet/intel/ice/ice_type.h +8 -0
index f1231a8162af..581b18cd32d0 100644
@@ -805,6 +805,13 @@ struct ice_mbx_data {
 	u16 async_watermark_val;
 };
 
+/* PHY model */
+enum ice_phy_model {
+	ICE_PHY_UNSUP = -1,
+	ICE_PHY_E810  = 1,
+	ICE_PHY_E822,
+};
+
 /* Port hardware description */
 struct ice_hw {
 	u8 __iomem *hw_addr;
@@ -826,6 +833,7 @@ struct ice_hw {
 	u8 revision_id;
 
 	u8 pf_id;		/* device profile info */
+	enum ice_phy_model phy_model;
 
 	u16 max_burst_size;	/* driver sets this value */
 

base-commit: 3a78e3e1ac7da2f416519fc52260761e563d9509

Signature · 6 lines
2.41.0.1.g9857a21e0017.dirty

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
maintainer
#1 lore raw
Quoted 48 lines · Jacob Keller

The ice driver has PTP support which works across a couple of different device families. The device families each have different PHY hardware which have unique requirements for programming.

Today, there is E810-based hardware, and E822-based hardware. To handle this, the driver checks the ice_is_e810() function to separate between the two existing families of hardware.

Future development is going to add new hardware designs which have further unique requirements. To make this easier, introduce a phy_model field to the HW structure. This field represents what PHY model the current device has, and is used to allow distinguishing which logic a particular device needs.

This will make supporting future upcoming hardware easier, by providing an obvious place to initialize the PHY model, and by already using switch/case statements instead of the previous if statements.

Astute reviewers may notice that there are a handful of remaining checks for ice_is_e810() left in ice_ptp.c These conflict with some other cleanup patches in development, and will be fixed in the near future.

---
  drivers/net/ethernet/intel/ice/ice_ptp.c    |  32 ++++--
  drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 104 ++++++++++++++++----
  drivers/net/ethernet/intel/ice/ice_ptp_hw.h |   2 +
  drivers/net/ethernet/intel/ice/ice_type.h   |   8 ++
  4 files changed, 120 insertions(+), 26 deletions(-)
drivers/net/ethernet/intel/ice/ice_ptp.c +1 -2
index db78bf156df4..8ac5afbbf9c2 100644
@@ -1366,6 +1366,7 @@ ice_ptp_port_phy_restart(struct ice_ptp_port *ptp_port)
  void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup)
  {
  	struct ice_ptp_port *ptp_port;
+	struct ice_hw *hw = &pf->hw;
 
  	if (!test_bit(ICE_FLAG_PTP, pf->flags))
  		return;
@@ -1380,11 +1381,18 @@ void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup)
  	/* Update cached link status for this port immediately */
  	ptp_port->link_up = linkup;
 
-	/* E810 devices do not need to reconfigure the PHY */
-	if (ice_is_e810(&pf->hw))

drivers/net/ethernet/intel/ice/ice_ptp.c void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup) · line 1392

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +7 -1
+	switch (hw->phy_model) {
+	case ICE_PHY_E810:
+		/* Do not reconfigure E810 PHY */
  		return;
+	case ICE_PHY_E822:
 
-	ice_ptp_port_phy_restart(ptp_port);
+		ice_ptp_port_phy_restart(ptp_port);
+
+		return;

nit (if you end up respinning and agree) but not sure the newlines here are helpful/making more readable

Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +3 -0
+	default:
+		dev_warn(ice_pf_to_dev(pf), "%s: Unknown PHY type\n", __func__);
+	}
  }

...

Quoted 16 lines

/**

drivers/net/ethernet/intel/ice/ice_ptp.c +2 -0
@@ -2730,6 +2746,8 @@ void ice_ptp_init(struct ice_pf *pf)
  	struct ice_hw *hw = &pf->hw;
  	int err;
 
+	ice_ptp_init_phy_model(hw);
+
  	/* If this function owns the clock hardware, it must allocate and
  	 * configure the PTP clock device to represent it.
  	 */
drivers/net/ethernet/intel/ice/ice_ptp_hw.c +0 -0
index f174bac58aba..8afedd28ff94 100644
@@ -3138,6 +3138,23 @@ void ice_ptp_unlock(struct ice_hw *hw)
  	wr32(hw, PFTSYN_SEM + (PFTSYN_SEM_BYTES * hw->pf_id), 0);

drivers/net/ethernet/intel/ice/ice_ptp_hw.c void ice_ptp_unlock(struct ice_hw *hw) · line 3148

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_ptp_hw.c +8 -0
  }
 
+/**
+ * ice_ptp_init_phy_model - Initialize hw->phy_model based on device type
+ * @hw: pointer to the HW structure
+ *
+ * Determine the PHY model for the device, and initialize hw->phy_model
+ * for use by other functions.
+ */
+int ice_ptp_init_phy_model(struct ice_hw *hw)

Seems like this can be void? Doesn't seem like caller checks return either.

drivers/net/ethernet/intel/ice/ice_ptp_hw.c void ice_ptp_unlock(struct ice_hw *hw) · line 3157

Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_ptp_hw.c +9 -0
+{
+	if (ice_is_e810(hw))
+		hw->phy_model = ICE_PHY_E810;
+	else
+		hw->phy_model = ICE_PHY_E822;
+
+	return 0;
+}
+

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#2 lore raw
Quoted 68 lines

-----Original Message-----
From: Nguyen, Anthony L <[email protected]>
Sent: Tuesday, July 18, 2023 11:28 AM
To: Keller, Jacob E <[email protected]>; Intel Wired LAN <intel-wired- [email protected]>
Subject: Re: [PATCH iwl-next] ice: introduce hw->phy_model for handling PTP PHY differences

Quoted 23 lines · Jacob Keller

The ice driver has PTP support which works across a couple of different device families. The device families each have different PHY hardware which have unique requirements for programming.

Today, there is E810-based hardware, and E822-based hardware. To handle this, the driver checks the ice_is_e810() function to separate between the two existing families of hardware.

Future development is going to add new hardware designs which have further unique requirements. To make this easier, introduce a phy_model field to the HW structure. This field represents what PHY model the current device has, and is used to allow distinguishing which logic a particular device needs.

This will make supporting future upcoming hardware easier, by providing an obvious place to initialize the PHY model, and by already using switch/case statements instead of the previous if statements.

Astute reviewers may notice that there are a handful of remaining checks for ice_is_e810() left in ice_ptp.c These conflict with some other cleanup patches in development, and will be fixed in the near future.

Review

Quoted 8 lines
---
  drivers/net/ethernet/intel/ice/ice_ptp.c    |  32 ++++--
  drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 104 ++++++++++++++++----
  drivers/net/ethernet/intel/ice/ice_ptp_hw.h |   2 +
  drivers/net/ethernet/intel/ice/ice_type.h   |   8 ++
  4 files changed, 120 insertions(+), 26 deletions(-)
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_ptp.c

drivers/net/ethernet/intel/ice/ice_ptp.c ice_ptp_port_phy_restart(struct ice_ptp_port

Quoted 4 lines

index db78bf156df4..8ac5afbbf9c2 100644

drivers/net/ethernet/intel/ice/ice_ptp.c +0 -0
@@ -1366,6 +1366,7 @@ ice_ptp_port_phy_restart(struct ice_ptp_port

*ptp_port)

drivers/net/ethernet/intel/ice/ice_ptp.c void ice_ptp_link_change(struct ice_pf *pf, u8

Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +1 -0
  void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup)
  {
  	struct ice_ptp_port *ptp_port;
+	struct ice_hw *hw = &pf->hw;
 
  	if (!test_bit(ICE_FLAG_PTP, pf->flags))
  		return;
@@ -1380,11 +1381,18 @@ void ice_ptp_link_change(struct ice_pf *pf, u8

port, bool linkup)

Quoted 11 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +4 -2
  	/* Update cached link status for this port immediately */
  	ptp_port->link_up = linkup;
 
-	/* E810 devices do not need to reconfigure the PHY */
-	if (ice_is_e810(&pf->hw))
+	switch (hw->phy_model) {
+	case ICE_PHY_E810:
+		/* Do not reconfigure E810 PHY */
  		return;
+	case ICE_PHY_E822:
 
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_ptp.c void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup) · line 1392

Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +3 -1
-	ice_ptp_port_phy_restart(ptp_port);
+		ice_ptp_port_phy_restart(ptp_port);
+
+		return;

nit (if you end up respinning and agree) but not sure the newlines here are helpful/making more readable

Yea this was unintentional.

Quoted 27 lines

drivers/net/ethernet/intel/ice/ice_ptp.c void ice_ptp_link_change(struct ice_pf *pf, u8 · line 1394

Quoted 2 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +2 -0
+	default:
+		dev_warn(ice_pf_to_dev(pf), "%s: Unknown PHY type\n",

__func__);

Quoted 2 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +1 -0
+	}
  }

...

Review

Quoted 11 lines

/**

drivers/net/ethernet/intel/ice/ice_ptp.c +2 -0
@@ -2730,6 +2746,8 @@ void ice_ptp_init(struct ice_pf *pf)
  	struct ice_hw *hw = &pf->hw;
  	int err;
 
+	ice_ptp_init_phy_model(hw);
+
  	/* If this function owns the clock hardware, it must allocate and
  	 * configure the PTP clock device to represent it.
  	 */
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c

Quoted 7 lines

index f174bac58aba..8afedd28ff94 100644

drivers/net/ethernet/intel/ice/ice_ptp_hw.c +0 -0
@@ -3138,6 +3138,23 @@ void ice_ptp_unlock(struct ice_hw *hw)
  	wr32(hw, PFTSYN_SEM + (PFTSYN_SEM_BYTES * hw->pf_id), 0);
  }
 
Quoted 11 lines

drivers/net/ethernet/intel/ice/ice_ptp_hw.c void ice_ptp_unlock(struct ice_hw *hw) · line 3148

Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_ptp_hw.c +8 -0
+/**
+ * ice_ptp_init_phy_model - Initialize hw->phy_model based on device type
+ * @hw: pointer to the HW structure
+ *
+ * Determine the PHY model for the device, and initialize hw->phy_model
+ * for use by other functions.
+ */
+int ice_ptp_init_phy_model(struct ice_hw *hw)

Seems like this can be void? Doesn't seem like caller checks return either.

Strictly speaking, for now yes. I think some of the future hardware we plan to support has to check some data to determine whether it’s a certain PHY or not, and those commands could theoretically fail and that’s where the return value is. I'll check that branch and see if we can make this whole thing void.

Thanks,
Jake

Quoted 9 lines

drivers/net/ethernet/intel/ice/ice_ptp_hw.c void ice_ptp_unlock(struct ice_hw *hw) · line 3157

Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_ptp_hw.c +9 -0
+{
+	if (ice_is_e810(hw))
+		hw->phy_model = ICE_PHY_E810;
+	else
+		hw->phy_model = ICE_PHY_E822;
+
+	return 0;
+}
+

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

Tested-by on v1 1/1
#3 lore raw
In reply to Jacob Keller
Quoted 17 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Tuesday, July 18, 2023 3:47 AM
To: Intel Wired LAN <[email protected]>
Cc: Nguyen, Anthony L <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-next] ice: introduce hw->phy_model for handling PTP PHY differences

The ice driver has PTP support which works across a couple of different device families. The device families each have different PHY hardware which have unique requirements for programming.

Today, there is E810-based hardware, and E822-based hardware. To handle this, the driver checks the ice_is_e810() function to separate between the two existing families of hardware.

Future development is going to add new hardware designs which have further unique requirements. To make this easier, introduce a phy_model field to the HW structure. This field represents what PHY model the current device has, and is used to allow distinguishing which logic a particular device needs.

This will make supporting future upcoming hardware easier, by providing an obvious place to initialize the PHY model, and by already using switch/case statements instead of the previous if statements.

Astute reviewers may notice that there are a handful of remaining checks for ice_is_e810() left in ice_ptp.c These conflict with some other cleanup patches in development, and will be fixed in the near future.

Quoted 8 lines
---
 drivers/net/ethernet/intel/ice/ice_ptp.c    |  32 ++++--
 drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 104 ++++++++++++++++----
 drivers/net/ethernet/intel/ice/ice_ptp_hw.h |   2 +
 drivers/net/ethernet/intel/ice/ice_type.h   |   8 ++
 4 files changed, 120 insertions(+), 26 deletions(-)

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan