i40e: when Rx timestamps disabled set specific mode
authorJacob Keller <jacob.e.keller@intel.com>
Sun, 14 Dec 2014 01:55:15 +0000 (01:55 +0000)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Fri, 16 Jan 2015 13:20:56 +0000 (05:20 -0800)
Instead of leaving the Rx timestamps in the same mode as before if we
disable the Rx logic, we can set it into a mode that has the fewest
possible timestamps generated. To do this, select only V1 mode, but do
not enable UDP packet recognition. This should eliminate all (or at
least almost all) Rx timestamps, since V1 packets are always over UDP.

Change-ID: If847288e0030a716e059c4c33ab114f2cf038f05
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Acked-by: Shannon Nelson <shannon.nelson@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/i40e/i40e_ptp.c

index 9f756b4..fabcfa1 100644 (file)
@@ -479,7 +479,12 @@ static int i40e_ptp_set_timestamp_mode(struct i40e_pf *pf,
        switch (config->rx_filter) {
        case HWTSTAMP_FILTER_NONE:
                pf->ptp_rx = false;
-               tsyntype = 0;
+               /* We set the type to V1, but do not enable UDP packet
+                * recognition. In this way, we should be as close to
+                * disabling PTP Rx timestamps as possible since V1 packets
+                * are always UDP, since L2 packets are a V2 feature.
+                */
+               tsyntype = I40E_PRTTSYN_CTL1_TSYNTYPE_V1;
                break;
        case HWTSTAMP_FILTER_PTP_V1_L4_SYNC:
        case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:
@@ -533,17 +538,18 @@ static int i40e_ptp_set_timestamp_mode(struct i40e_pf *pf,
                regval &= ~I40E_PFINT_ICR0_ENA_TIMESYNC_MASK;
        wr32(hw, I40E_PFINT_ICR0_ENA, regval);
 
-       /* There is no simple on/off switch for Rx. To "disable" Rx support,
-        * ignore any received timestamps, rather than turn off the clock.
+       /* Although there is no simple on/off switch for Rx, we "disable" Rx
+        * timestamps by setting to V1 only mode and clear the UDP
+        * recognition. This ought to disable all PTP Rx timestamps as V1
+        * packets are always over UDP. Note that software is configured to
+        * ignore Rx timestamps via the pf->ptp_rx flag.
         */
-       if (pf->ptp_rx) {
-               regval = rd32(hw, I40E_PRTTSYN_CTL1);
-               /* clear everything but the enable bit */
-               regval &= I40E_PRTTSYN_CTL1_TSYNENA_MASK;
-               /* now enable bits for desired Rx timestamps */
-               regval |= tsyntype;
-               wr32(hw, I40E_PRTTSYN_CTL1, regval);
-       }
+       regval = rd32(hw, I40E_PRTTSYN_CTL1);
+       /* clear everything but the enable bit */
+       regval &= I40E_PRTTSYN_CTL1_TSYNENA_MASK;
+       /* now enable bits for desired Rx timestamps */
+       regval |= tsyntype;
+       wr32(hw, I40E_PRTTSYN_CTL1, regval);
 
        return 0;
 }