From: Tony Nguyen <anthony.l.nguyen@intel.com>
To: Karol Kolacinski <karol.kolacinski@intel.com>,
<intel-wired-lan@lists.osuosl.org>
Subject: Re: [Intel-wired-lan] [PATCH net-next] ice: Add low latency Tx timestamp read
Date: Tue, 26 Jul 2022 14:39:03 -0700 [thread overview]
Message-ID: <63bf55b9-9889-a947-d689-b7c61d55ff5a@intel.com> (raw)
In-Reply-To: <20220722153610.499172-1-karol.kolacinski@intel.com>
On 7/22/2022 8:36 AM, Karol Kolacinski wrote:
> E810 products can support low latency Tx timestamp register read.
> This requires usage of threaded IRQ instead of kthread to reduce the
> kthread start latency (spikes up to 20 ms).
> Add a check for the device capability and use the new method if
> supported.
>
> Signed-off-by: Karol Kolacinski <karol.kolacinski@intel.com>
> ---
<snip>
> @@ -3121,6 +3123,24 @@ static irqreturn_t ice_misc_intr(int __always_unused irq, void *data)
> return ret;
> }
>
> +/**
> + * ice_misc_intr_thread_fn - misc interrupt thread function
> + * @irq: interrupt number
> + * @data: pointer to a q_vector
> + */
> +static irqreturn_t ice_misc_intr_thread_fn(int __always_unused irq, void *data)
> +{
> + struct ice_pf *pf = (struct ice_pf *)data;
Cast shouldn't be needed.
> + irqreturn_t ret = IRQ_HANDLED;
> + bool irq_handled;
> +
> + irq_handled = ice_ptp_process_ts(pf);
> + if (!irq_handled)
> + ret = IRQ_WAKE_THREAD;
> +
> + return ret;
> +}
> +
> /**
> * ice_dis_ctrlq_interrupts - disable control queue interrupts
> * @hw: pointer to HW structure
<snip>
> @@ -2171,16 +2170,17 @@ s8 ice_ptp_request_ts(struct ice_ptp_tx *tx, struct sk_buff *skb)
> }
>
> /**
> - * ice_ptp_process_ts - Spawn kthread work to handle timestamps
> + * ice_ptp_process_ts - Process the PTP Tx timestamps
> * @pf: Board private structure
> *
> - * Queue work required to process the PTP Tx timestamps outside of interrupt
> - * context.
> + * Returns true if timestamps are processed.
> */
> -void ice_ptp_process_ts(struct ice_pf *pf)
> +bool ice_ptp_process_ts(struct ice_pf *pf)
> {
> if (pf->ptp.port.tx.init)
> - kthread_queue_work(pf->ptp.kworker, &pf->ptp.port.tx.work);
> + return ice_ptp_tx_tstamp(&pf->ptp.port.tx);
> + else
> + return false;
I believe preference is to remove the else and have an un-indented
return false.
<snip>
> @@ -2587,38 +2588,113 @@ static int ice_write_phy_reg_e810(struct ice_hw *hw, u32 addr, u32 val)
> }
>
> /**
> - * ice_read_phy_tstamp_e810 - Read a PHY timestamp out of the external PHY
> + * ice_read_phy_tstamp_ll_e810 - Read a PHY timestamp registers through the FW
> + * @hw: pointer to the HW struct
> + * @idx: the timestamp index to read
> + * @hi: 8 bit timestamp high value
> + * @lo: 32 bit timestamp low value
> + *
> + * Read a 8bit timestamp high value and 32 bit timestamp low value out of the
> + * timestamp block of the external PHY on the E810 device using the low latency
> + * timestamp read.
> + */
> +static int
> +ice_read_phy_tstamp_ll_e810(struct ice_hw *hw, u8 idx, u8 *hi, u32 *lo)
> +{
> + u32 val;
> + u8 i;
> +
> + /* Write TS index to read to the PF register so the FW can read it */
> + val = FIELD_PREP(TS_LL_READ_TS_IDX, idx) | TS_LL_READ_TS;
> + wr32(hw, PF_SB_ATQBAL, val);
> +
> + /* Read the register repeatedly until the FW provides us the TS */
> + for (i = TS_LL_READ_RETRIES; i > 0; i--) {
> + val = rd32(hw, PF_SB_ATQBAL);
> +
> + /* When the bit is cleared, the TS is ready in the register */
> + if (!(FIELD_GET(TS_LL_READ_TS, val))) {
> + /* High 8 bit value of the TS is on the bits 16:23 */
> + *hi = FIELD_GET(TS_LL_READ_TS_HIGH, val);
> +
> + /* Read the low 32 bit value and set the TS valid bit */
> + *lo = rd32(hw, PF_SB_ATQBAH) | TS_VALID;
> + return 0;
> + }
> +
> + udelay(10);
CHECK: usleep_range is preferred over udelay; see
Documentation/timers/timers-howto.rst
> + }
> +
> + /* FW failed to provide the TS in time */
> + ice_debug(hw, ICE_DBG_PTP, "Failed to read PTP timestamp using low latency read\n");
> + return -EINVAL;
> +}
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
next prev parent reply other threads:[~2022-07-26 21:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-22 15:36 [Intel-wired-lan] [PATCH net-next] ice: Add low latency Tx timestamp read Karol Kolacinski
2022-07-25 8:48 ` Alexander Lobakin
2022-07-26 21:39 ` Tony Nguyen [this message]
2022-07-28 12:53 ` Kolacinski, Karol
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=63bf55b9-9889-a947-d689-b7c61d55ff5a@intel.com \
--to=anthony.l.nguyen@intel.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=karol.kolacinski@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox