From: Jacob Keller <jacob.e.keller@intel.com>
To: Intel Wired LAN <intel-wired-lan@lists.osuosl.org>
Subject: [Intel-wired-lan] [PATCH net-next v3 13/15] ice: only check set bits in ice_ptp_flush_tx_tracker
Date: Mon, 5 Dec 2022 11:52:51 -0800 [thread overview]
Message-ID: <20221205195253.2475492-14-jacob.e.keller@intel.com> (raw)
In-Reply-To: <20221205195253.2475492-1-jacob.e.keller@intel.com>
The ice_ptp_flush_tx_tracker function is called to clear all outstanding Tx
timestamp requests when the port is being brought down. This function
iterates over the entire list, but this is unnecessary. We only need to
check the bits which are actually set in the ready bitmap.
Replace this logic with for_each_set_bit, and follow a similar flow as in
ice_ptp_tx_tstamp_cleanup. Note that it is safe to call dev_kfree_skb_any
on a NULL pointer as it will perform a no-op so we do not need to verify
that the skb is actually NULL.
The new implementation also avoids clearing (and thus reading!) the PHY
timestamp unless the index is marked as having a valid timestamp in the
timestamp status bitmap. This ensures that we properly clear the status
registers as appropriate.
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Gurucharan G <gurucharanx.g@intel.com> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
No changes since v2.
drivers/net/ethernet/intel/ice/ice_ptp.c | 38 ++++++++++++++++++------
1 file changed, 29 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c
index d40c570297c5..e383dd7f0caf 100644
--- a/drivers/net/ethernet/intel/ice/ice_ptp.c
+++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
@@ -830,28 +830,48 @@ ice_ptp_alloc_tx_tracker(struct ice_ptp_tx *tx)
* ice_ptp_flush_tx_tracker - Flush any remaining timestamps from the tracker
* @pf: Board private structure
* @tx: the tracker to flush
+ *
+ * Called during teardown when a Tx tracker is being removed.
*/
static void
ice_ptp_flush_tx_tracker(struct ice_pf *pf, struct ice_ptp_tx *tx)
{
+ struct ice_hw *hw = &pf->hw;
+ u64 tstamp_ready;
+ int err;
u8 idx;
- for (idx = 0; idx < tx->len; idx++) {
+ err = ice_get_phy_tx_tstamp_ready(hw, tx->block, &tstamp_ready);
+ if (err) {
+ dev_dbg(ice_pf_to_dev(pf), "Failed to get the Tx tstamp ready bitmap for block %u, err %d\n",
+ tx->block, err);
+
+ /* If we fail to read the Tx timestamp ready bitmap just
+ * skip clearing the PHY timestamps.
+ */
+ tstamp_ready = 0;
+ }
+
+ for_each_set_bit(idx, tx->in_use, tx->len) {
u8 phy_idx = idx + tx->offset;
+ struct sk_buff *skb;
+
+ /* In case this timestamp is ready, we need to clear it. */
+ if (!hw->reset_ongoing && (tstamp_ready & BIT_ULL(phy_idx)))
+ ice_clear_phy_tstamp(hw, tx->block, phy_idx);
spin_lock(&tx->lock);
- if (tx->tstamps[idx].skb) {
- dev_kfree_skb_any(tx->tstamps[idx].skb);
- tx->tstamps[idx].skb = NULL;
- pf->ptp.tx_hwtstamp_flushed++;
- }
+ skb = tx->tstamps[idx].skb;
+ tx->tstamps[idx].skb = NULL;
clear_bit(idx, tx->in_use);
clear_bit(idx, tx->stale);
spin_unlock(&tx->lock);
- /* Clear any potential residual timestamp in the PHY block */
- if (!pf->hw.reset_ongoing)
- ice_clear_phy_tstamp(&pf->hw, tx->block, phy_idx);
+ /* Count the number of Tx timestamps flushed */
+ pf->ptp.tx_hwtstamp_flushed++;
+
+ /* Free the SKB after we've cleared the bit */
+ dev_kfree_skb_any(skb);
}
}
--
2.38.1.420.g319605f8f00e
_______________________________________________
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-12-05 19:53 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-05 19:52 [Intel-wired-lan] [PATCH net-next v3 00/15] ice: improve Tx timestamp corner cases Jacob Keller
2022-12-05 19:52 ` [Intel-wired-lan] [PATCH net-next v3 01/15] ice: Use more generic names for ice_ptp_tx fields Jacob Keller
2022-12-05 19:52 ` [Intel-wired-lan] [PATCH net-next v3 02/15] ice: Remove the E822 vernier "bypass" logic Jacob Keller
2022-12-05 19:52 ` [Intel-wired-lan] [PATCH net-next v3 03/15] ice: Reset TS memory for all quads Jacob Keller
2022-12-05 19:52 ` [Intel-wired-lan] [PATCH net-next v3 04/15] ice: fix misuse of "link err" with "link status" Jacob Keller
2022-12-05 19:52 ` [Intel-wired-lan] [PATCH net-next v3 05/15] ice: always call ice_ptp_link_change and make it void Jacob Keller
2022-12-05 19:52 ` [Intel-wired-lan] [PATCH net-next v3 06/15] ice: handle discarding old Tx requests in ice_ptp_tx_tstamp Jacob Keller
2022-12-05 19:52 ` [Intel-wired-lan] [PATCH net-next v3 07/15] ice: check Tx timestamp memory register for ready timestamps Jacob Keller
2022-12-05 19:52 ` [Intel-wired-lan] [PATCH net-next v3 08/15] ice: synchronize the misc IRQ when tearing down Tx tracker Jacob Keller
2022-12-07 9:04 ` G, GurucharanX
2022-12-05 19:52 ` [Intel-wired-lan] [PATCH net-next v3 09/15] ice: protect init and calibrating check in ice_ptp_request_ts Jacob Keller
2022-12-07 9:05 ` G, GurucharanX
2022-12-05 19:52 ` [Intel-wired-lan] [PATCH net-next v3 10/15] ice: disable Tx timestamps while link is down Jacob Keller
2022-12-05 19:52 ` [Intel-wired-lan] [PATCH net-next v3 11/15] ice: cleanup allocations in ice_ptp_alloc_tx_tracker Jacob Keller
2022-12-05 19:52 ` [Intel-wired-lan] [PATCH net-next v3 12/15] ice: handle flushing stale Tx timestamps in ice_ptp_tx_tstamp Jacob Keller
2022-12-05 19:52 ` Jacob Keller [this message]
2022-12-05 19:52 ` [Intel-wired-lan] [PATCH net-next v3 14/15] ice: make Tx and Rx vernier offset calibration independent Jacob Keller
2022-12-05 19:52 ` [Intel-wired-lan] [PATCH net-next v3 15/15] ice: reschedule ice_ptp_wait_for_offset_valid during reset Jacob Keller
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=20221205195253.2475492-14-jacob.e.keller@intel.com \
--to=jacob.e.keller@intel.com \
--cc=intel-wired-lan@lists.osuosl.org \
/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