From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
To: davem@davemloft.net
Cc: Andre Guedes <andre.guedes@intel.com>,
netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com,
Aaron Brown <aaron.f.brown@intel.com>,
Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Subject: [net-next v2 04/13] igc: Remove duplicate code in Tx timestamp handling
Date: Mon, 29 Jun 2020 18:27:39 -0700 [thread overview]
Message-ID: <20200630012748.518705-5-jeffrey.t.kirsher@intel.com> (raw)
In-Reply-To: <20200630012748.518705-1-jeffrey.t.kirsher@intel.com>
From: Andre Guedes <andre.guedes@intel.com>
The functions igc_ptp_tx_hang() and igc_ptp_tx_work() have duplicate
code which handles Tx timestamp timeouts. This patch does a trivial
refactoring by moving that code to its own function and reusing it.
Signed-off-by: Andre Guedes <andre.guedes@intel.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
drivers/net/ethernet/intel/igc/igc_ptp.c | 34 +++++++++++-------------
1 file changed, 15 insertions(+), 19 deletions(-)
diff --git a/drivers/net/ethernet/intel/igc/igc_ptp.c b/drivers/net/ethernet/intel/igc/igc_ptp.c
index 82e6c6c962d5..b1b23c6bf689 100644
--- a/drivers/net/ethernet/intel/igc/igc_ptp.c
+++ b/drivers/net/ethernet/intel/igc/igc_ptp.c
@@ -386,11 +386,23 @@ static int igc_ptp_set_timestamp_mode(struct igc_adapter *adapter,
return 0;
}
+static void igc_ptp_tx_timeout(struct igc_adapter *adapter)
+{
+ struct igc_hw *hw = &adapter->hw;
+
+ dev_kfree_skb_any(adapter->ptp_tx_skb);
+ adapter->ptp_tx_skb = NULL;
+ adapter->tx_hwtstamp_timeouts++;
+ clear_bit_unlock(__IGC_PTP_TX_IN_PROGRESS, &adapter->state);
+ /* Clear the tx valid bit in TSYNCTXCTL register to enable interrupt. */
+ rd32(IGC_TXSTMPH);
+ netdev_warn(adapter->netdev, "Tx timestamp timeout\n");
+}
+
void igc_ptp_tx_hang(struct igc_adapter *adapter)
{
bool timeout = time_is_before_jiffies(adapter->ptp_tx_start +
IGC_PTP_TX_TIMEOUT);
- struct igc_hw *hw = &adapter->hw;
if (!adapter->ptp_tx_skb)
return;
@@ -404,15 +416,7 @@ void igc_ptp_tx_hang(struct igc_adapter *adapter)
*/
if (timeout) {
cancel_work_sync(&adapter->ptp_tx_work);
- dev_kfree_skb_any(adapter->ptp_tx_skb);
- adapter->ptp_tx_skb = NULL;
- clear_bit_unlock(__IGC_PTP_TX_IN_PROGRESS, &adapter->state);
- adapter->tx_hwtstamp_timeouts++;
- /* Clear the Tx valid bit in TSYNCTXCTL register to enable
- * interrupt
- */
- rd32(IGC_TXSTMPH);
- netdev_warn(adapter->netdev, "Clearing Tx timestamp hang\n");
+ igc_ptp_tx_timeout(adapter);
}
}
@@ -467,15 +471,7 @@ static void igc_ptp_tx_work(struct work_struct *work)
if (time_is_before_jiffies(adapter->ptp_tx_start +
IGC_PTP_TX_TIMEOUT)) {
- dev_kfree_skb_any(adapter->ptp_tx_skb);
- adapter->ptp_tx_skb = NULL;
- clear_bit_unlock(__IGC_PTP_TX_IN_PROGRESS, &adapter->state);
- adapter->tx_hwtstamp_timeouts++;
- /* Clear the tx valid bit in TSYNCTXCTL register to enable
- * interrupt
- */
- rd32(IGC_TXSTMPH);
- netdev_warn(adapter->netdev, "Clearing Tx timestamp hang\n");
+ igc_ptp_tx_timeout(adapter);
return;
}
--
2.26.2
next prev parent reply other threads:[~2020-06-30 1:28 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-30 1:27 [net-next v2 00/13][pull request] 1GbE Intel Wired LAN Driver Updates 2020-06-29 Jeff Kirsher
2020-06-30 1:27 ` [net-next v2 01/13] igc: Add initial EEE support Jeff Kirsher
2020-06-30 1:27 ` [net-next v2 02/13] igc: Add initial LTR support Jeff Kirsher
2020-06-30 1:27 ` [net-next v2 03/13] igc: Clean up Rx timestamping logic Jeff Kirsher
2020-06-30 1:27 ` Jeff Kirsher [this message]
2020-06-30 1:27 ` [net-next v2 05/13] igc: Check __IGC_PTP_TX_IN_PROGRESS instead of ptp_tx_skb Jeff Kirsher
2020-06-30 1:27 ` [net-next v2 06/13] igc: Remove UDP filter setup in PTP code Jeff Kirsher
2020-06-30 1:27 ` [net-next v2 07/13] igc: Refactor igc_ptp_set_timestamp_mode() Jeff Kirsher
2020-06-30 1:27 ` [net-next v2 08/13] igc: Fix Rx timestamp disabling Jeff Kirsher
2020-06-30 1:27 ` [net-next v2 09/13] igc: Add LPI counters Jeff Kirsher
2020-06-30 1:27 ` [net-next v2 10/13] igc: Remove TCP segmentation TX fail counter Jeff Kirsher
2020-06-30 1:27 ` [net-next v2 11/13] igc: Refactor the igc_power_down_link() Jeff Kirsher
2020-06-30 1:27 ` [net-next v2 12/13] igc: Remove unneeded check for copper media type Jeff Kirsher
2020-06-30 1:27 ` [net-next v2 13/13] igc: Remove checking media type during MAC initialization Jeff Kirsher
2020-06-30 19:34 ` [net-next v2 00/13][pull request] 1GbE Intel Wired LAN Driver Updates 2020-06-29 David Miller
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=20200630012748.518705-5-jeffrey.t.kirsher@intel.com \
--to=jeffrey.t.kirsher@intel.com \
--cc=aaron.f.brown@intel.com \
--cc=andre.guedes@intel.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=nhorman@redhat.com \
--cc=sassmann@redhat.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;
as well as URLs for NNTP newsgroup(s).