Skip to content

Commit 1cbedab

Browse files
Andre GuedesJeff Kirsher
authored andcommitted
igc: Fix Rx timestamp disabling
When Rx timestamping is enabled, we set the timestamp bit in SRRCTL register for each queue, but we don't clear it when disabling. This patch fixes igc_ptp_disable_rx_timestamp() accordingly. Also, this patch gets rid of igc_ptp_enable_tstamp_rxqueue() and igc_ptp_enable_tstamp_all_rxqueues() and move their logic into igc_ptp_enable_rx_timestamp() to keep the enable and disable helpers symmetric. Signed-off-by: Andre Guedes <[email protected]> Tested-by: Aaron Brown <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 3df7fd7 commit 1cbedab

File tree

1 file changed

+17
-37
lines changed

1 file changed

+17
-37
lines changed

drivers/net/ethernet/intel/igc/igc_ptp.c

Lines changed: 17 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -205,47 +205,20 @@ void igc_ptp_rx_pktstamp(struct igc_q_vector *q_vector, void *va,
205205
ktime_sub_ns(skb_hwtstamps(skb)->hwtstamp, adjust);
206206
}
207207

208-
/**
209-
* igc_ptp_enable_tstamp_rxqueue - Enable RX timestamp for a queue
210-
* @rx_ring: Pointer to RX queue
211-
* @timer: Index for timer
212-
*
213-
* This function enables RX timestamping for a queue, and selects
214-
* which 1588 timer will provide the timestamp.
215-
*/
216-
static void igc_ptp_enable_tstamp_rxqueue(struct igc_adapter *adapter,
217-
struct igc_ring *rx_ring, u8 timer)
218-
{
219-
struct igc_hw *hw = &adapter->hw;
220-
int reg_idx = rx_ring->reg_idx;
221-
u32 srrctl = rd32(IGC_SRRCTL(reg_idx));
222-
223-
srrctl |= IGC_SRRCTL_TIMESTAMP;
224-
srrctl |= IGC_SRRCTL_TIMER1SEL(timer);
225-
srrctl |= IGC_SRRCTL_TIMER0SEL(timer);
226-
227-
wr32(IGC_SRRCTL(reg_idx), srrctl);
228-
}
229-
230-
static void igc_ptp_enable_tstamp_all_rxqueues(struct igc_adapter *adapter,
231-
u8 timer)
232-
{
233-
int i;
234-
235-
for (i = 0; i < adapter->num_rx_queues; i++) {
236-
struct igc_ring *ring = adapter->rx_ring[i];
237-
238-
igc_ptp_enable_tstamp_rxqueue(adapter, ring, timer);
239-
}
240-
}
241-
242208
static void igc_ptp_disable_rx_timestamp(struct igc_adapter *adapter)
243209
{
244210
struct igc_hw *hw = &adapter->hw;
245211
u32 val;
212+
int i;
246213

247214
wr32(IGC_TSYNCRXCTL, 0);
248215

216+
for (i = 0; i < adapter->num_rx_queues; i++) {
217+
val = rd32(IGC_SRRCTL(i));
218+
val &= ~IGC_SRRCTL_TIMESTAMP;
219+
wr32(IGC_SRRCTL(i), val);
220+
}
221+
249222
val = rd32(IGC_RXPBS);
250223
val &= ~IGC_RXPBS_CFG_TS_EN;
251224
wr32(IGC_RXPBS, val);
@@ -255,14 +228,21 @@ static void igc_ptp_enable_rx_timestamp(struct igc_adapter *adapter)
255228
{
256229
struct igc_hw *hw = &adapter->hw;
257230
u32 val;
231+
int i;
258232

259233
val = rd32(IGC_RXPBS);
260234
val |= IGC_RXPBS_CFG_TS_EN;
261235
wr32(IGC_RXPBS, val);
262236

263-
/* FIXME: For now, only support retrieving RX timestamps from timer 0
264-
*/
265-
igc_ptp_enable_tstamp_all_rxqueues(adapter, 0);
237+
for (i = 0; i < adapter->num_rx_queues; i++) {
238+
val = rd32(IGC_SRRCTL(i));
239+
/* FIXME: For now, only support retrieving RX timestamps from
240+
* timer 0.
241+
*/
242+
val |= IGC_SRRCTL_TIMER1SEL(0) | IGC_SRRCTL_TIMER0SEL(0) |
243+
IGC_SRRCTL_TIMESTAMP;
244+
wr32(IGC_SRRCTL(i), val);
245+
}
266246

267247
val = IGC_TSYNCRXCTL_ENABLED | IGC_TSYNCRXCTL_TYPE_ALL |
268248
IGC_TSYNCRXCTL_RXSYNSIG;

0 commit comments

Comments
 (0)