1 /*******************************************************************************
3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2008 Intel Corporation.
6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License,
8 version 2, as published by the Free Software Foundation.
10 This program is distributed in the hope it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *******************************************************************************/
29 #include <linux/module.h>
30 #include <linux/types.h>
31 #include <linux/init.h>
32 #include <linux/pci.h>
33 #include <linux/vmalloc.h>
34 #include <linux/pagemap.h>
35 #include <linux/delay.h>
36 #include <linux/netdevice.h>
37 #include <linux/tcp.h>
38 #include <linux/ipv6.h>
39 #include <net/checksum.h>
40 #include <net/ip6_checksum.h>
41 #include <linux/mii.h>
42 #include <linux/ethtool.h>
43 #include <linux/if_vlan.h>
44 #include <linux/cpu.h>
45 #include <linux/smp.h>
46 #include <linux/pm_qos_params.h>
47 #include <linux/aer.h>
51 #define DRV_VERSION "0.3.3.4-k2"
52 char e1000e_driver_name[] = "e1000e";
53 const char e1000e_driver_version[] = DRV_VERSION;
55 static const struct e1000_info *e1000_info_tbl[] = {
56 [board_82571] = &e1000_82571_info,
57 [board_82572] = &e1000_82572_info,
58 [board_82573] = &e1000_82573_info,
59 [board_82574] = &e1000_82574_info,
60 [board_80003es2lan] = &e1000_es2_info,
61 [board_ich8lan] = &e1000_ich8_info,
62 [board_ich9lan] = &e1000_ich9_info,
63 [board_ich10lan] = &e1000_ich10_info,
68 * e1000_get_hw_dev_name - return device name string
69 * used by hardware layer to print debugging information
71 char *e1000e_get_hw_dev_name(struct e1000_hw *hw)
73 return hw->adapter->netdev->name;
78 * e1000_desc_unused - calculate if we have unused descriptors
80 static int e1000_desc_unused(struct e1000_ring *ring)
82 if (ring->next_to_clean > ring->next_to_use)
83 return ring->next_to_clean - ring->next_to_use - 1;
85 return ring->count + ring->next_to_clean - ring->next_to_use - 1;
89 * e1000_receive_skb - helper function to handle Rx indications
90 * @adapter: board private structure
91 * @status: descriptor status field as written by hardware
92 * @vlan: descriptor vlan field as written by hardware (no le/be conversion)
93 * @skb: pointer to sk_buff to be indicated to stack
95 static void e1000_receive_skb(struct e1000_adapter *adapter,
96 struct net_device *netdev,
98 u8 status, __le16 vlan)
100 skb->protocol = eth_type_trans(skb, netdev);
102 if (adapter->vlgrp && (status & E1000_RXD_STAT_VP))
103 vlan_gro_receive(&adapter->napi, adapter->vlgrp,
104 le16_to_cpu(vlan), skb);
106 napi_gro_receive(&adapter->napi, skb);
110 * e1000_rx_checksum - Receive Checksum Offload for 82543
111 * @adapter: board private structure
112 * @status_err: receive descriptor status and error fields
113 * @csum: receive descriptor csum field
114 * @sk_buff: socket buffer with received data
116 static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err,
117 u32 csum, struct sk_buff *skb)
119 u16 status = (u16)status_err;
120 u8 errors = (u8)(status_err >> 24);
121 skb->ip_summed = CHECKSUM_NONE;
123 /* Ignore Checksum bit is set */
124 if (status & E1000_RXD_STAT_IXSM)
126 /* TCP/UDP checksum error bit is set */
127 if (errors & E1000_RXD_ERR_TCPE) {
128 /* let the stack verify checksum errors */
129 adapter->hw_csum_err++;
133 /* TCP/UDP Checksum has not been calculated */
134 if (!(status & (E1000_RXD_STAT_TCPCS | E1000_RXD_STAT_UDPCS)))
137 /* It must be a TCP or UDP packet with a valid checksum */
138 if (status & E1000_RXD_STAT_TCPCS) {
139 /* TCP checksum is good */
140 skb->ip_summed = CHECKSUM_UNNECESSARY;
143 * IP fragment with UDP payload
144 * Hardware complements the payload checksum, so we undo it
145 * and then put the value in host order for further stack use.
147 __sum16 sum = (__force __sum16)htons(csum);
148 skb->csum = csum_unfold(~sum);
149 skb->ip_summed = CHECKSUM_COMPLETE;
151 adapter->hw_csum_good++;
155 * e1000_alloc_rx_buffers - Replace used receive buffers; legacy & extended
156 * @adapter: address of board private structure
158 static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter,
161 struct net_device *netdev = adapter->netdev;
162 struct pci_dev *pdev = adapter->pdev;
163 struct e1000_ring *rx_ring = adapter->rx_ring;
164 struct e1000_rx_desc *rx_desc;
165 struct e1000_buffer *buffer_info;
168 unsigned int bufsz = adapter->rx_buffer_len + NET_IP_ALIGN;
170 i = rx_ring->next_to_use;
171 buffer_info = &rx_ring->buffer_info[i];
173 while (cleaned_count--) {
174 skb = buffer_info->skb;
180 skb = netdev_alloc_skb(netdev, bufsz);
182 /* Better luck next round */
183 adapter->alloc_rx_buff_failed++;
188 * Make buffer alignment 2 beyond a 16 byte boundary
189 * this will result in a 16 byte aligned IP header after
190 * the 14 byte MAC header is removed
192 skb_reserve(skb, NET_IP_ALIGN);
194 buffer_info->skb = skb;
196 buffer_info->dma = pci_map_single(pdev, skb->data,
197 adapter->rx_buffer_len,
199 if (pci_dma_mapping_error(pdev, buffer_info->dma)) {
200 dev_err(&pdev->dev, "RX DMA map failed\n");
201 adapter->rx_dma_failed++;
205 rx_desc = E1000_RX_DESC(*rx_ring, i);
206 rx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
209 if (i == rx_ring->count)
211 buffer_info = &rx_ring->buffer_info[i];
214 if (rx_ring->next_to_use != i) {
215 rx_ring->next_to_use = i;
217 i = (rx_ring->count - 1);
220 * Force memory writes to complete before letting h/w
221 * know there are new descriptors to fetch. (Only
222 * applicable for weak-ordered memory model archs,
226 writel(i, adapter->hw.hw_addr + rx_ring->tail);
231 * e1000_alloc_rx_buffers_ps - Replace used receive buffers; packet split
232 * @adapter: address of board private structure
234 static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter,
237 struct net_device *netdev = adapter->netdev;
238 struct pci_dev *pdev = adapter->pdev;
239 union e1000_rx_desc_packet_split *rx_desc;
240 struct e1000_ring *rx_ring = adapter->rx_ring;
241 struct e1000_buffer *buffer_info;
242 struct e1000_ps_page *ps_page;
246 i = rx_ring->next_to_use;
247 buffer_info = &rx_ring->buffer_info[i];
249 while (cleaned_count--) {
250 rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
252 for (j = 0; j < PS_PAGE_BUFFERS; j++) {
253 ps_page = &buffer_info->ps_pages[j];
254 if (j >= adapter->rx_ps_pages) {
255 /* all unused desc entries get hw null ptr */
256 rx_desc->read.buffer_addr[j+1] = ~cpu_to_le64(0);
259 if (!ps_page->page) {
260 ps_page->page = alloc_page(GFP_ATOMIC);
261 if (!ps_page->page) {
262 adapter->alloc_rx_buff_failed++;
265 ps_page->dma = pci_map_page(pdev,
269 if (pci_dma_mapping_error(pdev, ps_page->dma)) {
270 dev_err(&adapter->pdev->dev,
271 "RX DMA page map failed\n");
272 adapter->rx_dma_failed++;
277 * Refresh the desc even if buffer_addrs
278 * didn't change because each write-back
281 rx_desc->read.buffer_addr[j+1] =
282 cpu_to_le64(ps_page->dma);
285 skb = netdev_alloc_skb(netdev,
286 adapter->rx_ps_bsize0 + NET_IP_ALIGN);
289 adapter->alloc_rx_buff_failed++;
294 * Make buffer alignment 2 beyond a 16 byte boundary
295 * this will result in a 16 byte aligned IP header after
296 * the 14 byte MAC header is removed
298 skb_reserve(skb, NET_IP_ALIGN);
300 buffer_info->skb = skb;
301 buffer_info->dma = pci_map_single(pdev, skb->data,
302 adapter->rx_ps_bsize0,
304 if (pci_dma_mapping_error(pdev, buffer_info->dma)) {
305 dev_err(&pdev->dev, "RX DMA map failed\n");
306 adapter->rx_dma_failed++;
308 dev_kfree_skb_any(skb);
309 buffer_info->skb = NULL;
313 rx_desc->read.buffer_addr[0] = cpu_to_le64(buffer_info->dma);
316 if (i == rx_ring->count)
318 buffer_info = &rx_ring->buffer_info[i];
322 if (rx_ring->next_to_use != i) {
323 rx_ring->next_to_use = i;
326 i = (rx_ring->count - 1);
329 * Force memory writes to complete before letting h/w
330 * know there are new descriptors to fetch. (Only
331 * applicable for weak-ordered memory model archs,
336 * Hardware increments by 16 bytes, but packet split
337 * descriptors are 32 bytes...so we increment tail
340 writel(i<<1, adapter->hw.hw_addr + rx_ring->tail);
345 * e1000_alloc_jumbo_rx_buffers - Replace used jumbo receive buffers
346 * @adapter: address of board private structure
347 * @cleaned_count: number of buffers to allocate this pass
350 static void e1000_alloc_jumbo_rx_buffers(struct e1000_adapter *adapter,
353 struct net_device *netdev = adapter->netdev;
354 struct pci_dev *pdev = adapter->pdev;
355 struct e1000_rx_desc *rx_desc;
356 struct e1000_ring *rx_ring = adapter->rx_ring;
357 struct e1000_buffer *buffer_info;
360 unsigned int bufsz = 256 -
361 16 /* for skb_reserve */ -
364 i = rx_ring->next_to_use;
365 buffer_info = &rx_ring->buffer_info[i];
367 while (cleaned_count--) {
368 skb = buffer_info->skb;
374 skb = netdev_alloc_skb(netdev, bufsz);
375 if (unlikely(!skb)) {
376 /* Better luck next round */
377 adapter->alloc_rx_buff_failed++;
381 /* Make buffer alignment 2 beyond a 16 byte boundary
382 * this will result in a 16 byte aligned IP header after
383 * the 14 byte MAC header is removed
385 skb_reserve(skb, NET_IP_ALIGN);
387 buffer_info->skb = skb;
389 /* allocate a new page if necessary */
390 if (!buffer_info->page) {
391 buffer_info->page = alloc_page(GFP_ATOMIC);
392 if (unlikely(!buffer_info->page)) {
393 adapter->alloc_rx_buff_failed++;
398 if (!buffer_info->dma)
399 buffer_info->dma = pci_map_page(pdev,
400 buffer_info->page, 0,
404 rx_desc = E1000_RX_DESC(*rx_ring, i);
405 rx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
407 if (unlikely(++i == rx_ring->count))
409 buffer_info = &rx_ring->buffer_info[i];
412 if (likely(rx_ring->next_to_use != i)) {
413 rx_ring->next_to_use = i;
414 if (unlikely(i-- == 0))
415 i = (rx_ring->count - 1);
417 /* Force memory writes to complete before letting h/w
418 * know there are new descriptors to fetch. (Only
419 * applicable for weak-ordered memory model archs,
422 writel(i, adapter->hw.hw_addr + rx_ring->tail);
427 * e1000_clean_rx_irq - Send received data up the network stack; legacy
428 * @adapter: board private structure
430 * the return value indicates whether actual cleaning was done, there
431 * is no guarantee that everything was cleaned
433 static bool e1000_clean_rx_irq(struct e1000_adapter *adapter,
434 int *work_done, int work_to_do)
436 struct net_device *netdev = adapter->netdev;
437 struct pci_dev *pdev = adapter->pdev;
438 struct e1000_ring *rx_ring = adapter->rx_ring;
439 struct e1000_rx_desc *rx_desc, *next_rxd;
440 struct e1000_buffer *buffer_info, *next_buffer;
443 int cleaned_count = 0;
445 unsigned int total_rx_bytes = 0, total_rx_packets = 0;
447 i = rx_ring->next_to_clean;
448 rx_desc = E1000_RX_DESC(*rx_ring, i);
449 buffer_info = &rx_ring->buffer_info[i];
451 while (rx_desc->status & E1000_RXD_STAT_DD) {
455 if (*work_done >= work_to_do)
459 status = rx_desc->status;
460 skb = buffer_info->skb;
461 buffer_info->skb = NULL;
463 prefetch(skb->data - NET_IP_ALIGN);
466 if (i == rx_ring->count)
468 next_rxd = E1000_RX_DESC(*rx_ring, i);
471 next_buffer = &rx_ring->buffer_info[i];
475 pci_unmap_single(pdev,
477 adapter->rx_buffer_len,
479 buffer_info->dma = 0;
481 length = le16_to_cpu(rx_desc->length);
483 /* !EOP means multiple descriptors were used to store a single
484 * packet, also make sure the frame isn't just CRC only */
485 if (!(status & E1000_RXD_STAT_EOP) || (length <= 4)) {
486 /* All receives must fit into a single buffer */
487 e_dbg("%s: Receive packet consumed multiple buffers\n",
490 buffer_info->skb = skb;
494 if (rx_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK) {
496 buffer_info->skb = skb;
500 /* adjust length to remove Ethernet CRC */
501 if (!(adapter->flags2 & FLAG2_CRC_STRIPPING))
504 total_rx_bytes += length;
508 * code added for copybreak, this should improve
509 * performance for small packets with large amounts
510 * of reassembly being done in the stack
512 if (length < copybreak) {
513 struct sk_buff *new_skb =
514 netdev_alloc_skb(netdev, length + NET_IP_ALIGN);
516 skb_reserve(new_skb, NET_IP_ALIGN);
517 skb_copy_to_linear_data_offset(new_skb,
523 /* save the skb in buffer_info as good */
524 buffer_info->skb = skb;
527 /* else just continue with the old one */
529 /* end copybreak code */
530 skb_put(skb, length);
532 /* Receive Checksum Offload */
533 e1000_rx_checksum(adapter,
535 ((u32)(rx_desc->errors) << 24),
536 le16_to_cpu(rx_desc->csum), skb);
538 e1000_receive_skb(adapter, netdev, skb,status,rx_desc->special);
543 /* return some buffers to hardware, one at a time is too slow */
544 if (cleaned_count >= E1000_RX_BUFFER_WRITE) {
545 adapter->alloc_rx_buf(adapter, cleaned_count);
549 /* use prefetched values */
551 buffer_info = next_buffer;
553 rx_ring->next_to_clean = i;
555 cleaned_count = e1000_desc_unused(rx_ring);
557 adapter->alloc_rx_buf(adapter, cleaned_count);
559 adapter->total_rx_bytes += total_rx_bytes;
560 adapter->total_rx_packets += total_rx_packets;
561 adapter->net_stats.rx_bytes += total_rx_bytes;
562 adapter->net_stats.rx_packets += total_rx_packets;
566 static void e1000_put_txbuf(struct e1000_adapter *adapter,
567 struct e1000_buffer *buffer_info)
569 if (buffer_info->dma) {
570 pci_unmap_page(adapter->pdev, buffer_info->dma,
571 buffer_info->length, PCI_DMA_TODEVICE);
572 buffer_info->dma = 0;
574 if (buffer_info->skb) {
575 dev_kfree_skb_any(buffer_info->skb);
576 buffer_info->skb = NULL;
580 static void e1000_print_tx_hang(struct e1000_adapter *adapter)
582 struct e1000_ring *tx_ring = adapter->tx_ring;
583 unsigned int i = tx_ring->next_to_clean;
584 unsigned int eop = tx_ring->buffer_info[i].next_to_watch;
585 struct e1000_tx_desc *eop_desc = E1000_TX_DESC(*tx_ring, eop);
587 /* detected Tx unit hang */
588 e_err("Detected Tx Unit Hang:\n"
591 " next_to_use <%x>\n"
592 " next_to_clean <%x>\n"
593 "buffer_info[next_to_clean]:\n"
594 " time_stamp <%lx>\n"
595 " next_to_watch <%x>\n"
597 " next_to_watch.status <%x>\n",
598 readl(adapter->hw.hw_addr + tx_ring->head),
599 readl(adapter->hw.hw_addr + tx_ring->tail),
600 tx_ring->next_to_use,
601 tx_ring->next_to_clean,
602 tx_ring->buffer_info[eop].time_stamp,
605 eop_desc->upper.fields.status);
609 * e1000_clean_tx_irq - Reclaim resources after transmit completes
610 * @adapter: board private structure
612 * the return value indicates whether actual cleaning was done, there
613 * is no guarantee that everything was cleaned
615 static bool e1000_clean_tx_irq(struct e1000_adapter *adapter)
617 struct net_device *netdev = adapter->netdev;
618 struct e1000_hw *hw = &adapter->hw;
619 struct e1000_ring *tx_ring = adapter->tx_ring;
620 struct e1000_tx_desc *tx_desc, *eop_desc;
621 struct e1000_buffer *buffer_info;
623 unsigned int count = 0;
625 unsigned int total_tx_bytes = 0, total_tx_packets = 0;
627 i = tx_ring->next_to_clean;
628 eop = tx_ring->buffer_info[i].next_to_watch;
629 eop_desc = E1000_TX_DESC(*tx_ring, eop);
631 while (eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) {
632 for (cleaned = 0; !cleaned; ) {
633 tx_desc = E1000_TX_DESC(*tx_ring, i);
634 buffer_info = &tx_ring->buffer_info[i];
635 cleaned = (i == eop);
638 struct sk_buff *skb = buffer_info->skb;
639 unsigned int segs, bytecount;
640 segs = skb_shinfo(skb)->gso_segs ?: 1;
641 /* multiply data chunks by size of headers */
642 bytecount = ((segs - 1) * skb_headlen(skb)) +
644 total_tx_packets += segs;
645 total_tx_bytes += bytecount;
648 e1000_put_txbuf(adapter, buffer_info);
649 tx_desc->upper.data = 0;
652 if (i == tx_ring->count)
656 eop = tx_ring->buffer_info[i].next_to_watch;
657 eop_desc = E1000_TX_DESC(*tx_ring, eop);
658 #define E1000_TX_WEIGHT 64
659 /* weight of a sort for tx, to avoid endless transmit cleanup */
660 if (count++ == E1000_TX_WEIGHT)
664 tx_ring->next_to_clean = i;
666 #define TX_WAKE_THRESHOLD 32
667 if (cleaned && netif_carrier_ok(netdev) &&
668 e1000_desc_unused(tx_ring) >= TX_WAKE_THRESHOLD) {
669 /* Make sure that anybody stopping the queue after this
670 * sees the new next_to_clean.
674 if (netif_queue_stopped(netdev) &&
675 !(test_bit(__E1000_DOWN, &adapter->state))) {
676 netif_wake_queue(netdev);
677 ++adapter->restart_queue;
681 if (adapter->detect_tx_hung) {
683 * Detect a transmit hang in hardware, this serializes the
684 * check with the clearing of time_stamp and movement of i
686 adapter->detect_tx_hung = 0;
687 if (tx_ring->buffer_info[eop].dma &&
688 time_after(jiffies, tx_ring->buffer_info[eop].time_stamp
689 + (adapter->tx_timeout_factor * HZ))
690 && !(er32(STATUS) & E1000_STATUS_TXOFF)) {
691 e1000_print_tx_hang(adapter);
692 netif_stop_queue(netdev);
695 adapter->total_tx_bytes += total_tx_bytes;
696 adapter->total_tx_packets += total_tx_packets;
697 adapter->net_stats.tx_bytes += total_tx_bytes;
698 adapter->net_stats.tx_packets += total_tx_packets;
703 * e1000_clean_rx_irq_ps - Send received data up the network stack; packet split
704 * @adapter: board private structure
706 * the return value indicates whether actual cleaning was done, there
707 * is no guarantee that everything was cleaned
709 static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
710 int *work_done, int work_to_do)
712 union e1000_rx_desc_packet_split *rx_desc, *next_rxd;
713 struct net_device *netdev = adapter->netdev;
714 struct pci_dev *pdev = adapter->pdev;
715 struct e1000_ring *rx_ring = adapter->rx_ring;
716 struct e1000_buffer *buffer_info, *next_buffer;
717 struct e1000_ps_page *ps_page;
721 int cleaned_count = 0;
723 unsigned int total_rx_bytes = 0, total_rx_packets = 0;
725 i = rx_ring->next_to_clean;
726 rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
727 staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
728 buffer_info = &rx_ring->buffer_info[i];
730 while (staterr & E1000_RXD_STAT_DD) {
731 if (*work_done >= work_to_do)
734 skb = buffer_info->skb;
736 /* in the packet split case this is header only */
737 prefetch(skb->data - NET_IP_ALIGN);
740 if (i == rx_ring->count)
742 next_rxd = E1000_RX_DESC_PS(*rx_ring, i);
745 next_buffer = &rx_ring->buffer_info[i];
749 pci_unmap_single(pdev, buffer_info->dma,
750 adapter->rx_ps_bsize0,
752 buffer_info->dma = 0;
754 if (!(staterr & E1000_RXD_STAT_EOP)) {
755 e_dbg("%s: Packet Split buffers didn't pick up the "
756 "full packet\n", netdev->name);
757 dev_kfree_skb_irq(skb);
761 if (staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK) {
762 dev_kfree_skb_irq(skb);
766 length = le16_to_cpu(rx_desc->wb.middle.length0);
769 e_dbg("%s: Last part of the packet spanning multiple "
770 "descriptors\n", netdev->name);
771 dev_kfree_skb_irq(skb);
776 skb_put(skb, length);
780 * this looks ugly, but it seems compiler issues make it
781 * more efficient than reusing j
783 int l1 = le16_to_cpu(rx_desc->wb.upper.length[0]);
786 * page alloc/put takes too long and effects small packet
787 * throughput, so unsplit small packets and save the alloc/put
788 * only valid in softirq (napi) context to call kmap_*
790 if (l1 && (l1 <= copybreak) &&
791 ((length + l1) <= adapter->rx_ps_bsize0)) {
794 ps_page = &buffer_info->ps_pages[0];
797 * there is no documentation about how to call
798 * kmap_atomic, so we can't hold the mapping
801 pci_dma_sync_single_for_cpu(pdev, ps_page->dma,
802 PAGE_SIZE, PCI_DMA_FROMDEVICE);
803 vaddr = kmap_atomic(ps_page->page, KM_SKB_DATA_SOFTIRQ);
804 memcpy(skb_tail_pointer(skb), vaddr, l1);
805 kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ);
806 pci_dma_sync_single_for_device(pdev, ps_page->dma,
807 PAGE_SIZE, PCI_DMA_FROMDEVICE);
810 if (!(adapter->flags2 & FLAG2_CRC_STRIPPING))
818 for (j = 0; j < PS_PAGE_BUFFERS; j++) {
819 length = le16_to_cpu(rx_desc->wb.upper.length[j]);
823 ps_page = &buffer_info->ps_pages[j];
824 pci_unmap_page(pdev, ps_page->dma, PAGE_SIZE,
827 skb_fill_page_desc(skb, j, ps_page->page, 0, length);
828 ps_page->page = NULL;
830 skb->data_len += length;
831 skb->truesize += length;
834 /* strip the ethernet crc, problem is we're using pages now so
835 * this whole operation can get a little cpu intensive
837 if (!(adapter->flags2 & FLAG2_CRC_STRIPPING))
838 pskb_trim(skb, skb->len - 4);
841 total_rx_bytes += skb->len;
844 e1000_rx_checksum(adapter, staterr, le16_to_cpu(
845 rx_desc->wb.lower.hi_dword.csum_ip.csum), skb);
847 if (rx_desc->wb.upper.header_status &
848 cpu_to_le16(E1000_RXDPS_HDRSTAT_HDRSP))
849 adapter->rx_hdr_split++;
851 e1000_receive_skb(adapter, netdev, skb,
852 staterr, rx_desc->wb.middle.vlan);
855 rx_desc->wb.middle.status_error &= cpu_to_le32(~0xFF);
856 buffer_info->skb = NULL;
858 /* return some buffers to hardware, one at a time is too slow */
859 if (cleaned_count >= E1000_RX_BUFFER_WRITE) {
860 adapter->alloc_rx_buf(adapter, cleaned_count);
864 /* use prefetched values */
866 buffer_info = next_buffer;
868 staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
870 rx_ring->next_to_clean = i;
872 cleaned_count = e1000_desc_unused(rx_ring);
874 adapter->alloc_rx_buf(adapter, cleaned_count);
876 adapter->total_rx_bytes += total_rx_bytes;
877 adapter->total_rx_packets += total_rx_packets;
878 adapter->net_stats.rx_bytes += total_rx_bytes;
879 adapter->net_stats.rx_packets += total_rx_packets;
884 * e1000_consume_page - helper function
886 static void e1000_consume_page(struct e1000_buffer *bi, struct sk_buff *skb,
891 skb->data_len += length;
892 skb->truesize += length;
896 * e1000_clean_jumbo_rx_irq - Send received data up the network stack; legacy
897 * @adapter: board private structure
899 * the return value indicates whether actual cleaning was done, there
900 * is no guarantee that everything was cleaned
903 static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter,
904 int *work_done, int work_to_do)
906 struct net_device *netdev = adapter->netdev;
907 struct pci_dev *pdev = adapter->pdev;
908 struct e1000_ring *rx_ring = adapter->rx_ring;
909 struct e1000_rx_desc *rx_desc, *next_rxd;
910 struct e1000_buffer *buffer_info, *next_buffer;
913 int cleaned_count = 0;
914 bool cleaned = false;
915 unsigned int total_rx_bytes=0, total_rx_packets=0;
917 i = rx_ring->next_to_clean;
918 rx_desc = E1000_RX_DESC(*rx_ring, i);
919 buffer_info = &rx_ring->buffer_info[i];
921 while (rx_desc->status & E1000_RXD_STAT_DD) {
925 if (*work_done >= work_to_do)
929 status = rx_desc->status;
930 skb = buffer_info->skb;
931 buffer_info->skb = NULL;
934 if (i == rx_ring->count)
936 next_rxd = E1000_RX_DESC(*rx_ring, i);
939 next_buffer = &rx_ring->buffer_info[i];
943 pci_unmap_page(pdev, buffer_info->dma, PAGE_SIZE,
945 buffer_info->dma = 0;
947 length = le16_to_cpu(rx_desc->length);
949 /* errors is only valid for DD + EOP descriptors */
950 if (unlikely((status & E1000_RXD_STAT_EOP) &&
951 (rx_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK))) {
952 /* recycle both page and skb */
953 buffer_info->skb = skb;
954 /* an error means any chain goes out the window
956 if (rx_ring->rx_skb_top)
957 dev_kfree_skb(rx_ring->rx_skb_top);
958 rx_ring->rx_skb_top = NULL;
962 #define rxtop rx_ring->rx_skb_top
963 if (!(status & E1000_RXD_STAT_EOP)) {
964 /* this descriptor is only the beginning (or middle) */
966 /* this is the beginning of a chain */
968 skb_fill_page_desc(rxtop, 0, buffer_info->page,
971 /* this is the middle of a chain */
972 skb_fill_page_desc(rxtop,
973 skb_shinfo(rxtop)->nr_frags,
974 buffer_info->page, 0, length);
975 /* re-use the skb, only consumed the page */
976 buffer_info->skb = skb;
978 e1000_consume_page(buffer_info, rxtop, length);
982 /* end of the chain */
983 skb_fill_page_desc(rxtop,
984 skb_shinfo(rxtop)->nr_frags,
985 buffer_info->page, 0, length);
986 /* re-use the current skb, we only consumed the
988 buffer_info->skb = skb;
991 e1000_consume_page(buffer_info, skb, length);
993 /* no chain, got EOP, this buf is the packet
994 * copybreak to save the put_page/alloc_page */
995 if (length <= copybreak &&
996 skb_tailroom(skb) >= length) {
998 vaddr = kmap_atomic(buffer_info->page,
999 KM_SKB_DATA_SOFTIRQ);
1000 memcpy(skb_tail_pointer(skb), vaddr,
1002 kunmap_atomic(vaddr,
1003 KM_SKB_DATA_SOFTIRQ);
1004 /* re-use the page, so don't erase
1005 * buffer_info->page */
1006 skb_put(skb, length);
1008 skb_fill_page_desc(skb, 0,
1009 buffer_info->page, 0,
1011 e1000_consume_page(buffer_info, skb,
1017 /* Receive Checksum Offload XXX recompute due to CRC strip? */
1018 e1000_rx_checksum(adapter,
1020 ((u32)(rx_desc->errors) << 24),
1021 le16_to_cpu(rx_desc->csum), skb);
1023 /* probably a little skewed due to removing CRC */
1024 total_rx_bytes += skb->len;
1027 /* eth type trans needs skb->data to point to something */
1028 if (!pskb_may_pull(skb, ETH_HLEN)) {
1029 e_err("pskb_may_pull failed.\n");
1034 e1000_receive_skb(adapter, netdev, skb, status,
1038 rx_desc->status = 0;
1040 /* return some buffers to hardware, one at a time is too slow */
1041 if (unlikely(cleaned_count >= E1000_RX_BUFFER_WRITE)) {
1042 adapter->alloc_rx_buf(adapter, cleaned_count);
1046 /* use prefetched values */
1048 buffer_info = next_buffer;
1050 rx_ring->next_to_clean = i;
1052 cleaned_count = e1000_desc_unused(rx_ring);
1054 adapter->alloc_rx_buf(adapter, cleaned_count);
1056 adapter->total_rx_bytes += total_rx_bytes;
1057 adapter->total_rx_packets += total_rx_packets;
1058 adapter->net_stats.rx_bytes += total_rx_bytes;
1059 adapter->net_stats.rx_packets += total_rx_packets;
1064 * e1000_clean_rx_ring - Free Rx Buffers per Queue
1065 * @adapter: board private structure
1067 static void e1000_clean_rx_ring(struct e1000_adapter *adapter)
1069 struct e1000_ring *rx_ring = adapter->rx_ring;
1070 struct e1000_buffer *buffer_info;
1071 struct e1000_ps_page *ps_page;
1072 struct pci_dev *pdev = adapter->pdev;
1075 /* Free all the Rx ring sk_buffs */
1076 for (i = 0; i < rx_ring->count; i++) {
1077 buffer_info = &rx_ring->buffer_info[i];
1078 if (buffer_info->dma) {
1079 if (adapter->clean_rx == e1000_clean_rx_irq)
1080 pci_unmap_single(pdev, buffer_info->dma,
1081 adapter->rx_buffer_len,
1082 PCI_DMA_FROMDEVICE);
1083 else if (adapter->clean_rx == e1000_clean_jumbo_rx_irq)
1084 pci_unmap_page(pdev, buffer_info->dma,
1086 PCI_DMA_FROMDEVICE);
1087 else if (adapter->clean_rx == e1000_clean_rx_irq_ps)
1088 pci_unmap_single(pdev, buffer_info->dma,
1089 adapter->rx_ps_bsize0,
1090 PCI_DMA_FROMDEVICE);
1091 buffer_info->dma = 0;
1094 if (buffer_info->page) {
1095 put_page(buffer_info->page);
1096 buffer_info->page = NULL;
1099 if (buffer_info->skb) {
1100 dev_kfree_skb(buffer_info->skb);
1101 buffer_info->skb = NULL;
1104 for (j = 0; j < PS_PAGE_BUFFERS; j++) {
1105 ps_page = &buffer_info->ps_pages[j];
1108 pci_unmap_page(pdev, ps_page->dma, PAGE_SIZE,
1109 PCI_DMA_FROMDEVICE);
1111 put_page(ps_page->page);
1112 ps_page->page = NULL;
1116 /* there also may be some cached data from a chained receive */
1117 if (rx_ring->rx_skb_top) {
1118 dev_kfree_skb(rx_ring->rx_skb_top);
1119 rx_ring->rx_skb_top = NULL;
1122 /* Zero out the descriptor ring */
1123 memset(rx_ring->desc, 0, rx_ring->size);
1125 rx_ring->next_to_clean = 0;
1126 rx_ring->next_to_use = 0;
1128 writel(0, adapter->hw.hw_addr + rx_ring->head);
1129 writel(0, adapter->hw.hw_addr + rx_ring->tail);
1132 static void e1000e_downshift_workaround(struct work_struct *work)
1134 struct e1000_adapter *adapter = container_of(work,
1135 struct e1000_adapter, downshift_task);
1137 e1000e_gig_downshift_workaround_ich8lan(&adapter->hw);
1141 * e1000_intr_msi - Interrupt Handler
1142 * @irq: interrupt number
1143 * @data: pointer to a network interface device structure
1145 static irqreturn_t e1000_intr_msi(int irq, void *data)
1147 struct net_device *netdev = data;
1148 struct e1000_adapter *adapter = netdev_priv(netdev);
1149 struct e1000_hw *hw = &adapter->hw;
1150 u32 icr = er32(ICR);
1153 * read ICR disables interrupts using IAM
1156 if (icr & E1000_ICR_LSC) {
1157 hw->mac.get_link_status = 1;
1159 * ICH8 workaround-- Call gig speed drop workaround on cable
1160 * disconnect (LSC) before accessing any PHY registers
1162 if ((adapter->flags & FLAG_LSC_GIG_SPEED_DROP) &&
1163 (!(er32(STATUS) & E1000_STATUS_LU)))
1164 schedule_work(&adapter->downshift_task);
1167 * 80003ES2LAN workaround-- For packet buffer work-around on
1168 * link down event; disable receives here in the ISR and reset
1169 * adapter in watchdog
1171 if (netif_carrier_ok(netdev) &&
1172 adapter->flags & FLAG_RX_NEEDS_RESTART) {
1173 /* disable receives */
1174 u32 rctl = er32(RCTL);
1175 ew32(RCTL, rctl & ~E1000_RCTL_EN);
1176 adapter->flags |= FLAG_RX_RESTART_NOW;
1178 /* guard against interrupt when we're going down */
1179 if (!test_bit(__E1000_DOWN, &adapter->state))
1180 mod_timer(&adapter->watchdog_timer, jiffies + 1);
1183 if (napi_schedule_prep(&adapter->napi)) {
1184 adapter->total_tx_bytes = 0;
1185 adapter->total_tx_packets = 0;
1186 adapter->total_rx_bytes = 0;
1187 adapter->total_rx_packets = 0;
1188 __napi_schedule(&adapter->napi);
1195 * e1000_intr - Interrupt Handler
1196 * @irq: interrupt number
1197 * @data: pointer to a network interface device structure
1199 static irqreturn_t e1000_intr(int irq, void *data)
1201 struct net_device *netdev = data;
1202 struct e1000_adapter *adapter = netdev_priv(netdev);
1203 struct e1000_hw *hw = &adapter->hw;
1204 u32 rctl, icr = er32(ICR);
1207 return IRQ_NONE; /* Not our interrupt */
1210 * IMS will not auto-mask if INT_ASSERTED is not set, and if it is
1211 * not set, then the adapter didn't send an interrupt
1213 if (!(icr & E1000_ICR_INT_ASSERTED))
1217 * Interrupt Auto-Mask...upon reading ICR,
1218 * interrupts are masked. No need for the
1222 if (icr & E1000_ICR_LSC) {
1223 hw->mac.get_link_status = 1;
1225 * ICH8 workaround-- Call gig speed drop workaround on cable
1226 * disconnect (LSC) before accessing any PHY registers
1228 if ((adapter->flags & FLAG_LSC_GIG_SPEED_DROP) &&
1229 (!(er32(STATUS) & E1000_STATUS_LU)))
1230 schedule_work(&adapter->downshift_task);
1233 * 80003ES2LAN workaround--
1234 * For packet buffer work-around on link down event;
1235 * disable receives here in the ISR and
1236 * reset adapter in watchdog
1238 if (netif_carrier_ok(netdev) &&
1239 (adapter->flags & FLAG_RX_NEEDS_RESTART)) {
1240 /* disable receives */
1242 ew32(RCTL, rctl & ~E1000_RCTL_EN);
1243 adapter->flags |= FLAG_RX_RESTART_NOW;
1245 /* guard against interrupt when we're going down */
1246 if (!test_bit(__E1000_DOWN, &adapter->state))
1247 mod_timer(&adapter->watchdog_timer, jiffies + 1);
1250 if (napi_schedule_prep(&adapter->napi)) {
1251 adapter->total_tx_bytes = 0;
1252 adapter->total_tx_packets = 0;
1253 adapter->total_rx_bytes = 0;
1254 adapter->total_rx_packets = 0;
1255 __napi_schedule(&adapter->napi);
1261 static irqreturn_t e1000_msix_other(int irq, void *data)
1263 struct net_device *netdev = data;
1264 struct e1000_adapter *adapter = netdev_priv(netdev);
1265 struct e1000_hw *hw = &adapter->hw;
1266 u32 icr = er32(ICR);
1268 if (!(icr & E1000_ICR_INT_ASSERTED)) {
1269 ew32(IMS, E1000_IMS_OTHER);
1273 if (icr & adapter->eiac_mask)
1274 ew32(ICS, (icr & adapter->eiac_mask));
1276 if (icr & E1000_ICR_OTHER) {
1277 if (!(icr & E1000_ICR_LSC))
1278 goto no_link_interrupt;
1279 hw->mac.get_link_status = 1;
1280 /* guard against interrupt when we're going down */
1281 if (!test_bit(__E1000_DOWN, &adapter->state))
1282 mod_timer(&adapter->watchdog_timer, jiffies + 1);
1286 ew32(IMS, E1000_IMS_LSC | E1000_IMS_OTHER);
1292 static irqreturn_t e1000_intr_msix_tx(int irq, void *data)
1294 struct net_device *netdev = data;
1295 struct e1000_adapter *adapter = netdev_priv(netdev);
1296 struct e1000_hw *hw = &adapter->hw;
1297 struct e1000_ring *tx_ring = adapter->tx_ring;
1300 adapter->total_tx_bytes = 0;
1301 adapter->total_tx_packets = 0;
1303 if (!e1000_clean_tx_irq(adapter))
1304 /* Ring was not completely cleaned, so fire another interrupt */
1305 ew32(ICS, tx_ring->ims_val);
1310 static irqreturn_t e1000_intr_msix_rx(int irq, void *data)
1312 struct net_device *netdev = data;
1313 struct e1000_adapter *adapter = netdev_priv(netdev);
1315 /* Write the ITR value calculated at the end of the
1316 * previous interrupt.
1318 if (adapter->rx_ring->set_itr) {
1319 writel(1000000000 / (adapter->rx_ring->itr_val * 256),
1320 adapter->hw.hw_addr + adapter->rx_ring->itr_register);
1321 adapter->rx_ring->set_itr = 0;
1324 if (napi_schedule_prep(&adapter->napi)) {
1325 adapter->total_rx_bytes = 0;
1326 adapter->total_rx_packets = 0;
1327 __napi_schedule(&adapter->napi);
1333 * e1000_configure_msix - Configure MSI-X hardware
1335 * e1000_configure_msix sets up the hardware to properly
1336 * generate MSI-X interrupts.
1338 static void e1000_configure_msix(struct e1000_adapter *adapter)
1340 struct e1000_hw *hw = &adapter->hw;
1341 struct e1000_ring *rx_ring = adapter->rx_ring;
1342 struct e1000_ring *tx_ring = adapter->tx_ring;
1344 u32 ctrl_ext, ivar = 0;
1346 adapter->eiac_mask = 0;
1348 /* Workaround issue with spurious interrupts on 82574 in MSI-X mode */
1349 if (hw->mac.type == e1000_82574) {
1350 u32 rfctl = er32(RFCTL);
1351 rfctl |= E1000_RFCTL_ACK_DIS;
1355 #define E1000_IVAR_INT_ALLOC_VALID 0x8
1356 /* Configure Rx vector */
1357 rx_ring->ims_val = E1000_IMS_RXQ0;
1358 adapter->eiac_mask |= rx_ring->ims_val;
1359 if (rx_ring->itr_val)
1360 writel(1000000000 / (rx_ring->itr_val * 256),
1361 hw->hw_addr + rx_ring->itr_register);
1363 writel(1, hw->hw_addr + rx_ring->itr_register);
1364 ivar = E1000_IVAR_INT_ALLOC_VALID | vector;
1366 /* Configure Tx vector */
1367 tx_ring->ims_val = E1000_IMS_TXQ0;
1369 if (tx_ring->itr_val)
1370 writel(1000000000 / (tx_ring->itr_val * 256),
1371 hw->hw_addr + tx_ring->itr_register);
1373 writel(1, hw->hw_addr + tx_ring->itr_register);
1374 adapter->eiac_mask |= tx_ring->ims_val;
1375 ivar |= ((E1000_IVAR_INT_ALLOC_VALID | vector) << 8);
1377 /* set vector for Other Causes, e.g. link changes */
1379 ivar |= ((E1000_IVAR_INT_ALLOC_VALID | vector) << 16);
1380 if (rx_ring->itr_val)
1381 writel(1000000000 / (rx_ring->itr_val * 256),
1382 hw->hw_addr + E1000_EITR_82574(vector));
1384 writel(1, hw->hw_addr + E1000_EITR_82574(vector));
1386 /* Cause Tx interrupts on every write back */
1391 /* enable MSI-X PBA support */
1392 ctrl_ext = er32(CTRL_EXT);
1393 ctrl_ext |= E1000_CTRL_EXT_PBA_CLR;
1395 /* Auto-Mask Other interrupts upon ICR read */
1396 #define E1000_EIAC_MASK_82574 0x01F00000
1397 ew32(IAM, ~E1000_EIAC_MASK_82574 | E1000_IMS_OTHER);
1398 ctrl_ext |= E1000_CTRL_EXT_EIAME;
1399 ew32(CTRL_EXT, ctrl_ext);
1403 void e1000e_reset_interrupt_capability(struct e1000_adapter *adapter)
1405 if (adapter->msix_entries) {
1406 pci_disable_msix(adapter->pdev);
1407 kfree(adapter->msix_entries);
1408 adapter->msix_entries = NULL;
1409 } else if (adapter->flags & FLAG_MSI_ENABLED) {
1410 pci_disable_msi(adapter->pdev);
1411 adapter->flags &= ~FLAG_MSI_ENABLED;
1418 * e1000e_set_interrupt_capability - set MSI or MSI-X if supported
1420 * Attempt to configure interrupts using the best available
1421 * capabilities of the hardware and kernel.
1423 void e1000e_set_interrupt_capability(struct e1000_adapter *adapter)
1429 switch (adapter->int_mode) {
1430 case E1000E_INT_MODE_MSIX:
1431 if (adapter->flags & FLAG_HAS_MSIX) {
1432 numvecs = 3; /* RxQ0, TxQ0 and other */
1433 adapter->msix_entries = kcalloc(numvecs,
1434 sizeof(struct msix_entry),
1436 if (adapter->msix_entries) {
1437 for (i = 0; i < numvecs; i++)
1438 adapter->msix_entries[i].entry = i;
1440 err = pci_enable_msix(adapter->pdev,
1441 adapter->msix_entries,
1446 /* MSI-X failed, so fall through and try MSI */
1447 e_err("Failed to initialize MSI-X interrupts. "
1448 "Falling back to MSI interrupts.\n");
1449 e1000e_reset_interrupt_capability(adapter);
1451 adapter->int_mode = E1000E_INT_MODE_MSI;
1453 case E1000E_INT_MODE_MSI:
1454 if (!pci_enable_msi(adapter->pdev)) {
1455 adapter->flags |= FLAG_MSI_ENABLED;
1457 adapter->int_mode = E1000E_INT_MODE_LEGACY;
1458 e_err("Failed to initialize MSI interrupts. Falling "
1459 "back to legacy interrupts.\n");
1462 case E1000E_INT_MODE_LEGACY:
1463 /* Don't do anything; this is the system default */
1471 * e1000_request_msix - Initialize MSI-X interrupts
1473 * e1000_request_msix allocates MSI-X vectors and requests interrupts from the
1476 static int e1000_request_msix(struct e1000_adapter *adapter)
1478 struct net_device *netdev = adapter->netdev;
1479 int err = 0, vector = 0;
1481 if (strlen(netdev->name) < (IFNAMSIZ - 5))
1482 sprintf(adapter->rx_ring->name, "%s-rx-0", netdev->name);
1484 memcpy(adapter->rx_ring->name, netdev->name, IFNAMSIZ);
1485 err = request_irq(adapter->msix_entries[vector].vector,
1486 &e1000_intr_msix_rx, 0, adapter->rx_ring->name,
1490 adapter->rx_ring->itr_register = E1000_EITR_82574(vector);
1491 adapter->rx_ring->itr_val = adapter->itr;
1494 if (strlen(netdev->name) < (IFNAMSIZ - 5))
1495 sprintf(adapter->tx_ring->name, "%s-tx-0", netdev->name);
1497 memcpy(adapter->tx_ring->name, netdev->name, IFNAMSIZ);
1498 err = request_irq(adapter->msix_entries[vector].vector,
1499 &e1000_intr_msix_tx, 0, adapter->tx_ring->name,
1503 adapter->tx_ring->itr_register = E1000_EITR_82574(vector);
1504 adapter->tx_ring->itr_val = adapter->itr;
1507 err = request_irq(adapter->msix_entries[vector].vector,
1508 &e1000_msix_other, 0, netdev->name, netdev);
1512 e1000_configure_msix(adapter);
1519 * e1000_request_irq - initialize interrupts
1521 * Attempts to configure interrupts using the best available
1522 * capabilities of the hardware and kernel.
1524 static int e1000_request_irq(struct e1000_adapter *adapter)
1526 struct net_device *netdev = adapter->netdev;
1529 if (adapter->msix_entries) {
1530 err = e1000_request_msix(adapter);
1533 /* fall back to MSI */
1534 e1000e_reset_interrupt_capability(adapter);
1535 adapter->int_mode = E1000E_INT_MODE_MSI;
1536 e1000e_set_interrupt_capability(adapter);
1538 if (adapter->flags & FLAG_MSI_ENABLED) {
1539 err = request_irq(adapter->pdev->irq, &e1000_intr_msi, 0,
1540 netdev->name, netdev);
1544 /* fall back to legacy interrupt */
1545 e1000e_reset_interrupt_capability(adapter);
1546 adapter->int_mode = E1000E_INT_MODE_LEGACY;
1549 err = request_irq(adapter->pdev->irq, &e1000_intr, IRQF_SHARED,
1550 netdev->name, netdev);
1552 e_err("Unable to allocate interrupt, Error: %d\n", err);
1557 static void e1000_free_irq(struct e1000_adapter *adapter)
1559 struct net_device *netdev = adapter->netdev;
1561 if (adapter->msix_entries) {
1564 free_irq(adapter->msix_entries[vector].vector, netdev);
1567 free_irq(adapter->msix_entries[vector].vector, netdev);
1570 /* Other Causes interrupt vector */
1571 free_irq(adapter->msix_entries[vector].vector, netdev);
1575 free_irq(adapter->pdev->irq, netdev);
1579 * e1000_irq_disable - Mask off interrupt generation on the NIC
1581 static void e1000_irq_disable(struct e1000_adapter *adapter)
1583 struct e1000_hw *hw = &adapter->hw;
1586 if (adapter->msix_entries)
1587 ew32(EIAC_82574, 0);
1589 synchronize_irq(adapter->pdev->irq);
1593 * e1000_irq_enable - Enable default interrupt generation settings
1595 static void e1000_irq_enable(struct e1000_adapter *adapter)
1597 struct e1000_hw *hw = &adapter->hw;
1599 if (adapter->msix_entries) {
1600 ew32(EIAC_82574, adapter->eiac_mask & E1000_EIAC_MASK_82574);
1601 ew32(IMS, adapter->eiac_mask | E1000_IMS_OTHER | E1000_IMS_LSC);
1603 ew32(IMS, IMS_ENABLE_MASK);
1609 * e1000_get_hw_control - get control of the h/w from f/w
1610 * @adapter: address of board private structure
1612 * e1000_get_hw_control sets {CTRL_EXT|SWSM}:DRV_LOAD bit.
1613 * For ASF and Pass Through versions of f/w this means that
1614 * the driver is loaded. For AMT version (only with 82573)
1615 * of the f/w this means that the network i/f is open.
1617 static void e1000_get_hw_control(struct e1000_adapter *adapter)
1619 struct e1000_hw *hw = &adapter->hw;
1623 /* Let firmware know the driver has taken over */
1624 if (adapter->flags & FLAG_HAS_SWSM_ON_LOAD) {
1626 ew32(SWSM, swsm | E1000_SWSM_DRV_LOAD);
1627 } else if (adapter->flags & FLAG_HAS_CTRLEXT_ON_LOAD) {
1628 ctrl_ext = er32(CTRL_EXT);
1629 ew32(CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_DRV_LOAD);
1634 * e1000_release_hw_control - release control of the h/w to f/w
1635 * @adapter: address of board private structure
1637 * e1000_release_hw_control resets {CTRL_EXT|SWSM}:DRV_LOAD bit.
1638 * For ASF and Pass Through versions of f/w this means that the
1639 * driver is no longer loaded. For AMT version (only with 82573) i
1640 * of the f/w this means that the network i/f is closed.
1643 static void e1000_release_hw_control(struct e1000_adapter *adapter)
1645 struct e1000_hw *hw = &adapter->hw;
1649 /* Let firmware taken over control of h/w */
1650 if (adapter->flags & FLAG_HAS_SWSM_ON_LOAD) {
1652 ew32(SWSM, swsm & ~E1000_SWSM_DRV_LOAD);
1653 } else if (adapter->flags & FLAG_HAS_CTRLEXT_ON_LOAD) {
1654 ctrl_ext = er32(CTRL_EXT);
1655 ew32(CTRL_EXT, ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD);
1660 * @e1000_alloc_ring - allocate memory for a ring structure
1662 static int e1000_alloc_ring_dma(struct e1000_adapter *adapter,
1663 struct e1000_ring *ring)
1665 struct pci_dev *pdev = adapter->pdev;
1667 ring->desc = dma_alloc_coherent(&pdev->dev, ring->size, &ring->dma,
1676 * e1000e_setup_tx_resources - allocate Tx resources (Descriptors)
1677 * @adapter: board private structure
1679 * Return 0 on success, negative on failure
1681 int e1000e_setup_tx_resources(struct e1000_adapter *adapter)
1683 struct e1000_ring *tx_ring = adapter->tx_ring;
1684 int err = -ENOMEM, size;
1686 size = sizeof(struct e1000_buffer) * tx_ring->count;
1687 tx_ring->buffer_info = vmalloc(size);
1688 if (!tx_ring->buffer_info)
1690 memset(tx_ring->buffer_info, 0, size);
1692 /* round up to nearest 4K */
1693 tx_ring->size = tx_ring->count * sizeof(struct e1000_tx_desc);
1694 tx_ring->size = ALIGN(tx_ring->size, 4096);
1696 err = e1000_alloc_ring_dma(adapter, tx_ring);
1700 tx_ring->next_to_use = 0;
1701 tx_ring->next_to_clean = 0;
1705 vfree(tx_ring->buffer_info);
1706 e_err("Unable to allocate memory for the transmit descriptor ring\n");
1711 * e1000e_setup_rx_resources - allocate Rx resources (Descriptors)
1712 * @adapter: board private structure
1714 * Returns 0 on success, negative on failure
1716 int e1000e_setup_rx_resources(struct e1000_adapter *adapter)
1718 struct e1000_ring *rx_ring = adapter->rx_ring;
1719 struct e1000_buffer *buffer_info;
1720 int i, size, desc_len, err = -ENOMEM;
1722 size = sizeof(struct e1000_buffer) * rx_ring->count;
1723 rx_ring->buffer_info = vmalloc(size);
1724 if (!rx_ring->buffer_info)
1726 memset(rx_ring->buffer_info, 0, size);
1728 for (i = 0; i < rx_ring->count; i++) {
1729 buffer_info = &rx_ring->buffer_info[i];
1730 buffer_info->ps_pages = kcalloc(PS_PAGE_BUFFERS,
1731 sizeof(struct e1000_ps_page),
1733 if (!buffer_info->ps_pages)
1737 desc_len = sizeof(union e1000_rx_desc_packet_split);
1739 /* Round up to nearest 4K */
1740 rx_ring->size = rx_ring->count * desc_len;
1741 rx_ring->size = ALIGN(rx_ring->size, 4096);
1743 err = e1000_alloc_ring_dma(adapter, rx_ring);
1747 rx_ring->next_to_clean = 0;
1748 rx_ring->next_to_use = 0;
1749 rx_ring->rx_skb_top = NULL;
1754 for (i = 0; i < rx_ring->count; i++) {
1755 buffer_info = &rx_ring->buffer_info[i];
1756 kfree(buffer_info->ps_pages);
1759 vfree(rx_ring->buffer_info);
1760 e_err("Unable to allocate memory for the transmit descriptor ring\n");
1765 * e1000_clean_tx_ring - Free Tx Buffers
1766 * @adapter: board private structure
1768 static void e1000_clean_tx_ring(struct e1000_adapter *adapter)
1770 struct e1000_ring *tx_ring = adapter->tx_ring;
1771 struct e1000_buffer *buffer_info;
1775 for (i = 0; i < tx_ring->count; i++) {
1776 buffer_info = &tx_ring->buffer_info[i];
1777 e1000_put_txbuf(adapter, buffer_info);
1780 size = sizeof(struct e1000_buffer) * tx_ring->count;
1781 memset(tx_ring->buffer_info, 0, size);
1783 memset(tx_ring->desc, 0, tx_ring->size);
1785 tx_ring->next_to_use = 0;
1786 tx_ring->next_to_clean = 0;
1788 writel(0, adapter->hw.hw_addr + tx_ring->head);
1789 writel(0, adapter->hw.hw_addr + tx_ring->tail);
1793 * e1000e_free_tx_resources - Free Tx Resources per Queue
1794 * @adapter: board private structure
1796 * Free all transmit software resources
1798 void e1000e_free_tx_resources(struct e1000_adapter *adapter)
1800 struct pci_dev *pdev = adapter->pdev;
1801 struct e1000_ring *tx_ring = adapter->tx_ring;
1803 e1000_clean_tx_ring(adapter);
1805 vfree(tx_ring->buffer_info);
1806 tx_ring->buffer_info = NULL;
1808 dma_free_coherent(&pdev->dev, tx_ring->size, tx_ring->desc,
1810 tx_ring->desc = NULL;
1814 * e1000e_free_rx_resources - Free Rx Resources
1815 * @adapter: board private structure
1817 * Free all receive software resources
1820 void e1000e_free_rx_resources(struct e1000_adapter *adapter)
1822 struct pci_dev *pdev = adapter->pdev;
1823 struct e1000_ring *rx_ring = adapter->rx_ring;
1826 e1000_clean_rx_ring(adapter);
1828 for (i = 0; i < rx_ring->count; i++) {
1829 kfree(rx_ring->buffer_info[i].ps_pages);
1832 vfree(rx_ring->buffer_info);
1833 rx_ring->buffer_info = NULL;
1835 dma_free_coherent(&pdev->dev, rx_ring->size, rx_ring->desc,
1837 rx_ring->desc = NULL;
1841 * e1000_update_itr - update the dynamic ITR value based on statistics
1842 * @adapter: pointer to adapter
1843 * @itr_setting: current adapter->itr
1844 * @packets: the number of packets during this measurement interval
1845 * @bytes: the number of bytes during this measurement interval
1847 * Stores a new ITR value based on packets and byte
1848 * counts during the last interrupt. The advantage of per interrupt
1849 * computation is faster updates and more accurate ITR for the current
1850 * traffic pattern. Constants in this function were computed
1851 * based on theoretical maximum wire speed and thresholds were set based
1852 * on testing data as well as attempting to minimize response time
1853 * while increasing bulk throughput. This functionality is controlled
1854 * by the InterruptThrottleRate module parameter.
1856 static unsigned int e1000_update_itr(struct e1000_adapter *adapter,
1857 u16 itr_setting, int packets,
1860 unsigned int retval = itr_setting;
1863 goto update_itr_done;
1865 switch (itr_setting) {
1866 case lowest_latency:
1867 /* handle TSO and jumbo frames */
1868 if (bytes/packets > 8000)
1869 retval = bulk_latency;
1870 else if ((packets < 5) && (bytes > 512)) {
1871 retval = low_latency;
1874 case low_latency: /* 50 usec aka 20000 ints/s */
1875 if (bytes > 10000) {
1876 /* this if handles the TSO accounting */
1877 if (bytes/packets > 8000) {
1878 retval = bulk_latency;
1879 } else if ((packets < 10) || ((bytes/packets) > 1200)) {
1880 retval = bulk_latency;
1881 } else if ((packets > 35)) {
1882 retval = lowest_latency;
1884 } else if (bytes/packets > 2000) {
1885 retval = bulk_latency;
1886 } else if (packets <= 2 && bytes < 512) {
1887 retval = lowest_latency;
1890 case bulk_latency: /* 250 usec aka 4000 ints/s */
1891 if (bytes > 25000) {
1893 retval = low_latency;
1895 } else if (bytes < 6000) {
1896 retval = low_latency;
1905 static void e1000_set_itr(struct e1000_adapter *adapter)
1907 struct e1000_hw *hw = &adapter->hw;
1909 u32 new_itr = adapter->itr;
1911 /* for non-gigabit speeds, just fix the interrupt rate at 4000 */
1912 if (adapter->link_speed != SPEED_1000) {
1918 adapter->tx_itr = e1000_update_itr(adapter,
1920 adapter->total_tx_packets,
1921 adapter->total_tx_bytes);
1922 /* conservative mode (itr 3) eliminates the lowest_latency setting */
1923 if (adapter->itr_setting == 3 && adapter->tx_itr == lowest_latency)
1924 adapter->tx_itr = low_latency;
1926 adapter->rx_itr = e1000_update_itr(adapter,
1928 adapter->total_rx_packets,
1929 adapter->total_rx_bytes);
1930 /* conservative mode (itr 3) eliminates the lowest_latency setting */
1931 if (adapter->itr_setting == 3 && adapter->rx_itr == lowest_latency)
1932 adapter->rx_itr = low_latency;
1934 current_itr = max(adapter->rx_itr, adapter->tx_itr);
1936 switch (current_itr) {
1937 /* counts and packets in update_itr are dependent on these numbers */
1938 case lowest_latency:
1942 new_itr = 20000; /* aka hwitr = ~200 */
1952 if (new_itr != adapter->itr) {
1954 * this attempts to bias the interrupt rate towards Bulk
1955 * by adding intermediate steps when interrupt rate is
1958 new_itr = new_itr > adapter->itr ?
1959 min(adapter->itr + (new_itr >> 2), new_itr) :
1961 adapter->itr = new_itr;
1962 adapter->rx_ring->itr_val = new_itr;
1963 if (adapter->msix_entries)
1964 adapter->rx_ring->set_itr = 1;
1966 ew32(ITR, 1000000000 / (new_itr * 256));
1971 * e1000_alloc_queues - Allocate memory for all rings
1972 * @adapter: board private structure to initialize
1974 static int __devinit e1000_alloc_queues(struct e1000_adapter *adapter)
1976 adapter->tx_ring = kzalloc(sizeof(struct e1000_ring), GFP_KERNEL);
1977 if (!adapter->tx_ring)
1980 adapter->rx_ring = kzalloc(sizeof(struct e1000_ring), GFP_KERNEL);
1981 if (!adapter->rx_ring)
1986 e_err("Unable to allocate memory for queues\n");
1987 kfree(adapter->rx_ring);
1988 kfree(adapter->tx_ring);
1993 * e1000_clean - NAPI Rx polling callback
1994 * @napi: struct associated with this polling callback
1995 * @budget: amount of packets driver is allowed to process this poll
1997 static int e1000_clean(struct napi_struct *napi, int budget)
1999 struct e1000_adapter *adapter = container_of(napi, struct e1000_adapter, napi);
2000 struct e1000_hw *hw = &adapter->hw;
2001 struct net_device *poll_dev = adapter->netdev;
2002 int tx_cleaned = 0, work_done = 0;
2004 adapter = netdev_priv(poll_dev);
2006 if (adapter->msix_entries &&
2007 !(adapter->rx_ring->ims_val & adapter->tx_ring->ims_val))
2010 tx_cleaned = e1000_clean_tx_irq(adapter);
2013 adapter->clean_rx(adapter, &work_done, budget);
2018 /* If budget not fully consumed, exit the polling mode */
2019 if (work_done < budget) {
2020 if (adapter->itr_setting & 3)
2021 e1000_set_itr(adapter);
2022 napi_complete(napi);
2023 if (adapter->msix_entries)
2024 ew32(IMS, adapter->rx_ring->ims_val);
2026 e1000_irq_enable(adapter);
2032 static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
2034 struct e1000_adapter *adapter = netdev_priv(netdev);
2035 struct e1000_hw *hw = &adapter->hw;
2038 /* don't update vlan cookie if already programmed */
2039 if ((adapter->hw.mng_cookie.status &
2040 E1000_MNG_DHCP_COOKIE_STATUS_VLAN) &&
2041 (vid == adapter->mng_vlan_id))
2043 /* add VID to filter table */
2044 index = (vid >> 5) & 0x7F;
2045 vfta = E1000_READ_REG_ARRAY(hw, E1000_VFTA, index);
2046 vfta |= (1 << (vid & 0x1F));
2047 e1000e_write_vfta(hw, index, vfta);
2050 static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
2052 struct e1000_adapter *adapter = netdev_priv(netdev);
2053 struct e1000_hw *hw = &adapter->hw;
2056 if (!test_bit(__E1000_DOWN, &adapter->state))
2057 e1000_irq_disable(adapter);
2058 vlan_group_set_device(adapter->vlgrp, vid, NULL);
2060 if (!test_bit(__E1000_DOWN, &adapter->state))
2061 e1000_irq_enable(adapter);
2063 if ((adapter->hw.mng_cookie.status &
2064 E1000_MNG_DHCP_COOKIE_STATUS_VLAN) &&
2065 (vid == adapter->mng_vlan_id)) {
2066 /* release control to f/w */
2067 e1000_release_hw_control(adapter);
2071 /* remove VID from filter table */
2072 index = (vid >> 5) & 0x7F;
2073 vfta = E1000_READ_REG_ARRAY(hw, E1000_VFTA, index);
2074 vfta &= ~(1 << (vid & 0x1F));
2075 e1000e_write_vfta(hw, index, vfta);
2078 static void e1000_update_mng_vlan(struct e1000_adapter *adapter)
2080 struct net_device *netdev = adapter->netdev;
2081 u16 vid = adapter->hw.mng_cookie.vlan_id;
2082 u16 old_vid = adapter->mng_vlan_id;
2084 if (!adapter->vlgrp)
2087 if (!vlan_group_get_device(adapter->vlgrp, vid)) {
2088 adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
2089 if (adapter->hw.mng_cookie.status &
2090 E1000_MNG_DHCP_COOKIE_STATUS_VLAN) {
2091 e1000_vlan_rx_add_vid(netdev, vid);
2092 adapter->mng_vlan_id = vid;
2095 if ((old_vid != (u16)E1000_MNG_VLAN_NONE) &&
2097 !vlan_group_get_device(adapter->vlgrp, old_vid))
2098 e1000_vlan_rx_kill_vid(netdev, old_vid);
2100 adapter->mng_vlan_id = vid;
2105 static void e1000_vlan_rx_register(struct net_device *netdev,
2106 struct vlan_group *grp)
2108 struct e1000_adapter *adapter = netdev_priv(netdev);
2109 struct e1000_hw *hw = &adapter->hw;
2112 if (!test_bit(__E1000_DOWN, &adapter->state))
2113 e1000_irq_disable(adapter);
2114 adapter->vlgrp = grp;
2117 /* enable VLAN tag insert/strip */
2119 ctrl |= E1000_CTRL_VME;
2122 if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) {
2123 /* enable VLAN receive filtering */
2125 rctl &= ~E1000_RCTL_CFIEN;
2127 e1000_update_mng_vlan(adapter);
2130 /* disable VLAN tag insert/strip */
2132 ctrl &= ~E1000_CTRL_VME;
2135 if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) {
2136 if (adapter->mng_vlan_id !=
2137 (u16)E1000_MNG_VLAN_NONE) {
2138 e1000_vlan_rx_kill_vid(netdev,
2139 adapter->mng_vlan_id);
2140 adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
2145 if (!test_bit(__E1000_DOWN, &adapter->state))
2146 e1000_irq_enable(adapter);
2149 static void e1000_restore_vlan(struct e1000_adapter *adapter)
2153 e1000_vlan_rx_register(adapter->netdev, adapter->vlgrp);
2155 if (!adapter->vlgrp)
2158 for (vid = 0; vid < VLAN_GROUP_ARRAY_LEN; vid++) {
2159 if (!vlan_group_get_device(adapter->vlgrp, vid))
2161 e1000_vlan_rx_add_vid(adapter->netdev, vid);
2165 static void e1000_init_manageability(struct e1000_adapter *adapter)
2167 struct e1000_hw *hw = &adapter->hw;
2170 if (!(adapter->flags & FLAG_MNG_PT_ENABLED))
2176 * enable receiving management packets to the host. this will probably
2177 * generate destination unreachable messages from the host OS, but
2178 * the packets will be handled on SMBUS
2180 manc |= E1000_MANC_EN_MNG2HOST;
2181 manc2h = er32(MANC2H);
2182 #define E1000_MNG2HOST_PORT_623 (1 << 5)
2183 #define E1000_MNG2HOST_PORT_664 (1 << 6)
2184 manc2h |= E1000_MNG2HOST_PORT_623;
2185 manc2h |= E1000_MNG2HOST_PORT_664;
2186 ew32(MANC2H, manc2h);
2191 * e1000_configure_tx - Configure 8254x Transmit Unit after Reset
2192 * @adapter: board private structure
2194 * Configure the Tx unit of the MAC after a reset.
2196 static void e1000_configure_tx(struct e1000_adapter *adapter)
2198 struct e1000_hw *hw = &adapter->hw;
2199 struct e1000_ring *tx_ring = adapter->tx_ring;
2201 u32 tdlen, tctl, tipg, tarc;
2204 /* Setup the HW Tx Head and Tail descriptor pointers */
2205 tdba = tx_ring->dma;
2206 tdlen = tx_ring->count * sizeof(struct e1000_tx_desc);
2207 ew32(TDBAL, (tdba & DMA_32BIT_MASK));
2208 ew32(TDBAH, (tdba >> 32));
2212 tx_ring->head = E1000_TDH;
2213 tx_ring->tail = E1000_TDT;
2215 /* Set the default values for the Tx Inter Packet Gap timer */
2216 tipg = DEFAULT_82543_TIPG_IPGT_COPPER; /* 8 */
2217 ipgr1 = DEFAULT_82543_TIPG_IPGR1; /* 8 */
2218 ipgr2 = DEFAULT_82543_TIPG_IPGR2; /* 6 */
2220 if (adapter->flags & FLAG_TIPG_MEDIUM_FOR_80003ESLAN)
2221 ipgr2 = DEFAULT_80003ES2LAN_TIPG_IPGR2; /* 7 */
2223 tipg |= ipgr1 << E1000_TIPG_IPGR1_SHIFT;
2224 tipg |= ipgr2 << E1000_TIPG_IPGR2_SHIFT;
2227 /* Set the Tx Interrupt Delay register */
2228 ew32(TIDV, adapter->tx_int_delay);
2229 /* Tx irq moderation */
2230 ew32(TADV, adapter->tx_abs_int_delay);
2232 /* Program the Transmit Control Register */
2234 tctl &= ~E1000_TCTL_CT;
2235 tctl |= E1000_TCTL_PSP | E1000_TCTL_RTLC |
2236 (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);
2238 if (adapter->flags & FLAG_TARC_SPEED_MODE_BIT) {
2239 tarc = er32(TARC(0));
2241 * set the speed mode bit, we'll clear it if we're not at
2242 * gigabit link later
2244 #define SPEED_MODE_BIT (1 << 21)
2245 tarc |= SPEED_MODE_BIT;
2246 ew32(TARC(0), tarc);
2249 /* errata: program both queues to unweighted RR */
2250 if (adapter->flags & FLAG_TARC_SET_BIT_ZERO) {
2251 tarc = er32(TARC(0));
2253 ew32(TARC(0), tarc);
2254 tarc = er32(TARC(1));
2256 ew32(TARC(1), tarc);
2259 e1000e_config_collision_dist(hw);
2261 /* Setup Transmit Descriptor Settings for eop descriptor */
2262 adapter->txd_cmd = E1000_TXD_CMD_EOP | E1000_TXD_CMD_IFCS;
2264 /* only set IDE if we are delaying interrupts using the timers */
2265 if (adapter->tx_int_delay)
2266 adapter->txd_cmd |= E1000_TXD_CMD_IDE;
2268 /* enable Report Status bit */
2269 adapter->txd_cmd |= E1000_TXD_CMD_RS;
2273 adapter->tx_queue_len = adapter->netdev->tx_queue_len;
2277 * e1000_setup_rctl - configure the receive control registers
2278 * @adapter: Board private structure
2280 #define PAGE_USE_COUNT(S) (((S) >> PAGE_SHIFT) + \
2281 (((S) & (PAGE_SIZE - 1)) ? 1 : 0))
2282 static void e1000_setup_rctl(struct e1000_adapter *adapter)
2284 struct e1000_hw *hw = &adapter->hw;
2289 /* Program MC offset vector base */
2291 rctl &= ~(3 << E1000_RCTL_MO_SHIFT);
2292 rctl |= E1000_RCTL_EN | E1000_RCTL_BAM |
2293 E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF |
2294 (adapter->hw.mac.mc_filter_type << E1000_RCTL_MO_SHIFT);
2296 /* Do not Store bad packets */
2297 rctl &= ~E1000_RCTL_SBP;
2299 /* Enable Long Packet receive */
2300 if (adapter->netdev->mtu <= ETH_DATA_LEN)
2301 rctl &= ~E1000_RCTL_LPE;
2303 rctl |= E1000_RCTL_LPE;
2305 /* Some systems expect that the CRC is included in SMBUS traffic. The
2306 * hardware strips the CRC before sending to both SMBUS (BMC) and to
2307 * host memory when this is enabled
2309 if (adapter->flags2 & FLAG2_CRC_STRIPPING)
2310 rctl |= E1000_RCTL_SECRC;
2312 /* Setup buffer sizes */
2313 rctl &= ~E1000_RCTL_SZ_4096;
2314 rctl |= E1000_RCTL_BSEX;
2315 switch (adapter->rx_buffer_len) {
2317 rctl |= E1000_RCTL_SZ_256;
2318 rctl &= ~E1000_RCTL_BSEX;
2321 rctl |= E1000_RCTL_SZ_512;
2322 rctl &= ~E1000_RCTL_BSEX;
2325 rctl |= E1000_RCTL_SZ_1024;
2326 rctl &= ~E1000_RCTL_BSEX;
2330 rctl |= E1000_RCTL_SZ_2048;
2331 rctl &= ~E1000_RCTL_BSEX;
2334 rctl |= E1000_RCTL_SZ_4096;
2337 rctl |= E1000_RCTL_SZ_8192;
2340 rctl |= E1000_RCTL_SZ_16384;
2345 * 82571 and greater support packet-split where the protocol
2346 * header is placed in skb->data and the packet data is
2347 * placed in pages hanging off of skb_shinfo(skb)->nr_frags.
2348 * In the case of a non-split, skb->data is linearly filled,
2349 * followed by the page buffers. Therefore, skb->data is
2350 * sized to hold the largest protocol header.
2352 * allocations using alloc_page take too long for regular MTU
2353 * so only enable packet split for jumbo frames
2355 * Using pages when the page size is greater than 16k wastes
2356 * a lot of memory, since we allocate 3 pages at all times
2359 pages = PAGE_USE_COUNT(adapter->netdev->mtu);
2360 if (!(adapter->flags & FLAG_IS_ICH) && (pages <= 3) &&
2361 (PAGE_SIZE <= 16384) && (rctl & E1000_RCTL_LPE))
2362 adapter->rx_ps_pages = pages;
2364 adapter->rx_ps_pages = 0;
2366 if (adapter->rx_ps_pages) {
2367 /* Configure extra packet-split registers */
2368 rfctl = er32(RFCTL);
2369 rfctl |= E1000_RFCTL_EXTEN;
2371 * disable packet split support for IPv6 extension headers,
2372 * because some malformed IPv6 headers can hang the Rx
2374 rfctl |= (E1000_RFCTL_IPV6_EX_DIS |
2375 E1000_RFCTL_NEW_IPV6_EXT_DIS);
2379 /* Enable Packet split descriptors */
2380 rctl |= E1000_RCTL_DTYP_PS;
2382 psrctl |= adapter->rx_ps_bsize0 >>
2383 E1000_PSRCTL_BSIZE0_SHIFT;
2385 switch (adapter->rx_ps_pages) {
2387 psrctl |= PAGE_SIZE <<
2388 E1000_PSRCTL_BSIZE3_SHIFT;
2390 psrctl |= PAGE_SIZE <<
2391 E1000_PSRCTL_BSIZE2_SHIFT;
2393 psrctl |= PAGE_SIZE >>
2394 E1000_PSRCTL_BSIZE1_SHIFT;
2398 ew32(PSRCTL, psrctl);
2402 /* just started the receive unit, no need to restart */
2403 adapter->flags &= ~FLAG_RX_RESTART_NOW;
2407 * e1000_configure_rx - Configure Receive Unit after Reset
2408 * @adapter: board private structure
2410 * Configure the Rx unit of the MAC after a reset.
2412 static void e1000_configure_rx(struct e1000_adapter *adapter)
2414 struct e1000_hw *hw = &adapter->hw;
2415 struct e1000_ring *rx_ring = adapter->rx_ring;
2417 u32 rdlen, rctl, rxcsum, ctrl_ext;
2419 if (adapter->rx_ps_pages) {
2420 /* this is a 32 byte descriptor */
2421 rdlen = rx_ring->count *
2422 sizeof(union e1000_rx_desc_packet_split);
2423 adapter->clean_rx = e1000_clean_rx_irq_ps;
2424 adapter->alloc_rx_buf = e1000_alloc_rx_buffers_ps;
2425 } else if (adapter->netdev->mtu > ETH_FRAME_LEN + ETH_FCS_LEN) {
2426 rdlen = rx_ring->count * sizeof(struct e1000_rx_desc);
2427 adapter->clean_rx = e1000_clean_jumbo_rx_irq;
2428 adapter->alloc_rx_buf = e1000_alloc_jumbo_rx_buffers;
2430 rdlen = rx_ring->count * sizeof(struct e1000_rx_desc);
2431 adapter->clean_rx = e1000_clean_rx_irq;
2432 adapter->alloc_rx_buf = e1000_alloc_rx_buffers;
2435 /* disable receives while setting up the descriptors */
2437 ew32(RCTL, rctl & ~E1000_RCTL_EN);
2441 /* set the Receive Delay Timer Register */
2442 ew32(RDTR, adapter->rx_int_delay);
2444 /* irq moderation */
2445 ew32(RADV, adapter->rx_abs_int_delay);
2446 if (adapter->itr_setting != 0)
2447 ew32(ITR, 1000000000 / (adapter->itr * 256));
2449 ctrl_ext = er32(CTRL_EXT);
2450 /* Reset delay timers after every interrupt */
2451 ctrl_ext |= E1000_CTRL_EXT_INT_TIMER_CLR;
2452 /* Auto-Mask interrupts upon ICR access */
2453 ctrl_ext |= E1000_CTRL_EXT_IAME;
2454 ew32(IAM, 0xffffffff);
2455 ew32(CTRL_EXT, ctrl_ext);
2459 * Setup the HW Rx Head and Tail Descriptor Pointers and
2460 * the Base and Length of the Rx Descriptor Ring
2462 rdba = rx_ring->dma;
2463 ew32(RDBAL, (rdba & DMA_32BIT_MASK));
2464 ew32(RDBAH, (rdba >> 32));
2468 rx_ring->head = E1000_RDH;
2469 rx_ring->tail = E1000_RDT;
2471 /* Enable Receive Checksum Offload for TCP and UDP */
2472 rxcsum = er32(RXCSUM);
2473 if (adapter->flags & FLAG_RX_CSUM_ENABLED) {
2474 rxcsum |= E1000_RXCSUM_TUOFL;
2477 * IPv4 payload checksum for UDP fragments must be
2478 * used in conjunction with packet-split.
2480 if (adapter->rx_ps_pages)
2481 rxcsum |= E1000_RXCSUM_IPPCSE;
2483 rxcsum &= ~E1000_RXCSUM_TUOFL;
2484 /* no need to clear IPPCSE as it defaults to 0 */
2486 ew32(RXCSUM, rxcsum);
2489 * Enable early receives on supported devices, only takes effect when
2490 * packet size is equal or larger than the specified value (in 8 byte
2491 * units), e.g. using jumbo frames when setting to E1000_ERT_2048
2493 if ((adapter->flags & FLAG_HAS_ERT) &&
2494 (adapter->netdev->mtu > ETH_DATA_LEN)) {
2495 u32 rxdctl = er32(RXDCTL(0));
2496 ew32(RXDCTL(0), rxdctl | 0x3);
2497 ew32(ERT, E1000_ERT_2048 | (1 << 13));
2499 * With jumbo frames and early-receive enabled, excessive
2500 * C4->C2 latencies result in dropped transactions.
2502 pm_qos_update_requirement(PM_QOS_CPU_DMA_LATENCY,
2503 e1000e_driver_name, 55);
2505 pm_qos_update_requirement(PM_QOS_CPU_DMA_LATENCY,
2507 PM_QOS_DEFAULT_VALUE);
2510 /* Enable Receives */
2515 * e1000_update_mc_addr_list - Update Multicast addresses
2516 * @hw: pointer to the HW structure
2517 * @mc_addr_list: array of multicast addresses to program
2518 * @mc_addr_count: number of multicast addresses to program
2519 * @rar_used_count: the first RAR register free to program
2520 * @rar_count: total number of supported Receive Address Registers
2522 * Updates the Receive Address Registers and Multicast Table Array.
2523 * The caller must have a packed mc_addr_list of multicast addresses.
2524 * The parameter rar_count will usually be hw->mac.rar_entry_count
2525 * unless there are workarounds that change this. Currently no func pointer
2526 * exists and all implementations are handled in the generic version of this
2529 static void e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list,
2530 u32 mc_addr_count, u32 rar_used_count,
2533 hw->mac.ops.update_mc_addr_list(hw, mc_addr_list, mc_addr_count,
2534 rar_used_count, rar_count);
2538 * e1000_set_multi - Multicast and Promiscuous mode set
2539 * @netdev: network interface device structure
2541 * The set_multi entry point is called whenever the multicast address
2542 * list or the network interface flags are updated. This routine is
2543 * responsible for configuring the hardware for proper multicast,
2544 * promiscuous mode, and all-multi behavior.
2546 static void e1000_set_multi(struct net_device *netdev)
2548 struct e1000_adapter *adapter = netdev_priv(netdev);
2549 struct e1000_hw *hw = &adapter->hw;
2550 struct e1000_mac_info *mac = &hw->mac;
2551 struct dev_mc_list *mc_ptr;
2556 /* Check for Promiscuous and All Multicast modes */
2560 if (netdev->flags & IFF_PROMISC) {
2561 rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
2562 rctl &= ~E1000_RCTL_VFE;
2564 if (netdev->flags & IFF_ALLMULTI) {
2565 rctl |= E1000_RCTL_MPE;
2566 rctl &= ~E1000_RCTL_UPE;
2568 rctl &= ~(E1000_RCTL_UPE | E1000_RCTL_MPE);
2570 if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER)
2571 rctl |= E1000_RCTL_VFE;
2576 if (netdev->mc_count) {
2577 mta_list = kmalloc(netdev->mc_count * 6, GFP_ATOMIC);
2581 /* prepare a packed array of only addresses. */
2582 mc_ptr = netdev->mc_list;
2584 for (i = 0; i < netdev->mc_count; i++) {
2587 memcpy(mta_list + (i*ETH_ALEN), mc_ptr->dmi_addr,
2589 mc_ptr = mc_ptr->next;
2592 e1000_update_mc_addr_list(hw, mta_list, i, 1,
2593 mac->rar_entry_count);
2597 * if we're called from probe, we might not have
2598 * anything to do here, so clear out the list
2600 e1000_update_mc_addr_list(hw, NULL, 0, 1, mac->rar_entry_count);
2605 * e1000_configure - configure the hardware for Rx and Tx
2606 * @adapter: private board structure
2608 static void e1000_configure(struct e1000_adapter *adapter)
2610 e1000_set_multi(adapter->netdev);
2612 e1000_restore_vlan(adapter);
2613 e1000_init_manageability(adapter);
2615 e1000_configure_tx(adapter);
2616 e1000_setup_rctl(adapter);
2617 e1000_configure_rx(adapter);
2618 adapter->alloc_rx_buf(adapter, e1000_desc_unused(adapter->rx_ring));
2622 * e1000e_power_up_phy - restore link in case the phy was powered down
2623 * @adapter: address of board private structure
2625 * The phy may be powered down to save power and turn off link when the
2626 * driver is unloaded and wake on lan is not enabled (among others)
2627 * *** this routine MUST be followed by a call to e1000e_reset ***
2629 void e1000e_power_up_phy(struct e1000_adapter *adapter)
2633 /* Just clear the power down bit to wake the phy back up */
2634 if (adapter->hw.phy.media_type == e1000_media_type_copper) {
2636 * According to the manual, the phy will retain its
2637 * settings across a power-down/up cycle
2639 e1e_rphy(&adapter->hw, PHY_CONTROL, &mii_reg);
2640 mii_reg &= ~MII_CR_POWER_DOWN;
2641 e1e_wphy(&adapter->hw, PHY_CONTROL, mii_reg);
2644 adapter->hw.mac.ops.setup_link(&adapter->hw);
2648 * e1000_power_down_phy - Power down the PHY
2650 * Power down the PHY so no link is implied when interface is down
2651 * The PHY cannot be powered down is management or WoL is active
2653 static void e1000_power_down_phy(struct e1000_adapter *adapter)
2655 struct e1000_hw *hw = &adapter->hw;
2658 /* WoL is enabled */
2662 /* non-copper PHY? */
2663 if (adapter->hw.phy.media_type != e1000_media_type_copper)
2666 /* reset is blocked because of a SoL/IDER session */
2667 if (e1000e_check_mng_mode(hw) || e1000_check_reset_block(hw))
2670 /* manageability (AMT) is enabled */
2671 if (er32(MANC) & E1000_MANC_SMBUS_EN)
2674 /* power down the PHY */
2675 e1e_rphy(hw, PHY_CONTROL, &mii_reg);
2676 mii_reg |= MII_CR_POWER_DOWN;
2677 e1e_wphy(hw, PHY_CONTROL, mii_reg);
2682 * e1000e_reset - bring the hardware into a known good state
2684 * This function boots the hardware and enables some settings that
2685 * require a configuration cycle of the hardware - those cannot be
2686 * set/changed during runtime. After reset the device needs to be
2687 * properly configured for Rx, Tx etc.
2689 void e1000e_reset(struct e1000_adapter *adapter)
2691 struct e1000_mac_info *mac = &adapter->hw.mac;
2692 struct e1000_fc_info *fc = &adapter->hw.fc;
2693 struct e1000_hw *hw = &adapter->hw;
2694 u32 tx_space, min_tx_space, min_rx_space;
2695 u32 pba = adapter->pba;
2698 /* reset Packet Buffer Allocation to default */
2701 if (adapter->max_frame_size > ETH_FRAME_LEN + ETH_FCS_LEN) {
2703 * To maintain wire speed transmits, the Tx FIFO should be
2704 * large enough to accommodate two full transmit packets,
2705 * rounded up to the next 1KB and expressed in KB. Likewise,
2706 * the Rx FIFO should be large enough to accommodate at least
2707 * one full receive packet and is similarly rounded up and
2711 /* upper 16 bits has Tx packet buffer allocation size in KB */
2712 tx_space = pba >> 16;
2713 /* lower 16 bits has Rx packet buffer allocation size in KB */
2716 * the Tx fifo also stores 16 bytes of information about the tx
2717 * but don't include ethernet FCS because hardware appends it
2719 min_tx_space = (adapter->max_frame_size +
2720 sizeof(struct e1000_tx_desc) -
2722 min_tx_space = ALIGN(min_tx_space, 1024);
2723 min_tx_space >>= 10;
2724 /* software strips receive CRC, so leave room for it */
2725 min_rx_space = adapter->max_frame_size;
2726 min_rx_space = ALIGN(min_rx_space, 1024);
2727 min_rx_space >>= 10;
2730 * If current Tx allocation is less than the min Tx FIFO size,
2731 * and the min Tx FIFO size is less than the current Rx FIFO
2732 * allocation, take space away from current Rx allocation
2734 if ((tx_space < min_tx_space) &&
2735 ((min_tx_space - tx_space) < pba)) {
2736 pba -= min_tx_space - tx_space;
2739 * if short on Rx space, Rx wins and must trump tx
2740 * adjustment or use Early Receive if available
2742 if ((pba < min_rx_space) &&
2743 (!(adapter->flags & FLAG_HAS_ERT)))
2744 /* ERT enabled in e1000_configure_rx */
2753 * flow control settings
2755 * The high water mark must be low enough to fit one full frame
2756 * (or the size used for early receive) above it in the Rx FIFO.
2757 * Set it to the lower of:
2758 * - 90% of the Rx FIFO size, and
2759 * - the full Rx FIFO size minus the early receive size (for parts
2760 * with ERT support assuming ERT set to E1000_ERT_2048), or
2761 * - the full Rx FIFO size minus one full frame
2763 if (adapter->flags & FLAG_HAS_ERT)
2764 hwm = min(((pba << 10) * 9 / 10),
2765 ((pba << 10) - (E1000_ERT_2048 << 3)));
2767 hwm = min(((pba << 10) * 9 / 10),
2768 ((pba << 10) - adapter->max_frame_size));
2770 fc->high_water = hwm & 0xFFF8; /* 8-byte granularity */
2771 fc->low_water = fc->high_water - 8;
2773 if (adapter->flags & FLAG_DISABLE_FC_PAUSE_TIME)
2774 fc->pause_time = 0xFFFF;
2776 fc->pause_time = E1000_FC_PAUSE_TIME;
2778 fc->current_mode = fc->requested_mode;
2780 /* Allow time for pending master requests to run */
2781 mac->ops.reset_hw(hw);
2784 * For parts with AMT enabled, let the firmware know
2785 * that the network interface is in control
2787 if (adapter->flags & FLAG_HAS_AMT)
2788 e1000_get_hw_control(adapter);
2792 if (mac->ops.init_hw(hw))
2793 e_err("Hardware Error\n");
2795 e1000_update_mng_vlan(adapter);
2797 /* Enable h/w to recognize an 802.1Q VLAN Ethernet packet */
2798 ew32(VET, ETH_P_8021Q);
2800 e1000e_reset_adaptive(hw);
2801 e1000_get_phy_info(hw);
2803 if (!(adapter->flags & FLAG_SMART_POWER_DOWN)) {
2806 * speed up time to link by disabling smart power down, ignore
2807 * the return value of this function because there is nothing
2808 * different we would do if it failed
2810 e1e_rphy(hw, IGP02E1000_PHY_POWER_MGMT, &phy_data);
2811 phy_data &= ~IGP02E1000_PM_SPD;
2812 e1e_wphy(hw, IGP02E1000_PHY_POWER_MGMT, phy_data);
2816 int e1000e_up(struct e1000_adapter *adapter)
2818 struct e1000_hw *hw = &adapter->hw;
2820 /* hardware has been reset, we need to reload some things */
2821 e1000_configure(adapter);
2823 clear_bit(__E1000_DOWN, &adapter->state);
2825 napi_enable(&adapter->napi);
2826 if (adapter->msix_entries)
2827 e1000_configure_msix(adapter);
2828 e1000_irq_enable(adapter);
2830 /* fire a link change interrupt to start the watchdog */
2831 ew32(ICS, E1000_ICS_LSC);
2835 void e1000e_down(struct e1000_adapter *adapter)
2837 struct net_device *netdev = adapter->netdev;
2838 struct e1000_hw *hw = &adapter->hw;
2842 * signal that we're down so the interrupt handler does not
2843 * reschedule our watchdog timer
2845 set_bit(__E1000_DOWN, &adapter->state);
2847 /* disable receives in the hardware */
2849 ew32(RCTL, rctl & ~E1000_RCTL_EN);
2850 /* flush and sleep below */
2852 netif_tx_stop_all_queues(netdev);
2854 /* disable transmits in the hardware */
2856 tctl &= ~E1000_TCTL_EN;
2858 /* flush both disables and wait for them to finish */
2862 napi_disable(&adapter->napi);
2863 e1000_irq_disable(adapter);
2865 del_timer_sync(&adapter->watchdog_timer);
2866 del_timer_sync(&adapter->phy_info_timer);
2868 netdev->tx_queue_len = adapter->tx_queue_len;
2869 netif_carrier_off(netdev);
2870 adapter->link_speed = 0;
2871 adapter->link_duplex = 0;
2873 if (!pci_channel_offline(adapter->pdev))
2874 e1000e_reset(adapter);
2875 e1000_clean_tx_ring(adapter);
2876 e1000_clean_rx_ring(adapter);
2879 * TODO: for power management, we could drop the link and
2880 * pci_disable_device here.
2884 void e1000e_reinit_locked(struct e1000_adapter *adapter)
2887 while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
2889 e1000e_down(adapter);
2891 clear_bit(__E1000_RESETTING, &adapter->state);
2895 * e1000_sw_init - Initialize general software structures (struct e1000_adapter)
2896 * @adapter: board private structure to initialize
2898 * e1000_sw_init initializes the Adapter private data structure.
2899 * Fields are initialized based on PCI device information and
2900 * OS network device settings (MTU size).
2902 static int __devinit e1000_sw_init(struct e1000_adapter *adapter)
2904 struct net_device *netdev = adapter->netdev;
2906 adapter->rx_buffer_len = ETH_FRAME_LEN + VLAN_HLEN + ETH_FCS_LEN;
2907 adapter->rx_ps_bsize0 = 128;
2908 adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN;
2909 adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN;
2911 e1000e_set_interrupt_capability(adapter);
2913 if (e1000_alloc_queues(adapter))
2916 /* Explicitly disable IRQ since the NIC can be in any state. */
2917 e1000_irq_disable(adapter);
2919 set_bit(__E1000_DOWN, &adapter->state);
2924 * e1000_intr_msi_test - Interrupt Handler
2925 * @irq: interrupt number
2926 * @data: pointer to a network interface device structure
2928 static irqreturn_t e1000_intr_msi_test(int irq, void *data)
2930 struct net_device *netdev = data;
2931 struct e1000_adapter *adapter = netdev_priv(netdev);
2932 struct e1000_hw *hw = &adapter->hw;
2933 u32 icr = er32(ICR);
2935 e_dbg("%s: icr is %08X\n", netdev->name, icr);
2936 if (icr & E1000_ICR_RXSEQ) {
2937 adapter->flags &= ~FLAG_MSI_TEST_FAILED;
2945 * e1000_test_msi_interrupt - Returns 0 for successful test
2946 * @adapter: board private struct
2948 * code flow taken from tg3.c
2950 static int e1000_test_msi_interrupt(struct e1000_adapter *adapter)
2952 struct net_device *netdev = adapter->netdev;
2953 struct e1000_hw *hw = &adapter->hw;
2956 /* poll_enable hasn't been called yet, so don't need disable */
2957 /* clear any pending events */
2960 /* free the real vector and request a test handler */
2961 e1000_free_irq(adapter);
2962 e1000e_reset_interrupt_capability(adapter);
2964 /* Assume that the test fails, if it succeeds then the test
2965 * MSI irq handler will unset this flag */
2966 adapter->flags |= FLAG_MSI_TEST_FAILED;
2968 err = pci_enable_msi(adapter->pdev);
2970 goto msi_test_failed;
2972 err = request_irq(adapter->pdev->irq, &e1000_intr_msi_test, 0,
2973 netdev->name, netdev);
2975 pci_disable_msi(adapter->pdev);
2976 goto msi_test_failed;
2981 e1000_irq_enable(adapter);
2983 /* fire an unusual interrupt on the test handler */
2984 ew32(ICS, E1000_ICS_RXSEQ);
2988 e1000_irq_disable(adapter);
2992 if (adapter->flags & FLAG_MSI_TEST_FAILED) {
2993 adapter->int_mode = E1000E_INT_MODE_LEGACY;
2995 e_info("MSI interrupt test failed!\n");
2998 free_irq(adapter->pdev->irq, netdev);
2999 pci_disable_msi(adapter->pdev);
3002 goto msi_test_failed;
3004 /* okay so the test worked, restore settings */
3005 e_dbg("%s: MSI interrupt test succeeded!\n", netdev->name);
3007 e1000e_set_interrupt_capability(adapter);
3008 e1000_request_irq(adapter);
3013 * e1000_test_msi - Returns 0 if MSI test succeeds or INTx mode is restored
3014 * @adapter: board private struct
3016 * code flow taken from tg3.c, called with e1000 interrupts disabled.
3018 static int e1000_test_msi(struct e1000_adapter *adapter)
3023 if (!(adapter->flags & FLAG_MSI_ENABLED))
3026 /* disable SERR in case the MSI write causes a master abort */
3027 pci_read_config_word(adapter->pdev, PCI_COMMAND, &pci_cmd);
3028 pci_write_config_word(adapter->pdev, PCI_COMMAND,
3029 pci_cmd & ~PCI_COMMAND_SERR);
3031 err = e1000_test_msi_interrupt(adapter);
3033 /* restore previous setting of command word */
3034 pci_write_config_word(adapter->pdev, PCI_COMMAND, pci_cmd);
3040 /* EIO means MSI test failed */
3044 /* back to INTx mode */
3045 e_warn("MSI interrupt test failed, using legacy interrupt.\n");
3047 e1000_free_irq(adapter);
3049 err = e1000_request_irq(adapter);
3055 * e1000_open - Called when a network interface is made active
3056 * @netdev: network interface device structure
3058 * Returns 0 on success, negative value on failure
3060 * The open entry point is called when a network interface is made
3061 * active by the system (IFF_UP). At this point all resources needed
3062 * for transmit and receive operations are allocated, the interrupt
3063 * handler is registered with the OS, the watchdog timer is started,
3064 * and the stack is notified that the interface is ready.
3066 static int e1000_open(struct net_device *netdev)
3068 struct e1000_adapter *adapter = netdev_priv(netdev);
3069 struct e1000_hw *hw = &adapter->hw;
3072 /* disallow open during test */
3073 if (test_bit(__E1000_TESTING, &adapter->state))
3076 /* allocate transmit descriptors */
3077 err = e1000e_setup_tx_resources(adapter);
3081 /* allocate receive descriptors */
3082 err = e1000e_setup_rx_resources(adapter);
3086 e1000e_power_up_phy(adapter);
3088 adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
3089 if ((adapter->hw.mng_cookie.status &
3090 E1000_MNG_DHCP_COOKIE_STATUS_VLAN))
3091 e1000_update_mng_vlan(adapter);
3094 * If AMT is enabled, let the firmware know that the network
3095 * interface is now open
3097 if (adapter->flags & FLAG_HAS_AMT)
3098 e1000_get_hw_control(adapter);
3101 * before we allocate an interrupt, we must be ready to handle it.
3102 * Setting DEBUG_SHIRQ in the kernel makes it fire an interrupt
3103 * as soon as we call pci_request_irq, so we have to setup our
3104 * clean_rx handler before we do so.
3106 e1000_configure(adapter);
3108 err = e1000_request_irq(adapter);
3113 * Work around PCIe errata with MSI interrupts causing some chipsets to
3114 * ignore e1000e MSI messages, which means we need to test our MSI
3117 if (adapter->int_mode != E1000E_INT_MODE_LEGACY) {
3118 err = e1000_test_msi(adapter);
3120 e_err("Interrupt allocation failed\n");
3125 /* From here on the code is the same as e1000e_up() */
3126 clear_bit(__E1000_DOWN, &adapter->state);
3128 napi_enable(&adapter->napi);
3130 e1000_irq_enable(adapter);
3132 netif_tx_start_all_queues(netdev);
3134 /* fire a link status change interrupt to start the watchdog */
3135 ew32(ICS, E1000_ICS_LSC);
3140 e1000_release_hw_control(adapter);
3141 e1000_power_down_phy(adapter);
3142 e1000e_free_rx_resources(adapter);
3144 e1000e_free_tx_resources(adapter);
3146 e1000e_reset(adapter);
3152 * e1000_close - Disables a network interface
3153 * @netdev: network interface device structure
3155 * Returns 0, this is not allowed to fail
3157 * The close entry point is called when an interface is de-activated
3158 * by the OS. The hardware is still under the drivers control, but
3159 * needs to be disabled. A global MAC reset is issued to stop the
3160 * hardware, and all transmit and receive resources are freed.
3162 static int e1000_close(struct net_device *netdev)
3164 struct e1000_adapter *adapter = netdev_priv(netdev);
3166 WARN_ON(test_bit(__E1000_RESETTING, &adapter->state));
3167 e1000e_down(adapter);
3168 e1000_power_down_phy(adapter);
3169 e1000_free_irq(adapter);
3171 e1000e_free_tx_resources(adapter);
3172 e1000e_free_rx_resources(adapter);
3175 * kill manageability vlan ID if supported, but not if a vlan with
3176 * the same ID is registered on the host OS (let 8021q kill it)
3178 if ((adapter->hw.mng_cookie.status &
3179 E1000_MNG_DHCP_COOKIE_STATUS_VLAN) &&
3181 vlan_group_get_device(adapter->vlgrp, adapter->mng_vlan_id)))
3182 e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
3185 * If AMT is enabled, let the firmware know that the network
3186 * interface is now closed
3188 if (adapter->flags & FLAG_HAS_AMT)
3189 e1000_release_hw_control(adapter);
3194 * e1000_set_mac - Change the Ethernet Address of the NIC
3195 * @netdev: network interface device structure
3196 * @p: pointer to an address structure
3198 * Returns 0 on success, negative on failure
3200 static int e1000_set_mac(struct net_device *netdev, void *p)
3202 struct e1000_adapter *adapter = netdev_priv(netdev);
3203 struct sockaddr *addr = p;
3205 if (!is_valid_ether_addr(addr->sa_data))
3206 return -EADDRNOTAVAIL;
3208 memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
3209 memcpy(adapter->hw.mac.addr, addr->sa_data, netdev->addr_len);
3211 e1000e_rar_set(&adapter->hw, adapter->hw.mac.addr, 0);
3213 if (adapter->flags & FLAG_RESET_OVERWRITES_LAA) {
3214 /* activate the work around */
3215 e1000e_set_laa_state_82571(&adapter->hw, 1);
3218 * Hold a copy of the LAA in RAR[14] This is done so that
3219 * between the time RAR[0] gets clobbered and the time it
3220 * gets fixed (in e1000_watchdog), the actual LAA is in one
3221 * of the RARs and no incoming packets directed to this port
3222 * are dropped. Eventually the LAA will be in RAR[0] and
3225 e1000e_rar_set(&adapter->hw,
3226 adapter->hw.mac.addr,
3227 adapter->hw.mac.rar_entry_count - 1);
3234 * e1000e_update_phy_task - work thread to update phy
3235 * @work: pointer to our work struct
3237 * this worker thread exists because we must acquire a
3238 * semaphore to read the phy, which we could msleep while
3239 * waiting for it, and we can't msleep in a timer.
3241 static void e1000e_update_phy_task(struct work_struct *work)
3243 struct e1000_adapter *adapter = container_of(work,
3244 struct e1000_adapter, update_phy_task);
3245 e1000_get_phy_info(&adapter->hw);
3249 * Need to wait a few seconds after link up to get diagnostic information from
3252 static void e1000_update_phy_info(unsigned long data)
3254 struct e1000_adapter *adapter = (struct e1000_adapter *) data;
3255 schedule_work(&adapter->update_phy_task);
3259 * e1000e_update_stats - Update the board statistics counters
3260 * @adapter: board private structure
3262 void e1000e_update_stats(struct e1000_adapter *adapter)
3264 struct e1000_hw *hw = &adapter->hw;
3265 struct pci_dev *pdev = adapter->pdev;
3268 * Prevent stats update while adapter is being reset, or if the pci
3269 * connection is down.
3271 if (adapter->link_speed == 0)
3273 if (pci_channel_offline(pdev))
3276 adapter->stats.crcerrs += er32(CRCERRS);
3277 adapter->stats.gprc += er32(GPRC);
3278 adapter->stats.gorc += er32(GORCL);
3279 er32(GORCH); /* Clear gorc */
3280 adapter->stats.bprc += er32(BPRC);
3281 adapter->stats.mprc += er32(MPRC);
3282 adapter->stats.roc += er32(ROC);
3284 adapter->stats.mpc += er32(MPC);
3285 adapter->stats.scc += er32(SCC);
3286 adapter->stats.ecol += er32(ECOL);
3287 adapter->stats.mcc += er32(MCC);
3288 adapter->stats.latecol += er32(LATECOL);
3289 adapter->stats.dc += er32(DC);
3290 adapter->stats.xonrxc += er32(XONRXC);
3291 adapter->stats.xontxc += er32(XONTXC);
3292 adapter->stats.xoffrxc += er32(XOFFRXC);
3293 adapter->stats.xofftxc += er32(XOFFTXC);
3294 adapter->stats.gptc += er32(GPTC);
3295 adapter->stats.gotc += er32(GOTCL);
3296 er32(GOTCH); /* Clear gotc */
3297 adapter->stats.rnbc += er32(RNBC);
3298 adapter->stats.ruc += er32(RUC);
3300 adapter->stats.mptc += er32(MPTC);
3301 adapter->stats.bptc += er32(BPTC);
3303 /* used for adaptive IFS */
3305 hw->mac.tx_packet_delta = er32(TPT);
3306 adapter->stats.tpt += hw->mac.tx_packet_delta;
3307 hw->mac.collision_delta = er32(COLC);
3308 adapter->stats.colc += hw->mac.collision_delta;
3310 adapter->stats.algnerrc += er32(ALGNERRC);
3311 adapter->stats.rxerrc += er32(RXERRC);
3312 if (hw->mac.type != e1000_82574)
3313 adapter->stats.tncrs += er32(TNCRS);
3314 adapter->stats.cexterr += er32(CEXTERR);
3315 adapter->stats.tsctc += er32(TSCTC);
3316 adapter->stats.tsctfc += er32(TSCTFC);
3318 /* Fill out the OS statistics structure */
3319 adapter->net_stats.multicast = adapter->stats.mprc;
3320 adapter->net_stats.collisions = adapter->stats.colc;
3325 * RLEC on some newer hardware can be incorrect so build
3326 * our own version based on RUC and ROC
3328 adapter->net_stats.rx_errors = adapter->stats.rxerrc +
3329 adapter->stats.crcerrs + adapter->stats.algnerrc +
3330 adapter->stats.ruc + adapter->stats.roc +
3331 adapter->stats.cexterr;
3332 adapter->net_stats.rx_length_errors = adapter->stats.ruc +
3334 adapter->net_stats.rx_crc_errors = adapter->stats.crcerrs;
3335 adapter->net_stats.rx_frame_errors = adapter->stats.algnerrc;
3336 adapter->net_stats.rx_missed_errors = adapter->stats.mpc;
3339 adapter->net_stats.tx_errors = adapter->stats.ecol +
3340 adapter->stats.latecol;
3341 adapter->net_stats.tx_aborted_errors = adapter->stats.ecol;
3342 adapter->net_stats.tx_window_errors = adapter->stats.latecol;
3343 adapter->net_stats.tx_carrier_errors = adapter->stats.tncrs;
3345 /* Tx Dropped needs to be maintained elsewhere */
3347 /* Management Stats */
3348 adapter->stats.mgptc += er32(MGTPTC);
3349 adapter->stats.mgprc += er32(MGTPRC);
3350 adapter->stats.mgpdc += er32(MGTPDC);
3354 * e1000_phy_read_status - Update the PHY register status snapshot
3355 * @adapter: board private structure
3357 static void e1000_phy_read_status(struct e1000_adapter *adapter)
3359 struct e1000_hw *hw = &adapter->hw;
3360 struct e1000_phy_regs *phy = &adapter->phy_regs;
3363 if ((er32(STATUS) & E1000_STATUS_LU) &&
3364 (adapter->hw.phy.media_type == e1000_media_type_copper)) {
3365 ret_val = e1e_rphy(hw, PHY_CONTROL, &phy->bmcr);
3366 ret_val |= e1e_rphy(hw, PHY_STATUS, &phy->bmsr);
3367 ret_val |= e1e_rphy(hw, PHY_AUTONEG_ADV, &phy->advertise);
3368 ret_val |= e1e_rphy(hw, PHY_LP_ABILITY, &phy->lpa);
3369 ret_val |= e1e_rphy(hw, PHY_AUTONEG_EXP, &phy->expansion);
3370 ret_val |= e1e_rphy(hw, PHY_1000T_CTRL, &phy->ctrl1000);
3371 ret_val |= e1e_rphy(hw, PHY_1000T_STATUS, &phy->stat1000);
3372 ret_val |= e1e_rphy(hw, PHY_EXT_STATUS, &phy->estatus);
3374 e_warn("Error reading PHY register\n");
3377 * Do not read PHY registers if link is not up
3378 * Set values to typical power-on defaults
3380 phy->bmcr = (BMCR_SPEED1000 | BMCR_ANENABLE | BMCR_FULLDPLX);
3381 phy->bmsr = (BMSR_100FULL | BMSR_100HALF | BMSR_10FULL |
3382 BMSR_10HALF | BMSR_ESTATEN | BMSR_ANEGCAPABLE |
3384 phy->advertise = (ADVERTISE_PAUSE_ASYM | ADVERTISE_PAUSE_CAP |
3385 ADVERTISE_ALL | ADVERTISE_CSMA);
3387 phy->expansion = EXPANSION_ENABLENPAGE;
3388 phy->ctrl1000 = ADVERTISE_1000FULL;
3390 phy->estatus = (ESTATUS_1000_TFULL | ESTATUS_1000_THALF);
3394 static void e1000_print_link_info(struct e1000_adapter *adapter)
3396 struct e1000_hw *hw = &adapter->hw;
3397 u32 ctrl = er32(CTRL);
3399 /* Link status message must follow this format for user tools */
3400 printk(KERN_INFO "e1000e: %s NIC Link is Up %d Mbps %s, "
3401 "Flow Control: %s\n",
3402 adapter->netdev->name,
3403 adapter->link_speed,
3404 (adapter->link_duplex == FULL_DUPLEX) ?
3405 "Full Duplex" : "Half Duplex",
3406 ((ctrl & E1000_CTRL_TFCE) && (ctrl & E1000_CTRL_RFCE)) ?
3408 ((ctrl & E1000_CTRL_RFCE) ? "RX" :
3409 ((ctrl & E1000_CTRL_TFCE) ? "TX" : "None" )));
3412 bool e1000_has_link(struct e1000_adapter *adapter)
3414 struct e1000_hw *hw = &adapter->hw;
3415 bool link_active = 0;
3419 * get_link_status is set on LSC (link status) interrupt or
3420 * Rx sequence error interrupt. get_link_status will stay
3421 * false until the check_for_link establishes link
3422 * for copper adapters ONLY
3424 switch (hw->phy.media_type) {
3425 case e1000_media_type_copper:
3426 if (hw->mac.get_link_status) {
3427 ret_val = hw->mac.ops.check_for_link(hw);
3428 link_active = !hw->mac.get_link_status;
3433 case e1000_media_type_fiber:
3434 ret_val = hw->mac.ops.check_for_link(hw);
3435 link_active = !!(er32(STATUS) & E1000_STATUS_LU);
3437 case e1000_media_type_internal_serdes:
3438 ret_val = hw->mac.ops.check_for_link(hw);
3439 link_active = adapter->hw.mac.serdes_has_link;
3442 case e1000_media_type_unknown:
3446 if ((ret_val == E1000_ERR_PHY) && (hw->phy.type == e1000_phy_igp_3) &&
3447 (er32(CTRL) & E1000_PHY_CTRL_GBE_DISABLE)) {
3448 /* See e1000_kmrn_lock_loss_workaround_ich8lan() */
3449 e_info("Gigabit has been disabled, downgrading speed\n");
3455 static void e1000e_enable_receives(struct e1000_adapter *adapter)
3457 /* make sure the receive unit is started */
3458 if ((adapter->flags & FLAG_RX_NEEDS_RESTART) &&
3459 (adapter->flags & FLAG_RX_RESTART_NOW)) {
3460 struct e1000_hw *hw = &adapter->hw;
3461 u32 rctl = er32(RCTL);
3462 ew32(RCTL, rctl | E1000_RCTL_EN);
3463 adapter->flags &= ~FLAG_RX_RESTART_NOW;
3468 * e1000_watchdog - Timer Call-back
3469 * @data: pointer to adapter cast into an unsigned long
3471 static void e1000_watchdog(unsigned long data)
3473 struct e1000_adapter *adapter = (struct e1000_adapter *) data;
3475 /* Do the rest outside of interrupt context */
3476 schedule_work(&adapter->watchdog_task);
3478 /* TODO: make this use queue_delayed_work() */
3481 static void e1000_watchdog_task(struct work_struct *work)
3483 struct e1000_adapter *adapter = container_of(work,
3484 struct e1000_adapter, watchdog_task);
3485 struct net_device *netdev = adapter->netdev;
3486 struct e1000_mac_info *mac = &adapter->hw.mac;
3487 struct e1000_phy_info *phy = &adapter->hw.phy;
3488 struct e1000_ring *tx_ring = adapter->tx_ring;
3489 struct e1000_hw *hw = &adapter->hw;
3493 link = e1000_has_link(adapter);
3494 if ((netif_carrier_ok(netdev)) && link) {
3495 e1000e_enable_receives(adapter);
3499 if ((e1000e_enable_tx_pkt_filtering(hw)) &&
3500 (adapter->mng_vlan_id != adapter->hw.mng_cookie.vlan_id))
3501 e1000_update_mng_vlan(adapter);
3504 if (!netif_carrier_ok(netdev)) {
3506 /* update snapshot of PHY registers on LSC */
3507 e1000_phy_read_status(adapter);
3508 mac->ops.get_link_up_info(&adapter->hw,
3509 &adapter->link_speed,
3510 &adapter->link_duplex);
3511 e1000_print_link_info(adapter);
3513 * On supported PHYs, check for duplex mismatch only
3514 * if link has autonegotiated at 10/100 half
3516 if ((hw->phy.type == e1000_phy_igp_3 ||
3517 hw->phy.type == e1000_phy_bm) &&
3518 (hw->mac.autoneg == true) &&
3519 (adapter->link_speed == SPEED_10 ||
3520 adapter->link_speed == SPEED_100) &&
3521 (adapter->link_duplex == HALF_DUPLEX)) {
3524 e1e_rphy(hw, PHY_AUTONEG_EXP, &autoneg_exp);
3526 if (!(autoneg_exp & NWAY_ER_LP_NWAY_CAPS))
3527 e_info("Autonegotiated half duplex but"
3528 " link partner cannot autoneg. "
3529 " Try forcing full duplex if "
3530 "link gets many collisions.\n");
3534 * tweak tx_queue_len according to speed/duplex
3535 * and adjust the timeout factor
3537 netdev->tx_queue_len = adapter->tx_queue_len;
3538 adapter->tx_timeout_factor = 1;
3539 switch (adapter->link_speed) {
3542 netdev->tx_queue_len = 10;
3543 adapter->tx_timeout_factor = 16;
3547 netdev->tx_queue_len = 100;
3548 /* maybe add some timeout factor ? */
3553 * workaround: re-program speed mode bit after
3556 if ((adapter->flags & FLAG_TARC_SPEED_MODE_BIT) &&
3559 tarc0 = er32(TARC(0));
3560 tarc0 &= ~SPEED_MODE_BIT;
3561 ew32(TARC(0), tarc0);
3565 * disable TSO for pcie and 10/100 speeds, to avoid
3566 * some hardware issues
3568 if (!(adapter->flags & FLAG_TSO_FORCE)) {
3569 switch (adapter->link_speed) {
3572 e_info("10/100 speed: disabling TSO\n");
3573 netdev->features &= ~NETIF_F_TSO;
3574 netdev->features &= ~NETIF_F_TSO6;
3577 netdev->features |= NETIF_F_TSO;
3578 netdev->features |= NETIF_F_TSO6;
3587 * enable transmits in the hardware, need to do this
3588 * after setting TARC(0)
3591 tctl |= E1000_TCTL_EN;
3595 * Perform any post-link-up configuration before
3596 * reporting link up.
3598 if (phy->ops.cfg_on_link_up)
3599 phy->ops.cfg_on_link_up(hw);
3601 netif_carrier_on(netdev);
3602 netif_tx_wake_all_queues(netdev);
3604 if (!test_bit(__E1000_DOWN, &adapter->state))
3605 mod_timer(&adapter->phy_info_timer,
3606 round_jiffies(jiffies + 2 * HZ));
3609 if (netif_carrier_ok(netdev)) {
3610 adapter->link_speed = 0;
3611 adapter->link_duplex = 0;
3612 /* Link status message must follow this format */
3613 printk(KERN_INFO "e1000e: %s NIC Link is Down\n",
3614 adapter->netdev->name);
3615 netif_carrier_off(netdev);
3616 netif_tx_stop_all_queues(netdev);
3617 if (!test_bit(__E1000_DOWN, &adapter->state))
3618 mod_timer(&adapter->phy_info_timer,
3619 round_jiffies(jiffies + 2 * HZ));
3621 if (adapter->flags & FLAG_RX_NEEDS_RESTART)
3622 schedule_work(&adapter->reset_task);
3627 e1000e_update_stats(adapter);
3629 mac->tx_packet_delta = adapter->stats.tpt - adapter->tpt_old;
3630 adapter->tpt_old = adapter->stats.tpt;
3631 mac->collision_delta = adapter->stats.colc - adapter->colc_old;
3632 adapter->colc_old = adapter->stats.colc;
3634 adapter->gorc = adapter->stats.gorc - adapter->gorc_old;
3635 adapter->gorc_old = adapter->stats.gorc;
3636 adapter->gotc = adapter->stats.gotc - adapter->gotc_old;
3637 adapter->gotc_old = adapter->stats.gotc;
3639 e1000e_update_adaptive(&adapter->hw);
3641 if (!netif_carrier_ok(netdev)) {
3642 tx_pending = (e1000_desc_unused(tx_ring) + 1 <
3646 * We've lost link, so the controller stops DMA,
3647 * but we've got queued Tx work that's never going
3648 * to get done, so reset controller to flush Tx.
3649 * (Do the reset outside of interrupt context).
3651 adapter->tx_timeout_count++;
3652 schedule_work(&adapter->reset_task);
3656 /* Cause software interrupt to ensure Rx ring is cleaned */
3657 if (adapter->msix_entries)
3658 ew32(ICS, adapter->rx_ring->ims_val);
3660 ew32(ICS, E1000_ICS_RXDMT0);
3662 /* Force detection of hung controller every watchdog period */
3663 adapter->detect_tx_hung = 1;
3666 * With 82571 controllers, LAA may be overwritten due to controller
3667 * reset from the other port. Set the appropriate LAA in RAR[0]
3669 if (e1000e_get_laa_state_82571(hw))
3670 e1000e_rar_set(hw, adapter->hw.mac.addr, 0);
3672 /* Reset the timer */
3673 if (!test_bit(__E1000_DOWN, &adapter->state))
3674 mod_timer(&adapter->watchdog_timer,
3675 round_jiffies(jiffies + 2 * HZ));
3678 #define E1000_TX_FLAGS_CSUM 0x00000001
3679 #define E1000_TX_FLAGS_VLAN 0x00000002
3680 #define E1000_TX_FLAGS_TSO 0x00000004
3681 #define E1000_TX_FLAGS_IPV4 0x00000008
3682 #define E1000_TX_FLAGS_VLAN_MASK 0xffff0000
3683 #define E1000_TX_FLAGS_VLAN_SHIFT 16
3685 static int e1000_tso(struct e1000_adapter *adapter,
3686 struct sk_buff *skb)
3688 struct e1000_ring *tx_ring = adapter->tx_ring;
3689 struct e1000_context_desc *context_desc;
3690 struct e1000_buffer *buffer_info;
3693 u16 ipcse = 0, tucse, mss;
3694 u8 ipcss, ipcso, tucss, tucso, hdr_len;
3697 if (skb_is_gso(skb)) {
3698 if (skb_header_cloned(skb)) {
3699 err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
3704 hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
3705 mss = skb_shinfo(skb)->gso_size;
3706 if (skb->protocol == htons(ETH_P_IP)) {
3707 struct iphdr *iph = ip_hdr(skb);
3710 tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr,
3714 cmd_length = E1000_TXD_CMD_IP;
3715 ipcse = skb_transport_offset(skb) - 1;
3716 } else if (skb_shinfo(skb)->gso_type == SKB_GSO_TCPV6) {
3717 ipv6_hdr(skb)->payload_len = 0;
3718 tcp_hdr(skb)->check =
3719 ~csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
3720 &ipv6_hdr(skb)->daddr,
3724 ipcss = skb_network_offset(skb);
3725 ipcso = (void *)&(ip_hdr(skb)->check) - (void *)skb->data;
3726 tucss = skb_transport_offset(skb);
3727 tucso = (void *)&(tcp_hdr(skb)->check) - (void *)skb->data;
3730 cmd_length |= (E1000_TXD_CMD_DEXT | E1000_TXD_CMD_TSE |
3731 E1000_TXD_CMD_TCP | (skb->len - (hdr_len)));
3733 i = tx_ring->next_to_use;
3734 context_desc = E1000_CONTEXT_DESC(*tx_ring, i);
3735 buffer_info = &tx_ring->buffer_info[i];
3737 context_desc->lower_setup.ip_fields.ipcss = ipcss;
3738 context_desc->lower_setup.ip_fields.ipcso = ipcso;
3739 context_desc->lower_setup.ip_fields.ipcse = cpu_to_le16(ipcse);
3740 context_desc->upper_setup.tcp_fields.tucss = tucss;
3741 context_desc->upper_setup.tcp_fields.tucso = tucso;
3742 context_desc->upper_setup.tcp_fields.tucse = cpu_to_le16(tucse);
3743 context_desc->tcp_seg_setup.fields.mss = cpu_to_le16(mss);
3744 context_desc->tcp_seg_setup.fields.hdr_len = hdr_len;
3745 context_desc->cmd_and_length = cpu_to_le32(cmd_length);
3747 buffer_info->time_stamp = jiffies;
3748 buffer_info->next_to_watch = i;
3751 if (i == tx_ring->count)
3753 tx_ring->next_to_use = i;
3761 static bool e1000_tx_csum(struct e1000_adapter *adapter, struct sk_buff *skb)
3763 struct e1000_ring *tx_ring = adapter->tx_ring;
3764 struct e1000_context_desc *context_desc;
3765 struct e1000_buffer *buffer_info;
3768 u32 cmd_len = E1000_TXD_CMD_DEXT;
3770 if (skb->ip_summed != CHECKSUM_PARTIAL)
3773 switch (skb->protocol) {
3774 case cpu_to_be16(ETH_P_IP):
3775 if (ip_hdr(skb)->protocol == IPPROTO_TCP)
3776 cmd_len |= E1000_TXD_CMD_TCP;
3778 case cpu_to_be16(ETH_P_IPV6):
3779 /* XXX not handling all IPV6 headers */
3780 if (ipv6_hdr(skb)->nexthdr == IPPROTO_TCP)
3781 cmd_len |= E1000_TXD_CMD_TCP;
3784 if (unlikely(net_ratelimit()))
3785 e_warn("checksum_partial proto=%x!\n", skb->protocol);
3789 css = skb_transport_offset(skb);
3791 i = tx_ring->next_to_use;
3792 buffer_info = &tx_ring->buffer_info[i];
3793 context_desc = E1000_CONTEXT_DESC(*tx_ring, i);
3795 context_desc->lower_setup.ip_config = 0;
3796 context_desc->upper_setup.tcp_fields.tucss = css;
3797 context_desc->upper_setup.tcp_fields.tucso =
3798 css + skb->csum_offset;
3799 context_desc->upper_setup.tcp_fields.tucse = 0;
3800 context_desc->tcp_seg_setup.data = 0;
3801 context_desc->cmd_and_length = cpu_to_le32(cmd_len);
3803 buffer_info->time_stamp = jiffies;
3804 buffer_info->next_to_watch = i;
3807 if (i == tx_ring->count)
3809 tx_ring->next_to_use = i;
3814 #define E1000_MAX_PER_TXD 8192
3815 #define E1000_MAX_TXD_PWR 12
3817 static int e1000_tx_map(struct e1000_adapter *adapter,
3818 struct sk_buff *skb, unsigned int first,
3819 unsigned int max_per_txd, unsigned int nr_frags,
3822 struct e1000_ring *tx_ring = adapter->tx_ring;
3823 struct e1000_buffer *buffer_info;
3824 unsigned int len = skb->len - skb->data_len;
3825 unsigned int offset = 0, size, count = 0, i;
3828 i = tx_ring->next_to_use;
3831 buffer_info = &tx_ring->buffer_info[i];
3832 size = min(len, max_per_txd);
3834 buffer_info->length = size;
3835 /* set time_stamp *before* dma to help avoid a possible race */
3836 buffer_info->time_stamp = jiffies;
3838 pci_map_single(adapter->pdev,
3842 if (pci_dma_mapping_error(adapter->pdev, buffer_info->dma)) {
3843 dev_err(&adapter->pdev->dev, "TX DMA map failed\n");
3844 adapter->tx_dma_failed++;
3847 buffer_info->next_to_watch = i;
3853 if (i == tx_ring->count)
3857 for (f = 0; f < nr_frags; f++) {
3858 struct skb_frag_struct *frag;
3860 frag = &skb_shinfo(skb)->frags[f];
3862 offset = frag->page_offset;
3865 buffer_info = &tx_ring->buffer_info[i];
3866 size = min(len, max_per_txd);
3868 buffer_info->length = size;
3869 buffer_info->time_stamp = jiffies;
3871 pci_map_page(adapter->pdev,
3876 if (pci_dma_mapping_error(adapter->pdev,
3877 buffer_info->dma)) {
3878 dev_err(&adapter->pdev->dev,
3879 "TX DMA page map failed\n");
3880 adapter->tx_dma_failed++;
3884 buffer_info->next_to_watch = i;
3891 if (i == tx_ring->count)
3897 i = tx_ring->count - 1;
3901 tx_ring->buffer_info[i].skb = skb;
3902 tx_ring->buffer_info[first].next_to_watch = i;
3907 static void e1000_tx_queue(struct e1000_adapter *adapter,
3908 int tx_flags, int count)
3910 struct e1000_ring *tx_ring = adapter->tx_ring;
3911 struct e1000_tx_desc *tx_desc = NULL;
3912 struct e1000_buffer *buffer_info;
3913 u32 txd_upper = 0, txd_lower = E1000_TXD_CMD_IFCS;
3916 if (tx_flags & E1000_TX_FLAGS_TSO) {
3917 txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D |
3919 txd_upper |= E1000_TXD_POPTS_TXSM << 8;
3921 if (tx_flags & E1000_TX_FLAGS_IPV4)
3922 txd_upper |= E1000_TXD_POPTS_IXSM << 8;
3925 if (tx_flags & E1000_TX_FLAGS_CSUM) {
3926 txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D;
3927 txd_upper |= E1000_TXD_POPTS_TXSM << 8;
3930 if (tx_flags & E1000_TX_FLAGS_VLAN) {
3931 txd_lower |= E1000_TXD_CMD_VLE;
3932 txd_upper |= (tx_flags & E1000_TX_FLAGS_VLAN_MASK);
3935 i = tx_ring->next_to_use;
3938 buffer_info = &tx_ring->buffer_info[i];
3939 tx_desc = E1000_TX_DESC(*tx_ring, i);
3940 tx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
3941 tx_desc->lower.data =
3942 cpu_to_le32(txd_lower | buffer_info->length);
3943 tx_desc->upper.data = cpu_to_le32(txd_upper);
3946 if (i == tx_ring->count)
3950 tx_desc->lower.data |= cpu_to_le32(adapter->txd_cmd);
3953 * Force memory writes to complete before letting h/w
3954 * know there are new descriptors to fetch. (Only
3955 * applicable for weak-ordered memory model archs,
3960 tx_ring->next_to_use = i;
3961 writel(i, adapter->hw.hw_addr + tx_ring->tail);
3963 * we need this if more than one processor can write to our tail
3964 * at a time, it synchronizes IO on IA64/Altix systems
3969 #define MINIMUM_DHCP_PACKET_SIZE 282
3970 static int e1000_transfer_dhcp_info(struct e1000_adapter *adapter,
3971 struct sk_buff *skb)
3973 struct e1000_hw *hw = &adapter->hw;
3976 if (vlan_tx_tag_present(skb)) {
3977 if (!((vlan_tx_tag_get(skb) == adapter->hw.mng_cookie.vlan_id)
3978 && (adapter->hw.mng_cookie.status &
3979 E1000_MNG_DHCP_COOKIE_STATUS_VLAN)))
3983 if (skb->len <= MINIMUM_DHCP_PACKET_SIZE)
3986 if (((struct ethhdr *) skb->data)->h_proto != htons(ETH_P_IP))
3990 const struct iphdr *ip = (struct iphdr *)((u8 *)skb->data+14);
3993 if (ip->protocol != IPPROTO_UDP)
3996 udp = (struct udphdr *)((u8 *)ip + (ip->ihl << 2));
3997 if (ntohs(udp->dest) != 67)
4000 offset = (u8 *)udp + 8 - skb->data;
4001 length = skb->len - offset;
4002 return e1000e_mng_write_dhcp_info(hw, (u8 *)udp + 8, length);
4008 static int __e1000_maybe_stop_tx(struct net_device *netdev, int size)
4010 struct e1000_adapter *adapter = netdev_priv(netdev);
4012 netif_stop_queue(netdev);
4014 * Herbert's original patch had:
4015 * smp_mb__after_netif_stop_queue();
4016 * but since that doesn't exist yet, just open code it.
4021 * We need to check again in a case another CPU has just
4022 * made room available.
4024 if (e1000_desc_unused(adapter->tx_ring) < size)
4028 netif_start_queue(netdev);
4029 ++adapter->restart_queue;
4033 static int e1000_maybe_stop_tx(struct net_device *netdev, int size)
4035 struct e1000_adapter *adapter = netdev_priv(netdev);
4037 if (e1000_desc_unused(adapter->tx_ring) >= size)
4039 return __e1000_maybe_stop_tx(netdev, size);
4042 #define TXD_USE_COUNT(S, X) (((S) >> (X)) + 1 )
4043 static int e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
4045 struct e1000_adapter *adapter = netdev_priv(netdev);
4046 struct e1000_ring *tx_ring = adapter->tx_ring;
4048 unsigned int max_per_txd = E1000_MAX_PER_TXD;
4049 unsigned int max_txd_pwr = E1000_MAX_TXD_PWR;
4050 unsigned int tx_flags = 0;
4051 unsigned int len = skb->len - skb->data_len;
4052 unsigned int nr_frags;
4058 if (test_bit(__E1000_DOWN, &adapter->state)) {
4059 dev_kfree_skb_any(skb);
4060 return NETDEV_TX_OK;
4063 if (skb->len <= 0) {
4064 dev_kfree_skb_any(skb);
4065 return NETDEV_TX_OK;
4068 mss = skb_shinfo(skb)->gso_size;
4070 * The controller does a simple calculation to
4071 * make sure there is enough room in the FIFO before
4072 * initiating the DMA for each buffer. The calc is:
4073 * 4 = ceil(buffer len/mss). To make sure we don't
4074 * overrun the FIFO, adjust the max buffer len if mss
4079 max_per_txd = min(mss << 2, max_per_txd);
4080 max_txd_pwr = fls(max_per_txd) - 1;
4083 * TSO Workaround for 82571/2/3 Controllers -- if skb->data
4084 * points to just header, pull a few bytes of payload from
4085 * frags into skb->data
4087 hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
4089 * we do this workaround for ES2LAN, but it is un-necessary,
4090 * avoiding it could save a lot of cycles
4092 if (skb->data_len && (hdr_len == len)) {
4093 unsigned int pull_size;
4095 pull_size = min((unsigned int)4, skb->data_len);
4096 if (!__pskb_pull_tail(skb, pull_size)) {
4097 e_err("__pskb_pull_tail failed.\n");
4098 dev_kfree_skb_any(skb);
4099 return NETDEV_TX_OK;
4101 len = skb->len - skb->data_len;
4105 /* reserve a descriptor for the offload context */
4106 if ((mss) || (skb->ip_summed == CHECKSUM_PARTIAL))
4110 count += TXD_USE_COUNT(len, max_txd_pwr);
4112 nr_frags = skb_shinfo(skb)->nr_frags;
4113 for (f = 0; f < nr_frags; f++)
4114 count += TXD_USE_COUNT(skb_shinfo(skb)->frags[f].size,
4117 if (adapter->hw.mac.tx_pkt_filtering)
4118 e1000_transfer_dhcp_info(adapter, skb);
4121 * need: count + 2 desc gap to keep tail from touching
4122 * head, otherwise try next time
4124 if (e1000_maybe_stop_tx(netdev, count + 2))
4125 return NETDEV_TX_BUSY;
4127 if (adapter->vlgrp && vlan_tx_tag_present(skb)) {
4128 tx_flags |= E1000_TX_FLAGS_VLAN;
4129 tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT);
4132 first = tx_ring->next_to_use;
4134 tso = e1000_tso(adapter, skb);
4136 dev_kfree_skb_any(skb);
4137 return NETDEV_TX_OK;
4141 tx_flags |= E1000_TX_FLAGS_TSO;
4142 else if (e1000_tx_csum(adapter, skb))
4143 tx_flags |= E1000_TX_FLAGS_CSUM;
4146 * Old method was to assume IPv4 packet by default if TSO was enabled.
4147 * 82571 hardware supports TSO capabilities for IPv6 as well...
4148 * no longer assume, we must.
4150 if (skb->protocol == htons(ETH_P_IP))
4151 tx_flags |= E1000_TX_FLAGS_IPV4;
4153 count = e1000_tx_map(adapter, skb, first, max_per_txd, nr_frags, mss);
4155 /* handle pci_map_single() error in e1000_tx_map */
4156 dev_kfree_skb_any(skb);
4157 return NETDEV_TX_OK;
4160 e1000_tx_queue(adapter, tx_flags, count);
4162 netdev->trans_start = jiffies;
4164 /* Make sure there is space in the ring for the next send. */
4165 e1000_maybe_stop_tx(netdev, MAX_SKB_FRAGS + 2);
4167 return NETDEV_TX_OK;
4171 * e1000_tx_timeout - Respond to a Tx Hang
4172 * @netdev: network interface device structure
4174 static void e1000_tx_timeout(struct net_device *netdev)
4176 struct e1000_adapter *adapter = netdev_priv(netdev);
4178 /* Do the reset outside of interrupt context */
4179 adapter->tx_timeout_count++;
4180 schedule_work(&adapter->reset_task);
4183 static void e1000_reset_task(struct work_struct *work)
4185 struct e1000_adapter *adapter;
4186 adapter = container_of(work, struct e1000_adapter, reset_task);
4188 e1000e_reinit_locked(adapter);
4192 * e1000_get_stats - Get System Network Statistics
4193 * @netdev: network interface device structure
4195 * Returns the address of the device statistics structure.
4196 * The statistics are actually updated from the timer callback.
4198 static struct net_device_stats *e1000_get_stats(struct net_device *netdev)
4200 struct e1000_adapter *adapter = netdev_priv(netdev);
4202 /* only return the current stats */
4203 return &adapter->net_stats;
4207 * e1000_change_mtu - Change the Maximum Transfer Unit
4208 * @netdev: network interface device structure
4209 * @new_mtu: new value for maximum frame size
4211 * Returns 0 on success, negative on failure
4213 static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
4215 struct e1000_adapter *adapter = netdev_priv(netdev);
4216 int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN;
4218 if ((new_mtu < ETH_ZLEN + ETH_FCS_LEN + VLAN_HLEN) ||
4219 (max_frame > MAX_JUMBO_FRAME_SIZE)) {
4220 e_err("Invalid MTU setting\n");
4224 /* Jumbo frame size limits */
4225 if (max_frame > ETH_FRAME_LEN + ETH_FCS_LEN) {
4226 if (!(adapter->flags & FLAG_HAS_JUMBO_FRAMES)) {
4227 e_err("Jumbo Frames not supported.\n");
4230 if (adapter->hw.phy.type == e1000_phy_ife) {
4231 e_err("Jumbo Frames not supported.\n");
4236 #define MAX_STD_JUMBO_FRAME_SIZE 9234
4237 if (max_frame > MAX_STD_JUMBO_FRAME_SIZE) {
4238 e_err("MTU > 9216 not supported.\n");
4242 while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
4244 /* e1000e_down has a dependency on max_frame_size */
4245 adapter->max_frame_size = max_frame;
4246 if (netif_running(netdev))
4247 e1000e_down(adapter);
4250 * NOTE: netdev_alloc_skb reserves 16 bytes, and typically NET_IP_ALIGN
4251 * means we reserve 2 more, this pushes us to allocate from the next
4253 * i.e. RXBUFFER_2048 --> size-4096 slab
4254 * However with the new *_jumbo_rx* routines, jumbo receives will use
4258 if (max_frame <= 256)
4259 adapter->rx_buffer_len = 256;
4260 else if (max_frame <= 512)
4261 adapter->rx_buffer_len = 512;
4262 else if (max_frame <= 1024)
4263 adapter->rx_buffer_len = 1024;
4264 else if (max_frame <= 2048)
4265 adapter->rx_buffer_len = 2048;
4267 adapter->rx_buffer_len = 4096;
4269 /* adjust allocation if LPE protects us, and we aren't using SBP */
4270 if ((max_frame == ETH_FRAME_LEN + ETH_FCS_LEN) ||
4271 (max_frame == ETH_FRAME_LEN + VLAN_HLEN + ETH_FCS_LEN))
4272 adapter->rx_buffer_len = ETH_FRAME_LEN + VLAN_HLEN
4275 e_info("changing MTU from %d to %d\n", netdev->mtu, new_mtu);
4276 netdev->mtu = new_mtu;
4278 if (netif_running(netdev))
4281 e1000e_reset(adapter);
4283 clear_bit(__E1000_RESETTING, &adapter->state);
4288 static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
4291 struct e1000_adapter *adapter = netdev_priv(netdev);
4292 struct mii_ioctl_data *data = if_mii(ifr);
4294 if (adapter->hw.phy.media_type != e1000_media_type_copper)
4299 data->phy_id = adapter->hw.phy.addr;
4302 if (!capable(CAP_NET_ADMIN))
4304 switch (data->reg_num & 0x1F) {
4306 data->val_out = adapter->phy_regs.bmcr;
4309 data->val_out = adapter->phy_regs.bmsr;
4312 data->val_out = (adapter->hw.phy.id >> 16);
4315 data->val_out = (adapter->hw.phy.id & 0xFFFF);
4318 data->val_out = adapter->phy_regs.advertise;
4321 data->val_out = adapter->phy_regs.lpa;
4324 data->val_out = adapter->phy_regs.expansion;
4327 data->val_out = adapter->phy_regs.ctrl1000;
4330 data->val_out = adapter->phy_regs.stat1000;
4333 data->val_out = adapter->phy_regs.estatus;
4346 static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
4352 return e1000_mii_ioctl(netdev, ifr, cmd);
4358 static int e1000_suspend(struct pci_dev *pdev, pm_message_t state)
4360 struct net_device *netdev = pci_get_drvdata(pdev);
4361 struct e1000_adapter *adapter = netdev_priv(netdev);
4362 struct e1000_hw *hw = &adapter->hw;
4363 u32 ctrl, ctrl_ext, rctl, status;
4364 u32 wufc = adapter->wol;
4367 netif_device_detach(netdev);
4369 if (netif_running(netdev)) {
4370 WARN_ON(test_bit(__E1000_RESETTING, &adapter->state));
4371 e1000e_down(adapter);
4372 e1000_free_irq(adapter);
4374 e1000e_reset_interrupt_capability(adapter);
4376 retval = pci_save_state(pdev);
4380 status = er32(STATUS);
4381 if (status & E1000_STATUS_LU)
4382 wufc &= ~E1000_WUFC_LNKC;
4385 e1000_setup_rctl(adapter);
4386 e1000_set_multi(netdev);
4388 /* turn on all-multi mode if wake on multicast is enabled */
4389 if (wufc & E1000_WUFC_MC) {
4391 rctl |= E1000_RCTL_MPE;
4396 /* advertise wake from D3Cold */
4397 #define E1000_CTRL_ADVD3WUC 0x00100000
4398 /* phy power management enable */
4399 #define E1000_CTRL_EN_PHY_PWR_MGMT 0x00200000
4400 ctrl |= E1000_CTRL_ADVD3WUC |
4401 E1000_CTRL_EN_PHY_PWR_MGMT;
4404 if (adapter->hw.phy.media_type == e1000_media_type_fiber ||
4405 adapter->hw.phy.media_type ==
4406 e1000_media_type_internal_serdes) {
4407 /* keep the laser running in D3 */
4408 ctrl_ext = er32(CTRL_EXT);
4409 ctrl_ext |= E1000_CTRL_EXT_SDP7_DATA;
4410 ew32(CTRL_EXT, ctrl_ext);
4413 if (adapter->flags & FLAG_IS_ICH)
4414 e1000e_disable_gig_wol_ich8lan(&adapter->hw);
4416 /* Allow time for pending master requests to run */
4417 e1000e_disable_pcie_master(&adapter->hw);
4419 ew32(WUC, E1000_WUC_PME_EN);
4421 pci_enable_wake(pdev, PCI_D3hot, 1);
4422 pci_enable_wake(pdev, PCI_D3cold, 1);
4426 pci_enable_wake(pdev, PCI_D3hot, 0);
4427 pci_enable_wake(pdev, PCI_D3cold, 0);
4430 /* make sure adapter isn't asleep if manageability is enabled */
4431 if (adapter->flags & FLAG_MNG_PT_ENABLED) {
4432 pci_enable_wake(pdev, PCI_D3hot, 1);
4433 pci_enable_wake(pdev, PCI_D3cold, 1);
4436 if (adapter->hw.phy.type == e1000_phy_igp_3)
4437 e1000e_igp3_phy_powerdown_workaround_ich8lan(&adapter->hw);
4440 * Release control of h/w to f/w. If f/w is AMT enabled, this
4441 * would have already happened in close and is redundant.
4443 e1000_release_hw_control(adapter);
4445 pci_disable_device(pdev);
4448 * The pci-e switch on some quad port adapters will report a
4449 * correctable error when the MAC transitions from D0 to D3. To
4450 * prevent this we need to mask off the correctable errors on the
4451 * downstream port of the pci-e switch.
4453 if (adapter->flags & FLAG_IS_QUAD_PORT) {
4454 struct pci_dev *us_dev = pdev->bus->self;
4455 int pos = pci_find_capability(us_dev, PCI_CAP_ID_EXP);
4458 pci_read_config_word(us_dev, pos + PCI_EXP_DEVCTL, &devctl);
4459 pci_write_config_word(us_dev, pos + PCI_EXP_DEVCTL,
4460 (devctl & ~PCI_EXP_DEVCTL_CERE));
4462 pci_set_power_state(pdev, pci_choose_state(pdev, state));
4464 pci_write_config_word(us_dev, pos + PCI_EXP_DEVCTL, devctl);
4466 pci_set_power_state(pdev, pci_choose_state(pdev, state));
4472 static void e1000e_disable_l1aspm(struct pci_dev *pdev)
4478 * 82573 workaround - disable L1 ASPM on mobile chipsets
4480 * L1 ASPM on various mobile (ich7) chipsets do not behave properly
4481 * resulting in lost data or garbage information on the pci-e link
4482 * level. This could result in (false) bad EEPROM checksum errors,
4483 * long ping times (up to 2s) or even a system freeze/hang.
4485 * Unfortunately this feature saves about 1W power consumption when
4488 pos = pci_find_capability(pdev, PCI_CAP_ID_EXP);
4489 pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, &val);
4491 dev_warn(&pdev->dev, "Disabling L1 ASPM\n");
4493 pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, val);
4498 static int e1000_resume(struct pci_dev *pdev)
4500 struct net_device *netdev = pci_get_drvdata(pdev);
4501 struct e1000_adapter *adapter = netdev_priv(netdev);
4502 struct e1000_hw *hw = &adapter->hw;
4505 pci_set_power_state(pdev, PCI_D0);
4506 pci_restore_state(pdev);
4507 e1000e_disable_l1aspm(pdev);
4509 err = pci_enable_device_mem(pdev);
4512 "Cannot enable PCI device from suspend\n");
4516 /* AER (Advanced Error Reporting) hooks */
4517 err = pci_enable_pcie_error_reporting(pdev);
4519 dev_err(&pdev->dev, "pci_enable_pcie_error_reporting failed "
4521 /* non-fatal, continue */
4524 pci_set_master(pdev);
4526 pci_enable_wake(pdev, PCI_D3hot, 0);
4527 pci_enable_wake(pdev, PCI_D3cold, 0);
4529 e1000e_set_interrupt_capability(adapter);
4530 if (netif_running(netdev)) {
4531 err = e1000_request_irq(adapter);
4536 e1000e_power_up_phy(adapter);
4537 e1000e_reset(adapter);
4540 e1000_init_manageability(adapter);
4542 if (netif_running(netdev))
4545 netif_device_attach(netdev);
4548 * If the controller has AMT, do not set DRV_LOAD until the interface
4549 * is up. For all other cases, let the f/w know that the h/w is now
4550 * under the control of the driver.
4552 if (!(adapter->flags & FLAG_HAS_AMT))
4553 e1000_get_hw_control(adapter);
4559 static void e1000_shutdown(struct pci_dev *pdev)
4561 e1000_suspend(pdev, PMSG_SUSPEND);
4564 #ifdef CONFIG_NET_POLL_CONTROLLER
4566 * Polling 'interrupt' - used by things like netconsole to send skbs
4567 * without having to re-enable interrupts. It's not called while
4568 * the interrupt routine is executing.
4570 static void e1000_netpoll(struct net_device *netdev)
4572 struct e1000_adapter *adapter = netdev_priv(netdev);
4574 disable_irq(adapter->pdev->irq);
4575 e1000_intr(adapter->pdev->irq, netdev);
4577 enable_irq(adapter->pdev->irq);
4582 * e1000_io_error_detected - called when PCI error is detected
4583 * @pdev: Pointer to PCI device
4584 * @state: The current pci connection state
4586 * This function is called after a PCI bus error affecting
4587 * this device has been detected.
4589 static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev,
4590 pci_channel_state_t state)
4592 struct net_device *netdev = pci_get_drvdata(pdev);
4593 struct e1000_adapter *adapter = netdev_priv(netdev);
4595 netif_device_detach(netdev);
4597 if (netif_running(netdev))
4598 e1000e_down(adapter);
4599 pci_disable_device(pdev);
4601 /* Request a slot slot reset. */
4602 return PCI_ERS_RESULT_NEED_RESET;
4606 * e1000_io_slot_reset - called after the pci bus has been reset.
4607 * @pdev: Pointer to PCI device
4609 * Restart the card from scratch, as if from a cold-boot. Implementation
4610 * resembles the first-half of the e1000_resume routine.
4612 static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
4614 struct net_device *netdev = pci_get_drvdata(pdev);
4615 struct e1000_adapter *adapter = netdev_priv(netdev);
4616 struct e1000_hw *hw = &adapter->hw;
4618 pci_ers_result_t result;
4620 e1000e_disable_l1aspm(pdev);
4621 err = pci_enable_device_mem(pdev);
4624 "Cannot re-enable PCI device after reset.\n");
4625 result = PCI_ERS_RESULT_DISCONNECT;
4627 pci_set_master(pdev);
4628 pci_restore_state(pdev);
4630 pci_enable_wake(pdev, PCI_D3hot, 0);
4631 pci_enable_wake(pdev, PCI_D3cold, 0);
4633 e1000e_reset(adapter);
4635 result = PCI_ERS_RESULT_RECOVERED;
4638 pci_cleanup_aer_uncorrect_error_status(pdev);
4644 * e1000_io_resume - called when traffic can start flowing again.
4645 * @pdev: Pointer to PCI device
4647 * This callback is called when the error recovery driver tells us that
4648 * its OK to resume normal operation. Implementation resembles the
4649 * second-half of the e1000_resume routine.
4651 static void e1000_io_resume(struct pci_dev *pdev)
4653 struct net_device *netdev = pci_get_drvdata(pdev);
4654 struct e1000_adapter *adapter = netdev_priv(netdev);
4656 e1000_init_manageability(adapter);
4658 if (netif_running(netdev)) {
4659 if (e1000e_up(adapter)) {
4661 "can't bring device back up after reset\n");
4666 netif_device_attach(netdev);
4669 * If the controller has AMT, do not set DRV_LOAD until the interface
4670 * is up. For all other cases, let the f/w know that the h/w is now
4671 * under the control of the driver.
4673 if (!(adapter->flags & FLAG_HAS_AMT))
4674 e1000_get_hw_control(adapter);
4678 static void e1000_print_device_info(struct e1000_adapter *adapter)
4680 struct e1000_hw *hw = &adapter->hw;
4681 struct net_device *netdev = adapter->netdev;
4684 /* print bus type/speed/width info */
4685 e_info("(PCI Express:2.5GB/s:%s) %pM\n",
4687 ((hw->bus.width == e1000_bus_width_pcie_x4) ? "Width x4" :
4691 e_info("Intel(R) PRO/%s Network Connection\n",
4692 (hw->phy.type == e1000_phy_ife) ? "10/100" : "1000");
4693 e1000e_read_pba_num(hw, &pba_num);
4694 e_info("MAC: %d, PHY: %d, PBA No: %06x-%03x\n",
4695 hw->mac.type, hw->phy.type, (pba_num >> 8), (pba_num & 0xff));
4698 static void e1000_eeprom_checks(struct e1000_adapter *adapter)
4700 struct e1000_hw *hw = &adapter->hw;
4704 if (hw->mac.type != e1000_82573)
4707 ret_val = e1000_read_nvm(hw, NVM_INIT_CONTROL2_REG, 1, &buf);
4708 if (!ret_val && (!(le16_to_cpu(buf) & (1 << 0)))) {
4709 /* Deep Smart Power Down (DSPD) */
4710 dev_warn(&adapter->pdev->dev,
4711 "Warning: detected DSPD enabled in EEPROM\n");
4714 ret_val = e1000_read_nvm(hw, NVM_INIT_3GIO_3, 1, &buf);
4715 if (!ret_val && (le16_to_cpu(buf) & (3 << 2))) {
4717 dev_warn(&adapter->pdev->dev,
4718 "Warning: detected ASPM enabled in EEPROM\n");
4722 static const struct net_device_ops e1000e_netdev_ops = {
4723 .ndo_open = e1000_open,
4724 .ndo_stop = e1000_close,
4725 .ndo_start_xmit = e1000_xmit_frame,
4726 .ndo_get_stats = e1000_get_stats,
4727 .ndo_set_multicast_list = e1000_set_multi,
4728 .ndo_set_mac_address = e1000_set_mac,
4729 .ndo_change_mtu = e1000_change_mtu,
4730 .ndo_do_ioctl = e1000_ioctl,
4731 .ndo_tx_timeout = e1000_tx_timeout,
4732 .ndo_validate_addr = eth_validate_addr,
4734 .ndo_vlan_rx_register = e1000_vlan_rx_register,
4735 .ndo_vlan_rx_add_vid = e1000_vlan_rx_add_vid,
4736 .ndo_vlan_rx_kill_vid = e1000_vlan_rx_kill_vid,
4737 #ifdef CONFIG_NET_POLL_CONTROLLER
4738 .ndo_poll_controller = e1000_netpoll,
4743 * e1000_probe - Device Initialization Routine
4744 * @pdev: PCI device information struct
4745 * @ent: entry in e1000_pci_tbl
4747 * Returns 0 on success, negative on failure
4749 * e1000_probe initializes an adapter identified by a pci_dev structure.
4750 * The OS initialization, configuring of the adapter private structure,
4751 * and a hardware reset occur.
4753 static int __devinit e1000_probe(struct pci_dev *pdev,
4754 const struct pci_device_id *ent)
4756 struct net_device *netdev;
4757 struct e1000_adapter *adapter;
4758 struct e1000_hw *hw;
4759 const struct e1000_info *ei = e1000_info_tbl[ent->driver_data];
4760 resource_size_t mmio_start, mmio_len;
4761 resource_size_t flash_start, flash_len;
4763 static int cards_found;
4764 int i, err, pci_using_dac;
4765 u16 eeprom_data = 0;
4766 u16 eeprom_apme_mask = E1000_EEPROM_APME;
4768 e1000e_disable_l1aspm(pdev);
4770 err = pci_enable_device_mem(pdev);
4775 err = pci_set_dma_mask(pdev, DMA_64BIT_MASK);
4777 err = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK);
4781 err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
4783 err = pci_set_consistent_dma_mask(pdev,
4786 dev_err(&pdev->dev, "No usable DMA "
4787 "configuration, aborting\n");
4793 err = pci_request_selected_regions_exclusive(pdev,
4794 pci_select_bars(pdev, IORESOURCE_MEM),
4795 e1000e_driver_name);
4799 pci_set_master(pdev);
4800 /* PCI config space info */
4801 err = pci_save_state(pdev);
4803 goto err_alloc_etherdev;
4806 netdev = alloc_etherdev(sizeof(struct e1000_adapter));
4808 goto err_alloc_etherdev;
4810 SET_NETDEV_DEV(netdev, &pdev->dev);
4812 pci_set_drvdata(pdev, netdev);
4813 adapter = netdev_priv(netdev);
4815 adapter->netdev = netdev;
4816 adapter->pdev = pdev;
4818 adapter->pba = ei->pba;
4819 adapter->flags = ei->flags;
4820 adapter->flags2 = ei->flags2;
4821 adapter->hw.adapter = adapter;
4822 adapter->hw.mac.type = ei->mac;
4823 adapter->msg_enable = (1 << NETIF_MSG_DRV | NETIF_MSG_PROBE) - 1;
4825 mmio_start = pci_resource_start(pdev, 0);
4826 mmio_len = pci_resource_len(pdev, 0);
4829 adapter->hw.hw_addr = ioremap(mmio_start, mmio_len);
4830 if (!adapter->hw.hw_addr)
4833 if ((adapter->flags & FLAG_HAS_FLASH) &&
4834 (pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) {
4835 flash_start = pci_resource_start(pdev, 1);
4836 flash_len = pci_resource_len(pdev, 1);
4837 adapter->hw.flash_address = ioremap(flash_start, flash_len);
4838 if (!adapter->hw.flash_address)
4842 /* construct the net_device struct */
4843 netdev->netdev_ops = &e1000e_netdev_ops;
4844 e1000e_set_ethtool_ops(netdev);
4845 netdev->watchdog_timeo = 5 * HZ;
4846 netif_napi_add(netdev, &adapter->napi, e1000_clean, 64);
4847 strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
4849 netdev->mem_start = mmio_start;
4850 netdev->mem_end = mmio_start + mmio_len;
4852 adapter->bd_number = cards_found++;
4854 e1000e_check_options(adapter);
4856 /* setup adapter struct */
4857 err = e1000_sw_init(adapter);
4863 memcpy(&hw->mac.ops, ei->mac_ops, sizeof(hw->mac.ops));
4864 memcpy(&hw->nvm.ops, ei->nvm_ops, sizeof(hw->nvm.ops));
4865 memcpy(&hw->phy.ops, ei->phy_ops, sizeof(hw->phy.ops));
4867 err = ei->get_variants(adapter);
4871 if ((adapter->flags & FLAG_IS_ICH) &&
4872 (adapter->flags & FLAG_READ_ONLY_NVM))
4873 e1000e_write_protect_nvm_ich8lan(&adapter->hw);
4875 hw->mac.ops.get_bus_info(&adapter->hw);
4877 adapter->hw.phy.autoneg_wait_to_complete = 0;
4879 /* Copper options */
4880 if (adapter->hw.phy.media_type == e1000_media_type_copper) {
4881 adapter->hw.phy.mdix = AUTO_ALL_MODES;
4882 adapter->hw.phy.disable_polarity_correction = 0;
4883 adapter->hw.phy.ms_type = e1000_ms_hw_default;
4886 if (e1000_check_reset_block(&adapter->hw))
4887 e_info("PHY reset is blocked due to SOL/IDER session.\n");
4889 netdev->features = NETIF_F_SG |
4891 NETIF_F_HW_VLAN_TX |
4894 if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER)
4895 netdev->features |= NETIF_F_HW_VLAN_FILTER;
4897 netdev->features |= NETIF_F_TSO;
4898 netdev->features |= NETIF_F_TSO6;
4900 netdev->vlan_features |= NETIF_F_TSO;
4901 netdev->vlan_features |= NETIF_F_TSO6;
4902 netdev->vlan_features |= NETIF_F_HW_CSUM;
4903 netdev->vlan_features |= NETIF_F_SG;
4906 netdev->features |= NETIF_F_HIGHDMA;
4908 if (e1000e_enable_mng_pass_thru(&adapter->hw))
4909 adapter->flags |= FLAG_MNG_PT_ENABLED;
4912 * before reading the NVM, reset the controller to
4913 * put the device in a known good starting state
4915 adapter->hw.mac.ops.reset_hw(&adapter->hw);
4918 * systems with ASPM and others may see the checksum fail on the first
4919 * attempt. Let's give it a few tries
4922 if (e1000_validate_nvm_checksum(&adapter->hw) >= 0)
4925 e_err("The NVM Checksum Is Not Valid\n");
4931 e1000_eeprom_checks(adapter);
4933 /* copy the MAC address out of the NVM */
4934 if (e1000e_read_mac_addr(&adapter->hw))
4935 e_err("NVM Read Error while reading MAC address\n");
4937 memcpy(netdev->dev_addr, adapter->hw.mac.addr, netdev->addr_len);
4938 memcpy(netdev->perm_addr, adapter->hw.mac.addr, netdev->addr_len);
4940 if (!is_valid_ether_addr(netdev->perm_addr)) {
4941 e_err("Invalid MAC Address: %pM\n", netdev->perm_addr);
4946 init_timer(&adapter->watchdog_timer);
4947 adapter->watchdog_timer.function = &e1000_watchdog;
4948 adapter->watchdog_timer.data = (unsigned long) adapter;
4950 init_timer(&adapter->phy_info_timer);
4951 adapter->phy_info_timer.function = &e1000_update_phy_info;
4952 adapter->phy_info_timer.data = (unsigned long) adapter;
4954 INIT_WORK(&adapter->reset_task, e1000_reset_task);
4955 INIT_WORK(&adapter->watchdog_task, e1000_watchdog_task);
4956 INIT_WORK(&adapter->downshift_task, e1000e_downshift_workaround);
4957 INIT_WORK(&adapter->update_phy_task, e1000e_update_phy_task);
4959 /* Initialize link parameters. User can change them with ethtool */
4960 adapter->hw.mac.autoneg = 1;
4961 adapter->fc_autoneg = 1;
4962 adapter->hw.fc.requested_mode = e1000_fc_default;
4963 adapter->hw.fc.current_mode = e1000_fc_default;
4964 adapter->hw.phy.autoneg_advertised = 0x2f;
4966 /* ring size defaults */
4967 adapter->rx_ring->count = 256;
4968 adapter->tx_ring->count = 256;
4971 * Initial Wake on LAN setting - If APM wake is enabled in
4972 * the EEPROM, enable the ACPI Magic Packet filter
4974 if (adapter->flags & FLAG_APME_IN_WUC) {
4975 /* APME bit in EEPROM is mapped to WUC.APME */
4976 eeprom_data = er32(WUC);
4977 eeprom_apme_mask = E1000_WUC_APME;
4978 } else if (adapter->flags & FLAG_APME_IN_CTRL3) {
4979 if (adapter->flags & FLAG_APME_CHECK_PORT_B &&
4980 (adapter->hw.bus.func == 1))
4981 e1000_read_nvm(&adapter->hw,
4982 NVM_INIT_CONTROL3_PORT_B, 1, &eeprom_data);
4984 e1000_read_nvm(&adapter->hw,
4985 NVM_INIT_CONTROL3_PORT_A, 1, &eeprom_data);
4988 /* fetch WoL from EEPROM */
4989 if (eeprom_data & eeprom_apme_mask)
4990 adapter->eeprom_wol |= E1000_WUFC_MAG;
4993 * now that we have the eeprom settings, apply the special cases
4994 * where the eeprom may be wrong or the board simply won't support
4995 * wake on lan on a particular port
4997 if (!(adapter->flags & FLAG_HAS_WOL))
4998 adapter->eeprom_wol = 0;
5000 /* initialize the wol settings based on the eeprom settings */
5001 adapter->wol = adapter->eeprom_wol;
5002 device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol);
5004 /* save off EEPROM version number */
5005 e1000_read_nvm(&adapter->hw, 5, 1, &adapter->eeprom_vers);
5007 /* reset the hardware with the new settings */
5008 e1000e_reset(adapter);
5011 * If the controller has AMT, do not set DRV_LOAD until the interface
5012 * is up. For all other cases, let the f/w know that the h/w is now
5013 * under the control of the driver.
5015 if (!(adapter->flags & FLAG_HAS_AMT))
5016 e1000_get_hw_control(adapter);
5018 /* tell the stack to leave us alone until e1000_open() is called */
5019 netif_carrier_off(netdev);
5020 netif_tx_stop_all_queues(netdev);
5022 strcpy(netdev->name, "eth%d");
5023 err = register_netdev(netdev);
5027 e1000_print_device_info(adapter);
5032 if (!(adapter->flags & FLAG_HAS_AMT))
5033 e1000_release_hw_control(adapter);
5035 if (!e1000_check_reset_block(&adapter->hw))
5036 e1000_phy_hw_reset(&adapter->hw);
5039 kfree(adapter->tx_ring);
5040 kfree(adapter->rx_ring);
5042 if (adapter->hw.flash_address)
5043 iounmap(adapter->hw.flash_address);
5044 e1000e_reset_interrupt_capability(adapter);
5046 iounmap(adapter->hw.hw_addr);
5048 free_netdev(netdev);
5050 pci_release_selected_regions(pdev,
5051 pci_select_bars(pdev, IORESOURCE_MEM));
5054 pci_disable_device(pdev);
5059 * e1000_remove - Device Removal Routine
5060 * @pdev: PCI device information struct
5062 * e1000_remove is called by the PCI subsystem to alert the driver
5063 * that it should release a PCI device. The could be caused by a
5064 * Hot-Plug event, or because the driver is going to be removed from
5067 static void __devexit e1000_remove(struct pci_dev *pdev)
5069 struct net_device *netdev = pci_get_drvdata(pdev);
5070 struct e1000_adapter *adapter = netdev_priv(netdev);
5074 * flush_scheduled work may reschedule our watchdog task, so
5075 * explicitly disable watchdog tasks from being rescheduled
5077 set_bit(__E1000_DOWN, &adapter->state);
5078 del_timer_sync(&adapter->watchdog_timer);
5079 del_timer_sync(&adapter->phy_info_timer);
5081 flush_scheduled_work();
5084 * Release control of h/w to f/w. If f/w is AMT enabled, this
5085 * would have already happened in close and is redundant.
5087 e1000_release_hw_control(adapter);
5089 unregister_netdev(netdev);
5091 if (!e1000_check_reset_block(&adapter->hw))
5092 e1000_phy_hw_reset(&adapter->hw);
5094 e1000e_reset_interrupt_capability(adapter);
5095 kfree(adapter->tx_ring);
5096 kfree(adapter->rx_ring);
5098 iounmap(adapter->hw.hw_addr);
5099 if (adapter->hw.flash_address)
5100 iounmap(adapter->hw.flash_address);
5101 pci_release_selected_regions(pdev,
5102 pci_select_bars(pdev, IORESOURCE_MEM));
5104 free_netdev(netdev);
5107 err = pci_disable_pcie_error_reporting(pdev);
5110 "pci_disable_pcie_error_reporting failed 0x%x\n", err);
5112 pci_disable_device(pdev);
5115 /* PCI Error Recovery (ERS) */
5116 static struct pci_error_handlers e1000_err_handler = {
5117 .error_detected = e1000_io_error_detected,
5118 .slot_reset = e1000_io_slot_reset,
5119 .resume = e1000_io_resume,
5122 static struct pci_device_id e1000_pci_tbl[] = {
5123 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_COPPER), board_82571 },
5124 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_FIBER), board_82571 },
5125 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_QUAD_COPPER), board_82571 },
5126 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_QUAD_COPPER_LP), board_82571 },
5127 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_QUAD_FIBER), board_82571 },
5128 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_SERDES), board_82571 },
5129 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_SERDES_DUAL), board_82571 },
5130 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_SERDES_QUAD), board_82571 },
5131 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571PT_QUAD_COPPER), board_82571 },
5133 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82572EI), board_82572 },
5134 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82572EI_COPPER), board_82572 },
5135 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82572EI_FIBER), board_82572 },
5136 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82572EI_SERDES), board_82572 },
5138 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82573E), board_82573 },
5139 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82573E_IAMT), board_82573 },
5140 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82573L), board_82573 },
5142 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82574L), board_82574 },
5144 { PCI_VDEVICE(INTEL, E1000_DEV_ID_80003ES2LAN_COPPER_DPT),
5145 board_80003es2lan },
5146 { PCI_VDEVICE(INTEL, E1000_DEV_ID_80003ES2LAN_COPPER_SPT),
5147 board_80003es2lan },
5148 { PCI_VDEVICE(INTEL, E1000_DEV_ID_80003ES2LAN_SERDES_DPT),
5149 board_80003es2lan },
5150 { PCI_VDEVICE(INTEL, E1000_DEV_ID_80003ES2LAN_SERDES_SPT),
5151 board_80003es2lan },
5153 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IFE), board_ich8lan },
5154 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IFE_G), board_ich8lan },
5155 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IFE_GT), board_ich8lan },
5156 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IGP_AMT), board_ich8lan },
5157 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IGP_C), board_ich8lan },
5158 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IGP_M), board_ich8lan },
5159 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IGP_M_AMT), board_ich8lan },
5161 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IFE), board_ich9lan },
5162 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IFE_G), board_ich9lan },
5163 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IFE_GT), board_ich9lan },
5164 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IGP_AMT), board_ich9lan },
5165 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IGP_C), board_ich9lan },
5166 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_BM), board_ich9lan },
5167 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IGP_M), board_ich9lan },
5168 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IGP_M_AMT), board_ich9lan },
5169 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IGP_M_V), board_ich9lan },
5171 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH10_R_BM_LM), board_ich9lan },
5172 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH10_R_BM_LF), board_ich9lan },
5173 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH10_R_BM_V), board_ich9lan },
5175 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH10_D_BM_LM), board_ich10lan },
5176 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH10_D_BM_LF), board_ich10lan },
5178 { } /* terminate list */
5180 MODULE_DEVICE_TABLE(pci, e1000_pci_tbl);
5182 /* PCI Device API Driver */
5183 static struct pci_driver e1000_driver = {
5184 .name = e1000e_driver_name,
5185 .id_table = e1000_pci_tbl,
5186 .probe = e1000_probe,
5187 .remove = __devexit_p(e1000_remove),
5189 /* Power Management Hooks */
5190 .suspend = e1000_suspend,
5191 .resume = e1000_resume,
5193 .shutdown = e1000_shutdown,
5194 .err_handler = &e1000_err_handler
5198 * e1000_init_module - Driver Registration Routine
5200 * e1000_init_module is the first routine called when the driver is
5201 * loaded. All it does is register with the PCI subsystem.
5203 static int __init e1000_init_module(void)
5206 printk(KERN_INFO "%s: Intel(R) PRO/1000 Network Driver - %s\n",
5207 e1000e_driver_name, e1000e_driver_version);
5208 printk(KERN_INFO "%s: Copyright (c) 1999-2008 Intel Corporation.\n",
5209 e1000e_driver_name);
5210 ret = pci_register_driver(&e1000_driver);
5211 pm_qos_add_requirement(PM_QOS_CPU_DMA_LATENCY, e1000e_driver_name,
5212 PM_QOS_DEFAULT_VALUE);
5216 module_init(e1000_init_module);
5219 * e1000_exit_module - Driver Exit Cleanup Routine
5221 * e1000_exit_module is called just before the driver is removed
5224 static void __exit e1000_exit_module(void)
5226 pci_unregister_driver(&e1000_driver);
5227 pm_qos_remove_requirement(PM_QOS_CPU_DMA_LATENCY, e1000e_driver_name);
5229 module_exit(e1000_exit_module);
5232 MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>");
5233 MODULE_DESCRIPTION("Intel(R) PRO/1000 Network Driver");
5234 MODULE_LICENSE("GPL");
5235 MODULE_VERSION(DRV_VERSION);