Commit 29b821fe authored by Andre Guedes's avatar Andre Guedes Committed by Jeff Kirsher

igc: Remove duplicate code in Tx timestamp handling

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: default avatarAndre Guedes <andre.guedes@intel.com>
Tested-by: default avatarAaron Brown <aaron.f.brown@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent 3a66abe9
...@@ -386,11 +386,23 @@ static int igc_ptp_set_timestamp_mode(struct igc_adapter *adapter, ...@@ -386,11 +386,23 @@ static int igc_ptp_set_timestamp_mode(struct igc_adapter *adapter,
return 0; 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) void igc_ptp_tx_hang(struct igc_adapter *adapter)
{ {
bool timeout = time_is_before_jiffies(adapter->ptp_tx_start + bool timeout = time_is_before_jiffies(adapter->ptp_tx_start +
IGC_PTP_TX_TIMEOUT); IGC_PTP_TX_TIMEOUT);
struct igc_hw *hw = &adapter->hw;
if (!adapter->ptp_tx_skb) if (!adapter->ptp_tx_skb)
return; return;
...@@ -404,15 +416,7 @@ void igc_ptp_tx_hang(struct igc_adapter *adapter) ...@@ -404,15 +416,7 @@ void igc_ptp_tx_hang(struct igc_adapter *adapter)
*/ */
if (timeout) { if (timeout) {
cancel_work_sync(&adapter->ptp_tx_work); cancel_work_sync(&adapter->ptp_tx_work);
dev_kfree_skb_any(adapter->ptp_tx_skb); igc_ptp_tx_timeout(adapter);
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");
} }
} }
...@@ -467,15 +471,7 @@ static void igc_ptp_tx_work(struct work_struct *work) ...@@ -467,15 +471,7 @@ static void igc_ptp_tx_work(struct work_struct *work)
if (time_is_before_jiffies(adapter->ptp_tx_start + if (time_is_before_jiffies(adapter->ptp_tx_start +
IGC_PTP_TX_TIMEOUT)) { IGC_PTP_TX_TIMEOUT)) {
dev_kfree_skb_any(adapter->ptp_tx_skb); igc_ptp_tx_timeout(adapter);
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");
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment