aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/intel/e1000e/netdev.c
diff options
context:
space:
mode:
authorBruce Allan <bruce.w.allan@intel.com>2012-12-27 03:32:33 -0500
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2013-01-18 07:55:07 -0500
commitb67e191307a3f330525265af3e2877a74d557cbf (patch)
treeb1be965c24cf81c2a244c420427c3937888abb92 /drivers/net/ethernet/intel/e1000e/netdev.c
parentffe0b2ff17e1d59d33334767e07e8141de4bd5c8 (diff)
e1000e: add support for hardware timestamping on some devices
On 82574, 82583, 82579, I217 and I218 add support for hardware time stamping of all or no Rx packets and Tx packets which have the SKBTX_HW_TSTAMP flag set. Update the .get_ts_info ethtool operation to report the supported time stamping modes, and enable and disable hardware time stamping with the SIOCSHWTSTAMP ioctl. Signed-off-by: Bruce Allan <bruce.w.allan@intel.com> Tested-by: Jeff Pieper <jeffrey.e.pieper@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel/e1000e/netdev.c')
-rw-r--r--drivers/net/ethernet/intel/e1000e/netdev.c371
1 files changed, 365 insertions, 6 deletions
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index bf2c84cf250f..c15b7e438a44 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -488,20 +488,87 @@ static int e1000_desc_unused(struct e1000_ring *ring)
488} 488}
489 489
490/** 490/**
491 * e1000e_systim_to_hwtstamp - convert system time value to hw time stamp
492 * @adapter: board private structure
493 * @hwtstamps: time stamp structure to update
494 * @systim: unsigned 64bit system time value.
495 *
496 * Convert the system time value stored in the RX/TXSTMP registers into a
497 * hwtstamp which can be used by the upper level time stamping functions.
498 *
499 * The 'systim_lock' spinlock is used to protect the consistency of the
500 * system time value. This is needed because reading the 64 bit time
501 * value involves reading two 32 bit registers. The first read latches the
502 * value.
503 **/
504static void e1000e_systim_to_hwtstamp(struct e1000_adapter *adapter,
505 struct skb_shared_hwtstamps *hwtstamps,
506 u64 systim)
507{
508 u64 ns;
509 unsigned long flags;
510
511 spin_lock_irqsave(&adapter->systim_lock, flags);
512 ns = timecounter_cyc2time(&adapter->tc, systim);
513 spin_unlock_irqrestore(&adapter->systim_lock, flags);
514
515 memset(hwtstamps, 0, sizeof(*hwtstamps));
516 hwtstamps->hwtstamp = ns_to_ktime(ns);
517}
518
519/**
520 * e1000e_rx_hwtstamp - utility function which checks for Rx time stamp
521 * @adapter: board private structure
522 * @status: descriptor extended error and status field
523 * @skb: particular skb to include time stamp
524 *
525 * If the time stamp is valid, convert it into the timecounter ns value
526 * and store that result into the shhwtstamps structure which is passed
527 * up the network stack.
528 **/
529static void e1000e_rx_hwtstamp(struct e1000_adapter *adapter, u32 status,
530 struct sk_buff *skb)
531{
532 struct e1000_hw *hw = &adapter->hw;
533 u64 rxstmp;
534
535 if (!(adapter->flags & FLAG_HAS_HW_TIMESTAMP) ||
536 !(status & E1000_RXDEXT_STATERR_TST) ||
537 !(er32(TSYNCRXCTL) & E1000_TSYNCRXCTL_VALID))
538 return;
539
540 /* The Rx time stamp registers contain the time stamp. No other
541 * received packet will be time stamped until the Rx time stamp
542 * registers are read. Because only one packet can be time stamped
543 * at a time, the register values must belong to this packet and
544 * therefore none of the other additional attributes need to be
545 * compared.
546 */
547 rxstmp = (u64)er32(RXSTMPL);
548 rxstmp |= (u64)er32(RXSTMPH) << 32;
549 e1000e_systim_to_hwtstamp(adapter, skb_hwtstamps(skb), rxstmp);
550
551 adapter->flags2 &= ~FLAG2_CHECK_RX_HWTSTAMP;
552}
553
554/**
491 * e1000_receive_skb - helper function to handle Rx indications 555 * e1000_receive_skb - helper function to handle Rx indications
492 * @adapter: board private structure 556 * @adapter: board private structure
493 * @status: descriptor status field as written by hardware 557 * @staterr: descriptor extended error and status field as written by hardware
494 * @vlan: descriptor vlan field as written by hardware (no le/be conversion) 558 * @vlan: descriptor vlan field as written by hardware (no le/be conversion)
495 * @skb: pointer to sk_buff to be indicated to stack 559 * @skb: pointer to sk_buff to be indicated to stack
496 **/ 560 **/
497static void e1000_receive_skb(struct e1000_adapter *adapter, 561static void e1000_receive_skb(struct e1000_adapter *adapter,
498 struct net_device *netdev, struct sk_buff *skb, 562 struct net_device *netdev, struct sk_buff *skb,
499 u8 status, __le16 vlan) 563 u32 staterr, __le16 vlan)
500{ 564{
501 u16 tag = le16_to_cpu(vlan); 565 u16 tag = le16_to_cpu(vlan);
566
567 e1000e_rx_hwtstamp(adapter, staterr, skb);
568
502 skb->protocol = eth_type_trans(skb, netdev); 569 skb->protocol = eth_type_trans(skb, netdev);
503 570
504 if (status & E1000_RXD_STAT_VP) 571 if (staterr & E1000_RXD_STAT_VP)
505 __vlan_hwaccel_put_tag(skb, tag); 572 __vlan_hwaccel_put_tag(skb, tag);
506 573
507 napi_gro_receive(&adapter->napi, skb); 574 napi_gro_receive(&adapter->napi, skb);
@@ -1092,6 +1159,41 @@ static void e1000_print_hw_hang(struct work_struct *work)
1092} 1159}
1093 1160
1094/** 1161/**
1162 * e1000e_tx_hwtstamp_work - check for Tx time stamp
1163 * @work: pointer to work struct
1164 *
1165 * This work function polls the TSYNCTXCTL valid bit to determine when a
1166 * timestamp has been taken for the current stored skb. The timestamp must
1167 * be for this skb because only one such packet is allowed in the queue.
1168 */
1169static void e1000e_tx_hwtstamp_work(struct work_struct *work)
1170{
1171 struct e1000_adapter *adapter = container_of(work, struct e1000_adapter,
1172 tx_hwtstamp_work);
1173 struct e1000_hw *hw = &adapter->hw;
1174
1175 if (!adapter->tx_hwtstamp_skb)
1176 return;
1177
1178 if (er32(TSYNCTXCTL) & E1000_TSYNCTXCTL_VALID) {
1179 struct skb_shared_hwtstamps shhwtstamps;
1180 u64 txstmp;
1181
1182 txstmp = er32(TXSTMPL);
1183 txstmp |= (u64)er32(TXSTMPH) << 32;
1184
1185 e1000e_systim_to_hwtstamp(adapter, &shhwtstamps, txstmp);
1186
1187 skb_tstamp_tx(adapter->tx_hwtstamp_skb, &shhwtstamps);
1188 dev_kfree_skb_any(adapter->tx_hwtstamp_skb);
1189 adapter->tx_hwtstamp_skb = NULL;
1190 } else {
1191 /* reschedule to check later */
1192 schedule_work(&adapter->tx_hwtstamp_work);
1193 }
1194}
1195
1196/**
1095 * e1000_clean_tx_irq - Reclaim resources after transmit completes 1197 * e1000_clean_tx_irq - Reclaim resources after transmit completes
1096 * @tx_ring: Tx descriptor ring 1198 * @tx_ring: Tx descriptor ring
1097 * 1199 *
@@ -1345,8 +1447,8 @@ copydone:
1345 cpu_to_le16(E1000_RXDPS_HDRSTAT_HDRSP)) 1447 cpu_to_le16(E1000_RXDPS_HDRSTAT_HDRSP))
1346 adapter->rx_hdr_split++; 1448 adapter->rx_hdr_split++;
1347 1449
1348 e1000_receive_skb(adapter, netdev, skb, 1450 e1000_receive_skb(adapter, netdev, skb, staterr,
1349 staterr, rx_desc->wb.middle.vlan); 1451 rx_desc->wb.middle.vlan);
1350 1452
1351next_desc: 1453next_desc:
1352 rx_desc->wb.middle.status_error &= cpu_to_le32(~0xFF); 1454 rx_desc->wb.middle.status_error &= cpu_to_le32(~0xFF);
@@ -3304,6 +3406,159 @@ static void e1000e_setup_rss_hash(struct e1000_adapter *adapter)
3304} 3406}
3305 3407
3306/** 3408/**
3409 * e1000e_get_base_timinca - get default SYSTIM time increment attributes
3410 * @adapter: board private structure
3411 * @timinca: pointer to returned time increment attributes
3412 *
3413 * Get attributes for incrementing the System Time Register SYSTIML/H at
3414 * the default base frequency, and set the cyclecounter shift value.
3415 **/
3416static s32 e1000e_get_base_timinca(struct e1000_adapter *adapter, u32 *timinca)
3417{
3418 struct e1000_hw *hw = &adapter->hw;
3419 u32 incvalue, incperiod, shift;
3420
3421 /* Make sure clock is enabled on I217 before checking the frequency */
3422 if ((hw->mac.type == e1000_pch_lpt) &&
3423 !(er32(TSYNCTXCTL) & E1000_TSYNCTXCTL_ENABLED) &&
3424 !(er32(TSYNCRXCTL) & E1000_TSYNCRXCTL_ENABLED)) {
3425 u32 fextnvm7 = er32(FEXTNVM7);
3426
3427 if (!(fextnvm7 & (1 << 0))) {
3428 ew32(FEXTNVM7, fextnvm7 | (1 << 0));
3429 e1e_flush();
3430 }
3431 }
3432
3433 switch (hw->mac.type) {
3434 case e1000_pch2lan:
3435 case e1000_pch_lpt:
3436 /* On I217, the clock frequency is 25MHz or 96MHz as
3437 * indicated by the System Clock Frequency Indication
3438 */
3439 if ((hw->mac.type != e1000_pch_lpt) ||
3440 (er32(TSYNCRXCTL) & E1000_TSYNCRXCTL_SYSCFI)) {
3441 /* Stable 96MHz frequency */
3442 incperiod = INCPERIOD_96MHz;
3443 incvalue = INCVALUE_96MHz;
3444 shift = INCVALUE_SHIFT_96MHz;
3445 adapter->cc.shift = shift + INCPERIOD_SHIFT_96MHz;
3446 break;
3447 }
3448 /* fall-through */
3449 case e1000_82574:
3450 case e1000_82583:
3451 /* Stable 25MHz frequency */
3452 incperiod = INCPERIOD_25MHz;
3453 incvalue = INCVALUE_25MHz;
3454 shift = INCVALUE_SHIFT_25MHz;
3455 adapter->cc.shift = shift;
3456 break;
3457 default:
3458 return -EINVAL;
3459 }
3460
3461 *timinca = ((incperiod << E1000_TIMINCA_INCPERIOD_SHIFT) |
3462 ((incvalue << shift) & E1000_TIMINCA_INCVALUE_MASK));
3463
3464 return 0;
3465}
3466
3467/**
3468 * e1000e_config_hwtstamp - configure the hwtstamp registers and enable/disable
3469 * @adapter: board private structure
3470 *
3471 * Outgoing time stamping can be enabled and disabled. Play nice and
3472 * disable it when requested, although it shouldn't cause any overhead
3473 * when no packet needs it. At most one packet in the queue may be
3474 * marked for time stamping, otherwise it would be impossible to tell
3475 * for sure to which packet the hardware time stamp belongs.
3476 *
3477 * Incoming time stamping has to be configured via the hardware filters.
3478 * Not all combinations are supported, in particular event type has to be
3479 * specified. Matching the kind of event packet is not supported, with the
3480 * exception of "all V2 events regardless of level 2 or 4".
3481 **/
3482static int e1000e_config_hwtstamp(struct e1000_adapter *adapter)
3483{
3484 struct e1000_hw *hw = &adapter->hw;
3485 struct hwtstamp_config *config = &adapter->hwtstamp_config;
3486 u32 tsync_tx_ctl = E1000_TSYNCTXCTL_ENABLED;
3487 u32 tsync_rx_ctl = E1000_TSYNCRXCTL_ENABLED;
3488 u32 regval;
3489 s32 ret_val;
3490
3491 if (!(adapter->flags & FLAG_HAS_HW_TIMESTAMP))
3492 return -EINVAL;
3493
3494 /* flags reserved for future extensions - must be zero */
3495 if (config->flags)
3496 return -EINVAL;
3497
3498 switch (config->tx_type) {
3499 case HWTSTAMP_TX_OFF:
3500 tsync_tx_ctl = 0;
3501 break;
3502 case HWTSTAMP_TX_ON:
3503 break;
3504 default:
3505 return -ERANGE;
3506 }
3507
3508 switch (config->rx_filter) {
3509 case HWTSTAMP_FILTER_NONE:
3510 tsync_rx_ctl = 0;
3511 break;
3512 case HWTSTAMP_FILTER_ALL:
3513 tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_ALL;
3514 config->rx_filter = HWTSTAMP_FILTER_ALL;
3515 break;
3516 default:
3517 return -ERANGE;
3518 }
3519
3520 /* enable/disable Tx h/w time stamping */
3521 regval = er32(TSYNCTXCTL);
3522 regval &= ~E1000_TSYNCTXCTL_ENABLED;
3523 regval |= tsync_tx_ctl;
3524 ew32(TSYNCTXCTL, regval);
3525 if ((er32(TSYNCTXCTL) & E1000_TSYNCTXCTL_ENABLED) !=
3526 (regval & E1000_TSYNCTXCTL_ENABLED)) {
3527 e_err("Timesync Tx Control register not set as expected\n");
3528 return -EAGAIN;
3529 }
3530
3531 /* enable/disable Rx h/w time stamping */
3532 regval = er32(TSYNCRXCTL);
3533 regval &= ~(E1000_TSYNCRXCTL_ENABLED | E1000_TSYNCRXCTL_TYPE_MASK);
3534 regval |= tsync_rx_ctl;
3535 ew32(TSYNCRXCTL, regval);
3536 if ((er32(TSYNCRXCTL) & (E1000_TSYNCRXCTL_ENABLED |
3537 E1000_TSYNCRXCTL_TYPE_MASK)) !=
3538 (regval & (E1000_TSYNCRXCTL_ENABLED |
3539 E1000_TSYNCRXCTL_TYPE_MASK))) {
3540 e_err("Timesync Rx Control register not set as expected\n");
3541 return -EAGAIN;
3542 }
3543
3544 /* Clear TSYNCRXCTL_VALID & TSYNCTXCTL_VALID bit */
3545 regval = er32(RXSTMPH);
3546 regval = er32(TXSTMPH);
3547
3548 /* Get and set the System Time Register SYSTIM base frequency */
3549 ret_val = e1000e_get_base_timinca(adapter, &regval);
3550 if (ret_val)
3551 return ret_val;
3552 ew32(TIMINCA, regval);
3553
3554 /* reset the ns time counter */
3555 timecounter_init(&adapter->tc, &adapter->cc,
3556 ktime_to_ns(ktime_get_real()));
3557
3558 return 0;
3559}
3560
3561/**
3307 * e1000_configure - configure the hardware for Rx and Tx 3562 * e1000_configure - configure the hardware for Rx and Tx
3308 * @adapter: private board structure 3563 * @adapter: private board structure
3309 **/ 3564 **/
@@ -3529,6 +3784,9 @@ void e1000e_reset(struct e1000_adapter *adapter)
3529 3784
3530 e1000e_reset_adaptive(hw); 3785 e1000e_reset_adaptive(hw);
3531 3786
3787 /* initialize systim and reset the ns time counter */
3788 e1000e_config_hwtstamp(adapter);
3789
3532 if (!netif_running(adapter->netdev) && 3790 if (!netif_running(adapter->netdev) &&
3533 !test_bit(__E1000_TESTING, &adapter->state)) { 3791 !test_bit(__E1000_TESTING, &adapter->state)) {
3534 e1000_power_down_phy(adapter); 3792 e1000_power_down_phy(adapter);
@@ -3665,6 +3923,24 @@ void e1000e_reinit_locked(struct e1000_adapter *adapter)
3665} 3923}
3666 3924
3667/** 3925/**
3926 * e1000e_cyclecounter_read - read raw cycle counter (used by time counter)
3927 * @cc: cyclecounter structure
3928 **/
3929static cycle_t e1000e_cyclecounter_read(const struct cyclecounter *cc)
3930{
3931 struct e1000_adapter *adapter = container_of(cc, struct e1000_adapter,
3932 cc);
3933 struct e1000_hw *hw = &adapter->hw;
3934 cycle_t systim;
3935
3936 /* latch SYSTIMH on read of SYSTIML */
3937 systim = (cycle_t)er32(SYSTIML);
3938 systim |= (cycle_t)er32(SYSTIMH) << 32;
3939
3940 return systim;
3941}
3942
3943/**
3668 * e1000_sw_init - Initialize general software structures (struct e1000_adapter) 3944 * e1000_sw_init - Initialize general software structures (struct e1000_adapter)
3669 * @adapter: board private structure to initialize 3945 * @adapter: board private structure to initialize
3670 * 3946 *
@@ -3690,6 +3966,17 @@ static int e1000_sw_init(struct e1000_adapter *adapter)
3690 if (e1000_alloc_queues(adapter)) 3966 if (e1000_alloc_queues(adapter))
3691 return -ENOMEM; 3967 return -ENOMEM;
3692 3968
3969 /* Setup hardware time stamping cyclecounter */
3970 if (adapter->flags & FLAG_HAS_HW_TIMESTAMP) {
3971 adapter->cc.read = e1000e_cyclecounter_read;
3972 adapter->cc.mask = CLOCKSOURCE_MASK(64);
3973 adapter->cc.mult = 1;
3974 /* cc.shift set in e1000e_get_base_tininca() */
3975
3976 spin_lock_init(&adapter->systim_lock);
3977 INIT_WORK(&adapter->tx_hwtstamp_work, e1000e_tx_hwtstamp_work);
3978 }
3979
3693 /* Explicitly disable IRQ since the NIC can be in any state. */ 3980 /* Explicitly disable IRQ since the NIC can be in any state. */
3694 e1000_irq_disable(adapter); 3981 e1000_irq_disable(adapter);
3695 3982
@@ -4597,6 +4884,17 @@ link_up:
4597 if (adapter->flags2 & FLAG2_CHECK_PHY_HANG) 4884 if (adapter->flags2 & FLAG2_CHECK_PHY_HANG)
4598 e1000e_check_82574_phy_workaround(adapter); 4885 e1000e_check_82574_phy_workaround(adapter);
4599 4886
4887 /* Clear valid timestamp stuck in RXSTMPL/H due to a Rx error */
4888 if (adapter->hwtstamp_config.rx_filter != HWTSTAMP_FILTER_NONE) {
4889 if ((adapter->flags2 & FLAG2_CHECK_RX_HWTSTAMP) &&
4890 (er32(TSYNCRXCTL) & E1000_TSYNCRXCTL_VALID)) {
4891 er32(RXSTMPH);
4892 adapter->rx_hwtstamp_cleared++;
4893 } else {
4894 adapter->flags2 |= FLAG2_CHECK_RX_HWTSTAMP;
4895 }
4896 }
4897
4600 /* Reset the timer */ 4898 /* Reset the timer */
4601 if (!test_bit(__E1000_DOWN, &adapter->state)) 4899 if (!test_bit(__E1000_DOWN, &adapter->state))
4602 mod_timer(&adapter->watchdog_timer, 4900 mod_timer(&adapter->watchdog_timer,
@@ -4608,6 +4906,7 @@ link_up:
4608#define E1000_TX_FLAGS_TSO 0x00000004 4906#define E1000_TX_FLAGS_TSO 0x00000004
4609#define E1000_TX_FLAGS_IPV4 0x00000008 4907#define E1000_TX_FLAGS_IPV4 0x00000008
4610#define E1000_TX_FLAGS_NO_FCS 0x00000010 4908#define E1000_TX_FLAGS_NO_FCS 0x00000010
4909#define E1000_TX_FLAGS_HWTSTAMP 0x00000020
4611#define E1000_TX_FLAGS_VLAN_MASK 0xffff0000 4910#define E1000_TX_FLAGS_VLAN_MASK 0xffff0000
4612#define E1000_TX_FLAGS_VLAN_SHIFT 16 4911#define E1000_TX_FLAGS_VLAN_SHIFT 16
4613 4912
@@ -4866,6 +5165,11 @@ static void e1000_tx_queue(struct e1000_ring *tx_ring, int tx_flags, int count)
4866 if (unlikely(tx_flags & E1000_TX_FLAGS_NO_FCS)) 5165 if (unlikely(tx_flags & E1000_TX_FLAGS_NO_FCS))
4867 txd_lower &= ~(E1000_TXD_CMD_IFCS); 5166 txd_lower &= ~(E1000_TXD_CMD_IFCS);
4868 5167
5168 if (unlikely(tx_flags & E1000_TX_FLAGS_HWTSTAMP)) {
5169 txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D;
5170 txd_upper |= E1000_TXD_EXTCMD_TSTAMP;
5171 }
5172
4869 i = tx_ring->next_to_use; 5173 i = tx_ring->next_to_use;
4870 5174
4871 do { 5175 do {
@@ -5089,7 +5393,15 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
5089 count = e1000_tx_map(tx_ring, skb, first, adapter->tx_fifo_limit, 5393 count = e1000_tx_map(tx_ring, skb, first, adapter->tx_fifo_limit,
5090 nr_frags); 5394 nr_frags);
5091 if (count) { 5395 if (count) {
5092 skb_tx_timestamp(skb); 5396 if (unlikely((skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) &&
5397 !adapter->tx_hwtstamp_skb)) {
5398 skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
5399 tx_flags |= E1000_TX_FLAGS_HWTSTAMP;
5400 adapter->tx_hwtstamp_skb = skb_get(skb);
5401 schedule_work(&adapter->tx_hwtstamp_work);
5402 } else {
5403 skb_tx_timestamp(skb);
5404 }
5093 5405
5094 netdev_sent_queue(netdev, skb->len); 5406 netdev_sent_queue(netdev, skb->len);
5095 e1000_tx_queue(tx_ring, tx_flags, count); 5407 e1000_tx_queue(tx_ring, tx_flags, count);
@@ -5317,6 +5629,43 @@ static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
5317 return 0; 5629 return 0;
5318} 5630}
5319 5631
5632/**
5633 * e1000e_hwtstamp_ioctl - control hardware time stamping
5634 * @netdev: network interface device structure
5635 * @ifreq: interface request
5636 *
5637 * Outgoing time stamping can be enabled and disabled. Play nice and
5638 * disable it when requested, although it shouldn't cause any overhead
5639 * when no packet needs it. At most one packet in the queue may be
5640 * marked for time stamping, otherwise it would be impossible to tell
5641 * for sure to which packet the hardware time stamp belongs.
5642 *
5643 * Incoming time stamping has to be configured via the hardware filters.
5644 * Not all combinations are supported, in particular event type has to be
5645 * specified. Matching the kind of event packet is not supported, with the
5646 * exception of "all V2 events regardless of level 2 or 4".
5647 **/
5648static int e1000e_hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr)
5649{
5650 struct e1000_adapter *adapter = netdev_priv(netdev);
5651 struct hwtstamp_config config;
5652 int ret_val;
5653
5654 if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
5655 return -EFAULT;
5656
5657 adapter->hwtstamp_config = config;
5658
5659 ret_val = e1000e_config_hwtstamp(adapter);
5660 if (ret_val)
5661 return ret_val;
5662
5663 config = adapter->hwtstamp_config;
5664
5665 return copy_to_user(ifr->ifr_data, &config,
5666 sizeof(config)) ? -EFAULT : 0;
5667}
5668
5320static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) 5669static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
5321{ 5670{
5322 switch (cmd) { 5671 switch (cmd) {
@@ -5324,6 +5673,8 @@ static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
5324 case SIOCGMIIREG: 5673 case SIOCGMIIREG:
5325 case SIOCSMIIREG: 5674 case SIOCSMIIREG:
5326 return e1000_mii_ioctl(netdev, ifr, cmd); 5675 return e1000_mii_ioctl(netdev, ifr, cmd);
5676 case SIOCSHWTSTAMP:
5677 return e1000e_hwtstamp_ioctl(netdev, ifr);
5327 default: 5678 default:
5328 return -EOPNOTSUPP; 5679 return -EOPNOTSUPP;
5329 } 5680 }
@@ -6380,6 +6731,14 @@ static void e1000_remove(struct pci_dev *pdev)
6380 cancel_work_sync(&adapter->update_phy_task); 6731 cancel_work_sync(&adapter->update_phy_task);
6381 cancel_work_sync(&adapter->print_hang_task); 6732 cancel_work_sync(&adapter->print_hang_task);
6382 6733
6734 if (adapter->flags & FLAG_HAS_HW_TIMESTAMP) {
6735 cancel_work_sync(&adapter->tx_hwtstamp_work);
6736 if (adapter->tx_hwtstamp_skb) {
6737 dev_kfree_skb_any(adapter->tx_hwtstamp_skb);
6738 adapter->tx_hwtstamp_skb = NULL;
6739 }
6740 }
6741
6383 if (!(netdev->flags & IFF_UP)) 6742 if (!(netdev->flags & IFF_UP))
6384 e1000_power_down_phy(adapter); 6743 e1000_power_down_phy(adapter);
6385 6744