Skip to contentSkip to conversation

ice: add PTP auxiliary bus support

PATCH Superseded Michal Michalik 3 participants 13 messages Jul 21, 2023 – Jul 27, 2023

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover ice: add PTP auxiliary bus support

Auxiliary bus allow exchanging information between PFs, which allows both fixing problems and simplifying new features implementation. The auxiliary bus is enabled for all devices supported by ice driver.

Michal Michalik (3):
ice: Auxbus devices & driver for E822 TS
ice: Use PTP auxbus for all PHYs restart in E822
ice: PTP: add clock domain number to auxiliary interface

 drivers/net/ethernet/intel/ice/ice.h            |  14 +
 drivers/net/ethernet/intel/ice/ice_adminq_cmd.h |   5 -
 drivers/net/ethernet/intel/ice/ice_ethtool.c    |   2 +-
 drivers/net/ethernet/intel/ice/ice_hw_autogen.h |   1 +
 drivers/net/ethernet/intel/ice/ice_main.c       |  11 +-
 drivers/net/ethernet/intel/ice/ice_ptp.c        | 582 +++++++++++++++++-------
 drivers/net/ethernet/intel/ice/ice_ptp.h        |  41 +-
 7 files changed, 489 insertions(+), 167 deletions(-)
Signature · 7 lines
2.9.5

base-commit: aa29136c92a1122f30e3fdc3f36306ef00ddcf73
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#1 lore raw

PATCH v2 1/3 ice: Auxbus devices & driver for E822 TS

There is a problem in HW in E822-based devices leading to race condition.
It might happen that, in order:
- PF0 (which owns the PHC) requests few timestamps,
- PF1 requests a timestamp,
- interrupt is being triggered and both PF0 and PF1 threads are woken up,
- PF0 got one timestamp, still waiting for others so not going to sleep,
- PF1 gets it's timestamp, process it and go to sleep,
- PF1 requests a timestamp again,
- just before PF0 goes to sleep timestamp of PF1 appear,
- PF0 finishes all it's timestamps and go to sleep (PF1 also sleeping). That leaves PF1 timestamp memory not read, which lead to blocking the next interrupt from arriving.

Fix it by adding auxiliary devices and only one driver to handle all the timestamps for all PF's by PHC owner. In the past each PF requested it's own timestamps and process it from the start till the end which causes problem described above. Currently each PF requests the timestamps as before, but the actual reading of the completed timestamps is being done by the PTP auxilary driver, which is registered by the PF which owns PHC.

Additionally, the newly introduced auxiliary driver/devices for PTP clock owner will be used for other features in all products (including E810).

---
v1 -> v2:
* fixed duplicated docstring for 'ice_ptp_aux_dev_to_aux_pf'
* forwarded correct error in 'ice_ptp_create_auxbus_device' instead of -1
* simplified the 'ice_ptp_auxbus_probe', 'ice_ptp_auxbus_remove' and 'ice_ptp_remove_auxbus_device' functions

 drivers/net/ethernet/intel/ice/ice.h            |  14 +
 drivers/net/ethernet/intel/ice/ice_hw_autogen.h |   1 +
 drivers/net/ethernet/intel/ice/ice_main.c       |  11 +-
 drivers/net/ethernet/intel/ice/ice_ptp.c        | 399 +++++++++++++++++++++++-
 drivers/net/ethernet/intel/ice/ice_ptp.h        |  30 ++
 5 files changed, 436 insertions(+), 19 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +14 -0
index e6dd9f6..593b749 100644
@@ -195,6 +195,8 @@
 
 #define ice_pf_to_dev(pf) (&((pf)->pdev->dev))
 
+#define ice_pf_src_tmr_owned(pf) ((pf)->hw.func_caps.ts_func_info.src_tmr_owned)
+
 enum ice_feature {
 	ICE_F_DSCP,
 	ICE_F_PTP_EXTTS,
@@ -670,6 +672,18 @@ static inline bool ice_vector_ch_enabled(struct ice_q_vector *qv)
 }
 
 /**
+ * ice_ptp_pf_handles_tx_interrupt - Check if PF handles Tx interrupt
+ * @pf: Board private structure
+ *
+ * Return true if this PF should respond to the Tx timestamp interrupt
+ * indication in the miscellaneous OICR interrupt handler.
+ */
+static inline bool ice_ptp_pf_handles_tx_interrupt(struct ice_pf *pf)
+{
+	return pf->ptp.tx_interrupt_mode != ICE_PTP_TX_INTERRUPT_NONE;
+}
+
+/**
  * ice_irq_dynamic_ena - Enable default interrupt generation settings
  * @hw: pointer to HW struct
  * @vsi: pointer to VSI struct, can be NULL
drivers/net/ethernet/intel/ice/ice_hw_autogen.h +1 -0
index 531cc21..6756f3d 100644
@@ -231,6 +231,7 @@
 #define PFINT_SB_CTL				0x0016B600
 #define PFINT_SB_CTL_MSIX_INDX_M		ICE_M(0x7FF, 0)
 #define PFINT_SB_CTL_CAUSE_ENA_M		BIT(30)
+#define PFINT_TSYN_MSK				0x0016C980
 #define QINT_RQCTL(_QRX)			(0x00150000 + ((_QRX) * 4))
 #define QINT_RQCTL_MSIX_INDX_S			0
 #define QINT_RQCTL_MSIX_INDX_M			ICE_M(0x7FF, 0)
drivers/net/ethernet/intel/ice/ice_main.c +8 -3
index 02f9ef3..c5c0aa3 100644
@@ -3174,7 +3174,7 @@ 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 (!hw->reset_ongoing)
+		if (!hw->reset_ongoing && ice_ptp_pf_handles_tx_interrupt(pf))
 			set_bit(ICE_MISC_THREAD_TX_TSTAMP, pf->misc_thread);
 	}
 
@@ -7416,8 +7416,13 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type)
 	}
 
 	/* configure PTP timestamping after VSI rebuild */
