aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/intel/igb/igb_ptp.c
diff options
context:
space:
mode:
authorJeff Kirsher <jeffrey.t.kirsher@intel.com>2013-02-23 02:29:56 -0500
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2013-04-18 19:40:25 -0400
commitb980ac18c95f3251038da7a3826370aff05a7434 (patch)
tree938b3acb07b97963db1006e61933a02b77ac3dca /drivers/net/ethernet/intel/igb/igb_ptp.c
parentc8268921d443bd5c0c9b8fd7193d00533638ec03 (diff)
igb: Fix code comments and whitespace
Aligns the multi-line code comments with the desired style for the networking tree. Also cleaned up whitespace issues found during the cleanup of code comments (i.e. remove unnecessary blank lines, use tabs where possible, properly wrap lines and keep strings on a single line) Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel/igb/igb_ptp.c')
-rw-r--r--drivers/net/ethernet/intel/igb/igb_ptp.c57
1 files changed, 18 insertions, 39 deletions
diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c
index 0a237507ee85..9f7da269edc3 100644
--- a/drivers/net/ethernet/intel/igb/igb_ptp.c
+++ b/drivers/net/ethernet/intel/igb/igb_ptp.c
@@ -1,5 +1,4 @@
1/* 1/* PTP Hardware Clock (PHC) driver for the Intel 82576 and 82580
2 * PTP Hardware Clock (PHC) driver for the Intel 82576 and 82580
3 * 2 *
4 * Copyright (C) 2011 Richard Cochran <richardcochran@gmail.com> 3 * Copyright (C) 2011 Richard Cochran <richardcochran@gmail.com>
5 * 4 *
@@ -27,8 +26,7 @@
27#define INCVALUE_MASK 0x7fffffff 26#define INCVALUE_MASK 0x7fffffff
28#define ISGN 0x80000000 27#define ISGN 0x80000000
29 28
30/* 29/* The 82580 timesync updates the system timer every 8ns by 8ns,
31 * The 82580 timesync updates the system timer every 8ns by 8ns,
32 * and this update value cannot be reprogrammed. 30 * and this update value cannot be reprogrammed.
33 * 31 *
34 * Neither the 82576 nor the 82580 offer registers wide enough to hold 32 * Neither the 82576 nor the 82580 offer registers wide enough to hold
@@ -77,10 +75,7 @@
77#define INCVALUE_82576 (16 << IGB_82576_TSYNC_SHIFT) 75#define INCVALUE_82576 (16 << IGB_82576_TSYNC_SHIFT)
78#define IGB_NBITS_82580 40 76#define IGB_NBITS_82580 40
79 77
80/* 78/* SYSTIM read access for the 82576 */
81 * SYSTIM read access for the 82576
82 */
83
84static cycle_t igb_ptp_read_82576(const struct cyclecounter *cc) 79static cycle_t igb_ptp_read_82576(const struct cyclecounter *cc)
85{ 80{
86 struct igb_adapter *igb = container_of(cc, struct igb_adapter, cc); 81 struct igb_adapter *igb = container_of(cc, struct igb_adapter, cc);
@@ -97,10 +92,7 @@ static cycle_t igb_ptp_read_82576(const struct cyclecounter *cc)
97 return val; 92 return val;
98} 93}
99 94
100/* 95/* SYSTIM read access for the 82580 */
101 * SYSTIM read access for the 82580
102 */
103
104static cycle_t igb_ptp_read_82580(const struct cyclecounter *cc) 96static cycle_t igb_ptp_read_82580(const struct cyclecounter *cc)
105{ 97{
106 struct igb_adapter *igb = container_of(cc, struct igb_adapter, cc); 98 struct igb_adapter *igb = container_of(cc, struct igb_adapter, cc);
@@ -108,8 +100,7 @@ static cycle_t igb_ptp_read_82580(const struct cyclecounter *cc)
108 u64 val; 100 u64 val;
109 u32 lo, hi, jk; 101 u32 lo, hi, jk;
110 102
111 /* 103 /* The timestamp latches on lowest register read. For the 82580
112 * The timestamp latches on lowest register read. For the 82580
113 * the lowest register is SYSTIMR instead of SYSTIML. However we only 104 * the lowest register is SYSTIMR instead of SYSTIML. However we only
114 * need to provide nanosecond resolution, so we just ignore it. 105 * need to provide nanosecond resolution, so we just ignore it.
115 */ 106 */
@@ -123,17 +114,13 @@ static cycle_t igb_ptp_read_82580(const struct cyclecounter *cc)
123 return val; 114 return val;
124} 115}
125 116
126/* 117/* SYSTIM read access for I210/I211 */
127 * SYSTIM read access for I210/I211
128 */
129
130static void igb_ptp_read_i210(struct igb_adapter *adapter, struct timespec *ts) 118static void igb_ptp_read_i210(struct igb_adapter *adapter, struct timespec *ts)
131{ 119{
132 struct e1000_hw *hw = &adapter->hw; 120 struct e1000_hw *hw = &adapter->hw;
133 u32 sec, nsec, jk; 121 u32 sec, nsec, jk;
134 122
135 /* 123 /* The timestamp latches on lowest register read. For I210/I211, the
136 * The timestamp latches on lowest register read. For I210/I211, the
137 * lowest register is SYSTIMR. Since we only need to provide nanosecond 124 * lowest register is SYSTIMR. Since we only need to provide nanosecond
138 * resolution, we can ignore it. 125 * resolution, we can ignore it.
139 */ 126 */
@@ -150,8 +137,7 @@ static void igb_ptp_write_i210(struct igb_adapter *adapter,
150{ 137{
151 struct e1000_hw *hw = &adapter->hw; 138 struct e1000_hw *hw = &adapter->hw;
152 139
153 /* 140 /* Writing the SYSTIMR register is not necessary as it only provides
154 * Writing the SYSTIMR register is not necessary as it only provides
155 * sub-nanosecond resolution. 141 * sub-nanosecond resolution.
156 */ 142 */
157 wr32(E1000_SYSTIML, ts->tv_nsec); 143 wr32(E1000_SYSTIML, ts->tv_nsec);
@@ -207,10 +193,7 @@ static void igb_ptp_systim_to_hwtstamp(struct igb_adapter *adapter,
207 } 193 }
208} 194}
209 195
210/* 196/* PTP clock operations */
211 * PTP clock operations
212 */
213
214static int igb_ptp_adjfreq_82576(struct ptp_clock_info *ptp, s32 ppb) 197static int igb_ptp_adjfreq_82576(struct ptp_clock_info *ptp, s32 ppb)
215{ 198{
216 struct igb_adapter *igb = container_of(ptp, struct igb_adapter, 199 struct igb_adapter *igb = container_of(ptp, struct igb_adapter,
@@ -387,7 +370,7 @@ static int igb_ptp_enable(struct ptp_clock_info *ptp,
387 * 370 *
388 * This work function polls the TSYNCTXCTL valid bit to determine when a 371 * This work function polls the TSYNCTXCTL valid bit to determine when a
389 * timestamp has been taken for the current stored skb. 372 * timestamp has been taken for the current stored skb.
390 */ 373 **/
391void igb_ptp_tx_work(struct work_struct *work) 374void igb_ptp_tx_work(struct work_struct *work)
392{ 375{
393 struct igb_adapter *adapter = container_of(work, struct igb_adapter, 376 struct igb_adapter *adapter = container_of(work, struct igb_adapter,
@@ -437,7 +420,7 @@ static void igb_ptp_overflow_check(struct work_struct *work)
437 * dropped an Rx packet that was timestamped when the ring is full. The 420 * dropped an Rx packet that was timestamped when the ring is full. The
438 * particular error is rare but leaves the device in a state unable to timestamp 421 * particular error is rare but leaves the device in a state unable to timestamp
439 * any future packets. 422 * any future packets.
440 */ 423 **/
441void igb_ptp_rx_hang(struct igb_adapter *adapter) 424void igb_ptp_rx_hang(struct igb_adapter *adapter)
442{ 425{
443 struct e1000_hw *hw = &adapter->hw; 426 struct e1000_hw *hw = &adapter->hw;
@@ -481,7 +464,7 @@ void igb_ptp_rx_hang(struct igb_adapter *adapter)
481 * If we were asked to do hardware stamping and such a time stamp is 464 * If we were asked to do hardware stamping and such a time stamp is
482 * available, then it must have been for this skb here because we only 465 * available, then it must have been for this skb here because we only
483 * allow only one such packet into the queue. 466 * allow only one such packet into the queue.
484 */ 467 **/
485void igb_ptp_tx_hwtstamp(struct igb_adapter *adapter) 468void igb_ptp_tx_hwtstamp(struct igb_adapter *adapter)
486{ 469{
487 struct e1000_hw *hw = &adapter->hw; 470 struct e1000_hw *hw = &adapter->hw;
@@ -506,15 +489,14 @@ void igb_ptp_tx_hwtstamp(struct igb_adapter *adapter)
506 * This function is meant to retrieve a timestamp from the first buffer of an 489 * This function is meant to retrieve a timestamp from the first buffer of an
507 * incoming frame. The value is stored in little endian format starting on 490 * incoming frame. The value is stored in little endian format starting on
508 * byte 8. 491 * byte 8.
509 */ 492 **/
510void igb_ptp_rx_pktstamp(struct igb_q_vector *q_vector, 493void igb_ptp_rx_pktstamp(struct igb_q_vector *q_vector,
511 unsigned char *va, 494 unsigned char *va,
512 struct sk_buff *skb) 495 struct sk_buff *skb)
513{ 496{
514 __le64 *regval = (__le64 *)va; 497 __le64 *regval = (__le64 *)va;
515 498
516 /* 499 /* The timestamp is recorded in little endian format.
517 * The timestamp is recorded in little endian format.
518 * DWORD: 0 1 2 3 500 * DWORD: 0 1 2 3
519 * Field: Reserved Reserved SYSTIML SYSTIMH 501 * Field: Reserved Reserved SYSTIML SYSTIMH
520 */ 502 */
@@ -529,7 +511,7 @@ void igb_ptp_rx_pktstamp(struct igb_q_vector *q_vector,
529 * 511 *
530 * This function is meant to retrieve a timestamp from the internal registers 512 * This function is meant to retrieve a timestamp from the internal registers
531 * of the adapter and store it in the skb. 513 * of the adapter and store it in the skb.
532 */ 514 **/
533void igb_ptp_rx_rgtstamp(struct igb_q_vector *q_vector, 515void igb_ptp_rx_rgtstamp(struct igb_q_vector *q_vector,
534 struct sk_buff *skb) 516 struct sk_buff *skb)
535{ 517{
@@ -537,8 +519,7 @@ void igb_ptp_rx_rgtstamp(struct igb_q_vector *q_vector,
537 struct e1000_hw *hw = &adapter->hw; 519 struct e1000_hw *hw = &adapter->hw;
538 u64 regval; 520 u64 regval;
539 521
540 /* 522 /* If this bit is set, then the RX registers contain the time stamp. No
541 * If this bit is set, then the RX registers contain the time stamp. No
542 * other packet will be time stamped until we read these registers, so 523 * other packet will be time stamped until we read these registers, so
543 * read the registers to make them available again. Because only one 524 * read the registers to make them available again. Because only one
544 * packet can be time stamped at a time, we know that the register 525 * packet can be time stamped at a time, we know that the register
@@ -574,7 +555,6 @@ void igb_ptp_rx_rgtstamp(struct igb_q_vector *q_vector,
574 * type has to be specified. Matching the kind of event packet is 555 * type has to be specified. Matching the kind of event packet is
575 * not supported, with the exception of "all V2 events regardless of 556 * not supported, with the exception of "all V2 events regardless of
576 * level 2 or 4". 557 * level 2 or 4".
577 *
578 **/ 558 **/
579int igb_ptp_hwtstamp_ioctl(struct net_device *netdev, 559int igb_ptp_hwtstamp_ioctl(struct net_device *netdev,
580 struct ifreq *ifr, int cmd) 560 struct ifreq *ifr, int cmd)
@@ -655,10 +635,9 @@ int igb_ptp_hwtstamp_ioctl(struct net_device *netdev,
655 return 0; 635 return 0;
656 } 636 }
657 637
658 /* 638 /* Per-packet timestamping only works if all packets are
659 * Per-packet timestamping only works if all packets are
660 * timestamped, so enable timestamping in all packets as 639 * timestamped, so enable timestamping in all packets as
661 * long as one rx filter was configured. 640 * long as one Rx filter was configured.
662 */ 641 */
663 if ((hw->mac.type >= e1000_82580) && tsync_rx_ctl) { 642 if ((hw->mac.type >= e1000_82580) && tsync_rx_ctl) {
664 tsync_rx_ctl = E1000_TSYNCRXCTL_ENABLED; 643 tsync_rx_ctl = E1000_TSYNCRXCTL_ENABLED;