aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000/e1000_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/e1000/e1000_main.c')
-rw-r--r--drivers/net/e1000/e1000_main.c163
1 files changed, 88 insertions, 75 deletions
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index b28a915bd980..9267f16b1b32 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -409,25 +409,21 @@ e1000_release_hw_control(struct e1000_adapter *adapter)
409{ 409{
410 uint32_t ctrl_ext; 410 uint32_t ctrl_ext;
411 uint32_t swsm; 411 uint32_t swsm;
412 uint32_t extcnf;
413 412
414 /* Let firmware taken over control of h/w */ 413 /* Let firmware taken over control of h/w */
415 switch (adapter->hw.mac_type) { 414 switch (adapter->hw.mac_type) {
416 case e1000_82571:
417 case e1000_82572:
418 case e1000_80003es2lan:
419 ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
420 E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
421 ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD);
422 break;
423 case e1000_82573: 415 case e1000_82573:
424 swsm = E1000_READ_REG(&adapter->hw, SWSM); 416 swsm = E1000_READ_REG(&adapter->hw, SWSM);
425 E1000_WRITE_REG(&adapter->hw, SWSM, 417 E1000_WRITE_REG(&adapter->hw, SWSM,
426 swsm & ~E1000_SWSM_DRV_LOAD); 418 swsm & ~E1000_SWSM_DRV_LOAD);
419 break;
420 case e1000_82571:
421 case e1000_82572:
422 case e1000_80003es2lan:
427 case e1000_ich8lan: 423 case e1000_ich8lan:
428 extcnf = E1000_READ_REG(&adapter->hw, CTRL_EXT); 424 ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
429 E1000_WRITE_REG(&adapter->hw, CTRL_EXT, 425 E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
430 extcnf & ~E1000_CTRL_EXT_DRV_LOAD); 426 ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD);
431 break; 427 break;
432 default: 428 default:
433 break; 429 break;
@@ -450,26 +446,21 @@ e1000_get_hw_control(struct e1000_adapter *adapter)
450{ 446{
451 uint32_t ctrl_ext; 447 uint32_t ctrl_ext;
452 uint32_t swsm; 448 uint32_t swsm;
453 uint32_t extcnf;
454 449
455 /* Let firmware know the driver has taken over */ 450 /* Let firmware know the driver has taken over */
456 switch (adapter->hw.mac_type) { 451 switch (adapter->hw.mac_type) {
457 case e1000_82571:
458 case e1000_82572:
459 case e1000_80003es2lan:
460 ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
461 E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
462 ctrl_ext | E1000_CTRL_EXT_DRV_LOAD);
463 break;
464 case e1000_82573: 452 case e1000_82573:
465 swsm = E1000_READ_REG(&adapter->hw, SWSM); 453 swsm = E1000_READ_REG(&adapter->hw, SWSM);
466 E1000_WRITE_REG(&adapter->hw, SWSM, 454 E1000_WRITE_REG(&adapter->hw, SWSM,
467 swsm | E1000_SWSM_DRV_LOAD); 455 swsm | E1000_SWSM_DRV_LOAD);
468 break; 456 break;
457 case e1000_82571:
458 case e1000_82572:
459 case e1000_80003es2lan:
469 case e1000_ich8lan: 460 case e1000_ich8lan:
470 extcnf = E1000_READ_REG(&adapter->hw, EXTCNF_CTRL); 461 ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
471 E1000_WRITE_REG(&adapter->hw, EXTCNF_CTRL, 462 E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
472 extcnf | E1000_EXTCNF_CTRL_SWFLAG); 463 ctrl_ext | E1000_CTRL_EXT_DRV_LOAD);
473 break; 464 break;
474 default: 465 default:
475 break; 466 break;
@@ -522,14 +513,15 @@ e1000_release_manageability(struct e1000_adapter *adapter)
522 } 513 }
523} 514}
524 515
525int 516/**
526e1000_up(struct e1000_adapter *adapter) 517 * e1000_configure - configure the hardware for RX and TX
518 * @adapter = private board structure
519 **/
520static void e1000_configure(struct e1000_adapter *adapter)
527{ 521{
528 struct net_device *netdev = adapter->netdev; 522 struct net_device *netdev = adapter->netdev;
529 int i; 523 int i;
530 524
531 /* hardware has been reset, we need to reload some things */
532
533 e1000_set_multi(netdev); 525 e1000_set_multi(netdev);
534 526
535 e1000_restore_vlan(adapter); 527 e1000_restore_vlan(adapter);
@@ -548,14 +540,20 @@ e1000_up(struct e1000_adapter *adapter)
548 } 540 }
549 541
550 adapter->tx_queue_len = netdev->tx_queue_len; 542 adapter->tx_queue_len = netdev->tx_queue_len;
543}
544
545int e1000_up(struct e1000_adapter *adapter)
546{
547 /* hardware has been reset, we need to reload some things */
548 e1000_configure(adapter);
549
550 clear_bit(__E1000_DOWN, &adapter->flags);
551 551
552#ifdef CONFIG_E1000_NAPI 552#ifdef CONFIG_E1000_NAPI
553 netif_poll_enable(netdev); 553 netif_poll_enable(adapter->netdev);
554#endif 554#endif
555 e1000_irq_enable(adapter); 555 e1000_irq_enable(adapter);
556 556
557 clear_bit(__E1000_DOWN, &adapter->flags);
558
559 /* fire a link change interrupt to start the watchdog */ 557 /* fire a link change interrupt to start the watchdog */
560 E1000_WRITE_REG(&adapter->hw, ICS, E1000_ICS_LSC); 558 E1000_WRITE_REG(&adapter->hw, ICS, E1000_ICS_LSC);
561 return 0; 559 return 0;
@@ -640,15 +638,15 @@ e1000_down(struct e1000_adapter *adapter)
640 * reschedule our watchdog timer */ 638 * reschedule our watchdog timer */
641 set_bit(__E1000_DOWN, &adapter->flags); 639 set_bit(__E1000_DOWN, &adapter->flags);
642 640
641#ifdef CONFIG_E1000_NAPI
642 netif_poll_disable(netdev);
643#endif
643 e1000_irq_disable(adapter); 644 e1000_irq_disable(adapter);
644 645
645 del_timer_sync(&adapter->tx_fifo_stall_timer); 646 del_timer_sync(&adapter->tx_fifo_stall_timer);
646 del_timer_sync(&adapter->watchdog_timer); 647 del_timer_sync(&adapter->watchdog_timer);
647 del_timer_sync(&adapter->phy_info_timer); 648 del_timer_sync(&adapter->phy_info_timer);
648 649
649#ifdef CONFIG_E1000_NAPI
650 netif_poll_disable(netdev);
651#endif
652 netdev->tx_queue_len = adapter->tx_queue_len; 650 netdev->tx_queue_len = adapter->tx_queue_len;
653 adapter->link_speed = 0; 651 adapter->link_speed = 0;
654 adapter->link_duplex = 0; 652 adapter->link_duplex = 0;
@@ -1410,21 +1408,17 @@ e1000_open(struct net_device *netdev)
1410 return -EBUSY; 1408 return -EBUSY;
1411 1409
1412 /* allocate transmit descriptors */ 1410 /* allocate transmit descriptors */
1413 if ((err = e1000_setup_all_tx_resources(adapter))) 1411 err = e1000_setup_all_tx_resources(adapter);
1412 if (err)
1414 goto err_setup_tx; 1413 goto err_setup_tx;
1415 1414
1416 /* allocate receive descriptors */ 1415 /* allocate receive descriptors */
1417 if ((err = e1000_setup_all_rx_resources(adapter))) 1416 err = e1000_setup_all_rx_resources(adapter);
1418 goto err_setup_rx;
1419
1420 err = e1000_request_irq(adapter);
1421 if (err) 1417 if (err)
1422 goto err_req_irq; 1418 goto err_setup_rx;
1423 1419
1424 e1000_power_up_phy(adapter); 1420 e1000_power_up_phy(adapter);
1425 1421
1426 if ((err = e1000_up(adapter)))
1427 goto err_up;
1428 adapter->mng_vlan_id = E1000_MNG_VLAN_NONE; 1422 adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
1429 if ((adapter->hw.mng_cookie.status & 1423 if ((adapter->hw.mng_cookie.status &
1430 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) { 1424 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) {
@@ -1437,12 +1431,33 @@ e1000_open(struct net_device *netdev)
1437 e1000_check_mng_mode(&adapter->hw)) 1431 e1000_check_mng_mode(&adapter->hw))
1438 e1000_get_hw_control(adapter); 1432 e1000_get_hw_control(adapter);
1439 1433
1434 /* before we allocate an interrupt, we must be ready to handle it.
1435 * Setting DEBUG_SHIRQ in the kernel makes it fire an interrupt
1436 * as soon as we call pci_request_irq, so we have to setup our
1437 * clean_rx handler before we do so. */
1438 e1000_configure(adapter);
1439
1440 err = e1000_request_irq(adapter);
1441 if (err)
1442 goto err_req_irq;
1443
1444 /* From here on the code is the same as e1000_up() */
1445 clear_bit(__E1000_DOWN, &adapter->flags);
1446
1447#ifdef CONFIG_E1000_NAPI
1448 netif_poll_enable(netdev);
1449#endif
1450
1451 e1000_irq_enable(adapter);
1452
1453 /* fire a link status change interrupt to start the watchdog */
1454 E1000_WRITE_REG(&adapter->hw, ICS, E1000_ICS_LSC);
1455
1440 return E1000_SUCCESS; 1456 return E1000_SUCCESS;
1441 1457
1442err_up:
1443 e1000_power_down_phy(adapter);
1444 e1000_free_irq(adapter);
1445err_req_irq: 1458err_req_irq:
1459 e1000_release_hw_control(adapter);
1460 e1000_power_down_phy(adapter);
1446 e1000_free_all_rx_resources(adapter); 1461 e1000_free_all_rx_resources(adapter);
1447err_setup_rx: 1462err_setup_rx:
1448 e1000_free_all_tx_resources(adapter); 1463 e1000_free_all_tx_resources(adapter);
@@ -2887,33 +2902,30 @@ e1000_tso(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
2887 return err; 2902 return err;
2888 } 2903 }
2889 2904
2890 hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2)); 2905 hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
2891 mss = skb_shinfo(skb)->gso_size; 2906 mss = skb_shinfo(skb)->gso_size;
2892 if (skb->protocol == htons(ETH_P_IP)) { 2907 if (skb->protocol == htons(ETH_P_IP)) {
2893 skb->nh.iph->tot_len = 0; 2908 struct iphdr *iph = ip_hdr(skb);
2894 skb->nh.iph->check = 0; 2909 iph->tot_len = 0;
2895 skb->h.th->check = 2910 iph->check = 0;
2896 ~csum_tcpudp_magic(skb->nh.iph->saddr, 2911 tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr,
2897 skb->nh.iph->daddr, 2912 iph->daddr, 0,
2898 0, 2913 IPPROTO_TCP,
2899 IPPROTO_TCP, 2914 0);
2900 0);
2901 cmd_length = E1000_TXD_CMD_IP; 2915 cmd_length = E1000_TXD_CMD_IP;
2902 ipcse = skb->h.raw - skb->data - 1; 2916 ipcse = skb_transport_offset(skb) - 1;
2903 } else if (skb->protocol == htons(ETH_P_IPV6)) { 2917 } else if (skb->protocol == htons(ETH_P_IPV6)) {
2904 skb->nh.ipv6h->payload_len = 0; 2918 ipv6_hdr(skb)->payload_len = 0;
2905 skb->h.th->check = 2919 tcp_hdr(skb)->check =
2906 ~csum_ipv6_magic(&skb->nh.ipv6h->saddr, 2920 ~csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
2907 &skb->nh.ipv6h->daddr, 2921 &ipv6_hdr(skb)->daddr,
2908 0, 2922 0, IPPROTO_TCP, 0);
2909 IPPROTO_TCP,
2910 0);
2911 ipcse = 0; 2923 ipcse = 0;
2912 } 2924 }
2913 ipcss = skb->nh.raw - skb->data; 2925 ipcss = skb_network_offset(skb);
2914 ipcso = (void *)&(skb->nh.iph->check) - (void *)skb->data; 2926 ipcso = (void *)&(ip_hdr(skb)->check) - (void *)skb->data;
2915 tucss = skb->h.raw - skb->data; 2927 tucss = skb_transport_offset(skb);
2916 tucso = (void *)&(skb->h.th->check) - (void *)skb->data; 2928 tucso = (void *)&(tcp_hdr(skb)->check) - (void *)skb->data;
2917 tucse = 0; 2929 tucse = 0;
2918 2930
2919 cmd_length |= (E1000_TXD_CMD_DEXT | E1000_TXD_CMD_TSE | 2931 cmd_length |= (E1000_TXD_CMD_DEXT | E1000_TXD_CMD_TSE |
@@ -2954,7 +2966,7 @@ e1000_tx_csum(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
2954 uint8_t css; 2966 uint8_t css;
2955 2967
2956 if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) { 2968 if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) {
2957 css = skb->h.raw - skb->data; 2969 css = skb_transport_offset(skb);
2958 2970
2959 i = tx_ring->next_to_use; 2971 i = tx_ring->next_to_use;
2960 buffer_info = &tx_ring->buffer_info[i]; 2972 buffer_info = &tx_ring->buffer_info[i];
@@ -2962,7 +2974,8 @@ e1000_tx_csum(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
2962 2974
2963 context_desc->lower_setup.ip_config = 0; 2975 context_desc->lower_setup.ip_config = 0;
2964 context_desc->upper_setup.tcp_fields.tucss = css; 2976 context_desc->upper_setup.tcp_fields.tucss = css;
2965 context_desc->upper_setup.tcp_fields.tucso = css + skb->csum; 2977 context_desc->upper_setup.tcp_fields.tucso =
2978 css + skb->csum_offset;
2966 context_desc->upper_setup.tcp_fields.tucse = 0; 2979 context_desc->upper_setup.tcp_fields.tucse = 0;
2967 context_desc->tcp_seg_setup.data = 0; 2980 context_desc->tcp_seg_setup.data = 0;
2968 context_desc->cmd_and_length = cpu_to_le32(E1000_TXD_CMD_DEXT); 2981 context_desc->cmd_and_length = cpu_to_le32(E1000_TXD_CMD_DEXT);
@@ -3296,7 +3309,7 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
3296 /* TSO Workaround for 82571/2/3 Controllers -- if skb->data 3309 /* TSO Workaround for 82571/2/3 Controllers -- if skb->data
3297 * points to just header, pull a few bytes of payload from 3310 * points to just header, pull a few bytes of payload from
3298 * frags into skb->data */ 3311 * frags into skb->data */
3299 hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2)); 3312 hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
3300 if (skb->data_len && (hdr_len == (skb->len - skb->data_len))) { 3313 if (skb->data_len && (hdr_len == (skb->len - skb->data_len))) {
3301 switch (adapter->hw.mac_type) { 3314 switch (adapter->hw.mac_type) {
3302 unsigned int pull_size; 3315 unsigned int pull_size;
@@ -3307,7 +3320,7 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
3307 * NOTE: this is a TSO only workaround 3320 * NOTE: this is a TSO only workaround
3308 * if end byte alignment not correct move us 3321 * if end byte alignment not correct move us
3309 * into the next dword */ 3322 * into the next dword */
3310 if ((unsigned long)(skb->tail - 1) & 4) 3323 if ((unsigned long)(skb_tail_pointer(skb) - 1) & 4)
3311 break; 3324 break;
3312 /* fall through */ 3325 /* fall through */
3313 case e1000_82571: 3326 case e1000_82571:
@@ -3363,12 +3376,9 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
3363 (adapter->hw.mac_type == e1000_82573)) 3376 (adapter->hw.mac_type == e1000_82573))
3364 e1000_transfer_dhcp_info(adapter, skb); 3377 e1000_transfer_dhcp_info(adapter, skb);
3365 3378
3366 local_irq_save(flags); 3379 if (!spin_trylock_irqsave(&tx_ring->tx_lock, flags))
3367 if (!spin_trylock(&tx_ring->tx_lock)) {
3368 /* Collision - tell upper layer to requeue */ 3380 /* Collision - tell upper layer to requeue */
3369 local_irq_restore(flags);
3370 return NETDEV_TX_LOCKED; 3381 return NETDEV_TX_LOCKED;
3371 }
3372 3382
3373 /* need: count + 2 desc gap to keep tail from touching 3383 /* need: count + 2 desc gap to keep tail from touching
3374 * head, otherwise try next time */ 3384 * head, otherwise try next time */
@@ -4227,9 +4237,12 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter,
4227 netdev_alloc_skb(netdev, length + NET_IP_ALIGN); 4237 netdev_alloc_skb(netdev, length + NET_IP_ALIGN);
4228 if (new_skb) { 4238 if (new_skb) {
4229 skb_reserve(new_skb, NET_IP_ALIGN); 4239 skb_reserve(new_skb, NET_IP_ALIGN);
4230 memcpy(new_skb->data - NET_IP_ALIGN, 4240 skb_copy_to_linear_data_offset(new_skb,
4231 skb->data - NET_IP_ALIGN, 4241 -NET_IP_ALIGN,
4232 length + NET_IP_ALIGN); 4242 (skb->data -
4243 NET_IP_ALIGN),
4244 (length +
4245 NET_IP_ALIGN));
4233 /* save the skb in buffer_info as good */ 4246 /* save the skb in buffer_info as good */
4234 buffer_info->skb = skb; 4247 buffer_info->skb = skb;
4235 skb = new_skb; 4248 skb = new_skb;
@@ -4391,7 +4404,7 @@ e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
4391 PCI_DMA_FROMDEVICE); 4404 PCI_DMA_FROMDEVICE);
4392 vaddr = kmap_atomic(ps_page->ps_page[0], 4405 vaddr = kmap_atomic(ps_page->ps_page[0],
4393 KM_SKB_DATA_SOFTIRQ); 4406 KM_SKB_DATA_SOFTIRQ);
4394 memcpy(skb->tail, vaddr, l1); 4407 memcpy(skb_tail_pointer(skb), vaddr, l1);
4395 kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ); 4408 kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ);
4396 pci_dma_sync_single_for_device(pdev, 4409 pci_dma_sync_single_for_device(pdev,
4397 ps_page_dma->ps_page_dma[0], 4410 ps_page_dma->ps_page_dma[0],