-	if (test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags))
-		ice_ptp_cfg_timestamp(pf, false);
+	if (test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags)) {
+		if (pf->ptp.tx_interrupt_mode == ICE_PTP_TX_INTERRUPT_SELF)
+			ice_ptp_cfg_timestamp(pf, false);
+		else if (pf->ptp.tx_interrupt_mode == ICE_PTP_TX_INTERRUPT_ALL)
+			/* for E82x PHC owner always need to have interrupts */
+			ice_ptp_cfg_timestamp(pf, true);
+	}
 
 	err = ice_vsi_rebuild_by_type(pf, ICE_VSI_SWITCHDEV_CTRL);
 	if (err) {
drivers/net/ethernet/intel/ice/ice_ptp.c +383 -16

493 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_ptp.h +30 -0
index 995a570..d94c223 100644
@@ -157,7 +157,9 @@ struct ice_ptp_tx {
  * ready for PTP functionality. It is used to track the port initialization
  * and determine when the port's PHY offset is valid.
  *
+ * @list_member: list member structure of auxiliary device
  * @tx: Tx timestamp tracking for this port
+ * @aux_dev: auxiliary device associated with this port
  * @ov_work: delayed work task for tracking when PHY offset is valid
  * @ps_lock: mutex used to protect the overall PTP PHY start procedure
  * @link_up: indicates whether the link is up
@@ -165,7 +167,9 @@ struct ice_ptp_tx {
  * @port_num: the port number this structure represents
  */
 struct ice_ptp_port {
+	struct list_head list_member;
 	struct ice_ptp_tx tx;
+	struct auxiliary_device aux_dev;
 	struct kthread_delayed_work ov_work;
 	struct mutex ps_lock; /* protects overall PTP PHY start procedure */
 	bool link_up;
@@ -173,11 +177,35 @@ struct ice_ptp_port {
 	u8 port_num;
 };
 
+enum ice_ptp_tx_interrupt {
+	ICE_PTP_TX_INTERRUPT_NONE = 0,
+	ICE_PTP_TX_INTERRUPT_SELF,
+	ICE_PTP_TX_INTERRUPT_ALL,
+};
+
+/**
+ * struct ice_ptp_port_owner - data used to handle the PTP clock owner info
+ *
+ * This structure contains data necessary for the PTP clock owner to correctly
+ * handle the timestamping feature for all attached ports.
+ *
+ * @aux_driver: the structure carring the auxiliary driver information
+ * @ports: list of porst handled by this port owner
+ * @lock: protect access to ports list
+ */
+struct ice_ptp_port_owner {
+	struct auxiliary_driver aux_driver;
+	struct list_head ports;
+	struct mutex lock;
+};
+
 #define GLTSYN_TGT_H_IDX_MAX		4
 
 /**
  * struct ice_ptp - data used for integrating with CONFIG_PTP_1588_CLOCK
+ * @tx_interrupt_mode: the TX interrupt mode for the PTP clock
  * @port: data for the PHY port initialization procedure
+ * @ports_owner: data for the auxiliary driver owner
  * @work: delayed work function for periodic tasks
  * @cached_phc_time: a cached copy of the PHC time for timestamp extension
  * @cached_phc_jiffies: jiffies when cached_phc_time was last updated
@@ -197,7 +225,9 @@ struct ice_ptp_port {
  * @late_cached_phc_updates: number of times cached PHC update is late
  */
 struct ice_ptp {
+	enum ice_ptp_tx_interrupt tx_interrupt_mode;
 	struct ice_ptp_port port;
+	struct ice_ptp_port_owner ports_owner;
 	struct kthread_delayed_work work;
 	u64 cached_phc_time;
 	unsigned long cached_phc_jiffies;
Signature · 6 lines
2.9.5

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

Re: [Intel-wired-lan] [PATCH net-next v2 1/3] ice: Auxbus devices & driver for E822 TS

Quoted 15 lines · Michal Michalik

There is a problem in HW in E822-based devices leading to race condition.
It might happen that, in order:
- PF0 (which owns the PHC) requests few timestamps,
- PF1 requests a timestamp,
- interrupt is being triggered and both PF0 and PF1 threads are woken up,
- PF0 got one timestamp, still waiting for others so not going to sleep,
- PF1 gets it's timestamp, process it and go to sleep,
- PF1 requests a timestamp again,
- just before PF0 goes to sleep timestamp of PF1 appear,
- PF0 finishes all it's timestamps and go to sleep (PF1 also sleeping). That leaves PF1 timestamp memory not read, which lead to blocking the next interrupt from arriving.

Quoted 6 lines

Fix it by adding auxiliary devices and only one driver to handle all the timestamps for all PF's by PHC owner. In the past each PF requested it's own timestamps and process it from the start till the end which causes problem described above. Currently each PF requests the timestamps as before, but the actual reading of the completed timestamps is being done by the PTP auxilary driver, which is registered by the PF which owns PHC.

WARNING: 'auxilary' may be misspelled - perhaps 'auxiliary'?

...

Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +4 -0
+/**
+ * ice_ptp_auxbus_create_id_table - Create auxiliary device ID table
+ * @pf: Board private structure
+ * @name: auxiliary bus driver name

drivers/net/ethernet/intel/ice/ice_ptp.c void ice_ptp_reset(struct ice_pf *pf) · line 2751

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +10 -0
+ */
+static struct auxiliary_device_id *
+ice_ptp_auxbus_create_id_table(struct ice_pf *pf, const char *name)
+{
+	struct auxiliary_device_id *ids;
+
+	/* Second id left empty to terminate the array */
+	ids = (struct auxiliary_device_id *)
+	       devm_kcalloc(ice_pf_to_dev(pf), 2,
+			    sizeof(struct auxiliary_device_id), GFP_KERNEL);

This casting is no needed. Also, some void* casts below that aren't needed either.

Quoted 106 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +82 -2
+	if (!ids)
+		return NULL;
+
+	snprintf(ids[0].name, sizeof(ids[0].name), "ice.%s", name);
+
+	return ids;
+}
+
+/**
+ * ice_ptp_register_auxbus_driver - Register PTP auxiliary bus driver
+ * @pf: Board private structure
+ */
+static int ice_ptp_register_auxbus_driver(struct ice_pf *pf)
+{
+	struct auxiliary_driver *aux_driver;
+	struct ice_ptp *ptp;
+	struct device *dev;
+	char *name;
+	int err;
+
+	ptp = &pf->ptp;
+	dev = ice_pf_to_dev(pf);
+	aux_driver = &ptp->ports_owner.aux_driver;
+	INIT_LIST_HEAD(&ptp->ports_owner.ports);
+	mutex_init(&ptp->ports_owner.lock);
+	name = devm_kasprintf(dev, GFP_KERNEL, "ptp_aux_dev_%u_%u_clk%u",
+			      pf->pdev->bus->number, PCI_SLOT(pf->pdev->devfn),
+			      ice_get_ptp_src_clock_index(&pf->hw));
+
+	aux_driver->name = name;
+	aux_driver->shutdown = ice_ptp_auxbus_shutdown;
+	aux_driver->suspend = ice_ptp_auxbus_suspend;
+	aux_driver->remove = ice_ptp_auxbus_remove;
+	aux_driver->resume = ice_ptp_auxbus_resume;
+	aux_driver->probe = ice_ptp_auxbus_probe;
+	aux_driver->id_table = ice_ptp_auxbus_create_id_table(pf, name);
+	if (!aux_driver->id_table)
+		return -ENOMEM;
+
+	err = auxiliary_driver_register(aux_driver);
+	if (err) {
+		devm_kfree(dev, (void *)aux_driver->id_table);
+		dev_err(dev, "Failed registering aux_driver, name <%s>\n",
+			name);
+	}
+
+	return err;
+}
+
+/**
+ * ice_ptp_unregister_auxbus_driver - Unregister PTP auxiliary bus driver
+ * @pf: Board private structure
+ */
+static void ice_ptp_unregister_auxbus_driver(struct ice_pf *pf)
+{
+	struct auxiliary_driver *aux_driver = &pf->ptp.ports_owner.aux_driver;
+
+	auxiliary_driver_unregister(aux_driver);
+	devm_kfree(ice_pf_to_dev(pf), (void *)aux_driver->id_table);
+
+	mutex_destroy(&pf->ptp.ports_owner.lock);
+}
+
+/**
   * ice_ptp_prepare_for_reset - Prepare PTP for reset
   * @pf: Board private structure
   */
@@ -2652,7 +2890,15 @@ static int ice_ptp_init_owner(struct ice_pf *pf)
  	/* Release the global hardware lock */
  	ice_ptp_unlock(hw);
 
-	if (!ice_is_e810(hw)) {
+	if (pf->ptp.tx_interrupt_mode == ICE_PTP_TX_INTERRUPT_ALL) {
+		/* The clock owner for this device type handles the timestamp
+		 * interrupt for all ports.
+		 */
+		ice_ptp_configure_tx_tstamp(pf, true);
+
+		/* React on all quads interrupts for E82x */
+		wr32(hw, PFINT_TSYN_MSK + (0x4 * hw->pf_id), (u32)0x1f);
+
  		/* Enable quad interrupts */
  		err = ice_ptp_tx_ena_intr(pf, true, itr);
  		if (err)
@@ -2667,8 +2913,16 @@ static int ice_ptp_init_owner(struct ice_pf *pf)
  	/* Store the PTP clock index for other PFs */
  	ice_set_ptp_clock_index(pf);
 
-	return 0;
+	err = ice_ptp_register_auxbus_driver(pf);
+	if (err) {
+		dev_err(ice_pf_to_dev(pf), "Failed to register PTP auxbus driver");
+		goto err_aux;
+	}
 
+	return 0;
+err_aux:
+	ice_clear_ptp_clock_index(pf);
+	ptp_clock_unregister(pf->ptp.clock);
  err_clk:
  	pf->ptp.clock = NULL;
  err_exit:
@@ -2718,8 +2972,15 @@ static int ice_ptp_init_port(struct ice_pf *pf, struct ice_ptp_port *ptp_port)
  	case ICE_PHY_E810:
  		return ice_ptp_init_tx_e810(pf, &ptp_port->tx);
  	case ICE_PHY_E822:

drivers/net/ethernet/intel/ice/ice_ptp.c static int ice_ptp_init_port(struct ice_pf *pf, struct ice_ptp_port *ptp_port) · line 2983

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +8 -1
+		/* Non-owner PFs don't react to any interrupts on E82x,
+		 * neither on own quad nor on others
+		 */
+		if (!ice_ptp_pf_handles_tx_interrupt(pf)) {
+			ice_ptp_configure_tx_tstamp(pf, false);
+			wr32(hw, PFINT_TSYN_MSK + (0x4 * hw->pf_id), (u32)0x0);
+		}
  		kthread_init_delayed_work(&ptp_port->ov_work,
-					  ice_ptp_wait_for_offsets);
+				ice_ptp_wait_for_offsets);

I believe the original alignment is correct/no need for this change.

Quoted 32 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +25 -0
  		return ice_ptp_init_tx_e822(pf, &ptp_port->tx,
  					    ptp_port->port_num);
@@ -2729,6 +2990,102 @@ static int ice_ptp_init_port(struct ice_pf *pf, struct ice_ptp_port *ptp_port)
  }
 
  /**
+ * ice_ptp_release_auxbus_device
+ * @dev: device that utilizes the auxbus
+ */
+static void ice_ptp_release_auxbus_device(struct device *dev)
+{
+	/* Doing nothing here, but handle to auxbux device must be satisfied */
+}
+
+/**
+ * ice_ptp_create_auxbus_device - Create PTP auxiliary bus device
+ * @pf: Board private structure
+ */
+static int ice_ptp_create_auxbus_device(struct ice_pf *pf)
+{
+	struct auxiliary_device *aux_dev;
+	struct ice_ptp *ptp;
+	struct device *dev;
+	char *name;
+	int err;
+	u32 id;
+
+	ptp = &pf->ptp;
+	id = ptp->port.port_num;
+	dev = ice_pf_to_dev(pf);
+

drivers/net/ethernet/intel/ice/ice_ptp.c static int ice_ptp_init_port(struct ice_pf *pf, struct ice_ptp_port *ptp_port) · line 3027

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +10 -0
+	aux_dev = &ptp->port.aux_dev;
+
+	name = devm_kasprintf(dev, GFP_KERNEL, "ptp_aux_dev_%u_%u_clk%u",
+			      pf->pdev->bus->number, PCI_SLOT(pf->pdev->devfn),
+			      ice_get_ptp_src_clock_index(&pf->hw));
+
+	aux_dev->name = name;
+	aux_dev->id = id;
+	aux_dev->dev.release = ice_ptp_release_auxbus_device;
+	aux_dev->dev.parent = ice_pf_to_dev(pf);

You already have dev as a local var.

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +5 -0
+
+	err = auxiliary_device_init(aux_dev);
+	if (err)
+		goto aux_err;
+

drivers/net/ethernet/intel/ice/ice_ptp.c static int ice_ptp_init_port(struct ice_pf *pf, struct ice_ptp_port *ptp_port) · line 3042

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +10 -0
+	err = auxiliary_device_add(aux_dev);
+	if (err) {
+		auxiliary_device_uninit(aux_dev);
+		goto aux_err;
+	}
+
+	return 0;
+aux_err:
+	dev_err(ice_pf_to_dev(pf), "Failed to create PTP auxiliary bus device <%s>\n",
+		name);

Same here.

Quoted 152 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +57 -1
+	devm_kfree(dev, name);
+	return err;
+}
+
+/**
+ * ice_ptp_remove_auxbus_device - Remove PTP auxiliary bus device
+ * @pf: Board private structure
+ */
+static void ice_ptp_remove_auxbus_device(struct ice_pf *pf)
+{
+	struct auxiliary_device *aux_dev = &pf->ptp.port.aux_dev;
+
+	auxiliary_device_delete(aux_dev);
+	auxiliary_device_uninit(aux_dev);
+
+	memset(aux_dev, 0, sizeof(*aux_dev));
+}
+
+/**
+ * ice_ptp_init_tx_interrupt_mode - Initialize device Tx interrupt mode
+ * @pf: Board private structure
+ *
+ * Initialize the Tx timestamp interrupt mode for this device. For most device
+ * types, each PF processes the interrupt and manages its own timestamps. For
+ * E822-based devices, only the clock owner processes the timestamps. Other
+ * PFs disable the interrupt and do not process their own timestamps.
+ */
+static void ice_ptp_init_tx_interrupt_mode(struct ice_pf *pf)
+{
+	switch (pf->hw.phy_model) {
+	case ICE_PHY_E822:
+		/* E822 based PHY has the clock owner process the interrupt
+		 * for all ports.
+		 */
+		if (ice_pf_src_tmr_owned(pf))
+			pf->ptp.tx_interrupt_mode = ICE_PTP_TX_INTERRUPT_ALL;
+		else
+			pf->ptp.tx_interrupt_mode = ICE_PTP_TX_INTERRUPT_NONE;
+		break;
+	default:
+		/* other PHY types handle their own Tx interrupt */
+		pf->ptp.tx_interrupt_mode = ICE_PTP_TX_INTERRUPT_SELF;
+	}
+}
+
+/**
   * ice_ptp_init - Initialize PTP hardware clock support
   * @pf: Board private structure
   *
@@ -2748,10 +3105,12 @@ void ice_ptp_init(struct ice_pf *pf)
 
  	ice_ptp_init_phy_model(hw);
 
+	ice_ptp_init_tx_interrupt_mode(pf);
+
  	/* If this function owns the clock hardware, it must allocate and
  	 * configure the PTP clock device to represent it.
  	 */
-	if (hw->func_caps.ts_func_info.src_tmr_owned) {
+	if (ice_pf_src_tmr_owned(pf)) {
  		err = ice_ptp_init_owner(pf);
  		if (err)
  			goto err;
@@ -2770,6 +3129,10 @@ void ice_ptp_init(struct ice_pf *pf)
  	if (err)
  		goto err;
 
+	err = ice_ptp_create_auxbus_device(pf);
+	if (err)
+		goto err;
+
  	dev_info(ice_pf_to_dev(pf), "PTP init successful\n");
  	return;
 
@@ -2798,6 +3161,8 @@ void ice_ptp_release(struct ice_pf *pf)
  	/* Disable timestamping for both Tx and Rx */
  	ice_ptp_cfg_timestamp(pf, false);
 
+	ice_ptp_remove_auxbus_device(pf);
+
  	ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx);
 
  	clear_bit(ICE_FLAG_PTP, pf->flags);
@@ -2821,5 +3186,7 @@ void ice_ptp_release(struct ice_pf *pf)
  	ptp_clock_unregister(pf->ptp.clock);
  	pf->ptp.clock = NULL;
 
+	ice_ptp_unregister_auxbus_driver(pf);
+
  	dev_info(ice_pf_to_dev(pf), "Removed PTP clock\n");
  }
drivers/net/ethernet/intel/ice/ice_ptp.h +28 -0
index 995a570..d94c223 100644
@@ -157,7 +157,9 @@ struct ice_ptp_tx {
   * ready for PTP functionality. It is used to track the port initialization
   * and determine when the port's PHY offset is valid.
   *
+ * @list_member: list member structure of auxiliary device
   * @tx: Tx timestamp tracking for this port
+ * @aux_dev: auxiliary device associated with this port
   * @ov_work: delayed work task for tracking when PHY offset is valid
   * @ps_lock: mutex used to protect the overall PTP PHY start procedure
   * @link_up: indicates whether the link is up
@@ -165,7 +167,9 @@ struct ice_ptp_tx {
   * @port_num: the port number this structure represents
   */
  struct ice_ptp_port {
+	struct list_head list_member;
  	struct ice_ptp_tx tx;
+	struct auxiliary_device aux_dev;
  	struct kthread_delayed_work ov_work;
  	struct mutex ps_lock; /* protects overall PTP PHY start procedure */
  	bool link_up;
@@ -173,11 +177,35 @@ struct ice_ptp_port {
  	u8 port_num;
  };
 
+enum ice_ptp_tx_interrupt {
+	ICE_PTP_TX_INTERRUPT_NONE = 0,
+	ICE_PTP_TX_INTERRUPT_SELF,
+	ICE_PTP_TX_INTERRUPT_ALL,
+};
+
+/**
+ * struct ice_ptp_port_owner - data used to handle the PTP clock owner info
+ *
+ * This structure contains data necessary for the PTP clock owner to correctly
+ * handle the timestamping feature for all attached ports.
+ *
+ * @aux_driver: the structure carring the auxiliary driver information
+ * @ports: list of porst handled by this port owner
+ * @lock: protect access to ports list
+ */
+struct ice_ptp_port_owner {
+	struct auxiliary_driver aux_driver;
+	struct list_head ports;
+	struct mutex lock;
+};
+
  #define GLTSYN_TGT_H_IDX_MAX		4
 
  /**
   * struct ice_ptp - data used for integrating with CONFIG_PTP_1588_CLOCK
+ * @tx_interrupt_mode: the TX interrupt mode for the PTP clock
   * @port: data for the PHY port initialization procedure
+ * @ports_owner: data for the auxiliary driver owner
   * @work: delayed work function for periodic tasks
   * @cached_phc_time: a cached copy of the PHC time for timestamp extension
   * @cached_phc_jiffies: jiffies when cached_phc_time was last updated

drivers/net/ethernet/intel/ice/ice_ptp.h struct ice_ptp_port { · line 233

Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_ptp.h +2 -0
@@ -197,7 +225,9 @@ struct ice_ptp_port {
   * @late_cached_phc_updates: number of times cached PHC update is late
   */
  struct ice_ptp {
+	enum ice_ptp_tx_interrupt tx_interrupt_mode;
  	struct ice_ptp_port port;
+	struct ice_ptp_port_owner ports_owner;
  	struct kthread_delayed_work work;
  	u64 cached_phc_time;
  	unsigned long cached_phc_jiffies;

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

#3 lore raw

Re: [Intel-wired-lan] [PATCH net-next v2 1/3] ice: Auxbus devices & driver for E822 TS

Quoted 19 lines · Anthony L
Quoted 15 lines · Michal Michalik

There is a problem in HW in E822-based devices leading to race condition.
It might happen that, in order:
- PF0 (which owns the PHC) requests few timestamps,
- PF1 requests a timestamp,
- interrupt is being triggered and both PF0 and PF1 threads are woken up,
- PF0 got one timestamp, still waiting for others so not going to sleep,
- PF1 gets it's timestamp, process it and go to sleep,
- PF1 requests a timestamp again,
- just before PF0 goes to sleep timestamp of PF1 appear,
- PF0 finishes all it's timestamps and go to sleep (PF1 also sleeping). That leaves PF1 timestamp memory not read, which lead to blocking the next interrupt from arriving.

Quoted 9 lines
Quoted 6 lines

Fix it by adding auxiliary devices and only one driver to handle all the timestamps for all PF's by PHC owner. In the past each PF requested it's own timestamps and process it from the start till the end which causes problem described above. Currently each PF requests the timestamps as before, but the actual reading of the completed timestamps is being done by the PTP auxilary driver, which is registered by the PF which owns PHC.

WARNING: 'auxilary' may be misspelled - perhaps 'auxiliary'?

Thanks, will fix it.

Quoted 11 lines

...

Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +9 -0
+/**
+ * ice_ptp_auxbus_create_id_table - Create auxiliary device ID table
+ * @pf: Board private structure
+ * @name: auxiliary bus driver name
+ */
+static struct auxiliary_device_id *
+ice_ptp_auxbus_create_id_table(struct ice_pf *pf, const char *name)
+{
+	struct auxiliary_device_id *ids;
Quoted 9 lines

drivers/net/ethernet/intel/ice/ice_ptp.c void ice_ptp_reset(struct ice_pf *pf) · line 2751

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +5 -0
+
+	/* Second id left empty to terminate the array */
+	ids = (struct auxiliary_device_id *)
+	       devm_kcalloc(ice_pf_to_dev(pf), 2,
+			    sizeof(struct auxiliary_device_id), GFP_KERNEL);

This casting is no needed. Also, some void* casts below that aren't needed either.

Will remove all unnecessary castings [one (struct auxiliary_device_id *) and two (void *)], thanks.

Quoted 110 lines
Quoted 110 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +86 -2
+	if (!ids)
+		return NULL;
+
+	snprintf(ids[0].name, sizeof(ids[0].name), "ice.%s", name);
+
+	return ids;
+}
+
+/**
+ * ice_ptp_register_auxbus_driver - Register PTP auxiliary bus driver
+ * @pf: Board private structure
+ */
+static int ice_ptp_register_auxbus_driver(struct ice_pf *pf)
+{
+	struct auxiliary_driver *aux_driver;
+	struct ice_ptp *ptp;
+	struct device *dev;
+	char *name;
+	int err;
+
+	ptp = &pf->ptp;
+	dev = ice_pf_to_dev(pf);
+	aux_driver = &ptp->ports_owner.aux_driver;
+	INIT_LIST_HEAD(&ptp->ports_owner.ports);
+	mutex_init(&ptp->ports_owner.lock);
+	name = devm_kasprintf(dev, GFP_KERNEL, "ptp_aux_dev_%u_%u_clk%u",
+			      pf->pdev->bus->number, PCI_SLOT(pf->pdev->devfn),
+			      ice_get_ptp_src_clock_index(&pf->hw));
+
+	aux_driver->name = name;
+	aux_driver->shutdown = ice_ptp_auxbus_shutdown;
+	aux_driver->suspend = ice_ptp_auxbus_suspend;
+	aux_driver->remove = ice_ptp_auxbus_remove;
+	aux_driver->resume = ice_ptp_auxbus_resume;
+	aux_driver->probe = ice_ptp_auxbus_probe;
+	aux_driver->id_table = ice_ptp_auxbus_create_id_table(pf, name);
+	if (!aux_driver->id_table)
+		return -ENOMEM;
+
+	err = auxiliary_driver_register(aux_driver);
+	if (err) {
+		devm_kfree(dev, (void *)aux_driver->id_table);
+		dev_err(dev, "Failed registering aux_driver, name <%s>\n",
+			name);
+	}
+
+	return err;
+}
+
+/**
+ * ice_ptp_unregister_auxbus_driver - Unregister PTP auxiliary bus driver
+ * @pf: Board private structure
+ */
+static void ice_ptp_unregister_auxbus_driver(struct ice_pf *pf)
+{
+	struct auxiliary_driver *aux_driver = &pf->ptp.ports_owner.aux_driver;
+
+	auxiliary_driver_unregister(aux_driver);
+	devm_kfree(ice_pf_to_dev(pf), (void *)aux_driver->id_table);
+
+	mutex_destroy(&pf->ptp.ports_owner.lock);
+}
+
+/**
   * ice_ptp_prepare_for_reset - Prepare PTP for reset
   * @pf: Board private structure
   */
@@ -2652,7 +2890,15 @@ static int ice_ptp_init_owner(struct ice_pf *pf)
  	/* Release the global hardware lock */
  	ice_ptp_unlock(hw);
 
-	if (!ice_is_e810(hw)) {
+	if (pf->ptp.tx_interrupt_mode == ICE_PTP_TX_INTERRUPT_ALL) {
+		/* The clock owner for this device type handles the timestamp
+		 * interrupt for all ports.
+		 */
+		ice_ptp_configure_tx_tstamp(pf, true);
+
+		/* React on all quads interrupts for E82x */
+		wr32(hw, PFINT_TSYN_MSK + (0x4 * hw->pf_id), (u32)0x1f);
+
  		/* Enable quad interrupts */
  		err = ice_ptp_tx_ena_intr(pf, true, itr);
  		if (err)
@@ -2667,8 +2913,16 @@ static int ice_ptp_init_owner(struct ice_pf *pf)
  	/* Store the PTP clock index for other PFs */
  	ice_set_ptp_clock_index(pf);
 
-	return 0;
+	err = ice_ptp_register_auxbus_driver(pf);
+	if (err) {
+		dev_err(ice_pf_to_dev(pf), "Failed to register PTP auxbus driver");
+		goto err_aux;
+	}
 
+	return 0;
+err_aux:
+	ice_clear_ptp_clock_index(pf);
+	ptp_clock_unregister(pf->ptp.clock);
  err_clk:
  	pf->ptp.clock = NULL;
  err_exit:
@@ -2718,8 +2972,15 @@ static int ice_ptp_init_port(struct ice_pf *pf, struct ice_ptp_port *ptp_port)
  	case ICE_PHY_E810:
  		return ice_ptp_init_tx_e810(pf, &ptp_port->tx);
  	case ICE_PHY_E822:
+		/* Non-owner PFs don't react to any interrupts on E82x,
+		 * neither on own quad nor on others
+		 */
+		if (!ice_ptp_pf_handles_tx_interrupt(pf)) {
Quoted 9 lines

drivers/net/ethernet/intel/ice/ice_ptp.c static int ice_ptp_init_port(struct ice_pf *pf, struct ice_ptp_port *ptp_port) · line 2983

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +4 -1
+			ice_ptp_configure_tx_tstamp(pf, false);
+			wr32(hw, PFINT_TSYN_MSK + (0x4 * hw->pf_id), (u32)0x0);
+		}
  		kthread_init_delayed_work(&ptp_port->ov_work,
-					  ice_ptp_wait_for_offsets);
+				ice_ptp_wait_for_offsets);

I believe the original alignment is correct/no need for this change.

Agree, will remove it.

Quoted 36 lines
Quoted 36 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +29 -0
  		return ice_ptp_init_tx_e822(pf, &ptp_port->tx,
  					    ptp_port->port_num);
@@ -2729,6 +2990,102 @@ static int ice_ptp_init_port(struct ice_pf *pf, struct ice_ptp_port *ptp_port)
  }
 
  /**
+ * ice_ptp_release_auxbus_device
+ * @dev: device that utilizes the auxbus
+ */
+static void ice_ptp_release_auxbus_device(struct device *dev)
+{
+	/* Doing nothing here, but handle to auxbux device must be satisfied */
+}
+
+/**
+ * ice_ptp_create_auxbus_device - Create PTP auxiliary bus device
+ * @pf: Board private structure
+ */
+static int ice_ptp_create_auxbus_device(struct ice_pf *pf)
+{
+	struct auxiliary_device *aux_dev;
+	struct ice_ptp *ptp;
+	struct device *dev;
+	char *name;
+	int err;
+	u32 id;
+
+	ptp = &pf->ptp;
+	id = ptp->port.port_num;
+	dev = ice_pf_to_dev(pf);
+
+	aux_dev = &ptp->port.aux_dev;
+
+	name = devm_kasprintf(dev, GFP_KERNEL, "ptp_aux_dev_%u_%u_clk%u",
+			      pf->pdev->bus->number, PCI_SLOT(pf->pdev->devfn),
Quoted 9 lines

drivers/net/ethernet/intel/ice/ice_ptp.c static int ice_ptp_init_port(struct ice_pf *pf, struct ice_ptp_port *ptp_port) · line 3027

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +6 -0
+			      ice_get_ptp_src_clock_index(&pf->hw));
+
+	aux_dev->name = name;
+	aux_dev->id = id;
+	aux_dev->dev.release = ice_ptp_release_auxbus_device;
+	aux_dev->dev.parent = ice_pf_to_dev(pf);

You already have dev as a local var.

Nice eye Tony, will use the local one - thanks.

Quoted 9 lines
Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +9 -0
+
+	err = auxiliary_device_init(aux_dev);
+	if (err)
+		goto aux_err;
+
+	err = auxiliary_device_add(aux_dev);
+	if (err) {
+		auxiliary_device_uninit(aux_dev);
+		goto aux_err;
Quoted 9 lines

drivers/net/ethernet/intel/ice/ice_ptp.c static int ice_ptp_init_port(struct ice_pf *pf, struct ice_ptp_port *ptp_port) · line 3042

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +6 -0
+	}
+
+	return 0;
+aux_err:
+	dev_err(ice_pf_to_dev(pf), "Failed to create PTP auxiliary bus device <%s>\n",
+		name);

Same here.

Will use local.

Thanks,
M^2

Quoted 153 lines
Quoted 153 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +57 -1
+	devm_kfree(dev, name);
+	return err;
+}
+
+/**
+ * ice_ptp_remove_auxbus_device - Remove PTP auxiliary bus device
+ * @pf: Board private structure
+ */
+static void ice_ptp_remove_auxbus_device(struct ice_pf *pf)
+{
+	struct auxiliary_device *aux_dev = &pf->ptp.port.aux_dev;
+
+	auxiliary_device_delete(aux_dev);
+	auxiliary_device_uninit(aux_dev);
+
+	memset(aux_dev, 0, sizeof(*aux_dev));
+}
+
+/**
+ * ice_ptp_init_tx_interrupt_mode - Initialize device Tx interrupt mode
+ * @pf: Board private structure
+ *
+ * Initialize the Tx timestamp interrupt mode for this device. For most device
+ * types, each PF processes the interrupt and manages its own timestamps. For
+ * E822-based devices, only the clock owner processes the timestamps. Other
+ * PFs disable the interrupt and do not process their own timestamps.
+ */
+static void ice_ptp_init_tx_interrupt_mode(struct ice_pf *pf)
+{
+	switch (pf->hw.phy_model) {
+	case ICE_PHY_E822:
+		/* E822 based PHY has the clock owner process the interrupt
+		 * for all ports.
+		 */
+		if (ice_pf_src_tmr_owned(pf))
+			pf->ptp.tx_interrupt_mode = ICE_PTP_TX_INTERRUPT_ALL;
+		else
+			pf->ptp.tx_interrupt_mode = ICE_PTP_TX_INTERRUPT_NONE;
+		break;
+	default:
+		/* other PHY types handle their own Tx interrupt */
+		pf->ptp.tx_interrupt_mode = ICE_PTP_TX_INTERRUPT_SELF;
+	}
+}
+
+/**
   * ice_ptp_init - Initialize PTP hardware clock support
   * @pf: Board private structure
   *
@@ -2748,10 +3105,12 @@ void ice_ptp_init(struct ice_pf *pf)
 
  	ice_ptp_init_phy_model(hw);
 
+	ice_ptp_init_tx_interrupt_mode(pf);
+
  	/* If this function owns the clock hardware, it must allocate and
  	 * configure the PTP clock device to represent it.
  	 */
-	if (hw->func_caps.ts_func_info.src_tmr_owned) {
+	if (ice_pf_src_tmr_owned(pf)) {
  		err = ice_ptp_init_owner(pf);
  		if (err)
  			goto err;
@@ -2770,6 +3129,10 @@ void ice_ptp_init(struct ice_pf *pf)
  	if (err)
  		goto err;
 
+	err = ice_ptp_create_auxbus_device(pf);
+	if (err)
+		goto err;
+
  	dev_info(ice_pf_to_dev(pf), "PTP init successful\n");
  	return;
 
@@ -2798,6 +3161,8 @@ void ice_ptp_release(struct ice_pf *pf)
  	/* Disable timestamping for both Tx and Rx */
  	ice_ptp_cfg_timestamp(pf, false);
 
+	ice_ptp_remove_auxbus_device(pf);
+
  	ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx);
 
  	clear_bit(ICE_FLAG_PTP, pf->flags);
@@ -2821,5 +3186,7 @@ void ice_ptp_release(struct ice_pf *pf)
  	ptp_clock_unregister(pf->ptp.clock);
  	pf->ptp.clock = NULL;
 
+	ice_ptp_unregister_auxbus_driver(pf);
+
  	dev_info(ice_pf_to_dev(pf), "Removed PTP clock\n");
  }
drivers/net/ethernet/intel/ice/ice_ptp.h +28 -0
index 995a570..d94c223 100644
@@ -157,7 +157,9 @@ struct ice_ptp_tx {
   * ready for PTP functionality. It is used to track the port initialization
   * and determine when the port's PHY offset is valid.
   *
+ * @list_member: list member structure of auxiliary device
   * @tx: Tx timestamp tracking for this port
+ * @aux_dev: auxiliary device associated with this port
   * @ov_work: delayed work task for tracking when PHY offset is valid
   * @ps_lock: mutex used to protect the overall PTP PHY start procedure
   * @link_up: indicates whether the link is up
@@ -165,7 +167,9 @@ struct ice_ptp_tx {
   * @port_num: the port number this structure represents
   */
  struct ice_ptp_port {
+	struct list_head list_member;
  	struct ice_ptp_tx tx;
+	struct auxiliary_device aux_dev;
  	struct kthread_delayed_work ov_work;
  	struct mutex ps_lock; /* protects overall PTP PHY start procedure */
  	bool link_up;
@@ -173,11 +177,35 @@ struct ice_ptp_port {
  	u8 port_num;
  };
 
+enum ice_ptp_tx_interrupt {
+	ICE_PTP_TX_INTERRUPT_NONE = 0,
+	ICE_PTP_TX_INTERRUPT_SELF,
+	ICE_PTP_TX_INTERRUPT_ALL,
+};
+
+/**
+ * struct ice_ptp_port_owner - data used to handle the PTP clock owner info
+ *
+ * This structure contains data necessary for the PTP clock owner to correctly
+ * handle the timestamping feature for all attached ports.
+ *
+ * @aux_driver: the structure carring the auxiliary driver information
+ * @ports: list of porst handled by this port owner
+ * @lock: protect access to ports list
+ */
+struct ice_ptp_port_owner {
+	struct auxiliary_driver aux_driver;
+	struct list_head ports;
+	struct mutex lock;
+};
+
  #define GLTSYN_TGT_H_IDX_MAX		4
 
  /**
   * struct ice_ptp - data used for integrating with CONFIG_PTP_1588_CLOCK
+ * @tx_interrupt_mode: the TX interrupt mode for the PTP clock
   * @port: data for the PHY port initialization procedure
+ * @ports_owner: data for the auxiliary driver owner
   * @work: delayed work function for periodic tasks
   * @cached_phc_time: a cached copy of the PHC time for timestamp extension
   * @cached_phc_jiffies: jiffies when cached_phc_time was last updated
@@ -197,7 +225,9 @@ struct ice_ptp_port {
   * @late_cached_phc_updates: number of times cached PHC update is late
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_ptp.h struct ice_ptp_port { · line 233

Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_ptp.h +2 -0
   */
  struct ice_ptp {
+	enum ice_ptp_tx_interrupt tx_interrupt_mode;
  	struct ice_ptp_port port;
+	struct ice_ptp_port_owner ports_owner;
  	struct kthread_delayed_work work;
  	u64 cached_phc_time;
  	unsigned long cached_phc_jiffies;

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

#4 lore raw

PATCH v2 2/3 ice: Use PTP auxbus for all PHYs restart in E822

In reply to Michal Michalik

The E822 (and other devices based on the same PHY) is having issue while setting the PHC timer - the PHY timers are drifting from the PHC. After such a set all PHYs need to be restarted and resynchronised - do it using auxiliary bus.

---
 drivers/net/ethernet/intel/ice/ice_ptp.c | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/ice/ice_ptp.c +21 -3
index e144978..69a2bd0 100644
@@ -1491,6 +1491,24 @@ static void ice_ptp_reset_phy_timestamping(struct ice_pf *pf)
 }
 
 /**
+ * ice_ptp_restart_all_phy - Restart all PHYs to recalibrate timestamping
+ * @pf: Board private structure
+ */
+static void ice_ptp_restart_all_phy(struct ice_pf *pf)
+{
+	struct list_head *entry;
+
+	list_for_each(entry, &pf->ptp.ports_owner.ports) {
+		struct ice_ptp_port *port = list_entry(entry,
+						       struct ice_ptp_port,
+						       list_member);
+
+		if (port->link_up)
+			ice_ptp_port_phy_restart(port);
+	}
+}
+
+/**
  * ice_ptp_adjfine - Adjust clock increment rate
  * @info: the driver's PTP info structure
  * @scaled_ppm: Parts per million with 16-bit fractional field
@@ -1927,9 +1945,9 @@ ice_ptp_settime64(struct ptp_clock_info *info, const struct timespec64 *ts)
 	/* Reenable periodic outputs */
 	ice_ptp_enable_all_clkout(pf);
 
-	/* Recalibrate and re-enable timestamp block */
-	if (pf->ptp.port.link_up)
-		ice_ptp_port_phy_restart(&pf->ptp.port);
+	/* Recalibrate and re-enable timestamp blocks for E822/E823 */
+	if (!ice_is_e810(hw))
+		ice_ptp_restart_all_phy(pf);
 exit:
 	if (err) {
 		dev_err(ice_pf_to_dev(pf), "PTP failed to set time %d\n", err);
Signature · 6 lines
2.9.5

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

Re: [Intel-wired-lan] [PATCH net-next v2 2/3] ice: Use PTP auxbus for all PHYs restart in E822

On 7/21/2023 8:44 AM, Michal Michalik wrote:

...

drivers/net/ethernet/intel/ice/ice_ptp.c ice_ptp_settime64(struct ptp_clock_info *info, const struct timespec64 *ts) · line 1949

Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +2 -3
@@ -1927,9 +1945,9 @@ ice_ptp_settime64(struct ptp_clock_info *info, const struct timespec64 *ts)
  	/* Reenable periodic outputs */
  	ice_ptp_enable_all_clkout(pf);
 
-	/* Recalibrate and re-enable timestamp block */
-	if (pf->ptp.port.link_up)
-		ice_ptp_port_phy_restart(&pf->ptp.port);
+	/* Recalibrate and re-enable timestamp blocks for E822/E823 */
+	if (!ice_is_e810(hw))

Should this use PHY model since this is coming after it [1]?

drivers/net/ethernet/intel/ice/ice_ptp.c ice_ptp_settime64(struct ptp_clock_info *info, const struct timespec64 *ts) · line 1953

Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +1 -0
+		ice_ptp_restart_all_phy(pf);
  exit:
  	if (err) {
  		dev_err(ice_pf_to_dev(pf), "PTP failed to set time %d\n", err);

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

#6 lore raw

Re: [Intel-wired-lan] [PATCH net-next v2 2/3] ice: Use PTP auxbus for all PHYs restart in E822

Quoted 9 lines · Anthony L

On 7/21/2023 8:44 AM, Michal Michalik wrote:

...

Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +0 -0
@@ -1927,9 +1945,9 @@ ice_ptp_settime64(struct ptp_clock_info *info, const struct timespec64 *ts)
  	/* Reenable periodic outputs */
  	ice_ptp_enable_all_clkout(pf);
 
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_ptp.c ice_ptp_settime64(struct ptp_clock_info *info, const struct timespec64 *ts) · line 1949

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +2 -3
-	/* Recalibrate and re-enable timestamp block */
-	if (pf->ptp.port.link_up)
-		ice_ptp_port_phy_restart(&pf->ptp.port);
+	/* Recalibrate and re-enable timestamp blocks for E822/E823 */
+	if (!ice_is_e810(hw))

Should this use PHY model since this is coming after it [1]?

Good catch Tony, I changed it before [1] was available and forgot to reverse it after it's here. Will update in v3.

BR,
M^2

Quoted 7 lines

drivers/net/ethernet/intel/ice/ice_ptp.c ice_ptp_settime64(struct ptp_clock_info *info, const struct timespec64 *ts) · line 1953

Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +1 -0
+		ice_ptp_restart_all_phy(pf);
  exit:
  	if (err) {
  		dev_err(ice_pf_to_dev(pf), "PTP failed to set time %d\n", err);

[1]
https://lore.kernel.org/intel-wired-lan/[email protected]/

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

#7 lore raw

PATCH v2 3/3 ice: PTP: add clock domain number to auxiliary interface

In reply to Michal Michalik

The PHC clock id used to be moved between PFs using FW admin queue shared parameters - move the implementation to auxiliary bus.

---
v1 -> v2:
* fixed the "static declaration of 'ice_ptp_clock_index' follows non-static declaration"
* removed no longer required 'ice_aqc_driver_params' params

 drivers/net/ethernet/intel/ice/ice_adminq_cmd.h |   5 -
 drivers/net/ethernet/intel/ice/ice_ethtool.c    |   2 +-
 drivers/net/ethernet/intel/ice/ice_ptp.c        | 163 ++++--------------------
 drivers/net/ethernet/intel/ice/ice_ptp.h        |  11 +-
 4 files changed, 34 insertions(+), 147 deletions(-)
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +0 -5
index 8b1d2c4..0baa410 100644
@@ -2068,11 +2068,6 @@ struct ice_aqc_driver_shared_params {
 };
 
 enum ice_aqc_driver_params {
-	/* OS clock index for PTP timer Domain 0 */
-	ICE_AQC_DRIVER_PARAM_CLK_IDX_TMR0 = 0,
-	/* OS clock index for PTP timer Domain 1 */
-	ICE_AQC_DRIVER_PARAM_CLK_IDX_TMR1,
-
 	/* Add new parameters above */
 	ICE_AQC_DRIVER_PARAM_MAX = 16,
 };
drivers/net/ethernet/intel/ice/ice_ethtool.c +1 -1
index ad4d470..d3cb08e 100644
@@ -3285,7 +3285,7 @@ ice_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info)
 				SOF_TIMESTAMPING_RX_HARDWARE |
 				SOF_TIMESTAMPING_RAW_HARDWARE;
 
-	info->phc_index = ice_get_ptp_clock_index(pf);
+	info->phc_index = ice_ptp_clock_index(pf);
 
 	info->tx_types = BIT(HWTSTAMP_TX_OFF) | BIT(HWTSTAMP_TX_ON);
 
drivers/net/ethernet/intel/ice/ice_ptp.c +27 -136

205 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_ptp.h +6 -5
index d94c223..8f6f943 100644
@@ -288,11 +288,11 @@ struct ice_ptp {
 #define ETH_GLTSYN_ENA(_i)		(0x03000348 + ((_i) * 4))
 
 #if IS_ENABLED(CONFIG_PTP_1588_CLOCK)
+int ice_ptp_clock_index(struct ice_pf *pf);
 struct ice_pf;
 int ice_ptp_set_ts_config(struct ice_pf *pf, struct ifreq *ifr);
 int ice_ptp_get_ts_config(struct ice_pf *pf, struct ifreq *ifr);
 void ice_ptp_cfg_timestamp(struct ice_pf *pf, bool ena);
-int ice_get_ptp_clock_index(struct ice_pf *pf);
 
 void ice_ptp_extts_event(struct ice_pf *pf);
 s8 ice_ptp_request_ts(struct ice_ptp_tx *tx, struct sk_buff *skb);
@@ -318,10 +318,6 @@ static inline int ice_ptp_get_ts_config(struct ice_pf *pf, struct ifreq *ifr)
 }
 
 static inline void ice_ptp_cfg_timestamp(struct ice_pf *pf, bool ena) { }
-static inline int ice_get_ptp_clock_index(struct ice_pf *pf)
-{
-	return -1;
-}
 
 static inline void ice_ptp_extts_event(struct ice_pf *pf) { }
 static inline s8
@@ -344,5 +340,10 @@ static inline void ice_ptp_release(struct ice_pf *pf) { }
 static inline void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup)
 {
 }
+
+static inline int ice_ptp_clock_index(struct ice_pf *pf)
+{
+	return -1;
+}
 #endif /* IS_ENABLED(CONFIG_PTP_1588_CLOCK) */
 #endif /* _ICE_PTP_H_ */
Signature · 6 lines
2.9.5

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

Re: [Intel-wired-lan] [PATCH net-next v2 3/3] ice: PTP: add clock domain number to auxiliary interface

Quoted 5 lines · Michal Michalik

The PHC clock id used to be moved between PFs using FW admin queue shared parameters - move the implementation to auxiliary bus.

These aren't needed (or wanted) on new revisions

'not just a new version of the same patch/commit'

Quoted 21 lines

---
v1 -> v2:
* fixed the "static declaration of 'ice_ptp_clock_index' follows non-static declaration"
* removed no longer required 'ice_aqc_driver_params' params

  drivers/net/ethernet/intel/ice/ice_adminq_cmd.h |   5 -
  drivers/net/ethernet/intel/ice/ice_ethtool.c    |   2 +-
  drivers/net/ethernet/intel/ice/ice_ptp.c        | 163 ++++--------------------
  drivers/net/ethernet/intel/ice/ice_ptp.h        |  11 +-
  4 files changed, 34 insertions(+), 147 deletions(-)
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +0 -0
index 8b1d2c4..0baa410 100644
@@ -2068,11 +2068,6 @@ struct ice_aqc_driver_shared_params {
  };

drivers/net/ethernet/intel/ice/ice_adminq_cmd.h struct ice_aqc_driver_shared_params { · line 2073

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +0 -5
 
  enum ice_aqc_driver_params {
-	/* OS clock index for PTP timer Domain 0 */
-	ICE_AQC_DRIVER_PARAM_CLK_IDX_TMR0 = 0,
-	/* OS clock index for PTP timer Domain 1 */
-	ICE_AQC_DRIVER_PARAM_CLK_IDX_TMR1,
-
  	/* Add new parameters above */
  	ICE_AQC_DRIVER_PARAM_MAX = 16,
  };

Is this enum needed at all anymore?
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#9 lore raw

Re: [Intel-wired-lan] [PATCH net-next v2 3/3] ice: PTP: add clock domain number to auxiliary interface

Quoted 35 lines · Tony Nguyen
Quoted 5 lines · Michal Michalik

The PHC clock id used to be moved between PFs using FW admin queue shared parameters - move the implementation to auxiliary bus.

These aren't needed (or wanted) on new revisions

'not just a new version of the same patch/commit'

Quoted 22 lines

---
v1 -> v2:
* fixed the "static declaration of 'ice_ptp_clock_index' follows non-static declaration"
* removed no longer required 'ice_aqc_driver_params' params

  drivers/net/ethernet/intel/ice/ice_adminq_cmd.h |   5 -
  drivers/net/ethernet/intel/ice/ice_ethtool.c    |   2 +-
  drivers/net/ethernet/intel/ice/ice_ptp.c        | 163 ++++--------------------
  drivers/net/ethernet/intel/ice/ice_ptp.h        |  11 +-
  4 files changed, 34 insertions(+), 147 deletions(-)
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +0 -0
index 8b1d2c4..0baa410 100644
@@ -2068,11 +2068,6 @@ struct ice_aqc_driver_shared_params {
  };
 
Quoted 11 lines

drivers/net/ethernet/intel/ice/ice_adminq_cmd.h struct ice_aqc_driver_shared_params { · line 2073

Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +0 -5
  enum ice_aqc_driver_params {
-	/* OS clock index for PTP timer Domain 0 */
-	ICE_AQC_DRIVER_PARAM_CLK_IDX_TMR0 = 0,
-	/* OS clock index for PTP timer Domain 1 */
-	ICE_AQC_DRIVER_PARAM_CLK_IDX_TMR1,
-
  	/* Add new parameters above */
  	ICE_AQC_DRIVER_PARAM_MAX = 16,
  };

Is this enum needed at all anymore?

It should just be removed now I think.
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#10 lore raw

Re: [Intel-wired-lan] [PATCH net-next v2 3/3] ice: PTP: add clock domain number to auxiliary interface

Quoted 10 lines · Jacob E
Quoted 6 lines · Tony Nguyen
Quoted 3 lines · Michal Michalik

The PHC clock id used to be moved between PFs using FW admin queue shared parameters - move the implementation to auxiliary bus.

Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

These aren't needed (or wanted) on new revisions

'not just a new version of the same patch/commit'

Thanks, I misunderstand the idea behind it. I will remove it.

Quoted 34 lines
Quoted 22 lines
Quoted 22 lines

---
v1 -> v2:
* fixed the "static declaration of 'ice_ptp_clock_index' follows non-static declaration"
* removed no longer required 'ice_aqc_driver_params' params

  drivers/net/ethernet/intel/ice/ice_adminq_cmd.h |   5 -
  drivers/net/ethernet/intel/ice/ice_ethtool.c    |   2 +-
  drivers/net/ethernet/intel/ice/ice_ptp.c        | 163 ++++--------------------
  drivers/net/ethernet/intel/ice/ice_ptp.h        |  11 +-
  4 files changed, 34 insertions(+), 147 deletions(-)
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +0 -0
index 8b1d2c4..0baa410 100644
@@ -2068,11 +2068,6 @@ struct ice_aqc_driver_shared_params {
  };
 
Quoted 11 lines

drivers/net/ethernet/intel/ice/ice_adminq_cmd.h struct ice_aqc_driver_shared_params { · line 2073

Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +0 -5
  enum ice_aqc_driver_params {
-	/* OS clock index for PTP timer Domain 0 */
-	ICE_AQC_DRIVER_PARAM_CLK_IDX_TMR0 = 0,
-	/* OS clock index for PTP timer Domain 1 */
-	ICE_AQC_DRIVER_PARAM_CLK_IDX_TMR1,
-
  	/* Add new parameters above */
  	ICE_AQC_DRIVER_PARAM_MAX = 16,
  };

Is this enum needed at all anymore?

Quoted 1 line

It should just be removed now I think.

Ok - I will remove it fully.

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

maintainer
#11 lore raw
In reply to Michal Michalik

On 7/21/2023 8:44 AM, Michal Michalik wrote:

One last thing I just noticed: s/net-next/iwl-next

Quoted 9 lines

Auxiliary bus allow exchanging information between PFs, which allows both fixing problems and simplifying new features implementation. The auxiliary bus is enabled for all devices supported by ice driver.

Michal Michalik (3):
ice: Auxbus devices & driver for E822 TS
ice: Use PTP auxbus for all PHYs restart in E822
ice: PTP: add clock domain number to auxiliary interface

Quoted 9 lines
  drivers/net/ethernet/intel/ice/ice.h            |  14 +
  drivers/net/ethernet/intel/ice/ice_adminq_cmd.h |   5 -
  drivers/net/ethernet/intel/ice/ice_ethtool.c    |   2 +-
  drivers/net/ethernet/intel/ice/ice_hw_autogen.h |   1 +
  drivers/net/ethernet/intel/ice/ice_main.c       |  11 +-
  drivers/net/ethernet/intel/ice/ice_ptp.c        | 582 +++++++++++++++++-------
  drivers/net/ethernet/intel/ice/ice_ptp.h        |  41 +-
  7 files changed, 489 insertions(+), 167 deletions(-)

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

#12 lore raw
Quoted 5 lines · Anthony L

On 7/21/2023 8:44 AM, Michal Michalik wrote:

One last thing I just noticed: s/net-next/iwl-next

Ok! Changing it - thanks.

BR,
M^2

Quoted 9 lines
Quoted 9 lines

Auxiliary bus allow exchanging information between PFs, which allows both fixing problems and simplifying new features implementation. The auxiliary bus is enabled for all devices supported by ice driver.

Michal Michalik (3):
ice: Auxbus devices & driver for E822 TS
ice: Use PTP auxbus for all PHYs restart in E822
ice: PTP: add clock domain number to auxiliary interface

Quoted 9 lines
Quoted 9 lines
  drivers/net/ethernet/intel/ice/ice.h            |  14 +
  drivers/net/ethernet/intel/ice/ice_adminq_cmd.h |   5 -
  drivers/net/ethernet/intel/ice/ice_ethtool.c    |   2 +-
  drivers/net/ethernet/intel/ice/ice_hw_autogen.h |   1 +
  drivers/net/ethernet/intel/ice/ice_main.c       |  11 +-
  drivers/net/ethernet/intel/ice/ice_ptp.c        | 582 +++++++++++++++++-------
  drivers/net/ethernet/intel/ice/ice_ptp.h        |  41 +-
  7 files changed, 489 insertions(+), 167 deletions(-)

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