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 buffer_info->dma = 0;
570 if (buffer_info->skb) {
571 skb_dma_unmap(&adapter->pdev->dev, buffer_info->skb,
573 dev_kfree_skb_any(buffer_info->skb);
574 buffer_info->skb = NULL;
578 static void e1000_print_tx_hang(struct e1000_adapter *adapter)
580 struct e1000_ring *tx_ring = adapter->tx_ring;
581 unsigned int i = tx_ring->next_to_clean;
582 unsigned int eop = tx_ring->buffer_info[i].next_to_watch;
583 struct e1000_tx_desc *eop_desc = E1000_TX_DESC(*tx_ring, eop);
585 /* detected Tx unit hang */
586 e_err("Detected Tx Unit Hang:\n"
589 " next_to_use <%x>\n"
590 " next_to_clean <%x>\n"
591 "buffer_info[next_to_clean]:\n"
592 " time_stamp <%lx>\n"
593 " next_to_watch <%x>\n"
595 " next_to_watch.status <%x>\n",
596 readl(adapter->hw.hw_addr + tx_ring->head),
597 readl(adapter->hw.hw_addr + tx_ring->tail),
598 tx_ring->next_to_use,
599 tx_ring->next_to_clean,
600 tx_ring->buffer_info[eop].time_stamp,
603 eop_desc->upper.fields.status);
607 * e1000_clean_tx_irq - Reclaim resources after transmit completes
608 * @adapter: board private structure
610 * the return value indicates whether actual cleaning was done, there
611 * is no guarantee that everything was cleaned
613 static bool e1000_clean_tx_irq(struct e1000_adapter *adapter)
615 struct net_device *netdev = adapter->netdev;
616 struct e1000_hw *hw = &adapter->hw;
617 struct e1000_ring *tx_ring = adapter->tx_ring;
618 struct e1000_tx_desc *tx_desc, *eop_desc;
619 struct e1000_buffer *buffer_info;
621 unsigned int count = 0;
623 unsigned int total_tx_bytes = 0, total_tx_packets = 0;
625 i = tx_ring->next_to_clean;
626 eop = tx_ring->buffer_info[i].next_to_watch;
627 eop_desc = E1000_TX_DESC(*tx_ring, eop);
629 while (eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) {
630 for (cleaned = 0; !cleaned; ) {
631 tx_desc = E1000_TX_DESC(*tx_ring, i);
632 buffer_info = &tx_ring->buffer_info[i];
633 cleaned = (i == eop);
636 struct sk_buff *skb = buffer_info->skb;
637 unsigned int segs, bytecount;
638 segs = skb_shinfo(skb)->gso_segs ?: 1;
639 /* multiply data chunks by size of headers */
640 bytecount = ((segs - 1) * skb_headlen(skb)) +
642 total_tx_packets += segs;
643 total_tx_bytes += bytecount;
646 e1000_put_txbuf(adapter, buffer_info);
647 tx_desc->upper.data = 0;
650 if (i == tx_ring->count)
654 eop = tx_ring->buffer_info[i].next_to_watch;
655 eop_desc = E1000_TX_DESC(*tx_ring, eop);
656 #define E1000_TX_WEIGHT 64
657 /* weight of a sort for tx, to avoid endless transmit cleanup */
658 if (count++ == E1000_TX_WEIGHT)
662 tx_ring->next_to_clean = i;
664 #define TX_WAKE_THRESHOLD 32
665 if (cleaned && netif_carrier_ok(netdev) &&
666 e1000_desc_unused(tx_ring) >= TX_WAKE_THRESHOLD) {
667 /* Make sure that anybody stopping the queue after this
668 * sees the new next_to_clean.
672 if (netif_queue_stopped(netdev) &&
673 !(test_bit(__E1000_DOWN, &adapter->state))) {
674 netif_wake_queue(netdev);
675 ++adapter->restart_queue;
679 if (adapter->detect_tx_hung) {
681 * Detect a transmit hang in hardware, this serializes the
682 * check with the clearing of time_stamp and movement of i
684 adapter->detect_tx_hung = 0;
686 * read barrier to make sure that the ->dma member and time
687 * stamp are updated fully
690 if (tx_ring->buffer_info[eop].dma &&
691 time_after(jiffies, tx_ring->buffer_info[eop].time_stamp
692 + (adapter->tx_timeout_factor * HZ))
693 && !(er32(STATUS) & E1000_STATUS_TXOFF)) {
694 e1000_print_tx_hang(adapter);
695 netif_stop_queue(netdev);
698 adapter->total_tx_bytes += total_tx_bytes;
699 adapter->total_tx_packets += total_tx_packets;
700 adapter->net_stats.tx_bytes += total_tx_bytes;
701 adapter->net_stats.tx_packets += total_tx_packets;
706 * e1000_clean_rx_irq_ps - Send received data up the network stack; packet split
707 * @adapter: board private structure
709 * the return value indicates whether actual cleaning was done, there
710 * is no guarantee that everything was cleaned
712 static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
713 int *work_done, int work_to_do)
715 union e1000_rx_desc_packet_split *rx_desc, *next_rxd;
716 struct net_device *netdev = adapter->netdev;
717 struct pci_dev *pdev = adapter->pdev;
718 struct e1000_ring *rx_ring = adapter->rx_ring;
719 struct e1000_buffer *buffer_info, *next_buffer;
720 struct e1000_ps_page *ps_page;
724 int cleaned_count = 0;
726 unsigned int total_rx_bytes = 0, total_rx_packets = 0;
728 i = rx_ring->next_to_clean;
729 rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
730 staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
731 buffer_info = &rx_ring->buffer_info[i];
733 while (staterr & E1000_RXD_STAT_DD) {
734 if (*work_done >= work_to_do)
737 skb = buffer_info->skb;
739 /* in the packet split case this is header only */
740 prefetch(skb->data - NET_IP_ALIGN);
743 if (i == rx_ring->count)
745 next_rxd = E1000_RX_DESC_PS(*rx_ring, i);
748 next_buffer = &rx_ring->buffer_info[i];
752 pci_unmap_single(pdev, buffer_info->dma,
753 adapter->rx_ps_bsize0,
755 buffer_info->dma = 0;
757 if (!(staterr & E1000_RXD_STAT_EOP)) {
758 e_dbg("%s: Packet Split buffers didn't pick up the "
759 "full packet\n", netdev->name);
760 dev_kfree_skb_irq(skb);
764 if (staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK) {
765 dev_kfree_skb_irq(skb);
769 length = le16_to_cpu(rx_desc->wb.middle.length0);
772 e_dbg("%s: Last part of the packet spanning multiple "
773 "descriptors\n", netdev->name);
774 dev_kfree_skb_irq(skb);
779 skb_put(skb, length);
783 * this looks ugly, but it seems compiler issues make it
784 * more efficient than reusing j
786 int l1 = le16_to_cpu(rx_desc->wb.upper.length[0]);
789 * page alloc/put takes too long and effects small packet
790 * throughput, so unsplit small packets and save the alloc/put
791 * only valid in softirq (napi) context to call kmap_*
793 if (l1 && (l1 <= copybreak) &&
794 ((length + l1) <= adapter->rx_ps_bsize0)) {
797 ps_page = &buffer_info->ps_pages[0];
800 * there is no documentation about how to call
801 * kmap_atomic, so we can't hold the mapping
804 pci_dma_sync_single_for_cpu(pdev, ps_page->dma,
805 PAGE_SIZE, PCI_DMA_FROMDEVICE);
806 vaddr = kmap_atomic(ps_page->page, KM_SKB_DATA_SOFTIRQ);
807 memcpy(skb_tail_pointer(skb), vaddr, l1);
808 kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ);
809 pci_dma_sync_single_for_device(pdev, ps_page->dma,
810 PAGE_SIZE, PCI_DMA_FROMDEVICE);
813 if (!(adapter->flags2 & FLAG2_CRC_STRIPPING))
821 for (j = 0; j < PS_PAGE_BUFFERS; j++) {
822 length = le16_to_cpu(rx_desc->wb.upper.length[j]);
826 ps_page = &buffer_info->ps_pages[j];
827 pci_unmap_page(pdev, ps_page->dma, PAGE_SIZE,
830 skb_fill_page_desc(skb, j, ps_page->page, 0, length);
831 ps_page->page = NULL;
833 skb->data_len += length;
834 skb->truesize += length;
837 /* strip the ethernet crc, problem is we're using pages now so
838 * this whole operation can get a little cpu intensive
840 if (!(adapter->flags2 & FLAG2_CRC_STRIPPING))
841 pskb_trim(skb, skb->len - 4);
844 total_rx_bytes += skb->len;
847 e1000_rx_checksum(adapter, staterr, le16_to_cpu(
848 rx_desc->wb.lower.hi_dword.csum_ip.csum), skb);
850 if (rx_desc->wb.upper.header_status &
851 cpu_to_le16(E1000_RXDPS_HDRSTAT_HDRSP))
852 adapter->rx_hdr_split++;
854 e1000_receive_skb(adapter, netdev, skb,
855 staterr, rx_desc->wb.middle.vlan);
858 rx_desc->wb.middle.status_error &= cpu_to_le32(~0xFF);
859 buffer_info->skb = NULL;
861 /* return some buffers to hardware, one at a time is too slow */
862 if (cleaned_count >= E1000_RX_BUFFER_WRITE) {
863 adapter->alloc_rx_buf(adapter, cleaned_count);
867 /* use prefetched values */
869 buffer_info = next_buffer;
871 staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
873 rx_ring->next_to_clean = i;
875 cleaned_count = e1000_desc_unused(rx_ring);
877 adapter->alloc_rx_buf(adapter, cleaned_count);
879 adapter->total_rx_bytes += total_rx_bytes;
880 adapter->total_rx_packets += total_rx_packets;
881 adapter->net_stats.rx_bytes += total_rx_bytes;
882 adapter->net_stats.rx_packets += total_rx_packets;
887 * e1000_consume_page - helper function
889 static void e1000_consume_page(struct e1000_buffer *bi, struct sk_buff *skb,
894 skb->data_len += length;
895 skb->truesize += length;
899 * e1000_clean_jumbo_rx_irq - Send received data up the network stack; legacy
900 * @adapter: board private structure
902 * the return value indicates whether actual cleaning was done, there
903 * is no guarantee that everything was cleaned
906 static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter,
907 int *work_done, int work_to_do)
909 struct net_device *netdev = adapter->netdev;
910 struct pci_dev *pdev = adapter->pdev;
911 struct e1000_ring *rx_ring = adapter->rx_ring;
912 struct e1000_rx_desc *rx_desc, *next_rxd;
913 struct e1000_buffer *buffer_info, *next_buffer;
916 int cleaned_count = 0;
917 bool cleaned = false;
918 unsigned int total_rx_bytes=0, total_rx_packets=0;
920 i = rx_ring->next_to_clean;
921 rx_desc = E1000_RX_DESC(*rx_ring, i);
922 buffer_info = &rx_ring->buffer_info[i];
924 while (rx_desc->status & E1000_RXD_STAT_DD) {
928 if (*work_done >= work_to_do)
932 status = rx_desc->status;
933 skb = buffer_info->skb;
934 buffer_info->skb = NULL;
937 if (i == rx_ring->count)
939 next_rxd = E1000_RX_DESC(*rx_ring, i);
942 next_buffer = &rx_ring->buffer_info[i];
946 pci_unmap_page(pdev, buffer_info->dma, PAGE_SIZE,
948 buffer_info->dma = 0;
950 length = le16_to_cpu(rx_desc->length);
952 /* errors is only valid for DD + EOP descriptors */
953 if (unlikely((status & E1000_RXD_STAT_EOP) &&
954 (rx_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK))) {
955 /* recycle both page and skb */
956 buffer_info->skb = skb;
957 /* an error means any chain goes out the window
959 if (rx_ring->rx_skb_top)
960 dev_kfree_skb(rx_ring->rx_skb_top);
961 rx_ring->rx_skb_top = NULL;
965 #define rxtop rx_ring->rx_skb_top
966 if (!(status & E1000_RXD_STAT_EOP)) {
967 /* this descriptor is only the beginning (or middle) */
969 /* this is the beginning of a chain */
971 skb_fill_page_desc(rxtop, 0, buffer_info->page,
974 /* this is the middle of a chain */
975 skb_fill_page_desc(rxtop,
976 skb_shinfo(rxtop)->nr_frags,
977 buffer_info->page, 0, length);
978 /* re-use the skb, only consumed the page */
979 buffer_info->skb = skb;
981 e1000_consume_page(buffer_info, rxtop, length);
985 /* end of the chain */
986 skb_fill_page_desc(rxtop,
987 skb_shinfo(rxtop)->nr_frags,
988 buffer_info->page, 0, length);
989 /* re-use the current skb, we only consumed the
991 buffer_info->skb = skb;
994 e1000_consume_page(buffer_info, skb, length);
996 /* no chain, got EOP, this buf is the packet
997 * copybreak to save the put_page/alloc_page */
998 if (length <= copybreak &&
999 skb_tailroom(skb) >= length) {
1001 vaddr = kmap_atomic(buffer_info->page,
1002 KM_SKB_DATA_SOFTIRQ);
1003 memcpy(skb_tail_pointer(skb), vaddr,
1005 kunmap_atomic(vaddr,
1006 KM_SKB_DATA_SOFTIRQ);
1007 /* re-use the page, so don't erase
1008 * buffer_info->page */
1009 skb_put(skb, length);
1011 skb_fill_page_desc(skb, 0,
1012 buffer_info->page, 0,
1014 e1000_consume_page(buffer_info, skb,
1020 /* Receive Checksum Offload XXX recompute due to CRC strip? */
1021 e1000_rx_checksum(adapter,
1023 ((u32)(rx_desc->errors) << 24),
1024 le16_to_cpu(rx_desc->csum), skb);
1026 /* probably a little skewed due to removing CRC */
1027 total_rx_bytes += skb->len;
1030 /* eth type trans needs skb->data to point to something */
1031 if (!pskb_may_pull(skb, ETH_HLEN)) {
1032 e_err("pskb_may_pull failed.\n");
1037 e1000_receive_skb(adapter, netdev, skb, status,
1041 rx_desc->status = 0;
1043 /* return some buffers to hardware, one at a time is too slow */
1044 if (unlikely(cleaned_count >= E1000_RX_BUFFER_WRITE)) {
1045 adapter->alloc_rx_buf(adapter, cleaned_count);
1049 /* use prefetched values */
1051 buffer_info = next_buffer;
1053 rx_ring->next_to_clean = i;
1055 cleaned_count = e1000_desc_unused(rx_ring);
1057 adapter->alloc_rx_buf(adapter, cleaned_count);
1059 adapter->total_rx_bytes += total_rx_bytes;
1060 adapter->total_rx_packets += total_rx_packets;
1061 adapter->net_stats.rx_bytes += total_rx_bytes;
1062 adapter->net_stats.rx_packets += total_rx_packets;
1067 * e1000_clean_rx_ring - Free Rx Buffers per Queue
1068 * @adapter: board private structure
1070 static void e1000_clean_rx_ring(struct e1000_adapter *adapter)
1072 struct e1000_ring *rx_ring = adapter->rx_ring;
1073 struct e1000_buffer *buffer_info;
1074 struct e1000_ps_page *ps_page;
1075 struct pci_dev *pdev = adapter->pdev;
1078 /* Free all the Rx ring sk_buffs */
1079 for (i = 0; i < rx_ring->count; i++) {
1080 buffer_info = &rx_ring->buffer_info[i];
1081 if (buffer_info->dma) {
1082 if (adapter->clean_rx == e1000_clean_rx_irq)
1083 pci_unmap_single(pdev, buffer_info->dma,
1084 adapter->rx_buffer_len,
1085 PCI_DMA_FROMDEVICE);
1086 else if (adapter->clean_rx == e1000_clean_jumbo_rx_irq)
1087 pci_unmap_page(pdev, buffer_info->dma,
1089 PCI_DMA_FROMDEVICE);
1090 else if (adapter->clean_rx == e1000_clean_rx_irq_ps)
1091 pci_unmap_single(pdev, buffer_info->dma,
1092 adapter->rx_ps_bsize0,
1093 PCI_DMA_FROMDEVICE);
1094 buffer_info->dma = 0;
1097 if (buffer_info->page) {
1098 put_page(buffer_info->page);
1099 buffer_info->page = NULL;
1102 if (buffer_info->skb) {
1103 dev_kfree_skb(buffer_info->skb);
1104 buffer_info->skb = NULL;
1107 for (j = 0; j < PS_PAGE_BUFFERS; j++) {
1108 ps_page = &buffer_info->ps_pages[j];
1111 pci_unmap_page(pdev, ps_page->dma, PAGE_SIZE,
1112 PCI_DMA_FROMDEVICE);
1114 put_page(ps_page->page);
1115 ps_page->page = NULL;
1119 /* there also may be some cached data from a chained receive */
1120 if (rx_ring->rx_skb_top) {
1121 dev_kfree_skb(rx_ring->rx_skb_top);
1122 rx_ring->rx_skb_top = NULL;
1125 /* Zero out the descriptor ring */
1126 memset(rx_ring->desc, 0, rx_ring->size);
1128 rx_ring->next_to_clean = 0;
1129 rx_ring->next_to_use = 0;
1131 writel(0, adapter->hw.hw_addr + rx_ring->head);
1132 writel(0, adapter->hw.hw_addr + rx_ring->tail);
1135 static void e1000e_downshift_workaround(struct work_struct *work)
1137 struct e1000_adapter *adapter = container_of(work,
1138 struct e1000_adapter, downshift_task);
1140 e1000e_gig_downshift_workaround_ich8lan(&adapter->hw);
1144 * e1000_intr_msi - Interrupt Handler
1145 * @irq: interrupt number
1146 * @data: pointer to a network interface device structure
1148 static irqreturn_t e1000_intr_msi(int irq, void *data)
1150 struct net_device *netdev = data;
1151 struct e1000_adapter *adapter = netdev_priv(netdev);
1152 struct e1000_hw *hw = &adapter->hw;
1153 u32 icr = er32(ICR);
1156 * read ICR disables interrupts using IAM
1159 if (icr & E1000_ICR_LSC) {
1160 hw->mac.get_link_status = 1;
1162 * ICH8 workaround-- Call gig speed drop workaround on cable
1163 * disconnect (LSC) before accessing any PHY registers
1165 if ((adapter->flags & FLAG_LSC_GIG_SPEED_DROP) &&
1166 (!(er32(STATUS) & E1000_STATUS_LU)))
1167 schedule_work(&adapter->downshift_task);
1170 * 80003ES2LAN workaround-- For packet buffer work-around on
1171 * link down event; disable receives here in the ISR and reset
1172 * adapter in watchdog
1174 if (netif_carrier_ok(netdev) &&
1175 adapter->flags & FLAG_RX_NEEDS_RESTART) {
1176 /* disable receives */
1177 u32 rctl = er32(RCTL);
1178 ew32(RCTL, rctl & ~E1000_RCTL_EN);
1179 adapter->flags |= FLAG_RX_RESTART_NOW;
1181 /* guard against interrupt when we're going down */
1182 if (!test_bit(__E1000_DOWN, &adapter->state))
1183 mod_timer(&adapter->watchdog_timer, jiffies + 1);
1186 if (napi_schedule_prep(&adapter->napi)) {
1187 adapter->total_tx_bytes = 0;
1188 adapter->total_tx_packets = 0;
1189 adapter->total_rx_bytes = 0;
1190 adapter->total_rx_packets = 0;
1191 __napi_schedule(&adapter->napi);
1198 * e1000_intr - Interrupt Handler
1199 * @irq: interrupt number
1200 * @data: pointer to a network interface device structure
1202 static irqreturn_t e1000_intr(int irq, void *data)
1204 struct net_device *netdev = data;
1205 struct e1000_adapter *adapter = netdev_priv(netdev);
1206 struct e1000_hw *hw = &adapter->hw;
1207 u32 rctl, icr = er32(ICR);
1210 return IRQ_NONE; /* Not our interrupt */
1213 * IMS will not auto-mask if INT_ASSERTED is not set, and if it is
1214 * not set, then the adapter didn't send an interrupt
1216 if (!(icr & E1000_ICR_INT_ASSERTED))
1220 * Interrupt Auto-Mask...upon reading ICR,
1221 * interrupts are masked. No need for the
1225 if (icr & E1000_ICR_LSC) {
1226 hw->mac.get_link_status = 1;
1228 * ICH8 workaround-- Call gig speed drop workaround on cable
1229 * disconnect (LSC) before accessing any PHY registers
1231 if ((adapter->flags & FLAG_LSC_GIG_SPEED_DROP) &&
1232 (!(er32(STATUS) & E1000_STATUS_LU)))
1233 schedule_work(&adapter->downshift_task);
1236 * 80003ES2LAN workaround--
1237 * For packet buffer work-around on link down event;
1238 * disable receives here in the ISR and
1239 * reset adapter in watchdog
1241 if (netif_carrier_ok(netdev) &&
1242 (adapter->flags & FLAG_RX_NEEDS_RESTART)) {
1243 /* disable receives */
1245 ew32(RCTL, rctl & ~E1000_RCTL_EN);
1246 adapter->flags |= FLAG_RX_RESTART_NOW;
1248 /* guard against interrupt when we're going down */
1249 if (!test_bit(__E1000_DOWN, &adapter->state))
1250 mod_timer(&adapter->watchdog_timer, jiffies + 1);
1253 if (napi_schedule_prep(&adapter->napi)) {
1254 adapter->total_tx_bytes = 0;
1255 adapter->total_tx_packets = 0;
1256 adapter->total_rx_bytes = 0;
1257 adapter->total_rx_packets = 0;
1258 __napi_schedule(&adapter->napi);
1264 static irqreturn_t e1000_msix_other(int irq, void *data)
1266 struct net_device *netdev = data;
1267 struct e1000_adapter *adapter = netdev_priv(netdev);
1268 struct e1000_hw *hw = &adapter->hw;
1269 u32 icr = er32(ICR);
1271 if (!(icr & E1000_ICR_INT_ASSERTED)) {
1272 ew32(IMS, E1000_IMS_OTHER);
1276 if (icr & adapter->eiac_mask)
1277 ew32(ICS, (icr & adapter->eiac_mask));
1279 if (icr & E1000_ICR_OTHER) {
1280 if (!(icr & E1000_ICR_LSC))
1281 goto no_link_interrupt;
1282 hw->mac.get_link_status = 1;
1283 /* guard against interrupt when we're going down */
1284 if (!test_bit(__E1000_DOWN, &adapter->state))
1285 mod_timer(&adapter->watchdog_timer, jiffies + 1);
1289 ew32(IMS, E1000_IMS_LSC | E1000_IMS_OTHER);
1295 static irqreturn_t e1000_intr_msix_tx(int irq, void *data)
1297 struct net_device *netdev = data;
1298 struct e1000_adapter *adapter = netdev_priv(netdev);
1299 struct e1000_hw *hw = &adapter->hw;
1300 struct e1000_ring *tx_ring = adapter->tx_ring;
1303 adapter->total_tx_bytes = 0;
1304 adapter->total_tx_packets = 0;
1306 if (!e1000_clean_tx_irq(adapter))
1307 /* Ring was not completely cleaned, so fire another interrupt */
1308 ew32(ICS, tx_ring->ims_val);
1313 static irqreturn_t e1000_intr_msix_rx(int irq, void *data)
1315 struct net_device *netdev = data;
1316 struct e1000_adapter *adapter = netdev_priv(netdev);
1318 /* Write the ITR value calculated at the end of the
1319 * previous interrupt.
1321 if (adapter->rx_ring->set_itr) {
1322 writel(1000000000 / (adapter->rx_ring->itr_val * 256),
1323 adapter->hw.hw_addr + adapter->rx_ring->itr_register);
1324 adapter->rx_ring->set_itr = 0;
1327 if (napi_schedule_prep(&adapter->napi)) {
1328 adapter->total_rx_bytes = 0;
1329 adapter->total_rx_packets = 0;
1330 __napi_schedule(&adapter->napi);
1336 * e1000_configure_msix - Configure MSI-X hardware
1338 * e1000_configure_msix sets up the hardware to properly
1339 * generate MSI-X interrupts.
1341 static void e1000_configure_msix(struct e1000_adapter *adapter)
1343 struct e1000_hw *hw = &adapter->hw;
1344 struct e1000_ring *rx_ring = adapter->rx_ring;
1345 struct e1000_ring *tx_ring = adapter->tx_ring;
1347 u32 ctrl_ext, ivar = 0;
1349 adapter->eiac_mask = 0;
1351 /* Workaround issue with spurious interrupts on 82574 in MSI-X mode */
1352 if (hw->mac.type == e1000_82574) {
1353 u32 rfctl = er32(RFCTL);
1354 rfctl |= E1000_RFCTL_ACK_DIS;
1358 #define E1000_IVAR_INT_ALLOC_VALID 0x8
1359 /* Configure Rx vector */
1360 rx_ring->ims_val = E1000_IMS_RXQ0;
1361 adapter->eiac_mask |= rx_ring->ims_val;
1362 if (rx_ring->itr_val)
1363 writel(1000000000 / (rx_ring->itr_val * 256),
1364 hw->hw_addr + rx_ring->itr_register);
1366 writel(1, hw->hw_addr + rx_ring->itr_register);
1367 ivar = E1000_IVAR_INT_ALLOC_VALID | vector;
1369 /* Configure Tx vector */
1370 tx_ring->ims_val = E1000_IMS_TXQ0;
1372 if (tx_ring->itr_val)
1373 writel(1000000000 / (tx_ring->itr_val * 256),
1374 hw->hw_addr + tx_ring->itr_register);
1376 writel(1, hw->hw_addr + tx_ring->itr_register);
1377 adapter->eiac_mask |= tx_ring->ims_val;
1378 ivar |= ((E1000_IVAR_INT_ALLOC_VALID | vector) << 8);
1380 /* set vector for Other Causes, e.g. link changes */
1382 ivar |= ((E1000_IVAR_INT_ALLOC_VALID | vector) << 16);
1383 if (rx_ring->itr_val)
1384 writel(1000000000 / (rx_ring->itr_val * 256),
1385 hw->hw_addr + E1000_EITR_82574(vector));
1387 writel(1, hw->hw_addr + E1000_EITR_82574(vector));
1389 /* Cause Tx interrupts on every write back */
1394 /* enable MSI-X PBA support */
1395 ctrl_ext = er32(CTRL_EXT);
1396 ctrl_ext |= E1000_CTRL_EXT_PBA_CLR;
1398 /* Auto-Mask Other interrupts upon ICR read */
1399 #define E1000_EIAC_MASK_82574 0x01F00000
1400 ew32(IAM, ~E1000_EIAC_MASK_82574 | E1000_IMS_OTHER);
1401 ctrl_ext |= E1000_CTRL_EXT_EIAME;
1402 ew32(CTRL_EXT, ctrl_ext);
1406 void e1000e_reset_interrupt_capability(struct e1000_adapter *adapter)
1408 if (adapter->msix_entries) {
1409 pci_disable_msix(adapter->pdev);
1410 kfree(adapter->msix_entries);
1411 adapter->msix_entries = NULL;
1412 } else if (adapter->flags & FLAG_MSI_ENABLED) {
1413 pci_disable_msi(adapter->pdev);
1414 adapter->flags &= ~FLAG_MSI_ENABLED;
1421 * e1000e_set_interrupt_capability - set MSI or MSI-X if supported
1423 * Attempt to configure interrupts using the best available
1424 * capabilities of the hardware and kernel.
1426 void e1000e_set_interrupt_capability(struct e1000_adapter *adapter)
1432 switch (adapter->int_mode) {
1433 case E1000E_INT_MODE_MSIX:
1434 if (adapter->flags & FLAG_HAS_MSIX) {
1435 numvecs = 3; /* RxQ0, TxQ0 and other */
1436 adapter->msix_entries = kcalloc(numvecs,
1437 sizeof(struct msix_entry),
1439 if (adapter->msix_entries) {
1440 for (i = 0; i < numvecs; i++)
1441 adapter->msix_entries[i].entry = i;
1443 err = pci_enable_msix(adapter->pdev,
1444 adapter->msix_entries,
1449 /* MSI-X failed, so fall through and try MSI */
1450 e_err("Failed to initialize MSI-X interrupts. "
1451 "Falling back to MSI interrupts.\n");
1452 e1000e_reset_interrupt_capability(adapter);
1454 adapter->int_mode = E1000E_INT_MODE_MSI;
1456 case E1000E_INT_MODE_MSI:
1457 if (!pci_enable_msi(adapter->pdev)) {
1458 adapter->flags |= FLAG_MSI_ENABLED;
1460 adapter->int_mode = E1000E_INT_MODE_LEGACY;
1461 e_err("Failed to initialize MSI interrupts. Falling "
1462 "back to legacy interrupts.\n");
1465 case E1000E_INT_MODE_LEGACY:
1466 /* Don't do anything; this is the system default */
1474 * e1000_request_msix - Initialize MSI-X interrupts
1476 * e1000_request_msix allocates MSI-X vectors and requests interrupts from the
1479 static int e1000_request_msix(struct e1000_adapter *adapter)
1481 struct net_device *netdev = adapter->netdev;
1482 int err = 0, vector = 0;
1484 if (strlen(netdev->name) < (IFNAMSIZ - 5))
1485 sprintf(adapter->rx_ring->name, "%s-rx-0", netdev->name);
1487 memcpy(adapter->rx_ring->name, netdev->name, IFNAMSIZ);
1488 err = request_irq(adapter->msix_entries[vector].vector,
1489 &e1000_intr_msix_rx, 0, adapter->rx_ring->name,
1493 adapter->rx_ring->itr_register = E1000_EITR_82574(vector);
1494 adapter->rx_ring->itr_val = adapter->itr;
1497 if (strlen(netdev->name) < (IFNAMSIZ - 5))
1498 sprintf(adapter->tx_ring->name, "%s-tx-0", netdev->name);
1500 memcpy(adapter->tx_ring->name, netdev->name, IFNAMSIZ);
1501 err = request_irq(adapter->msix_entries[vector].vector,
1502 &e1000_intr_msix_tx, 0, adapter->tx_ring->name,
1506 adapter->tx_ring->itr_register = E1000_EITR_82574(vector);
1507 adapter->tx_ring->itr_val = adapter->itr;
1510 err = request_irq(adapter->msix_entries[vector].vector,
1511 &e1000_msix_other, 0, netdev->name, netdev);
1515 e1000_configure_msix(adapter);
1522 * e1000_request_irq - initialize interrupts
1524 * Attempts to configure interrupts using the best available
1525 * capabilities of the hardware and kernel.
1527 static int e1000_request_irq(struct e1000_adapter *adapter)
1529 struct net_device *netdev = adapter->netdev;
1532 if (adapter->msix_entries) {
1533 err = e1000_request_msix(adapter);
1536 /* fall back to MSI */
1537 e1000e_reset_interrupt_capability(adapter);
1538 adapter->int_mode = E1000E_INT_MODE_MSI;
1539 e1000e_set_interrupt_capability(adapter);
1541 if (adapter->flags & FLAG_MSI_ENABLED) {
1542 err = request_irq(adapter->pdev->irq, &e1000_intr_msi, 0,
1543 netdev->name, netdev);
1547 /* fall back to legacy interrupt */
1548 e1000e_reset_interrupt_capability(adapter);
1549 adapter->int_mode = E1000E_INT_MODE_LEGACY;
1552 err = request_irq(adapter->pdev->irq, &e1000_intr, IRQF_SHARED,
1553 netdev->name, netdev);
1555 e_err("Unable to allocate interrupt, Error: %d\n", err);
1560 static void e1000_free_irq(struct e1000_adapter *adapter)
1562 struct net_device *netdev = adapter->netdev;
1564 if (adapter->msix_entries) {
1567 free_irq(adapter->msix_entries[vector].vector, netdev);
1570 free_irq(adapter->msix_entries[vector].vector, netdev);
1573 /* Other Causes interrupt vector */
1574 free_irq(adapter->msix_entries[vector].vector, netdev);
1578 free_irq(adapter->pdev->irq, netdev);
1582 * e1000_irq_disable - Mask off interrupt generation on the NIC
1584 static void e1000_irq_disable(struct e1000_adapter *adapter)
1586 struct e1000_hw *hw = &adapter->hw;
1589 if (adapter->msix_entries)
1590 ew32(EIAC_82574, 0);
1592 synchronize_irq(adapter->pdev->irq);
1596 * e1000_irq_enable - Enable default interrupt generation settings
1598 static void e1000_irq_enable(struct e1000_adapter *adapter)
1600 struct e1000_hw *hw = &adapter->hw;
1602 if (adapter->msix_entries) {
1603 ew32(EIAC_82574, adapter->eiac_mask & E1000_EIAC_MASK_82574);
1604 ew32(IMS, adapter->eiac_mask | E1000_IMS_OTHER | E1000_IMS_LSC);
1606 ew32(IMS, IMS_ENABLE_MASK);
1612 * e1000_get_hw_control - get control of the h/w from f/w
1613 * @adapter: address of board private structure
1615 * e1000_get_hw_control sets {CTRL_EXT|SWSM}:DRV_LOAD bit.
1616 * For ASF and Pass Through versions of f/w this means that
1617 * the driver is loaded. For AMT version (only with 82573)
1618 * of the f/w this means that the network i/f is open.
1620 static void e1000_get_hw_control(struct e1000_adapter *adapter)
1622 struct e1000_hw *hw = &adapter->hw;
1626 /* Let firmware know the driver has taken over */
1627 if (adapter->flags & FLAG_HAS_SWSM_ON_LOAD) {
1629 ew32(SWSM, swsm | E1000_SWSM_DRV_LOAD);
1630 } else if (adapter->flags & FLAG_HAS_CTRLEXT_ON_LOAD) {
1631 ctrl_ext = er32(CTRL_EXT);
1632 ew32(CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_DRV_LOAD);
1637 * e1000_release_hw_control - release control of the h/w to f/w
1638 * @adapter: address of board private structure
1640 * e1000_release_hw_control resets {CTRL_EXT|SWSM}:DRV_LOAD bit.
1641 * For ASF and Pass Through versions of f/w this means that the
1642 * driver is no longer loaded. For AMT version (only with 82573) i
1643 * of the f/w this means that the network i/f is closed.
1646 static void e1000_release_hw_control(struct e1000_adapter *adapter)
1648 struct e1000_hw *hw = &adapter->hw;
1652 /* Let firmware taken over control of h/w */
1653 if (adapter->flags & FLAG_HAS_SWSM_ON_LOAD) {
1655 ew32(SWSM, swsm & ~E1000_SWSM_DRV_LOAD);
1656 } else if (adapter->flags & FLAG_HAS_CTRLEXT_ON_LOAD) {
1657 ctrl_ext = er32(CTRL_EXT);
1658 ew32(CTRL_EXT, ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD);
1663 * @e1000_alloc_ring - allocate memory for a ring structure
1665 static int e1000_alloc_ring_dma(struct e1000_adapter *adapter,
1666 struct e1000_ring *ring)
1668 struct pci_dev *pdev = adapter->pdev;
1670 ring->desc = dma_alloc_coherent(&pdev->dev, ring->size, &ring->dma,
1679 * e1000e_setup_tx_resources - allocate Tx resources (Descriptors)
1680 * @adapter: board private structure
1682 * Return 0 on success, negative on failure
1684 int e1000e_setup_tx_resources(struct e1000_adapter *adapter)
1686 struct e1000_ring *tx_ring = adapter->tx_ring;
1687 int err = -ENOMEM, size;
1689 size = sizeof(struct e1000_buffer) * tx_ring->count;
1690 tx_ring->buffer_info = vmalloc(size);
1691 if (!tx_ring->buffer_info)
1693 memset(tx_ring->buffer_info, 0, size);
1695 /* round up to nearest 4K */
1696 tx_ring->size = tx_ring->count * sizeof(struct e1000_tx_desc);
1697 tx_ring->size = ALIGN(tx_ring->size, 4096);
1699 err = e1000_alloc_ring_dma(adapter, tx_ring);
1703 tx_ring->next_to_use = 0;
1704 tx_ring->next_to_clean = 0;
1708 vfree(tx_ring->buffer_info);
1709 e_err("Unable to allocate memory for the transmit descriptor ring\n");
1714 * e1000e_setup_rx_resources - allocate Rx resources (Descriptors)
1715 * @adapter: board private structure
1717 * Returns 0 on success, negative on failure
1719 int e1000e_setup_rx_resources(struct e1000_adapter *adapter)
1721 struct e1000_ring *rx_ring = adapter->rx_ring;
1722 struct e1000_buffer *buffer_info;
1723 int i, size, desc_len, err = -ENOMEM;
1725 size = sizeof(struct e1000_buffer) * rx_ring->count;
1726 rx_ring->buffer_info = vmalloc(size);
1727 if (!rx_ring->buffer_info)
1729 memset(rx_ring->buffer_info, 0, size);
1731 for (i = 0; i < rx_ring->count; i++) {
1732 buffer_info = &rx_ring->buffer_info[i];
1733 buffer_info->ps_pages = kcalloc(PS_PAGE_BUFFERS,
1734 sizeof(struct e1000_ps_page),
1736 if (!buffer_info->ps_pages)
1740 desc_len = sizeof(union e1000_rx_desc_packet_split);
1742 /* Round up to nearest 4K */
1743 rx_ring->size = rx_ring->count * desc_len;
1744 rx_ring->size = ALIGN(rx_ring->size, 4096);
1746 err = e1000_alloc_ring_dma(adapter, rx_ring);
1750 rx_ring->next_to_clean = 0;
1751 rx_ring->next_to_use = 0;
1752 rx_ring->rx_skb_top = NULL;
1757 for (i = 0; i < rx_ring->count; i++) {
1758 buffer_info = &rx_ring->buffer_info[i];
1759 kfree(buffer_info->ps_pages);
1762 vfree(rx_ring->buffer_info);
1763 e_err("Unable to allocate memory for the transmit descriptor ring\n");
1768 * e1000_clean_tx_ring - Free Tx Buffers
1769 * @adapter: board private structure
1771 static void e1000_clean_tx_ring(struct e1000_adapter *adapter)
1773 struct e1000_ring *tx_ring = adapter->tx_ring;
1774 struct e1000_buffer *buffer_info;
1778 for (i = 0; i < tx_ring->count; i++) {
1779 buffer_info = &tx_ring->buffer_info[i];
1780 e1000_put_txbuf(adapter, buffer_info);
1783 size = sizeof(struct e1000_buffer) * tx_ring->count;
1784 memset(tx_ring->buffer_info, 0, size);
1786 memset(tx_ring->desc, 0, tx_ring->size);
1788 tx_ring->next_to_use = 0;
1789 tx_ring->next_to_clean = 0;
1791 writel(0, adapter->hw.hw_addr + tx_ring->head);
1792 writel(0, adapter->hw.hw_addr + tx_ring->tail);
1796 * e1000e_free_tx_resources - Free Tx Resources per Queue
1797 * @adapter: board private structure
1799 * Free all transmit software resources
1801 void e1000e_free_tx_resources(struct e1000_adapter *adapter)
1803 struct pci_dev *pdev = adapter->pdev;
1804 struct e1000_ring *tx_ring = adapter->tx_ring;
1806 e1000_clean_tx_ring(adapter);
1808 vfree(tx_ring->buffer_info);
1809 tx_ring->buffer_info = NULL;
1811 dma_free_coherent(&pdev->dev, tx_ring->size, tx_ring->desc,
1813 tx_ring->desc = NULL;
1817 * e1000e_free_rx_resources - Free Rx Resources
1818 * @adapter: board private structure
1820 * Free all receive software resources
1823 void e1000e_free_rx_resources(struct e1000_adapter *adapter)
1825 struct pci_dev *pdev = adapter->pdev;
1826 struct e1000_ring *rx_ring = adapter->rx_ring;
1829 e1000_clean_rx_ring(adapter);
1831 for (i = 0; i < rx_ring->count; i++) {
1832 kfree(rx_ring->buffer_info[i].ps_pages);
1835 vfree(rx_ring->buffer_info);
1836 rx_ring->buffer_info = NULL;
1838 dma_free_coherent(&pdev->dev, rx_ring->size, rx_ring->desc,
1840 rx_ring->desc = NULL;
1844 * e1000_update_itr - update the dynamic ITR value based on statistics
1845 * @adapter: pointer to adapter
1846 * @itr_setting: current adapter->itr
1847 * @packets: the number of packets during this measurement interval
1848 * @bytes: the number of bytes during this measurement interval
1850 * Stores a new ITR value based on packets and byte
1851 * counts during the last interrupt. The advantage of per interrupt
1852 * computation is faster updates and more accurate ITR for the current
1853 * traffic pattern. Constants in this function were computed
1854 * based on theoretical maximum wire speed and thresholds were set based
1855 * on testing data as well as attempting to minimize response time
1856 * while increasing bulk throughput. This functionality is controlled
1857 * by the InterruptThrottleRate module parameter.
1859 static unsigned int e1000_update_itr(struct e1000_adapter *adapter,
1860 u16 itr_setting, int packets,
1863 unsigned int retval = itr_setting;
1866 goto update_itr_done;
1868 switch (itr_setting) {
1869 case lowest_latency:
1870 /* handle TSO and jumbo frames */
1871 if (bytes/packets > 8000)
1872 retval = bulk_latency;
1873 else if ((packets < 5) && (bytes > 512)) {
1874 retval = low_latency;
1877 case low_latency: /* 50 usec aka 20000 ints/s */
1878 if (bytes > 10000) {
1879 /* this if handles the TSO accounting */
1880 if (bytes/packets > 8000) {
1881 retval = bulk_latency;
1882 } else if ((packets < 10) || ((bytes/packets) > 1200)) {
1883 retval = bulk_latency;
1884 } else if ((packets > 35)) {
1885 retval = lowest_latency;
1887 } else if (bytes/packets > 2000) {
1888 retval = bulk_latency;
1889 } else if (packets <= 2 && bytes < 512) {
1890 retval = lowest_latency;
1893 case bulk_latency: /* 250 usec aka 4000 ints/s */
1894 if (bytes > 25000) {
1896 retval = low_latency;
1898 } else if (bytes < 6000) {
1899 retval = low_latency;
1908 static void e1000_set_itr(struct e1000_adapter *adapter)
1910 struct e1000_hw *hw = &adapter->hw;
1912 u32 new_itr = adapter->itr;
1914 /* for non-gigabit speeds, just fix the interrupt rate at 4000 */
1915 if (adapter->link_speed != SPEED_1000) {
1921 adapter->tx_itr = e1000_update_itr(adapter,
1923 adapter->total_tx_packets,
1924 adapter->total_tx_bytes);
1925 /* conservative mode (itr 3) eliminates the lowest_latency setting */
1926 if (adapter->itr_setting == 3 && adapter->tx_itr == lowest_latency)
1927 adapter->tx_itr = low_latency;
1929 adapter->rx_itr = e1000_update_itr(adapter,
1931 adapter->total_rx_packets,
1932 adapter->total_rx_bytes);
1933 /* conservative mode (itr 3) eliminates the lowest_latency setting */
1934 if (adapter->itr_setting == 3 && adapter->rx_itr == lowest_latency)
1935 adapter->rx_itr = low_latency;
1937 current_itr = max(adapter->rx_itr, adapter->tx_itr);
1939 switch (current_itr) {
1940 /* counts and packets in update_itr are dependent on these numbers */
1941 case lowest_latency:
1945 new_itr = 20000; /* aka hwitr = ~200 */
1955 if (new_itr != adapter->itr) {
1957 * this attempts to bias the interrupt rate towards Bulk
1958 * by adding intermediate steps when interrupt rate is
1961 new_itr = new_itr > adapter->itr ?
1962 min(adapter->itr + (new_itr >> 2), new_itr) :
1964 adapter->itr = new_itr;
1965 adapter->rx_ring->itr_val = new_itr;
1966 if (adapter->msix_entries)
1967 adapter->rx_ring->set_itr = 1;
1969 ew32(ITR, 1000000000 / (new_itr * 256));
1974 * e1000_alloc_queues - Allocate memory for all rings
1975 * @adapter: board private structure to initialize
1977 static int __devinit e1000_alloc_queues(struct e1000_adapter *adapter)
1979 adapter->tx_ring = kzalloc(sizeof(struct e1000_ring), GFP_KERNEL);
1980 if (!adapter->tx_ring)
1983 adapter->rx_ring = kzalloc(sizeof(struct e1000_ring), GFP_KERNEL);
1984 if (!adapter->rx_ring)
1989 e_err("Unable to allocate memory for queues\n");
1990 kfree(adapter->rx_ring);
1991 kfree(adapter->tx_ring);
1996 * e1000_clean - NAPI Rx polling callback
1997 * @napi: struct associated with this polling callback
1998 * @budget: amount of packets driver is allowed to process this poll
2000 static int e1000_clean(struct napi_struct *napi, int budget)
2002 struct e1000_adapter *adapter = container_of(napi, struct e1000_adapter, napi);
2003 struct e1000_hw *hw = &adapter->hw;
2004 struct net_device *poll_dev = adapter->netdev;
2005 int tx_cleaned = 0, work_done = 0;
2007 adapter = netdev_priv(poll_dev);
2009 if (adapter->msix_entries &&
2010 !(adapter->rx_ring->ims_val & adapter->tx_ring->ims_val))
2013 tx_cleaned = e1000_clean_tx_irq(adapter);
2016 adapter->clean_rx(adapter, &work_done, budget);
2021 /* If budget not fully consumed, exit the polling mode */
2022 if (work_done < budget) {
2023 if (adapter->itr_setting & 3)
2024 e1000_set_itr(adapter);
2025 napi_complete(napi);
2026 if (adapter->msix_entries)
2027 ew32(IMS, adapter->rx_ring->ims_val);
2029 e1000_irq_enable(adapter);
2035 static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
2037 struct e1000_adapter *adapter = netdev_priv(netdev);
2038 struct e1000_hw *hw = &adapter->hw;
2041 /* don't update vlan cookie if already programmed */
2042 if ((adapter->hw.mng_cookie.status &
2043 E1000_MNG_DHCP_COOKIE_STATUS_VLAN) &&
2044 (vid == adapter->mng_vlan_id))
2046 /* add VID to filter table */
2047 index = (vid >> 5) & 0x7F;
2048 vfta = E1000_READ_REG_ARRAY(hw, E1000_VFTA, index);
2049 vfta |= (1 << (vid & 0x1F));
2050 e1000e_write_vfta(hw, index, vfta);
2053 static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
2055 struct e1000_adapter *adapter = netdev_priv(netdev);
2056 struct e1000_hw *hw = &adapter->hw;
2059 if (!test_bit(__E1000_DOWN, &adapter->state))
2060 e1000_irq_disable(adapter);
2061 vlan_group_set_device(adapter->vlgrp, vid, NULL);
2063 if (!test_bit(__E1000_DOWN, &adapter->state))
2064 e1000_irq_enable(adapter);
2066 if ((adapter->hw.mng_cookie.status &
2067 E1000_MNG_DHCP_COOKIE_STATUS_VLAN) &&
2068 (vid == adapter->mng_vlan_id)) {
2069 /* release control to f/w */
2070 e1000_release_hw_control(adapter);
2074 /* remove VID from filter table */
2075 index = (vid >> 5) & 0x7F;
2076 vfta = E1000_READ_REG_ARRAY(hw, E1000_VFTA, index);
2077 vfta &= ~(1 << (vid & 0x1F));
2078 e1000e_write_vfta(hw, index, vfta);
2081 static void e1000_update_mng_vlan(struct e1000_adapter *adapter)
2083 struct net_device *netdev = adapter->netdev;
2084 u16 vid = adapter->hw.mng_cookie.vlan_id;
2085 u16 old_vid = adapter->mng_vlan_id;
2087 if (!adapter->vlgrp)
2090 if (!vlan_group_get_device(adapter->vlgrp, vid)) {
2091 adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
2092 if (adapter->hw.mng_cookie.status &
2093 E1000_MNG_DHCP_COOKIE_STATUS_VLAN) {
2094 e1000_vlan_rx_add_vid(netdev, vid);
2095 adapter->mng_vlan_id = vid;
2098 if ((old_vid != (u16)E1000_MNG_VLAN_NONE) &&
2100 !vlan_group_get_device(adapter->vlgrp, old_vid))
2101 e1000_vlan_rx_kill_vid(netdev, old_vid);
2103 adapter->mng_vlan_id = vid;
2108 static void e1000_vlan_rx_register(struct net_device *netdev,
2109 struct vlan_group *grp)
2111 struct e1000_adapter *adapter = netdev_priv(netdev);
2112 struct e1000_hw *hw = &adapter->hw;
2115 if (!test_bit(__E1000_DOWN, &adapter->state))
2116 e1000_irq_disable(adapter);
2117 adapter->vlgrp = grp;
2120 /* enable VLAN tag insert/strip */
2122 ctrl |= E1000_CTRL_VME;
2125 if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) {
2126 /* enable VLAN receive filtering */
2128 rctl &= ~E1000_RCTL_CFIEN;
2130 e1000_update_mng_vlan(adapter);
2133 /* disable VLAN tag insert/strip */
2135 ctrl &= ~E1000_CTRL_VME;
2138 if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) {
2139 if (adapter->mng_vlan_id !=
2140 (u16)E1000_MNG_VLAN_NONE) {
2141 e1000_vlan_rx_kill_vid(netdev,
2142 adapter->mng_vlan_id);
2143 adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
2148 if (!test_bit(__E1000_DOWN, &adapter->state))
2149 e1000_irq_enable(adapter);
2152 static void e1000_restore_vlan(struct e1000_adapter *adapter)
2156 e1000_vlan_rx_register(adapter->netdev, adapter->vlgrp);
2158 if (!adapter->vlgrp)
2161 for (vid = 0; vid < VLAN_GROUP_ARRAY_LEN; vid++) {
2162 if (!vlan_group_get_device(adapter->vlgrp, vid))
2164 e1000_vlan_rx_add_vid(adapter->netdev, vid);
2168 static void e1000_init_manageability(struct e1000_adapter *adapter)
2170 struct e1000_hw *hw = &adapter->hw;
2173 if (!(adapter->flags & FLAG_MNG_PT_ENABLED))
2179 * enable receiving management packets to the host. this will probably
2180 * generate destination unreachable messages from the host OS, but
2181 * the packets will be handled on SMBUS
2183 manc |= E1000_MANC_EN_MNG2HOST;
2184 manc2h = er32(MANC2H);
2185 #define E1000_MNG2HOST_PORT_623 (1 << 5)
2186 #define E1000_MNG2HOST_PORT_664 (1 << 6)
2187 manc2h |= E1000_MNG2HOST_PORT_623;
2188 manc2h |= E1000_MNG2HOST_PORT_664;
2189 ew32(MANC2H, manc2h);
2194 * e1000_configure_tx - Configure 8254x Transmit Unit after Reset
2195 * @adapter: board private structure
2197 * Configure the Tx unit of the MAC after a reset.
2199 static void e1000_configure_tx(struct e1000_adapter *adapter)
2201 struct e1000_hw *hw = &adapter->hw;
2202 struct e1000_ring *tx_ring = adapter->tx_ring;
2204 u32 tdlen, tctl, tipg, tarc;
2207 /* Setup the HW Tx Head and Tail descriptor pointers */
2208 tdba = tx_ring->dma;
2209 tdlen = tx_ring->count * sizeof(struct e1000_tx_desc);
2210 ew32(TDBAL, (tdba & DMA_32BIT_MASK));
2211 ew32(TDBAH, (tdba >> 32));
2215 tx_ring->head = E1000_TDH;
2216 tx_ring->tail = E1000_TDT;
2218 /* Set the default values for the Tx Inter Packet Gap timer */
2219 tipg = DEFAULT_82543_TIPG_IPGT_COPPER; /* 8 */
2220 ipgr1 = DEFAULT_82543_TIPG_IPGR1; /* 8 */
2221 ipgr2 = DEFAULT_82543_TIPG_IPGR2; /* 6 */
2223 if (adapter->flags & FLAG_TIPG_MEDIUM_FOR_80003ESLAN)
2224 ipgr2 = DEFAULT_80003ES2LAN_TIPG_IPGR2; /* 7 */
2226 tipg |= ipgr1 << E1000_TIPG_IPGR1_SHIFT;
2227 tipg |= ipgr2 << E1000_TIPG_IPGR2_SHIFT;
2230 /* Set the Tx Interrupt Delay register */
2231 ew32(TIDV, adapter->tx_int_delay);
2232 /* Tx irq moderation */
2233 ew32(TADV, adapter->tx_abs_int_delay);
2235 /* Program the Transmit Control Register */
2237 tctl &= ~E1000_TCTL_CT;
2238 tctl |= E1000_TCTL_PSP | E1000_TCTL_RTLC |
2239 (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);
2241 if (adapter->flags & FLAG_TARC_SPEED_MODE_BIT) {
2242 tarc = er32(TARC(0));
2244 * set the speed mode bit, we'll clear it if we're not at
2245 * gigabit link later
2247 #define SPEED_MODE_BIT (1 << 21)
2248 tarc |= SPEED_MODE_BIT;
2249 ew32(TARC(0), tarc);
2252 /* errata: program both queues to unweighted RR */
2253 if (adapter->flags & FLAG_TARC_SET_BIT_ZERO) {
2254 tarc = er32(TARC(0));
2256 ew32(TARC(0), tarc);
2257 tarc = er32(TARC(1));
2259 ew32(TARC(1), tarc);
2262 e1000e_config_collision_dist(hw);
2264 /* Setup Transmit Descriptor Settings for eop descriptor */
2265 adapter->txd_cmd = E1000_TXD_CMD_EOP | E1000_TXD_CMD_IFCS;
2267 /* only set IDE if we are delaying interrupts using the timers */
2268 if (adapter->tx_int_delay)
2269 adapter->txd_cmd |= E1000_TXD_CMD_IDE;
2271 /* enable Report Status bit */
2272 adapter->txd_cmd |= E1000_TXD_CMD_RS;
2276 adapter->tx_queue_len = adapter->netdev->tx_queue_len;
2280 * e1000_setup_rctl - configure the receive control registers
2281 * @adapter: Board private structure
2283 #define PAGE_USE_COUNT(S) (((S) >> PAGE_SHIFT) + \
2284 (((S) & (PAGE_SIZE - 1)) ? 1 : 0))
2285 static void e1000_setup_rctl(struct e1000_adapter *adapter)
2287 struct e1000_hw *hw = &adapter->hw;
2292 /* Program MC offset vector base */
2294 rctl &= ~(3 << E1000_RCTL_MO_SHIFT);
2295 rctl |= E1000_RCTL_EN | E1000_RCTL_BAM |
2296 E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF |
2297 (adapter->hw.mac.mc_filter_type << E1000_RCTL_MO_SHIFT);
2299 /* Do not Store bad packets */
2300 rctl &= ~E1000_RCTL_SBP;
2302 /* Enable Long Packet receive */
2303 if (adapter->netdev->mtu <= ETH_DATA_LEN)
2304 rctl &= ~E1000_RCTL_LPE;
2306 rctl |= E1000_RCTL_LPE;
2308 /* Some systems expect that the CRC is included in SMBUS traffic. The
2309 * hardware strips the CRC before sending to both SMBUS (BMC) and to
2310 * host memory when this is enabled
2312 if (adapter->flags2 & FLAG2_CRC_STRIPPING)
2313 rctl |= E1000_RCTL_SECRC;
2315 /* Setup buffer sizes */
2316 rctl &= ~E1000_RCTL_SZ_4096;
2317 rctl |= E1000_RCTL_BSEX;
2318 switch (adapter->rx_buffer_len) {
2320 rctl |= E1000_RCTL_SZ_256;
2321 rctl &= ~E1000_RCTL_BSEX;
2324 rctl |= E1000_RCTL_SZ_512;
2325 rctl &= ~E1000_RCTL_BSEX;
2328 rctl |= E1000_RCTL_SZ_1024;
2329 rctl &= ~E1000_RCTL_BSEX;
2333 rctl |= E1000_RCTL_SZ_2048;
2334 rctl &= ~E1000_RCTL_BSEX;
2337 rctl |= E1000_RCTL_SZ_4096;
2340 rctl |= E1000_RCTL_SZ_8192;
2343 rctl |= E1000_RCTL_SZ_16384;
2348 * 82571 and greater support packet-split where the protocol
2349 * header is placed in skb->data and the packet data is
2350 * placed in pages hanging off of skb_shinfo(skb)->nr_frags.
2351 * In the case of a non-split, skb->data is linearly filled,
2352 * followed by the page buffers. Therefore, skb->data is
2353 * sized to hold the largest protocol header.
2355 * allocations using alloc_page take too long for regular MTU
2356 * so only enable packet split for jumbo frames
2358 * Using pages when the page size is greater than 16k wastes
2359 * a lot of memory, since we allocate 3 pages at all times
2362 pages = PAGE_USE_COUNT(adapter->netdev->mtu);
2363 if (!(adapter->flags & FLAG_IS_ICH) && (pages <= 3) &&
2364 (PAGE_SIZE <= 16384) && (rctl & E1000_RCTL_LPE))
2365 adapter->rx_ps_pages = pages;
2367 adapter->rx_ps_pages = 0;
2369 if (adapter->rx_ps_pages) {
2370 /* Configure extra packet-split registers */
2371 rfctl = er32(RFCTL);
2372 rfctl |= E1000_RFCTL_EXTEN;
2374 * disable packet split support for IPv6 extension headers,
2375 * because some malformed IPv6 headers can hang the Rx
2377 rfctl |= (E1000_RFCTL_IPV6_EX_DIS |
2378 E1000_RFCTL_NEW_IPV6_EXT_DIS);
2382 /* Enable Packet split descriptors */
2383 rctl |= E1000_RCTL_DTYP_PS;
2385 psrctl |= adapter->rx_ps_bsize0 >>
2386 E1000_PSRCTL_BSIZE0_SHIFT;
2388 switch (adapter->rx_ps_pages) {
2390 psrctl |= PAGE_SIZE <<
2391 E1000_PSRCTL_BSIZE3_SHIFT;
2393 psrctl |= PAGE_SIZE <<
2394 E1000_PSRCTL_BSIZE2_SHIFT;
2396 psrctl |= PAGE_SIZE >>
2397 E1000_PSRCTL_BSIZE1_SHIFT;
2401 ew32(PSRCTL, psrctl);
2405 /* just started the receive unit, no need to restart */
2406 adapter->flags &= ~FLAG_RX_RESTART_NOW;
2410 * e1000_configure_rx - Configure Receive Unit after Reset
2411 * @adapter: board private structure
2413 * Configure the Rx unit of the MAC after a reset.
2415 static void e1000_configure_rx(struct e1000_adapter *adapter)
2417 struct e1000_hw *hw = &adapter->hw;
2418 struct e1000_ring *rx_ring = adapter->rx_ring;
2420 u32 rdlen, rctl, rxcsum, ctrl_ext;
2422 if (adapter->rx_ps_pages) {
2423 /* this is a 32 byte descriptor */
2424 rdlen = rx_ring->count *
2425 sizeof(union e1000_rx_desc_packet_split);
2426 adapter->clean_rx = e1000_clean_rx_irq_ps;
2427 adapter->alloc_rx_buf = e1000_alloc_rx_buffers_ps;
2428 } else if (adapter->netdev->mtu > ETH_FRAME_LEN + ETH_FCS_LEN) {
2429 rdlen = rx_ring->count * sizeof(struct e1000_rx_desc);
2430 adapter->clean_rx = e1000_clean_jumbo_rx_irq;
2431 adapter->alloc_rx_buf = e1000_alloc_jumbo_rx_buffers;
2433 rdlen = rx_ring->count * sizeof(struct e1000_rx_desc);
2434 adapter->clean_rx = e1000_clean_rx_irq;
2435 adapter->alloc_rx_buf = e1000_alloc_rx_buffers;
2438 /* disable receives while setting up the descriptors */
2440 ew32(RCTL, rctl & ~E1000_RCTL_EN);
2444 /* set the Receive Delay Timer Register */
2445 ew32(RDTR, adapter->rx_int_delay);
2447 /* irq moderation */
2448 ew32(RADV, adapter->rx_abs_int_delay);
2449 if (adapter->itr_setting != 0)
2450 ew32(ITR, 1000000000 / (adapter->itr * 256));
2452 ctrl_ext = er32(CTRL_EXT);
2453 /* Reset delay timers after every interrupt */
2454 ctrl_ext |= E1000_CTRL_EXT_INT_TIMER_CLR;
2455 /* Auto-Mask interrupts upon ICR access */
2456 ctrl_ext |= E1000_CTRL_EXT_IAME;
2457 ew32(IAM, 0xffffffff);
2458 ew32(CTRL_EXT, ctrl_ext);
2462 * Setup the HW Rx Head and Tail Descriptor Pointers and
2463 * the Base and Length of the Rx Descriptor Ring
2465 rdba = rx_ring->dma;
2466 ew32(RDBAL, (rdba & DMA_32BIT_MASK));
2467 ew32(RDBAH, (rdba >> 32));
2471 rx_ring->head = E1000_RDH;
2472 rx_ring->tail = E1000_RDT;
2474 /* Enable Receive Checksum Offload for TCP and UDP */
2475 rxcsum = er32(RXCSUM);
2476 if (adapter->flags & FLAG_RX_CSUM_ENABLED) {
2477 rxcsum |= E1000_RXCSUM_TUOFL;
2480 * IPv4 payload checksum for UDP fragments must be
2481 * used in conjunction with packet-split.
2483 if (adapter->rx_ps_pages)
2484 rxcsum |= E1000_RXCSUM_IPPCSE;
2486 rxcsum &= ~E1000_RXCSUM_TUOFL;
2487 /* no need to clear IPPCSE as it defaults to 0 */
2489 ew32(RXCSUM, rxcsum);
2492 * Enable early receives on supported devices, only takes effect when
2493 * packet size is equal or larger than the specified value (in 8 byte
2494 * units), e.g. using jumbo frames when setting to E1000_ERT_2048
2496 if ((adapter->flags & FLAG_HAS_ERT) &&
2497 (adapter->netdev->mtu > ETH_DATA_LEN)) {
2498 u32 rxdctl = er32(RXDCTL(0));
2499 ew32(RXDCTL(0), rxdctl | 0x3);
2500 ew32(ERT, E1000_ERT_2048 | (1 << 13));
2502 * With jumbo frames and early-receive enabled, excessive
2503 * C4->C2 latencies result in dropped transactions.
2505 pm_qos_update_requirement(PM_QOS_CPU_DMA_LATENCY,
2506 e1000e_driver_name, 55);
2508 pm_qos_update_requirement(PM_QOS_CPU_DMA_LATENCY,
2510 PM_QOS_DEFAULT_VALUE);
2513 /* Enable Receives */
2518 * e1000_update_mc_addr_list - Update Multicast addresses
2519 * @hw: pointer to the HW structure
2520 * @mc_addr_list: array of multicast addresses to program
2521 * @mc_addr_count: number of multicast addresses to program
2522 * @rar_used_count: the first RAR register free to program
2523 * @rar_count: total number of supported Receive Address Registers
2525 * Updates the Receive Address Registers and Multicast Table Array.
2526 * The caller must have a packed mc_addr_list of multicast addresses.
2527 * The parameter rar_count will usually be hw->mac.rar_entry_count
2528 * unless there are workarounds that change this. Currently no func pointer
2529 * exists and all implementations are handled in the generic version of this
2532 static void e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list,
2533 u32 mc_addr_count, u32 rar_used_count,
2536 hw->mac.ops.update_mc_addr_list(hw, mc_addr_list, mc_addr_count,
2537 rar_used_count, rar_count);
2541 * e1000_set_multi - Multicast and Promiscuous mode set
2542 * @netdev: network interface device structure
2544 * The set_multi entry point is called whenever the multicast address
2545 * list or the network interface flags are updated. This routine is
2546 * responsible for configuring the hardware for proper multicast,
2547 * promiscuous mode, and all-multi behavior.
2549 static void e1000_set_multi(struct net_device *netdev)
2551 struct e1000_adapter *adapter = netdev_priv(netdev);
2552 struct e1000_hw *hw = &adapter->hw;
2553 struct e1000_mac_info *mac = &hw->mac;
2554 struct dev_mc_list *mc_ptr;
2559 /* Check for Promiscuous and All Multicast modes */
2563 if (netdev->flags & IFF_PROMISC) {
2564 rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
2565 rctl &= ~E1000_RCTL_VFE;
2567 if (netdev->flags & IFF_ALLMULTI) {
2568 rctl |= E1000_RCTL_MPE;
2569 rctl &= ~E1000_RCTL_UPE;
2571 rctl &= ~(E1000_RCTL_UPE | E1000_RCTL_MPE);
2573 if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER)
2574 rctl |= E1000_RCTL_VFE;
2579 if (netdev->mc_count) {
2580 mta_list = kmalloc(netdev->mc_count * 6, GFP_ATOMIC);
2584 /* prepare a packed array of only addresses. */
2585 mc_ptr = netdev->mc_list;
2587 for (i = 0; i < netdev->mc_count; i++) {
2590 memcpy(mta_list + (i*ETH_ALEN), mc_ptr->dmi_addr,
2592 mc_ptr = mc_ptr->next;
2595 e1000_update_mc_addr_list(hw, mta_list, i, 1,
2596 mac->rar_entry_count);
2600 * if we're called from probe, we might not have
2601 * anything to do here, so clear out the list
2603 e1000_update_mc_addr_list(hw, NULL, 0, 1, mac->rar_entry_count);
2608 * e1000_configure - configure the hardware for Rx and Tx
2609 * @adapter: private board structure
2611 static void e1000_configure(struct e1000_adapter *adapter)
2613 e1000_set_multi(adapter->netdev);
2615 e1000_restore_vlan(adapter);
2616 e1000_init_manageability(adapter);
2618 e1000_configure_tx(adapter);
2619 e1000_setup_rctl(adapter);
2620 e1000_configure_rx(adapter);
2621 adapter->alloc_rx_buf(adapter, e1000_desc_unused(adapter->rx_ring));
2625 * e1000e_power_up_phy - restore link in case the phy was powered down
2626 * @adapter: address of board private structure
2628 * The phy may be powered down to save power and turn off link when the
2629 * driver is unloaded and wake on lan is not enabled (among others)
2630 * *** this routine MUST be followed by a call to e1000e_reset ***
2632 void e1000e_power_up_phy(struct e1000_adapter *adapter)
2636 /* Just clear the power down bit to wake the phy back up */
2637 if (adapter->hw.phy.media_type == e1000_media_type_copper) {
2639 * According to the manual, the phy will retain its
2640 * settings across a power-down/up cycle
2642 e1e_rphy(&adapter->hw, PHY_CONTROL, &mii_reg);
2643 mii_reg &= ~MII_CR_POWER_DOWN;
2644 e1e_wphy(&adapter->hw, PHY_CONTROL, mii_reg);
2647 adapter->hw.mac.ops.setup_link(&adapter->hw);
2651 * e1000_power_down_phy - Power down the PHY
2653 * Power down the PHY so no link is implied when interface is down
2654 * The PHY cannot be powered down is management or WoL is active
2656 static void e1000_power_down_phy(struct e1000_adapter *adapter)
2658 struct e1000_hw *hw = &adapter->hw;
2661 /* WoL is enabled */
2665 /* non-copper PHY? */
2666 if (adapter->hw.phy.media_type != e1000_media_type_copper)
2669 /* reset is blocked because of a SoL/IDER session */
2670 if (e1000e_check_mng_mode(hw) || e1000_check_reset_block(hw))
2673 /* manageability (AMT) is enabled */
2674 if (er32(MANC) & E1000_MANC_SMBUS_EN)
2677 /* power down the PHY */
2678 e1e_rphy(hw, PHY_CONTROL, &mii_reg);
2679 mii_reg |= MII_CR_POWER_DOWN;
2680 e1e_wphy(hw, PHY_CONTROL, mii_reg);
2685 * e1000e_reset - bring the hardware into a known good state
2687 * This function boots the hardware and enables some settings that
2688 * require a configuration cycle of the hardware - those cannot be
2689 * set/changed during runtime. After reset the device needs to be
2690 * properly configured for Rx, Tx etc.
2692 void e1000e_reset(struct e1000_adapter *adapter)
2694 struct e1000_mac_info *mac = &adapter->hw.mac;
2695 struct e1000_fc_info *fc = &adapter->hw.fc;
2696 struct e1000_hw *hw = &adapter->hw;
2697 u32 tx_space, min_tx_space, min_rx_space;
2698 u32 pba = adapter->pba;
2701 /* reset Packet Buffer Allocation to default */
2704 if (adapter->max_frame_size > ETH_FRAME_LEN + ETH_FCS_LEN) {
2706 * To maintain wire speed transmits, the Tx FIFO should be
2707 * large enough to accommodate two full transmit packets,
2708 * rounded up to the next 1KB and expressed in KB. Likewise,
2709 * the Rx FIFO should be large enough to accommodate at least
2710 * one full receive packet and is similarly rounded up and
2714 /* upper 16 bits has Tx packet buffer allocation size in KB */
2715 tx_space = pba >> 16;
2716 /* lower 16 bits has Rx packet buffer allocation size in KB */
2719 * the Tx fifo also stores 16 bytes of information about the tx
2720 * but don't include ethernet FCS because hardware appends it
2722 min_tx_space = (adapter->max_frame_size +
2723 sizeof(struct e1000_tx_desc) -
2725 min_tx_space = ALIGN(min_tx_space, 1024);
2726 min_tx_space >>= 10;
2727 /* software strips receive CRC, so leave room for it */
2728 min_rx_space = adapter->max_frame_size;
2729 min_rx_space = ALIGN(min_rx_space, 1024);
2730 min_rx_space >>= 10;
2733 * If current Tx allocation is less than the min Tx FIFO size,
2734 * and the min Tx FIFO size is less than the current Rx FIFO
2735 * allocation, take space away from current Rx allocation
2737 if ((tx_space < min_tx_space) &&
2738 ((min_tx_space - tx_space) < pba)) {
2739 pba -= min_tx_space - tx_space;
2742 * if short on Rx space, Rx wins and must trump tx
2743 * adjustment or use Early Receive if available
2745 if ((pba < min_rx_space) &&
2746 (!(adapter->flags & FLAG_HAS_ERT)))
2747 /* ERT enabled in e1000_configure_rx */
2756 * flow control settings
2758 * The high water mark must be low enough to fit one full frame
2759 * (or the size used for early receive) above it in the Rx FIFO.
2760 * Set it to the lower of:
2761 * - 90% of the Rx FIFO size, and
2762 * - the full Rx FIFO size minus the early receive size (for parts
2763 * with ERT support assuming ERT set to E1000_ERT_2048), or
2764 * - the full Rx FIFO size minus one full frame
2766 if (adapter->flags & FLAG_HAS_ERT)
2767 hwm = min(((pba << 10) * 9 / 10),
2768 ((pba << 10) - (E1000_ERT_2048 << 3)));
2770 hwm = min(((pba << 10) * 9 / 10),
2771 ((pba << 10) - adapter->max_frame_size));
2773 fc->high_water = hwm & 0xFFF8; /* 8-byte granularity */
2774 fc->low_water = fc->high_water - 8;
2776 if (adapter->flags & FLAG_DISABLE_FC_PAUSE_TIME)
2777 fc->pause_time = 0xFFFF;
2779 fc->pause_time = E1000_FC_PAUSE_TIME;
2781 fc->current_mode = fc->requested_mode;
2783 /* Allow time for pending master requests to run */
2784 mac->ops.reset_hw(hw);
2787 * For parts with AMT enabled, let the firmware know
2788 * that the network interface is in control
2790 if (adapter->flags & FLAG_HAS_AMT)
2791 e1000_get_hw_control(adapter);
2795 if (mac->ops.init_hw(hw))
2796 e_err("Hardware Error\n");
2798 e1000_update_mng_vlan(adapter);
2800 /* Enable h/w to recognize an 802.1Q VLAN Ethernet packet */
2801 ew32(VET, ETH_P_8021Q);
2803 e1000e_reset_adaptive(hw);
2804 e1000_get_phy_info(hw);
2806 if (!(adapter->flags & FLAG_SMART_POWER_DOWN)) {
2809 * speed up time to link by disabling smart power down, ignore
2810 * the return value of this function because there is nothing
2811 * different we would do if it failed
2813 e1e_rphy(hw, IGP02E1000_PHY_POWER_MGMT, &phy_data);
2814 phy_data &= ~IGP02E1000_PM_SPD;
2815 e1e_wphy(hw, IGP02E1000_PHY_POWER_MGMT, phy_data);
2819 int e1000e_up(struct e1000_adapter *adapter)
2821 struct e1000_hw *hw = &adapter->hw;
2823 /* hardware has been reset, we need to reload some things */
2824 e1000_configure(adapter);
2826 clear_bit(__E1000_DOWN, &adapter->state);
2828 napi_enable(&adapter->napi);
2829 if (adapter->msix_entries)
2830 e1000_configure_msix(adapter);
2831 e1000_irq_enable(adapter);
2833 /* fire a link change interrupt to start the watchdog */
2834 ew32(ICS, E1000_ICS_LSC);
2838 void e1000e_down(struct e1000_adapter *adapter)
2840 struct net_device *netdev = adapter->netdev;
2841 struct e1000_hw *hw = &adapter->hw;
2845 * signal that we're down so the interrupt handler does not
2846 * reschedule our watchdog timer
2848 set_bit(__E1000_DOWN, &adapter->state);
2850 /* disable receives in the hardware */
2852 ew32(RCTL, rctl & ~E1000_RCTL_EN);
2853 /* flush and sleep below */
2855 netif_tx_stop_all_queues(netdev);
2857 /* disable transmits in the hardware */
2859 tctl &= ~E1000_TCTL_EN;
2861 /* flush both disables and wait for them to finish */
2865 napi_disable(&adapter->napi);
2866 e1000_irq_disable(adapter);
2868 del_timer_sync(&adapter->watchdog_timer);
2869 del_timer_sync(&adapter->phy_info_timer);
2871 netdev->tx_queue_len = adapter->tx_queue_len;
2872 netif_carrier_off(netdev);
2873 adapter->link_speed = 0;
2874 adapter->link_duplex = 0;
2876 if (!pci_channel_offline(adapter->pdev))
2877 e1000e_reset(adapter);
2878 e1000_clean_tx_ring(adapter);
2879 e1000_clean_rx_ring(adapter);
2882 * TODO: for power management, we could drop the link and
2883 * pci_disable_device here.
2887 void e1000e_reinit_locked(struct e1000_adapter *adapter)
2890 while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
2892 e1000e_down(adapter);
2894 clear_bit(__E1000_RESETTING, &adapter->state);
2898 * e1000_sw_init - Initialize general software structures (struct e1000_adapter)
2899 * @adapter: board private structure to initialize
2901 * e1000_sw_init initializes the Adapter private data structure.
2902 * Fields are initialized based on PCI device information and
2903 * OS network device settings (MTU size).
2905 static int __devinit e1000_sw_init(struct e1000_adapter *adapter)
2907 struct net_device *netdev = adapter->netdev;
2909 adapter->rx_buffer_len = ETH_FRAME_LEN + VLAN_HLEN + ETH_FCS_LEN;
2910 adapter->rx_ps_bsize0 = 128;
2911 adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN;
2912 adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN;
2914 e1000e_set_interrupt_capability(adapter);
2916 if (e1000_alloc_queues(adapter))
2919 /* Explicitly disable IRQ since the NIC can be in any state. */
2920 e1000_irq_disable(adapter);
2922 set_bit(__E1000_DOWN, &adapter->state);
2927 * e1000_intr_msi_test - Interrupt Handler
2928 * @irq: interrupt number
2929 * @data: pointer to a network interface device structure
2931 static irqreturn_t e1000_intr_msi_test(int irq, void *data)
2933 struct net_device *netdev = data;
2934 struct e1000_adapter *adapter = netdev_priv(netdev);
2935 struct e1000_hw *hw = &adapter->hw;
2936 u32 icr = er32(ICR);
2938 e_dbg("%s: icr is %08X\n", netdev->name, icr);
2939 if (icr & E1000_ICR_RXSEQ) {
2940 adapter->flags &= ~FLAG_MSI_TEST_FAILED;
2948 * e1000_test_msi_interrupt - Returns 0 for successful test
2949 * @adapter: board private struct
2951 * code flow taken from tg3.c
2953 static int e1000_test_msi_interrupt(struct e1000_adapter *adapter)
2955 struct net_device *netdev = adapter->netdev;
2956 struct e1000_hw *hw = &adapter->hw;
2959 /* poll_enable hasn't been called yet, so don't need disable */
2960 /* clear any pending events */
2963 /* free the real vector and request a test handler */
2964 e1000_free_irq(adapter);
2965 e1000e_reset_interrupt_capability(adapter);
2967 /* Assume that the test fails, if it succeeds then the test
2968 * MSI irq handler will unset this flag */
2969 adapter->flags |= FLAG_MSI_TEST_FAILED;
2971 err = pci_enable_msi(adapter->pdev);
2973 goto msi_test_failed;
2975 err = request_irq(adapter->pdev->irq, &e1000_intr_msi_test, 0,
2976 netdev->name, netdev);
2978 pci_disable_msi(adapter->pdev);
2979 goto msi_test_failed;
2984 e1000_irq_enable(adapter);
2986 /* fire an unusual interrupt on the test handler */
2987 ew32(ICS, E1000_ICS_RXSEQ);
2991 e1000_irq_disable(adapter);
2995 if (adapter->flags & FLAG_MSI_TEST_FAILED) {
2996 adapter->int_mode = E1000E_INT_MODE_LEGACY;
2998 e_info("MSI interrupt test failed!\n");
3001 free_irq(adapter->pdev->irq, netdev);
3002 pci_disable_msi(adapter->pdev);
3005 goto msi_test_failed;
3007 /* okay so the test worked, restore settings */
3008 e_dbg("%s: MSI interrupt test succeeded!\n", netdev->name);
3010 e1000e_set_interrupt_capability(adapter);
3011 e1000_request_irq(adapter);
3016 * e1000_test_msi - Returns 0 if MSI test succeeds or INTx mode is restored
3017 * @adapter: board private struct
3019 * code flow taken from tg3.c, called with e1000 interrupts disabled.
3021 static int e1000_test_msi(struct e1000_adapter *adapter)
3026 if (!(adapter->flags & FLAG_MSI_ENABLED))
3029 /* disable SERR in case the MSI write causes a master abort */
3030 pci_read_config_word(adapter->pdev, PCI_COMMAND, &pci_cmd);
3031 pci_write_config_word(adapter->pdev, PCI_COMMAND,
3032 pci_cmd & ~PCI_COMMAND_SERR);
3034 err = e1000_test_msi_interrupt(adapter);
3036 /* restore previous setting of command word */
3037 pci_write_config_word(adapter->pdev, PCI_COMMAND, pci_cmd);
3043 /* EIO means MSI test failed */
3047 /* back to INTx mode */
3048 e_warn("MSI interrupt test failed, using legacy interrupt.\n");
3050 e1000_free_irq(adapter);
3052 err = e1000_request_irq(adapter);
3058 * e1000_open - Called when a network interface is made active
3059 * @netdev: network interface device structure
3061 * Returns 0 on success, negative value on failure
3063 * The open entry point is called when a network interface is made
3064 * active by the system (IFF_UP). At this point all resources needed
3065 * for transmit and receive operations are allocated, the interrupt
3066 * handler is registered with the OS, the watchdog timer is started,
3067 * and the stack is notified that the interface is ready.
3069 static int e1000_open(struct net_device *netdev)
3071 struct e1000_adapter *adapter = netdev_priv(netdev);
3072 struct e1000_hw *hw = &adapter->hw;
3075 /* disallow open during test */
3076 if (test_bit(__E1000_TESTING, &adapter->state))
3079 /* allocate transmit descriptors */
3080 err = e1000e_setup_tx_resources(adapter);
3084 /* allocate receive descriptors */
3085 err = e1000e_setup_rx_resources(adapter);
3089 e1000e_power_up_phy(adapter);
3091 adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
3092 if ((adapter->hw.mng_cookie.status &
3093 E1000_MNG_DHCP_COOKIE_STATUS_VLAN))
3094 e1000_update_mng_vlan(adapter);
3097 * If AMT is enabled, let the firmware know that the network
3098 * interface is now open
3100 if (adapter->flags & FLAG_HAS_AMT)
3101 e1000_get_hw_control(adapter);
3104 * before we allocate an interrupt, we must be ready to handle it.
3105 * Setting DEBUG_SHIRQ in the kernel makes it fire an interrupt
3106 * as soon as we call pci_request_irq, so we have to setup our
3107 * clean_rx handler before we do so.
3109 e1000_configure(adapter);
3111 err = e1000_request_irq(adapter);
3116 * Work around PCIe errata with MSI interrupts causing some chipsets to
3117 * ignore e1000e MSI messages, which means we need to test our MSI
3120 if (adapter->int_mode != E1000E_INT_MODE_LEGACY) {
3121 err = e1000_test_msi(adapter);
3123 e_err("Interrupt allocation failed\n");
3128 /* From here on the code is the same as e1000e_up() */
3129 clear_bit(__E1000_DOWN, &adapter->state);
3131 napi_enable(&adapter->napi);
3133 e1000_irq_enable(adapter);
3135 netif_tx_start_all_queues(netdev);
3137 /* fire a link status change interrupt to start the watchdog */
3138 ew32(ICS, E1000_ICS_LSC);
3143 e1000_release_hw_control(adapter);
3144 e1000_power_down_phy(adapter);
3145 e1000e_free_rx_resources(adapter);
3147 e1000e_free_tx_resources(adapter);
3149 e1000e_reset(adapter);
3155 * e1000_close - Disables a network interface
3156 * @netdev: network interface device structure
3158 * Returns 0, this is not allowed to fail
3160 * The close entry point is called when an interface is de-activated
3161 * by the OS. The hardware is still under the drivers control, but
3162 * needs to be disabled. A global MAC reset is issued to stop the
3163 * hardware, and all transmit and receive resources are freed.
3165 static int e1000_close(struct net_device *netdev)
3167 struct e1000_adapter *adapter = netdev_priv(netdev);
3169 WARN_ON(test_bit(__E1000_RESETTING, &adapter->state));
3170 e1000e_down(adapter);
3171 e1000_power_down_phy(adapter);
3172 e1000_free_irq(adapter);
3174 e1000e_free_tx_resources(adapter);
3175 e1000e_free_rx_resources(adapter);
3178 * kill manageability vlan ID if supported, but not if a vlan with
3179 * the same ID is registered on the host OS (let 8021q kill it)
3181 if ((adapter->hw.mng_cookie.status &
3182 E1000_MNG_DHCP_COOKIE_STATUS_VLAN) &&
3184 vlan_group_get_device(adapter->vlgrp, adapter->mng_vlan_id)))
3185 e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
3188 * If AMT is enabled, let the firmware know that the network
3189 * interface is now closed
3191 if (adapter->flags & FLAG_HAS_AMT)
3192 e1000_release_hw_control(adapter);
3197 * e1000_set_mac - Change the Ethernet Address of the NIC
3198 * @netdev: network interface device structure
3199 * @p: pointer to an address structure
3201 * Returns 0 on success, negative on failure
3203 static int e1000_set_mac(struct net_device *netdev, void *p)
3205 struct e1000_adapter *adapter = netdev_priv(netdev);
3206 struct sockaddr *addr = p;
3208 if (!is_valid_ether_addr(addr->sa_data))
3209 return -EADDRNOTAVAIL;
3211 memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
3212 memcpy(adapter->hw.mac.addr, addr->sa_data, netdev->addr_len);
3214 e1000e_rar_set(&adapter->hw, adapter->hw.mac.addr, 0);
3216 if (adapter->flags & FLAG_RESET_OVERWRITES_LAA) {
3217 /* activate the work around */
3218 e1000e_set_laa_state_82571(&adapter->hw, 1);
3221 * Hold a copy of the LAA in RAR[14] This is done so that
3222 * between the time RAR[0] gets clobbered and the time it
3223 * gets fixed (in e1000_watchdog), the actual LAA is in one
3224 * of the RARs and no incoming packets directed to this port
3225 * are dropped. Eventually the LAA will be in RAR[0] and
3228 e1000e_rar_set(&adapter->hw,
3229 adapter->hw.mac.addr,
3230 adapter->hw.mac.rar_entry_count - 1);
3237 * e1000e_update_phy_task - work thread to update phy
3238 * @work: pointer to our work struct
3240 * this worker thread exists because we must acquire a
3241 * semaphore to read the phy, which we could msleep while
3242 * waiting for it, and we can't msleep in a timer.
3244 static void e1000e_update_phy_task(struct work_struct *work)
3246 struct e1000_adapter *adapter = container_of(work,
3247 struct e1000_adapter, update_phy_task);
3248 e1000_get_phy_info(&adapter->hw);
3252 * Need to wait a few seconds after link up to get diagnostic information from
3255 static void e1000_update_phy_info(unsigned long data)
3257 struct e1000_adapter *adapter = (struct e1000_adapter *) data;
3258 schedule_work(&adapter->update_phy_task);
3262 * e1000e_update_stats - Update the board statistics counters
3263 * @adapter: board private structure
3265 void e1000e_update_stats(struct e1000_adapter *adapter)
3267 struct e1000_hw *hw = &adapter->hw;
3268 struct pci_dev *pdev = adapter->pdev;
3271 * Prevent stats update while adapter is being reset, or if the pci
3272 * connection is down.
3274 if (adapter->link_speed == 0)
3276 if (pci_channel_offline(pdev))
3279 adapter->stats.crcerrs += er32(CRCERRS);
3280 adapter->stats.gprc += er32(GPRC);
3281 adapter->stats.gorc += er32(GORCL);
3282 er32(GORCH); /* Clear gorc */
3283 adapter->stats.bprc += er32(BPRC);
3284 adapter->stats.mprc += er32(MPRC);
3285 adapter->stats.roc += er32(ROC);
3287 adapter->stats.mpc += er32(MPC);
3288 adapter->stats.scc += er32(SCC);
3289 adapter->stats.ecol += er32(ECOL);
3290 adapter->stats.mcc += er32(MCC);
3291 adapter->stats.latecol += er32(LATECOL);
3292 adapter->stats.dc += er32(DC);
3293 adapter->stats.xonrxc += er32(XONRXC);
3294 adapter->stats.xontxc += er32(XONTXC);
3295 adapter->stats.xoffrxc += er32(XOFFRXC);
3296 adapter->stats.xofftxc += er32(XOFFTXC);
3297 adapter->stats.gptc += er32(GPTC);
3298 adapter->stats.gotc += er32(GOTCL);
3299 er32(GOTCH); /* Clear gotc */
3300 adapter->stats.rnbc += er32(RNBC);
3301 adapter->stats.ruc += er32(RUC);
3303 adapter->stats.mptc += er32(MPTC);
3304 adapter->stats.bptc += er32(BPTC);
3306 /* used for adaptive IFS */
3308 hw->mac.tx_packet_delta = er32(TPT);
3309 adapter->stats.tpt += hw->mac.tx_packet_delta;
3310 hw->mac.collision_delta = er32(COLC);
3311 adapter->stats.colc += hw->mac.collision_delta;
3313 adapter->stats.algnerrc += er32(ALGNERRC);
3314 adapter->stats.rxerrc += er32(RXERRC);
3315 if (hw->mac.type != e1000_82574)
3316 adapter->stats.tncrs += er32(TNCRS);
3317 adapter->stats.cexterr += er32(CEXTERR);
3318 adapter->stats.tsctc += er32(TSCTC);
3319 adapter->stats.tsctfc += er32(TSCTFC);
3321 /* Fill out the OS statistics structure */
3322 adapter->net_stats.multicast = adapter->stats.mprc;
3323 adapter->net_stats.collisions = adapter->stats.colc;
3328 * RLEC on some newer hardware can be incorrect so build
3329 * our own version based on RUC and ROC
3331 adapter->net_stats.rx_errors = adapter->stats.rxerrc +
3332 adapter->stats.crcerrs + adapter->stats.algnerrc +
3333 adapter->stats.ruc + adapter->stats.roc +
3334 adapter->stats.cexterr;
3335 adapter->net_stats.rx_length_errors = adapter->stats.ruc +
3337 adapter->net_stats.rx_crc_errors = adapter->stats.crcerrs;
3338 adapter->net_stats.rx_frame_errors = adapter->stats.algnerrc;
3339 adapter->net_stats.rx_missed_errors = adapter->stats.mpc;
3342 adapter->net_stats.tx_errors = adapter->stats.ecol +
3343 adapter->stats.latecol;
3344 adapter->net_stats.tx_aborted_errors = adapter->stats.ecol;
3345 adapter->net_stats.tx_window_errors = adapter->stats.latecol;
3346 adapter->net_stats.tx_carrier_errors = adapter->stats.tncrs;
3348 /* Tx Dropped needs to be maintained elsewhere */
3350 /* Management Stats */
3351 adapter->stats.mgptc += er32(MGTPTC);
3352 adapter->stats.mgprc += er32(MGTPRC);
3353 adapter->stats.mgpdc += er32(MGTPDC);
3357 * e1000_phy_read_status - Update the PHY register status snapshot
3358 * @adapter: board private structure
3360 static void e1000_phy_read_status(struct e1000_adapter *adapter)
3362 struct e1000_hw *hw = &adapter->hw;
3363 struct e1000_phy_regs *phy = &adapter->phy_regs;
3366 if ((er32(STATUS) & E1000_STATUS_LU) &&
3367 (adapter->hw.phy.media_type == e1000_media_type_copper)) {
3368 ret_val = e1e_rphy(hw, PHY_CONTROL, &phy->bmcr);
3369 ret_val |= e1e_rphy(hw, PHY_STATUS, &phy->bmsr);
3370 ret_val |= e1e_rphy(hw, PHY_AUTONEG_ADV, &phy->advertise);
3371 ret_val |= e1e_rphy(hw, PHY_LP_ABILITY, &phy->lpa);
3372 ret_val |= e1e_rphy(hw, PHY_AUTONEG_EXP, &phy->expansion);
3373 ret_val |= e1e_rphy(hw, PHY_1000T_CTRL, &phy->ctrl1000);
3374 ret_val |= e1e_rphy(hw, PHY_1000T_STATUS, &phy->stat1000);
3375 ret_val |= e1e_rphy(hw, PHY_EXT_STATUS, &phy->estatus);
3377 e_warn("Error reading PHY register\n");
3380 * Do not read PHY registers if link is not up
3381 * Set values to typical power-on defaults
3383 phy->bmcr = (BMCR_SPEED1000 | BMCR_ANENABLE | BMCR_FULLDPLX);
3384 phy->bmsr = (BMSR_100FULL | BMSR_100HALF | BMSR_10FULL |
3385 BMSR_10HALF | BMSR_ESTATEN | BMSR_ANEGCAPABLE |
3387 phy->advertise = (ADVERTISE_PAUSE_ASYM | ADVERTISE_PAUSE_CAP |
3388 ADVERTISE_ALL | ADVERTISE_CSMA);
3390 phy->expansion = EXPANSION_ENABLENPAGE;
3391 phy->ctrl1000 = ADVERTISE_1000FULL;
3393 phy->estatus = (ESTATUS_1000_TFULL | ESTATUS_1000_THALF);
3397 static void e1000_print_link_info(struct e1000_adapter *adapter)
3399 struct e1000_hw *hw = &adapter->hw;
3400 u32 ctrl = er32(CTRL);
3402 /* Link status message must follow this format for user tools */
3403 printk(KERN_INFO "e1000e: %s NIC Link is Up %d Mbps %s, "
3404 "Flow Control: %s\n",
3405 adapter->netdev->name,
3406 adapter->link_speed,
3407 (adapter->link_duplex == FULL_DUPLEX) ?
3408 "Full Duplex" : "Half Duplex",
3409 ((ctrl & E1000_CTRL_TFCE) && (ctrl & E1000_CTRL_RFCE)) ?
3411 ((ctrl & E1000_CTRL_RFCE) ? "RX" :
3412 ((ctrl & E1000_CTRL_TFCE) ? "TX" : "None" )));
3415 bool e1000_has_link(struct e1000_adapter *adapter)
3417 struct e1000_hw *hw = &adapter->hw;
3418 bool link_active = 0;
3422 * get_link_status is set on LSC (link status) interrupt or
3423 * Rx sequence error interrupt. get_link_status will stay
3424 * false until the check_for_link establishes link
3425 * for copper adapters ONLY
3427 switch (hw->phy.media_type) {
3428 case e1000_media_type_copper:
3429 if (hw->mac.get_link_status) {
3430 ret_val = hw->mac.ops.check_for_link(hw);
3431 link_active = !hw->mac.get_link_status;
3436 case e1000_media_type_fiber:
3437 ret_val = hw->mac.ops.check_for_link(hw);
3438 link_active = !!(er32(STATUS) & E1000_STATUS_LU);
3440 case e1000_media_type_internal_serdes:
3441 ret_val = hw->mac.ops.check_for_link(hw);
3442 link_active = adapter->hw.mac.serdes_has_link;
3445 case e1000_media_type_unknown:
3449 if ((ret_val == E1000_ERR_PHY) && (hw->phy.type == e1000_phy_igp_3) &&
3450 (er32(CTRL) & E1000_PHY_CTRL_GBE_DISABLE)) {
3451 /* See e1000_kmrn_lock_loss_workaround_ich8lan() */
3452 e_info("Gigabit has been disabled, downgrading speed\n");
3458 static void e1000e_enable_receives(struct e1000_adapter *adapter)
3460 /* make sure the receive unit is started */
3461 if ((adapter->flags & FLAG_RX_NEEDS_RESTART) &&
3462 (adapter->flags & FLAG_RX_RESTART_NOW)) {
3463 struct e1000_hw *hw = &adapter->hw;
3464 u32 rctl = er32(RCTL);
3465 ew32(RCTL, rctl | E1000_RCTL_EN);
3466 adapter->flags &= ~FLAG_RX_RESTART_NOW;
3471 * e1000_watchdog - Timer Call-back
3472 * @data: pointer to adapter cast into an unsigned long
3474 static void e1000_watchdog(unsigned long data)
3476 struct e1000_adapter *adapter = (struct e1000_adapter *) data;
3478 /* Do the rest outside of interrupt context */
3479 schedule_work(&adapter->watchdog_task);
3481 /* TODO: make this use queue_delayed_work() */
3484 static void e1000_watchdog_task(struct work_struct *work)
3486 struct e1000_adapter *adapter = container_of(work,
3487 struct e1000_adapter, watchdog_task);
3488 struct net_device *netdev = adapter->netdev;
3489 struct e1000_mac_info *mac = &adapter->hw.mac;
3490 struct e1000_phy_info *phy = &adapter->hw.phy;
3491 struct e1000_ring *tx_ring = adapter->tx_ring;
3492 struct e1000_hw *hw = &adapter->hw;
3496 link = e1000_has_link(adapter);
3497 if ((netif_carrier_ok(netdev)) && link) {
3498 e1000e_enable_receives(adapter);
3502 if ((e1000e_enable_tx_pkt_filtering(hw)) &&
3503 (adapter->mng_vlan_id != adapter->hw.mng_cookie.vlan_id))
3504 e1000_update_mng_vlan(adapter);
3507 if (!netif_carrier_ok(netdev)) {
3509 /* update snapshot of PHY registers on LSC */
3510 e1000_phy_read_status(adapter);
3511 mac->ops.get_link_up_info(&adapter->hw,
3512 &adapter->link_speed,
3513 &adapter->link_duplex);
3514 e1000_print_link_info(adapter);
3516 * On supported PHYs, check for duplex mismatch only
3517 * if link has autonegotiated at 10/100 half
3519 if ((hw->phy.type == e1000_phy_igp_3 ||
3520 hw->phy.type == e1000_phy_bm) &&
3521 (hw->mac.autoneg == true) &&
3522 (adapter->link_speed == SPEED_10 ||
3523 adapter->link_speed == SPEED_100) &&
3524 (adapter->link_duplex == HALF_DUPLEX)) {
3527 e1e_rphy(hw, PHY_AUTONEG_EXP, &autoneg_exp);
3529 if (!(autoneg_exp & NWAY_ER_LP_NWAY_CAPS))
3530 e_info("Autonegotiated half duplex but"
3531 " link partner cannot autoneg. "
3532 " Try forcing full duplex if "
3533 "link gets many collisions.\n");
3537 * tweak tx_queue_len according to speed/duplex
3538 * and adjust the timeout factor
3540 netdev->tx_queue_len = adapter->tx_queue_len;
3541 adapter->tx_timeout_factor = 1;
3542 switch (adapter->link_speed) {
3545 netdev->tx_queue_len = 10;
3546 adapter->tx_timeout_factor = 16;
3550 netdev->tx_queue_len = 100;
3551 /* maybe add some timeout factor ? */
3556 * workaround: re-program speed mode bit after
3559 if ((adapter->flags & FLAG_TARC_SPEED_MODE_BIT) &&
3562 tarc0 = er32(TARC(0));
3563 tarc0 &= ~SPEED_MODE_BIT;
3564 ew32(TARC(0), tarc0);
3568 * disable TSO for pcie and 10/100 speeds, to avoid
3569 * some hardware issues
3571 if (!(adapter->flags & FLAG_TSO_FORCE)) {
3572 switch (adapter->link_speed) {
3575 e_info("10/100 speed: disabling TSO\n");
3576 netdev->features &= ~NETIF_F_TSO;
3577 netdev->features &= ~NETIF_F_TSO6;
3580 netdev->features |= NETIF_F_TSO;
3581 netdev->features |= NETIF_F_TSO6;
3590 * enable transmits in the hardware, need to do this
3591 * after setting TARC(0)
3594 tctl |= E1000_TCTL_EN;
3598 * Perform any post-link-up configuration before
3599 * reporting link up.
3601 if (phy->ops.cfg_on_link_up)
3602 phy->ops.cfg_on_link_up(hw);
3604 netif_carrier_on(netdev);
3605 netif_tx_wake_all_queues(netdev);
3607 if (!test_bit(__E1000_DOWN, &adapter->state))
3608 mod_timer(&adapter->phy_info_timer,
3609 round_jiffies(jiffies + 2 * HZ));
3612 if (netif_carrier_ok(netdev)) {
3613 adapter->link_speed = 0;
3614 adapter->link_duplex = 0;
3615 /* Link status message must follow this format */
3616 printk(KERN_INFO "e1000e: %s NIC Link is Down\n",
3617 adapter->netdev->name);
3618 netif_carrier_off(netdev);
3619 netif_tx_stop_all_queues(netdev);
3620 if (!test_bit(__E1000_DOWN, &adapter->state))
3621 mod_timer(&adapter->phy_info_timer,
3622 round_jiffies(jiffies + 2 * HZ));
3624 if (adapter->flags & FLAG_RX_NEEDS_RESTART)
3625 schedule_work(&adapter->reset_task);
3630 e1000e_update_stats(adapter);
3632 mac->tx_packet_delta = adapter->stats.tpt - adapter->tpt_old;
3633 adapter->tpt_old = adapter->stats.tpt;
3634 mac->collision_delta = adapter->stats.colc - adapter->colc_old;
3635 adapter->colc_old = adapter->stats.colc;
3637 adapter->gorc = adapter->stats.gorc - adapter->gorc_old;
3638 adapter->gorc_old = adapter->stats.gorc;
3639 adapter->gotc = adapter->stats.gotc - adapter->gotc_old;
3640 adapter->gotc_old = adapter->stats.gotc;
3642 e1000e_update_adaptive(&adapter->hw);
3644 if (!netif_carrier_ok(netdev)) {
3645 tx_pending = (e1000_desc_unused(tx_ring) + 1 <
3649 * We've lost link, so the controller stops DMA,
3650 * but we've got queued Tx work that's never going
3651 * to get done, so reset controller to flush Tx.
3652 * (Do the reset outside of interrupt context).
3654 adapter->tx_timeout_count++;
3655 schedule_work(&adapter->reset_task);
3659 /* Cause software interrupt to ensure Rx ring is cleaned */
3660 if (adapter->msix_entries)
3661 ew32(ICS, adapter->rx_ring->ims_val);
3663 ew32(ICS, E1000_ICS_RXDMT0);
3665 /* Force detection of hung controller every watchdog period */
3666 adapter->detect_tx_hung = 1;
3669 * With 82571 controllers, LAA may be overwritten due to controller
3670 * reset from the other port. Set the appropriate LAA in RAR[0]
3672 if (e1000e_get_laa_state_82571(hw))
3673 e1000e_rar_set(hw, adapter->hw.mac.addr, 0);
3675 /* Reset the timer */
3676 if (!test_bit(__E1000_DOWN, &adapter->state))
3677 mod_timer(&adapter->watchdog_timer,
3678 round_jiffies(jiffies + 2 * HZ));
3681 #define E1000_TX_FLAGS_CSUM 0x00000001
3682 #define E1000_TX_FLAGS_VLAN 0x00000002
3683 #define E1000_TX_FLAGS_TSO 0x00000004
3684 #define E1000_TX_FLAGS_IPV4 0x00000008
3685 #define E1000_TX_FLAGS_VLAN_MASK 0xffff0000
3686 #define E1000_TX_FLAGS_VLAN_SHIFT 16
3688 static int e1000_tso(struct e1000_adapter *adapter,
3689 struct sk_buff *skb)
3691 struct e1000_ring *tx_ring = adapter->tx_ring;
3692 struct e1000_context_desc *context_desc;
3693 struct e1000_buffer *buffer_info;
3696 u16 ipcse = 0, tucse, mss;
3697 u8 ipcss, ipcso, tucss, tucso, hdr_len;
3700 if (skb_is_gso(skb)) {
3701 if (skb_header_cloned(skb)) {
3702 err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
3707 hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
3708 mss = skb_shinfo(skb)->gso_size;
3709 if (skb->protocol == htons(ETH_P_IP)) {
3710 struct iphdr *iph = ip_hdr(skb);
3713 tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr,
3717 cmd_length = E1000_TXD_CMD_IP;
3718 ipcse = skb_transport_offset(skb) - 1;
3719 } else if (skb_shinfo(skb)->gso_type == SKB_GSO_TCPV6) {
3720 ipv6_hdr(skb)->payload_len = 0;
3721 tcp_hdr(skb)->check =
3722 ~csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
3723 &ipv6_hdr(skb)->daddr,
3727 ipcss = skb_network_offset(skb);
3728 ipcso = (void *)&(ip_hdr(skb)->check) - (void *)skb->data;
3729 tucss = skb_transport_offset(skb);
3730 tucso = (void *)&(tcp_hdr(skb)->check) - (void *)skb->data;
3733 cmd_length |= (E1000_TXD_CMD_DEXT | E1000_TXD_CMD_TSE |
3734 E1000_TXD_CMD_TCP | (skb->len - (hdr_len)));
3736 i = tx_ring->next_to_use;
3737 context_desc = E1000_CONTEXT_DESC(*tx_ring, i);
3738 buffer_info = &tx_ring->buffer_info[i];
3740 context_desc->lower_setup.ip_fields.ipcss = ipcss;
3741 context_desc->lower_setup.ip_fields.ipcso = ipcso;
3742 context_desc->lower_setup.ip_fields.ipcse = cpu_to_le16(ipcse);
3743 context_desc->upper_setup.tcp_fields.tucss = tucss;
3744 context_desc->upper_setup.tcp_fields.tucso = tucso;
3745 context_desc->upper_setup.tcp_fields.tucse = cpu_to_le16(tucse);
3746 context_desc->tcp_seg_setup.fields.mss = cpu_to_le16(mss);
3747 context_desc->tcp_seg_setup.fields.hdr_len = hdr_len;
3748 context_desc->cmd_and_length = cpu_to_le32(cmd_length);
3750 buffer_info->time_stamp = jiffies;
3751 buffer_info->next_to_watch = i;
3754 if (i == tx_ring->count)
3756 tx_ring->next_to_use = i;
3764 static bool e1000_tx_csum(struct e1000_adapter *adapter, struct sk_buff *skb)
3766 struct e1000_ring *tx_ring = adapter->tx_ring;
3767 struct e1000_context_desc *context_desc;
3768 struct e1000_buffer *buffer_info;
3771 u32 cmd_len = E1000_TXD_CMD_DEXT;
3773 if (skb->ip_summed != CHECKSUM_PARTIAL)
3776 switch (skb->protocol) {
3777 case cpu_to_be16(ETH_P_IP):
3778 if (ip_hdr(skb)->protocol == IPPROTO_TCP)
3779 cmd_len |= E1000_TXD_CMD_TCP;
3781 case cpu_to_be16(ETH_P_IPV6):
3782 /* XXX not handling all IPV6 headers */
3783 if (ipv6_hdr(skb)->nexthdr == IPPROTO_TCP)
3784 cmd_len |= E1000_TXD_CMD_TCP;
3787 if (unlikely(net_ratelimit()))
3788 e_warn("checksum_partial proto=%x!\n", skb->protocol);
3792 css = skb_transport_offset(skb);
3794 i = tx_ring->next_to_use;
3795 buffer_info = &tx_ring->buffer_info[i];
3796 context_desc = E1000_CONTEXT_DESC(*tx_ring, i);
3798 context_desc->lower_setup.ip_config = 0;
3799 context_desc->upper_setup.tcp_fields.tucss = css;
3800 context_desc->upper_setup.tcp_fields.tucso =
3801 css + skb->csum_offset;
3802 context_desc->upper_setup.tcp_fields.tucse = 0;
3803 context_desc->tcp_seg_setup.data = 0;
3804 context_desc->cmd_and_length = cpu_to_le32(cmd_len);
3806 buffer_info->time_stamp = jiffies;
3807 buffer_info->next_to_watch = i;
3810 if (i == tx_ring->count)
3812 tx_ring->next_to_use = i;
3817 #define E1000_MAX_PER_TXD 8192
3818 #define E1000_MAX_TXD_PWR 12
3820 static int e1000_tx_map(struct e1000_adapter *adapter,
3821 struct sk_buff *skb, unsigned int first,
3822 unsigned int max_per_txd, unsigned int nr_frags,
3825 struct e1000_ring *tx_ring = adapter->tx_ring;
3826 unsigned int len = skb_headlen(skb);
3827 unsigned int offset, size, count = 0, i;
3831 i = tx_ring->next_to_use;
3833 if (skb_dma_map(&adapter->pdev->dev, skb, DMA_TO_DEVICE)) {
3834 dev_err(&adapter->pdev->dev, "TX DMA map failed\n");
3835 adapter->tx_dma_failed++;
3840 map = skb_shinfo(skb)->dma_maps[0];
3844 struct e1000_buffer *buffer_info = &tx_ring->buffer_info[i];
3845 size = min(len, max_per_txd);
3847 buffer_info->length = size;
3848 /* set time_stamp *before* dma to help avoid a possible race */
3849 buffer_info->time_stamp = jiffies;
3850 buffer_info->dma = map + offset;
3851 buffer_info->next_to_watch = i;
3857 if (i == tx_ring->count)
3861 for (f = 0; f < nr_frags; f++) {
3862 struct skb_frag_struct *frag;
3864 frag = &skb_shinfo(skb)->frags[f];
3866 map = skb_shinfo(skb)->dma_maps[f + 1];
3870 struct e1000_buffer *buffer_info;
3871 buffer_info = &tx_ring->buffer_info[i];
3872 size = min(len, max_per_txd);
3874 buffer_info->length = size;
3875 buffer_info->time_stamp = jiffies;
3876 buffer_info->dma = map + offset;
3877 buffer_info->next_to_watch = i;
3884 if (i == tx_ring->count)
3890 i = tx_ring->count - 1;
3894 tx_ring->buffer_info[i].skb = skb;
3895 tx_ring->buffer_info[first].next_to_watch = i;
3901 static void e1000_tx_queue(struct e1000_adapter *adapter,
3902 int tx_flags, int count)
3904 struct e1000_ring *tx_ring = adapter->tx_ring;
3905 struct e1000_tx_desc *tx_desc = NULL;
3906 struct e1000_buffer *buffer_info;
3907 u32 txd_upper = 0, txd_lower = E1000_TXD_CMD_IFCS;
3910 if (tx_flags & E1000_TX_FLAGS_TSO) {
3911 txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D |
3913 txd_upper |= E1000_TXD_POPTS_TXSM << 8;
3915 if (tx_flags & E1000_TX_FLAGS_IPV4)
3916 txd_upper |= E1000_TXD_POPTS_IXSM << 8;
3919 if (tx_flags & E1000_TX_FLAGS_CSUM) {
3920 txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D;
3921 txd_upper |= E1000_TXD_POPTS_TXSM << 8;
3924 if (tx_flags & E1000_TX_FLAGS_VLAN) {
3925 txd_lower |= E1000_TXD_CMD_VLE;
3926 txd_upper |= (tx_flags & E1000_TX_FLAGS_VLAN_MASK);
3929 i = tx_ring->next_to_use;
3932 buffer_info = &tx_ring->buffer_info[i];
3933 tx_desc = E1000_TX_DESC(*tx_ring, i);
3934 tx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
3935 tx_desc->lower.data =
3936 cpu_to_le32(txd_lower | buffer_info->length);
3937 tx_desc->upper.data = cpu_to_le32(txd_upper);
3940 if (i == tx_ring->count)
3944 tx_desc->lower.data |= cpu_to_le32(adapter->txd_cmd);
3947 * Force memory writes to complete before letting h/w
3948 * know there are new descriptors to fetch. (Only
3949 * applicable for weak-ordered memory model archs,
3954 tx_ring->next_to_use = i;
3955 writel(i, adapter->hw.hw_addr + tx_ring->tail);
3957 * we need this if more than one processor can write to our tail
3958 * at a time, it synchronizes IO on IA64/Altix systems
3963 #define MINIMUM_DHCP_PACKET_SIZE 282
3964 static int e1000_transfer_dhcp_info(struct e1000_adapter *adapter,
3965 struct sk_buff *skb)
3967 struct e1000_hw *hw = &adapter->hw;
3970 if (vlan_tx_tag_present(skb)) {
3971 if (!((vlan_tx_tag_get(skb) == adapter->hw.mng_cookie.vlan_id)
3972 && (adapter->hw.mng_cookie.status &
3973 E1000_MNG_DHCP_COOKIE_STATUS_VLAN)))
3977 if (skb->len <= MINIMUM_DHCP_PACKET_SIZE)
3980 if (((struct ethhdr *) skb->data)->h_proto != htons(ETH_P_IP))
3984 const struct iphdr *ip = (struct iphdr *)((u8 *)skb->data+14);
3987 if (ip->protocol != IPPROTO_UDP)
3990 udp = (struct udphdr *)((u8 *)ip + (ip->ihl << 2));
3991 if (ntohs(udp->dest) != 67)
3994 offset = (u8 *)udp + 8 - skb->data;
3995 length = skb->len - offset;
3996 return e1000e_mng_write_dhcp_info(hw, (u8 *)udp + 8, length);
4002 static int __e1000_maybe_stop_tx(struct net_device *netdev, int size)
4004 struct e1000_adapter *adapter = netdev_priv(netdev);
4006 netif_stop_queue(netdev);
4008 * Herbert's original patch had:
4009 * smp_mb__after_netif_stop_queue();
4010 * but since that doesn't exist yet, just open code it.
4015 * We need to check again in a case another CPU has just
4016 * made room available.
4018 if (e1000_desc_unused(adapter->tx_ring) < size)
4022 netif_start_queue(netdev);
4023 ++adapter->restart_queue;
4027 static int e1000_maybe_stop_tx(struct net_device *netdev, int size)
4029 struct e1000_adapter *adapter = netdev_priv(netdev);
4031 if (e1000_desc_unused(adapter->tx_ring) >= size)
4033 return __e1000_maybe_stop_tx(netdev, size);
4036 #define TXD_USE_COUNT(S, X) (((S) >> (X)) + 1 )
4037 static int e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
4039 struct e1000_adapter *adapter = netdev_priv(netdev);
4040 struct e1000_ring *tx_ring = adapter->tx_ring;
4042 unsigned int max_per_txd = E1000_MAX_PER_TXD;
4043 unsigned int max_txd_pwr = E1000_MAX_TXD_PWR;
4044 unsigned int tx_flags = 0;
4045 unsigned int len = skb->len - skb->data_len;
4046 unsigned int nr_frags;
4052 if (test_bit(__E1000_DOWN, &adapter->state)) {
4053 dev_kfree_skb_any(skb);
4054 return NETDEV_TX_OK;
4057 if (skb->len <= 0) {
4058 dev_kfree_skb_any(skb);
4059 return NETDEV_TX_OK;
4062 mss = skb_shinfo(skb)->gso_size;
4064 * The controller does a simple calculation to
4065 * make sure there is enough room in the FIFO before
4066 * initiating the DMA for each buffer. The calc is:
4067 * 4 = ceil(buffer len/mss). To make sure we don't
4068 * overrun the FIFO, adjust the max buffer len if mss
4073 max_per_txd = min(mss << 2, max_per_txd);
4074 max_txd_pwr = fls(max_per_txd) - 1;
4077 * TSO Workaround for 82571/2/3 Controllers -- if skb->data
4078 * points to just header, pull a few bytes of payload from
4079 * frags into skb->data
4081 hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
4083 * we do this workaround for ES2LAN, but it is un-necessary,
4084 * avoiding it could save a lot of cycles
4086 if (skb->data_len && (hdr_len == len)) {
4087 unsigned int pull_size;
4089 pull_size = min((unsigned int)4, skb->data_len);
4090 if (!__pskb_pull_tail(skb, pull_size)) {
4091 e_err("__pskb_pull_tail failed.\n");
4092 dev_kfree_skb_any(skb);
4093 return NETDEV_TX_OK;
4095 len = skb->len - skb->data_len;
4099 /* reserve a descriptor for the offload context */
4100 if ((mss) || (skb->ip_summed == CHECKSUM_PARTIAL))
4104 count += TXD_USE_COUNT(len, max_txd_pwr);
4106 nr_frags = skb_shinfo(skb)->nr_frags;
4107 for (f = 0; f < nr_frags; f++)
4108 count += TXD_USE_COUNT(skb_shinfo(skb)->frags[f].size,
4111 if (adapter->hw.mac.tx_pkt_filtering)
4112 e1000_transfer_dhcp_info(adapter, skb);
4115 * need: count + 2 desc gap to keep tail from touching
4116 * head, otherwise try next time
4118 if (e1000_maybe_stop_tx(netdev, count + 2))
4119 return NETDEV_TX_BUSY;
4121 if (adapter->vlgrp && vlan_tx_tag_present(skb)) {
4122 tx_flags |= E1000_TX_FLAGS_VLAN;
4123 tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT);
4126 first = tx_ring->next_to_use;
4128 tso = e1000_tso(adapter, skb);
4130 dev_kfree_skb_any(skb);
4131 return NETDEV_TX_OK;
4135 tx_flags |= E1000_TX_FLAGS_TSO;
4136 else if (e1000_tx_csum(adapter, skb))
4137 tx_flags |= E1000_TX_FLAGS_CSUM;
4140 * Old method was to assume IPv4 packet by default if TSO was enabled.
4141 * 82571 hardware supports TSO capabilities for IPv6 as well...
4142 * no longer assume, we must.
4144 if (skb->protocol == htons(ETH_P_IP))
4145 tx_flags |= E1000_TX_FLAGS_IPV4;
4147 count = e1000_tx_map(adapter, skb, first, max_per_txd, nr_frags, mss);
4149 /* handle pci_map_single() error in e1000_tx_map */
4150 dev_kfree_skb_any(skb);
4151 return NETDEV_TX_OK;
4154 e1000_tx_queue(adapter, tx_flags, count);
4156 netdev->trans_start = jiffies;
4158 /* Make sure there is space in the ring for the next send. */
4159 e1000_maybe_stop_tx(netdev, MAX_SKB_FRAGS + 2);
4161 return NETDEV_TX_OK;
4165 * e1000_tx_timeout - Respond to a Tx Hang
4166 * @netdev: network interface device structure
4168 static void e1000_tx_timeout(struct net_device *netdev)
4170 struct e1000_adapter *adapter = netdev_priv(netdev);
4172 /* Do the reset outside of interrupt context */
4173 adapter->tx_timeout_count++;
4174 schedule_work(&adapter->reset_task);
4177 static void e1000_reset_task(struct work_struct *work)
4179 struct e1000_adapter *adapter;
4180 adapter = container_of(work, struct e1000_adapter, reset_task);
4182 e1000e_reinit_locked(adapter);
4186 * e1000_get_stats - Get System Network Statistics
4187 * @netdev: network interface device structure
4189 * Returns the address of the device statistics structure.
4190 * The statistics are actually updated from the timer callback.
4192 static struct net_device_stats *e1000_get_stats(struct net_device *netdev)
4194 struct e1000_adapter *adapter = netdev_priv(netdev);
4196 /* only return the current stats */
4197 return &adapter->net_stats;
4201 * e1000_change_mtu - Change the Maximum Transfer Unit
4202 * @netdev: network interface device structure
4203 * @new_mtu: new value for maximum frame size
4205 * Returns 0 on success, negative on failure
4207 static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
4209 struct e1000_adapter *adapter = netdev_priv(netdev);
4210 int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN;
4212 if ((new_mtu < ETH_ZLEN + ETH_FCS_LEN + VLAN_HLEN) ||
4213 (max_frame > MAX_JUMBO_FRAME_SIZE)) {
4214 e_err("Invalid MTU setting\n");
4218 /* Jumbo frame size limits */
4219 if (max_frame > ETH_FRAME_LEN + ETH_FCS_LEN) {
4220 if (!(adapter->flags & FLAG_HAS_JUMBO_FRAMES)) {
4221 e_err("Jumbo Frames not supported.\n");
4224 if (adapter->hw.phy.type == e1000_phy_ife) {
4225 e_err("Jumbo Frames not supported.\n");
4230 #define MAX_STD_JUMBO_FRAME_SIZE 9234
4231 if (max_frame > MAX_STD_JUMBO_FRAME_SIZE) {
4232 e_err("MTU > 9216 not supported.\n");
4236 while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
4238 /* e1000e_down has a dependency on max_frame_size */
4239 adapter->max_frame_size = max_frame;
4240 if (netif_running(netdev))
4241 e1000e_down(adapter);
4244 * NOTE: netdev_alloc_skb reserves 16 bytes, and typically NET_IP_ALIGN
4245 * means we reserve 2 more, this pushes us to allocate from the next
4247 * i.e. RXBUFFER_2048 --> size-4096 slab
4248 * However with the new *_jumbo_rx* routines, jumbo receives will use
4252 if (max_frame <= 256)
4253 adapter->rx_buffer_len = 256;
4254 else if (max_frame <= 512)
4255 adapter->rx_buffer_len = 512;
4256 else if (max_frame <= 1024)
4257 adapter->rx_buffer_len = 1024;
4258 else if (max_frame <= 2048)
4259 adapter->rx_buffer_len = 2048;
4261 adapter->rx_buffer_len = 4096;
4263 /* adjust allocation if LPE protects us, and we aren't using SBP */
4264 if ((max_frame == ETH_FRAME_LEN + ETH_FCS_LEN) ||
4265 (max_frame == ETH_FRAME_LEN + VLAN_HLEN + ETH_FCS_LEN))
4266 adapter->rx_buffer_len = ETH_FRAME_LEN + VLAN_HLEN
4269 e_info("changing MTU from %d to %d\n", netdev->mtu, new_mtu);
4270 netdev->mtu = new_mtu;
4272 if (netif_running(netdev))
4275 e1000e_reset(adapter);
4277 clear_bit(__E1000_RESETTING, &adapter->state);
4282 static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
4285 struct e1000_adapter *adapter = netdev_priv(netdev);
4286 struct mii_ioctl_data *data = if_mii(ifr);
4288 if (adapter->hw.phy.media_type != e1000_media_type_copper)
4293 data->phy_id = adapter->hw.phy.addr;
4296 if (!capable(CAP_NET_ADMIN))
4298 switch (data->reg_num & 0x1F) {
4300 data->val_out = adapter->phy_regs.bmcr;
4303 data->val_out = adapter->phy_regs.bmsr;
4306 data->val_out = (adapter->hw.phy.id >> 16);
4309 data->val_out = (adapter->hw.phy.id & 0xFFFF);
4312 data->val_out = adapter->phy_regs.advertise;
4315 data->val_out = adapter->phy_regs.lpa;
4318 data->val_out = adapter->phy_regs.expansion;
4321 data->val_out = adapter->phy_regs.ctrl1000;
4324 data->val_out = adapter->phy_regs.stat1000;
4327 data->val_out = adapter->phy_regs.estatus;
4340 static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
4346 return e1000_mii_ioctl(netdev, ifr, cmd);
4352 static int e1000_suspend(struct pci_dev *pdev, pm_message_t state)
4354 struct net_device *netdev = pci_get_drvdata(pdev);
4355 struct e1000_adapter *adapter = netdev_priv(netdev);
4356 struct e1000_hw *hw = &adapter->hw;
4357 u32 ctrl, ctrl_ext, rctl, status;
4358 u32 wufc = adapter->wol;
4361 netif_device_detach(netdev);
4363 if (netif_running(netdev)) {
4364 WARN_ON(test_bit(__E1000_RESETTING, &adapter->state));
4365 e1000e_down(adapter);
4366 e1000_free_irq(adapter);
4368 e1000e_reset_interrupt_capability(adapter);
4370 retval = pci_save_state(pdev);
4374 status = er32(STATUS);
4375 if (status & E1000_STATUS_LU)
4376 wufc &= ~E1000_WUFC_LNKC;
4379 e1000_setup_rctl(adapter);
4380 e1000_set_multi(netdev);
4382 /* turn on all-multi mode if wake on multicast is enabled */
4383 if (wufc & E1000_WUFC_MC) {
4385 rctl |= E1000_RCTL_MPE;
4390 /* advertise wake from D3Cold */
4391 #define E1000_CTRL_ADVD3WUC 0x00100000
4392 /* phy power management enable */
4393 #define E1000_CTRL_EN_PHY_PWR_MGMT 0x00200000
4394 ctrl |= E1000_CTRL_ADVD3WUC |
4395 E1000_CTRL_EN_PHY_PWR_MGMT;
4398 if (adapter->hw.phy.media_type == e1000_media_type_fiber ||
4399 adapter->hw.phy.media_type ==
4400 e1000_media_type_internal_serdes) {
4401 /* keep the laser running in D3 */
4402 ctrl_ext = er32(CTRL_EXT);
4403 ctrl_ext |= E1000_CTRL_EXT_SDP7_DATA;
4404 ew32(CTRL_EXT, ctrl_ext);
4407 if (adapter->flags & FLAG_IS_ICH)
4408 e1000e_disable_gig_wol_ich8lan(&adapter->hw);
4410 /* Allow time for pending master requests to run */
4411 e1000e_disable_pcie_master(&adapter->hw);
4413 ew32(WUC, E1000_WUC_PME_EN);
4415 pci_enable_wake(pdev, PCI_D3hot, 1);
4416 pci_enable_wake(pdev, PCI_D3cold, 1);
4420 pci_enable_wake(pdev, PCI_D3hot, 0);
4421 pci_enable_wake(pdev, PCI_D3cold, 0);
4424 /* make sure adapter isn't asleep if manageability is enabled */
4425 if (adapter->flags & FLAG_MNG_PT_ENABLED) {
4426 pci_enable_wake(pdev, PCI_D3hot, 1);
4427 pci_enable_wake(pdev, PCI_D3cold, 1);
4430 if (adapter->hw.phy.type == e1000_phy_igp_3)
4431 e1000e_igp3_phy_powerdown_workaround_ich8lan(&adapter->hw);
4434 * Release control of h/w to f/w. If f/w is AMT enabled, this
4435 * would have already happened in close and is redundant.
4437 e1000_release_hw_control(adapter);
4439 pci_disable_device(pdev);
4442 * The pci-e switch on some quad port adapters will report a
4443 * correctable error when the MAC transitions from D0 to D3. To
4444 * prevent this we need to mask off the correctable errors on the
4445 * downstream port of the pci-e switch.
4447 if (adapter->flags & FLAG_IS_QUAD_PORT) {
4448 struct pci_dev *us_dev = pdev->bus->self;
4449 int pos = pci_find_capability(us_dev, PCI_CAP_ID_EXP);
4452 pci_read_config_word(us_dev, pos + PCI_EXP_DEVCTL, &devctl);
4453 pci_write_config_word(us_dev, pos + PCI_EXP_DEVCTL,
4454 (devctl & ~PCI_EXP_DEVCTL_CERE));
4456 pci_set_power_state(pdev, pci_choose_state(pdev, state));
4458 pci_write_config_word(us_dev, pos + PCI_EXP_DEVCTL, devctl);
4460 pci_set_power_state(pdev, pci_choose_state(pdev, state));
4466 static void e1000e_disable_l1aspm(struct pci_dev *pdev)
4472 * 82573 workaround - disable L1 ASPM on mobile chipsets
4474 * L1 ASPM on various mobile (ich7) chipsets do not behave properly
4475 * resulting in lost data or garbage information on the pci-e link
4476 * level. This could result in (false) bad EEPROM checksum errors,
4477 * long ping times (up to 2s) or even a system freeze/hang.
4479 * Unfortunately this feature saves about 1W power consumption when
4482 pos = pci_find_capability(pdev, PCI_CAP_ID_EXP);
4483 pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, &val);
4485 dev_warn(&pdev->dev, "Disabling L1 ASPM\n");
4487 pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, val);
4492 static int e1000_resume(struct pci_dev *pdev)
4494 struct net_device *netdev = pci_get_drvdata(pdev);
4495 struct e1000_adapter *adapter = netdev_priv(netdev);
4496 struct e1000_hw *hw = &adapter->hw;
4499 pci_set_power_state(pdev, PCI_D0);
4500 pci_restore_state(pdev);
4501 e1000e_disable_l1aspm(pdev);
4503 err = pci_enable_device_mem(pdev);
4506 "Cannot enable PCI device from suspend\n");
4510 /* AER (Advanced Error Reporting) hooks */
4511 err = pci_enable_pcie_error_reporting(pdev);
4513 dev_err(&pdev->dev, "pci_enable_pcie_error_reporting failed "
4515 /* non-fatal, continue */
4518 pci_set_master(pdev);
4520 pci_enable_wake(pdev, PCI_D3hot, 0);
4521 pci_enable_wake(pdev, PCI_D3cold, 0);
4523 e1000e_set_interrupt_capability(adapter);
4524 if (netif_running(netdev)) {
4525 err = e1000_request_irq(adapter);
4530 e1000e_power_up_phy(adapter);
4531 e1000e_reset(adapter);
4534 e1000_init_manageability(adapter);
4536 if (netif_running(netdev))
4539 netif_device_attach(netdev);
4542 * If the controller has AMT, do not set DRV_LOAD until the interface
4543 * is up. For all other cases, let the f/w know that the h/w is now
4544 * under the control of the driver.
4546 if (!(adapter->flags & FLAG_HAS_AMT))
4547 e1000_get_hw_control(adapter);
4553 static void e1000_shutdown(struct pci_dev *pdev)
4555 e1000_suspend(pdev, PMSG_SUSPEND);
4558 #ifdef CONFIG_NET_POLL_CONTROLLER
4560 * Polling 'interrupt' - used by things like netconsole to send skbs
4561 * without having to re-enable interrupts. It's not called while
4562 * the interrupt routine is executing.
4564 static void e1000_netpoll(struct net_device *netdev)
4566 struct e1000_adapter *adapter = netdev_priv(netdev);
4568 disable_irq(adapter->pdev->irq);
4569 e1000_intr(adapter->pdev->irq, netdev);
4571 enable_irq(adapter->pdev->irq);
4576 * e1000_io_error_detected - called when PCI error is detected
4577 * @pdev: Pointer to PCI device
4578 * @state: The current pci connection state
4580 * This function is called after a PCI bus error affecting
4581 * this device has been detected.
4583 static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev,
4584 pci_channel_state_t state)
4586 struct net_device *netdev = pci_get_drvdata(pdev);
4587 struct e1000_adapter *adapter = netdev_priv(netdev);
4589 netif_device_detach(netdev);
4591 if (netif_running(netdev))
4592 e1000e_down(adapter);
4593 pci_disable_device(pdev);
4595 /* Request a slot slot reset. */
4596 return PCI_ERS_RESULT_NEED_RESET;
4600 * e1000_io_slot_reset - called after the pci bus has been reset.
4601 * @pdev: Pointer to PCI device
4603 * Restart the card from scratch, as if from a cold-boot. Implementation
4604 * resembles the first-half of the e1000_resume routine.
4606 static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
4608 struct net_device *netdev = pci_get_drvdata(pdev);
4609 struct e1000_adapter *adapter = netdev_priv(netdev);
4610 struct e1000_hw *hw = &adapter->hw;
4612 pci_ers_result_t result;
4614 e1000e_disable_l1aspm(pdev);
4615 err = pci_enable_device_mem(pdev);
4618 "Cannot re-enable PCI device after reset.\n");
4619 result = PCI_ERS_RESULT_DISCONNECT;
4621 pci_set_master(pdev);
4622 pci_restore_state(pdev);
4624 pci_enable_wake(pdev, PCI_D3hot, 0);
4625 pci_enable_wake(pdev, PCI_D3cold, 0);
4627 e1000e_reset(adapter);
4629 result = PCI_ERS_RESULT_RECOVERED;
4632 pci_cleanup_aer_uncorrect_error_status(pdev);
4638 * e1000_io_resume - called when traffic can start flowing again.
4639 * @pdev: Pointer to PCI device
4641 * This callback is called when the error recovery driver tells us that
4642 * its OK to resume normal operation. Implementation resembles the
4643 * second-half of the e1000_resume routine.
4645 static void e1000_io_resume(struct pci_dev *pdev)
4647 struct net_device *netdev = pci_get_drvdata(pdev);
4648 struct e1000_adapter *adapter = netdev_priv(netdev);
4650 e1000_init_manageability(adapter);
4652 if (netif_running(netdev)) {
4653 if (e1000e_up(adapter)) {
4655 "can't bring device back up after reset\n");
4660 netif_device_attach(netdev);
4663 * If the controller has AMT, do not set DRV_LOAD until the interface
4664 * is up. For all other cases, let the f/w know that the h/w is now
4665 * under the control of the driver.
4667 if (!(adapter->flags & FLAG_HAS_AMT))
4668 e1000_get_hw_control(adapter);
4672 static void e1000_print_device_info(struct e1000_adapter *adapter)
4674 struct e1000_hw *hw = &adapter->hw;
4675 struct net_device *netdev = adapter->netdev;
4678 /* print bus type/speed/width info */
4679 e_info("(PCI Express:2.5GB/s:%s) %pM\n",
4681 ((hw->bus.width == e1000_bus_width_pcie_x4) ? "Width x4" :
4685 e_info("Intel(R) PRO/%s Network Connection\n",
4686 (hw->phy.type == e1000_phy_ife) ? "10/100" : "1000");
4687 e1000e_read_pba_num(hw, &pba_num);
4688 e_info("MAC: %d, PHY: %d, PBA No: %06x-%03x\n",
4689 hw->mac.type, hw->phy.type, (pba_num >> 8), (pba_num & 0xff));
4692 static void e1000_eeprom_checks(struct e1000_adapter *adapter)
4694 struct e1000_hw *hw = &adapter->hw;
4698 if (hw->mac.type != e1000_82573)
4701 ret_val = e1000_read_nvm(hw, NVM_INIT_CONTROL2_REG, 1, &buf);
4702 if (!ret_val && (!(le16_to_cpu(buf) & (1 << 0)))) {
4703 /* Deep Smart Power Down (DSPD) */
4704 dev_warn(&adapter->pdev->dev,
4705 "Warning: detected DSPD enabled in EEPROM\n");
4708 ret_val = e1000_read_nvm(hw, NVM_INIT_3GIO_3, 1, &buf);
4709 if (!ret_val && (le16_to_cpu(buf) & (3 << 2))) {
4711 dev_warn(&adapter->pdev->dev,
4712 "Warning: detected ASPM enabled in EEPROM\n");
4716 static const struct net_device_ops e1000e_netdev_ops = {
4717 .ndo_open = e1000_open,
4718 .ndo_stop = e1000_close,
4719 .ndo_start_xmit = e1000_xmit_frame,
4720 .ndo_get_stats = e1000_get_stats,
4721 .ndo_set_multicast_list = e1000_set_multi,
4722 .ndo_set_mac_address = e1000_set_mac,
4723 .ndo_change_mtu = e1000_change_mtu,
4724 .ndo_do_ioctl = e1000_ioctl,
4725 .ndo_tx_timeout = e1000_tx_timeout,
4726 .ndo_validate_addr = eth_validate_addr,
4728 .ndo_vlan_rx_register = e1000_vlan_rx_register,
4729 .ndo_vlan_rx_add_vid = e1000_vlan_rx_add_vid,
4730 .ndo_vlan_rx_kill_vid = e1000_vlan_rx_kill_vid,
4731 #ifdef CONFIG_NET_POLL_CONTROLLER
4732 .ndo_poll_controller = e1000_netpoll,
4737 * e1000_probe - Device Initialization Routine
4738 * @pdev: PCI device information struct
4739 * @ent: entry in e1000_pci_tbl
4741 * Returns 0 on success, negative on failure
4743 * e1000_probe initializes an adapter identified by a pci_dev structure.
4744 * The OS initialization, configuring of the adapter private structure,
4745 * and a hardware reset occur.
4747 static int __devinit e1000_probe(struct pci_dev *pdev,
4748 const struct pci_device_id *ent)
4750 struct net_device *netdev;
4751 struct e1000_adapter *adapter;
4752 struct e1000_hw *hw;
4753 const struct e1000_info *ei = e1000_info_tbl[ent->driver_data];
4754 resource_size_t mmio_start, mmio_len;
4755 resource_size_t flash_start, flash_len;
4757 static int cards_found;
4758 int i, err, pci_using_dac;
4759 u16 eeprom_data = 0;
4760 u16 eeprom_apme_mask = E1000_EEPROM_APME;
4762 e1000e_disable_l1aspm(pdev);
4764 err = pci_enable_device_mem(pdev);
4769 err = pci_set_dma_mask(pdev, DMA_64BIT_MASK);
4771 err = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK);
4775 err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
4777 err = pci_set_consistent_dma_mask(pdev,
4780 dev_err(&pdev->dev, "No usable DMA "
4781 "configuration, aborting\n");
4787 err = pci_request_selected_regions_exclusive(pdev,
4788 pci_select_bars(pdev, IORESOURCE_MEM),
4789 e1000e_driver_name);
4793 pci_set_master(pdev);
4794 /* PCI config space info */
4795 err = pci_save_state(pdev);
4797 goto err_alloc_etherdev;
4800 netdev = alloc_etherdev(sizeof(struct e1000_adapter));
4802 goto err_alloc_etherdev;
4804 SET_NETDEV_DEV(netdev, &pdev->dev);
4806 pci_set_drvdata(pdev, netdev);
4807 adapter = netdev_priv(netdev);
4809 adapter->netdev = netdev;
4810 adapter->pdev = pdev;
4812 adapter->pba = ei->pba;
4813 adapter->flags = ei->flags;
4814 adapter->flags2 = ei->flags2;
4815 adapter->hw.adapter = adapter;
4816 adapter->hw.mac.type = ei->mac;
4817 adapter->msg_enable = (1 << NETIF_MSG_DRV | NETIF_MSG_PROBE) - 1;
4819 mmio_start = pci_resource_start(pdev, 0);
4820 mmio_len = pci_resource_len(pdev, 0);
4823 adapter->hw.hw_addr = ioremap(mmio_start, mmio_len);
4824 if (!adapter->hw.hw_addr)
4827 if ((adapter->flags & FLAG_HAS_FLASH) &&
4828 (pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) {
4829 flash_start = pci_resource_start(pdev, 1);
4830 flash_len = pci_resource_len(pdev, 1);
4831 adapter->hw.flash_address = ioremap(flash_start, flash_len);
4832 if (!adapter->hw.flash_address)
4836 /* construct the net_device struct */
4837 netdev->netdev_ops = &e1000e_netdev_ops;
4838 e1000e_set_ethtool_ops(netdev);
4839 netdev->watchdog_timeo = 5 * HZ;
4840 netif_napi_add(netdev, &adapter->napi, e1000_clean, 64);
4841 strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
4843 netdev->mem_start = mmio_start;
4844 netdev->mem_end = mmio_start + mmio_len;
4846 adapter->bd_number = cards_found++;
4848 e1000e_check_options(adapter);
4850 /* setup adapter struct */
4851 err = e1000_sw_init(adapter);
4857 memcpy(&hw->mac.ops, ei->mac_ops, sizeof(hw->mac.ops));
4858 memcpy(&hw->nvm.ops, ei->nvm_ops, sizeof(hw->nvm.ops));
4859 memcpy(&hw->phy.ops, ei->phy_ops, sizeof(hw->phy.ops));
4861 err = ei->get_variants(adapter);
4865 if ((adapter->flags & FLAG_IS_ICH) &&
4866 (adapter->flags & FLAG_READ_ONLY_NVM))
4867 e1000e_write_protect_nvm_ich8lan(&adapter->hw);
4869 hw->mac.ops.get_bus_info(&adapter->hw);
4871 adapter->hw.phy.autoneg_wait_to_complete = 0;
4873 /* Copper options */
4874 if (adapter->hw.phy.media_type == e1000_media_type_copper) {
4875 adapter->hw.phy.mdix = AUTO_ALL_MODES;
4876 adapter->hw.phy.disable_polarity_correction = 0;
4877 adapter->hw.phy.ms_type = e1000_ms_hw_default;
4880 if (e1000_check_reset_block(&adapter->hw))
4881 e_info("PHY reset is blocked due to SOL/IDER session.\n");
4883 netdev->features = NETIF_F_SG |
4885 NETIF_F_HW_VLAN_TX |
4888 if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER)
4889 netdev->features |= NETIF_F_HW_VLAN_FILTER;
4891 netdev->features |= NETIF_F_TSO;
4892 netdev->features |= NETIF_F_TSO6;
4894 netdev->vlan_features |= NETIF_F_TSO;
4895 netdev->vlan_features |= NETIF_F_TSO6;
4896 netdev->vlan_features |= NETIF_F_HW_CSUM;
4897 netdev->vlan_features |= NETIF_F_SG;
4900 netdev->features |= NETIF_F_HIGHDMA;
4902 if (e1000e_enable_mng_pass_thru(&adapter->hw))
4903 adapter->flags |= FLAG_MNG_PT_ENABLED;
4906 * before reading the NVM, reset the controller to
4907 * put the device in a known good starting state
4909 adapter->hw.mac.ops.reset_hw(&adapter->hw);
4912 * systems with ASPM and others may see the checksum fail on the first
4913 * attempt. Let's give it a few tries
4916 if (e1000_validate_nvm_checksum(&adapter->hw) >= 0)
4919 e_err("The NVM Checksum Is Not Valid\n");
4925 e1000_eeprom_checks(adapter);
4927 /* copy the MAC address out of the NVM */
4928 if (e1000e_read_mac_addr(&adapter->hw))
4929 e_err("NVM Read Error while reading MAC address\n");
4931 memcpy(netdev->dev_addr, adapter->hw.mac.addr, netdev->addr_len);
4932 memcpy(netdev->perm_addr, adapter->hw.mac.addr, netdev->addr_len);
4934 if (!is_valid_ether_addr(netdev->perm_addr)) {
4935 e_err("Invalid MAC Address: %pM\n", netdev->perm_addr);
4940 init_timer(&adapter->watchdog_timer);
4941 adapter->watchdog_timer.function = &e1000_watchdog;
4942 adapter->watchdog_timer.data = (unsigned long) adapter;
4944 init_timer(&adapter->phy_info_timer);
4945 adapter->phy_info_timer.function = &e1000_update_phy_info;
4946 adapter->phy_info_timer.data = (unsigned long) adapter;
4948 INIT_WORK(&adapter->reset_task, e1000_reset_task);
4949 INIT_WORK(&adapter->watchdog_task, e1000_watchdog_task);
4950 INIT_WORK(&adapter->downshift_task, e1000e_downshift_workaround);
4951 INIT_WORK(&adapter->update_phy_task, e1000e_update_phy_task);
4953 /* Initialize link parameters. User can change them with ethtool */
4954 adapter->hw.mac.autoneg = 1;
4955 adapter->fc_autoneg = 1;
4956 adapter->hw.fc.requested_mode = e1000_fc_default;
4957 adapter->hw.fc.current_mode = e1000_fc_default;
4958 adapter->hw.phy.autoneg_advertised = 0x2f;
4960 /* ring size defaults */
4961 adapter->rx_ring->count = 256;
4962 adapter->tx_ring->count = 256;
4965 * Initial Wake on LAN setting - If APM wake is enabled in
4966 * the EEPROM, enable the ACPI Magic Packet filter
4968 if (adapter->flags & FLAG_APME_IN_WUC) {
4969 /* APME bit in EEPROM is mapped to WUC.APME */
4970 eeprom_data = er32(WUC);
4971 eeprom_apme_mask = E1000_WUC_APME;
4972 } else if (adapter->flags & FLAG_APME_IN_CTRL3) {
4973 if (adapter->flags & FLAG_APME_CHECK_PORT_B &&
4974 (adapter->hw.bus.func == 1))
4975 e1000_read_nvm(&adapter->hw,
4976 NVM_INIT_CONTROL3_PORT_B, 1, &eeprom_data);
4978 e1000_read_nvm(&adapter->hw,
4979 NVM_INIT_CONTROL3_PORT_A, 1, &eeprom_data);
4982 /* fetch WoL from EEPROM */
4983 if (eeprom_data & eeprom_apme_mask)
4984 adapter->eeprom_wol |= E1000_WUFC_MAG;
4987 * now that we have the eeprom settings, apply the special cases
4988 * where the eeprom may be wrong or the board simply won't support
4989 * wake on lan on a particular port
4991 if (!(adapter->flags & FLAG_HAS_WOL))
4992 adapter->eeprom_wol = 0;
4994 /* initialize the wol settings based on the eeprom settings */
4995 adapter->wol = adapter->eeprom_wol;
4996 device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol);
4998 /* save off EEPROM version number */
4999 e1000_read_nvm(&adapter->hw, 5, 1, &adapter->eeprom_vers);
5001 /* reset the hardware with the new settings */
5002 e1000e_reset(adapter);
5005 * If the controller has AMT, do not set DRV_LOAD until the interface
5006 * is up. For all other cases, let the f/w know that the h/w is now
5007 * under the control of the driver.
5009 if (!(adapter->flags & FLAG_HAS_AMT))
5010 e1000_get_hw_control(adapter);
5012 /* tell the stack to leave us alone until e1000_open() is called */
5013 netif_carrier_off(netdev);
5014 netif_tx_stop_all_queues(netdev);
5016 strcpy(netdev->name, "eth%d");
5017 err = register_netdev(netdev);
5021 e1000_print_device_info(adapter);
5026 if (!(adapter->flags & FLAG_HAS_AMT))
5027 e1000_release_hw_control(adapter);
5029 if (!e1000_check_reset_block(&adapter->hw))
5030 e1000_phy_hw_reset(&adapter->hw);
5033 kfree(adapter->tx_ring);
5034 kfree(adapter->rx_ring);
5036 if (adapter->hw.flash_address)
5037 iounmap(adapter->hw.flash_address);
5038 e1000e_reset_interrupt_capability(adapter);
5040 iounmap(adapter->hw.hw_addr);
5042 free_netdev(netdev);
5044 pci_release_selected_regions(pdev,
5045 pci_select_bars(pdev, IORESOURCE_MEM));
5048 pci_disable_device(pdev);
5053 * e1000_remove - Device Removal Routine
5054 * @pdev: PCI device information struct
5056 * e1000_remove is called by the PCI subsystem to alert the driver
5057 * that it should release a PCI device. The could be caused by a
5058 * Hot-Plug event, or because the driver is going to be removed from
5061 static void __devexit e1000_remove(struct pci_dev *pdev)
5063 struct net_device *netdev = pci_get_drvdata(pdev);
5064 struct e1000_adapter *adapter = netdev_priv(netdev);
5068 * flush_scheduled work may reschedule our watchdog task, so
5069 * explicitly disable watchdog tasks from being rescheduled
5071 set_bit(__E1000_DOWN, &adapter->state);
5072 del_timer_sync(&adapter->watchdog_timer);
5073 del_timer_sync(&adapter->phy_info_timer);
5075 flush_scheduled_work();
5078 * Release control of h/w to f/w. If f/w is AMT enabled, this
5079 * would have already happened in close and is redundant.
5081 e1000_release_hw_control(adapter);
5083 unregister_netdev(netdev);
5085 if (!e1000_check_reset_block(&adapter->hw))
5086 e1000_phy_hw_reset(&adapter->hw);
5088 e1000e_reset_interrupt_capability(adapter);
5089 kfree(adapter->tx_ring);
5090 kfree(adapter->rx_ring);
5092 iounmap(adapter->hw.hw_addr);
5093 if (adapter->hw.flash_address)
5094 iounmap(adapter->hw.flash_address);
5095 pci_release_selected_regions(pdev,
5096 pci_select_bars(pdev, IORESOURCE_MEM));
5098 free_netdev(netdev);
5101 err = pci_disable_pcie_error_reporting(pdev);
5104 "pci_disable_pcie_error_reporting failed 0x%x\n", err);
5106 pci_disable_device(pdev);
5109 /* PCI Error Recovery (ERS) */
5110 static struct pci_error_handlers e1000_err_handler = {
5111 .error_detected = e1000_io_error_detected,
5112 .slot_reset = e1000_io_slot_reset,
5113 .resume = e1000_io_resume,
5116 static struct pci_device_id e1000_pci_tbl[] = {
5117 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_COPPER), board_82571 },
5118 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_FIBER), board_82571 },
5119 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_QUAD_COPPER), board_82571 },
5120 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_QUAD_COPPER_LP), board_82571 },
5121 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_QUAD_FIBER), board_82571 },
5122 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_SERDES), board_82571 },
5123 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_SERDES_DUAL), board_82571 },
5124 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_SERDES_QUAD), board_82571 },
5125 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571PT_QUAD_COPPER), board_82571 },
5127 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82572EI), board_82572 },
5128 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82572EI_COPPER), board_82572 },
5129 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82572EI_FIBER), board_82572 },
5130 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82572EI_SERDES), board_82572 },
5132 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82573E), board_82573 },
5133 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82573E_IAMT), board_82573 },
5134 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82573L), board_82573 },
5136 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82574L), board_82574 },
5138 { PCI_VDEVICE(INTEL, E1000_DEV_ID_80003ES2LAN_COPPER_DPT),
5139 board_80003es2lan },
5140 { PCI_VDEVICE(INTEL, E1000_DEV_ID_80003ES2LAN_COPPER_SPT),
5141 board_80003es2lan },
5142 { PCI_VDEVICE(INTEL, E1000_DEV_ID_80003ES2LAN_SERDES_DPT),
5143 board_80003es2lan },
5144 { PCI_VDEVICE(INTEL, E1000_DEV_ID_80003ES2LAN_SERDES_SPT),
5145 board_80003es2lan },
5147 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IFE), board_ich8lan },
5148 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IFE_G), board_ich8lan },
5149 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IFE_GT), board_ich8lan },
5150 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IGP_AMT), board_ich8lan },
5151 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IGP_C), board_ich8lan },
5152 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IGP_M), board_ich8lan },
5153 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IGP_M_AMT), board_ich8lan },
5155 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IFE), board_ich9lan },
5156 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IFE_G), board_ich9lan },
5157 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IFE_GT), board_ich9lan },
5158 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IGP_AMT), board_ich9lan },
5159 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IGP_C), board_ich9lan },
5160 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_BM), board_ich9lan },
5161 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IGP_M), board_ich9lan },
5162 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IGP_M_AMT), board_ich9lan },
5163 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IGP_M_V), board_ich9lan },
5165 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH10_R_BM_LM), board_ich9lan },
5166 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH10_R_BM_LF), board_ich9lan },
5167 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH10_R_BM_V), board_ich9lan },
5169 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH10_D_BM_LM), board_ich10lan },
5170 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH10_D_BM_LF), board_ich10lan },
5172 { } /* terminate list */
5174 MODULE_DEVICE_TABLE(pci, e1000_pci_tbl);
5176 /* PCI Device API Driver */
5177 static struct pci_driver e1000_driver = {
5178 .name = e1000e_driver_name,
5179 .id_table = e1000_pci_tbl,
5180 .probe = e1000_probe,
5181 .remove = __devexit_p(e1000_remove),
5183 /* Power Management Hooks */
5184 .suspend = e1000_suspend,
5185 .resume = e1000_resume,
5187 .shutdown = e1000_shutdown,
5188 .err_handler = &e1000_err_handler
5192 * e1000_init_module - Driver Registration Routine
5194 * e1000_init_module is the first routine called when the driver is
5195 * loaded. All it does is register with the PCI subsystem.
5197 static int __init e1000_init_module(void)
5200 printk(KERN_INFO "%s: Intel(R) PRO/1000 Network Driver - %s\n",
5201 e1000e_driver_name, e1000e_driver_version);
5202 printk(KERN_INFO "%s: Copyright (c) 1999-2008 Intel Corporation.\n",
5203 e1000e_driver_name);
5204 ret = pci_register_driver(&e1000_driver);
5205 pm_qos_add_requirement(PM_QOS_CPU_DMA_LATENCY, e1000e_driver_name,
5206 PM_QOS_DEFAULT_VALUE);
5210 module_init(e1000_init_module);
5213 * e1000_exit_module - Driver Exit Cleanup Routine
5215 * e1000_exit_module is called just before the driver is removed
5218 static void __exit e1000_exit_module(void)
5220 pci_unregister_driver(&e1000_driver);
5221 pm_qos_remove_requirement(PM_QOS_CPU_DMA_LATENCY, e1000e_driver_name);
5223 module_exit(e1000_exit_module);
5226 MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>");
5227 MODULE_DESCRIPTION("Intel(R) PRO/1000 Network Driver");
5228 MODULE_LICENSE("GPL");
5229 MODULE_VERSION(DRV_VERSION);