2 * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved.
3 * Copyright(c) 2006 Chris Snook <csnook@redhat.com>
4 * Copyright(c) 2006 Jay Cliburn <jcliburn@gmail.com>
6 * Derived from Intel e1000 driver
7 * Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the Free
11 * Software Foundation; either version 2 of the License, or (at your option)
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
19 * You should have received a copy of the GNU General Public License along with
20 * this program; if not, write to the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 * The full GNU General Public License is included in this distribution in the
24 * file called COPYING.
26 * Contact Information:
27 * Xiong Huang <xiong_huang@attansic.com>
28 * Attansic Technology Corp. 3F 147, Xianzheng 9th Road, Zhubei,
29 * Xinzhu 302, TAIWAN, REPUBLIC OF CHINA
31 * Chris Snook <csnook@redhat.com>
32 * Jay Cliburn <jcliburn@gmail.com>
34 * This version is adapted from the Attansic reference driver for
35 * inclusion in the Linux kernel. It is currently under heavy development.
36 * A very incomplete list of things that need to be dealt with:
39 * Fix TSO; tx performance is horrible with TSO enabled.
41 * Add more ethtool functions, including set ring parameters.
42 * Fix abstruse irq enable/disable condition described here:
43 * http://marc.theaimsgroup.com/?l=linux-netdev&m=116398508500553&w=2
49 * interrupt coalescing
53 #include <linux/types.h>
54 #include <linux/netdevice.h>
55 #include <linux/pci.h>
56 #include <linux/spinlock.h>
57 #include <linux/slab.h>
58 #include <linux/string.h>
59 #include <linux/skbuff.h>
60 #include <linux/etherdevice.h>
61 #include <linux/if_vlan.h>
62 #include <linux/irqreturn.h>
63 #include <linux/workqueue.h>
64 #include <linux/timer.h>
65 #include <linux/jiffies.h>
66 #include <linux/hardirq.h>
67 #include <linux/interrupt.h>
68 #include <linux/irqflags.h>
69 #include <linux/dma-mapping.h>
70 #include <linux/net.h>
74 #include <linux/tcp.h>
75 #include <linux/compiler.h>
76 #include <linux/delay.h>
77 #include <linux/mii.h>
78 #include <net/checksum.h>
80 #include <asm/atomic.h>
81 #include <asm/byteorder.h>
85 #define DRIVER_VERSION "2.0.7"
87 char atl1_driver_name
[] = "atl1";
88 static const char atl1_driver_string
[] = "Attansic L1 Ethernet Network Driver";
89 static const char atl1_copyright
[] = "Copyright(c) 2005-2006 Attansic Corporation.";
90 char atl1_driver_version
[] = DRIVER_VERSION
;
93 ("Attansic Corporation <xiong_huang@attansic.com>, Chris Snook <csnook@redhat.com>, Jay Cliburn <jcliburn@gmail.com>");
94 MODULE_DESCRIPTION("Attansic 1000M Ethernet Network Driver");
95 MODULE_LICENSE("GPL");
96 MODULE_VERSION(DRIVER_VERSION
);
99 * atl1_pci_tbl - PCI Device ID Table
101 static const struct pci_device_id atl1_pci_tbl
[] = {
102 {PCI_DEVICE(PCI_VENDOR_ID_ATTANSIC
, PCI_DEVICE_ID_ATTANSIC_L1
)},
103 /* required last entry */
107 MODULE_DEVICE_TABLE(pci
, atl1_pci_tbl
);
110 * atl1_sw_init - Initialize general software structures (struct atl1_adapter)
111 * @adapter: board private structure to initialize
113 * atl1_sw_init initializes the Adapter private data structure.
114 * Fields are initialized based on PCI device information and
115 * OS network device settings (MTU size).
117 static int __devinit
atl1_sw_init(struct atl1_adapter
*adapter
)
119 struct atl1_hw
*hw
= &adapter
->hw
;
120 struct net_device
*netdev
= adapter
->netdev
;
121 struct pci_dev
*pdev
= adapter
->pdev
;
123 /* PCI config space info */
124 pci_read_config_byte(pdev
, PCI_REVISION_ID
, &hw
->revision_id
);
126 hw
->max_frame_size
= netdev
->mtu
+ ENET_HEADER_SIZE
+ ETHERNET_FCS_SIZE
;
127 hw
->min_frame_size
= MINIMUM_ETHERNET_FRAME_SIZE
;
130 adapter
->rx_buffer_len
= (hw
->max_frame_size
+ 7) & ~7;
131 adapter
->ict
= 50000; /* 100ms */
132 adapter
->link_speed
= SPEED_0
; /* hardware init */
133 adapter
->link_duplex
= FULL_DUPLEX
;
135 hw
->phy_configured
= false;
136 hw
->preamble_len
= 7;
146 hw
->rfd_fetch_gap
= 1;
147 hw
->rx_jumbo_th
= adapter
->rx_buffer_len
/ 8;
148 hw
->rx_jumbo_lkah
= 1;
149 hw
->rrd_ret_timer
= 16;
151 hw
->tpd_fetch_th
= 16;
152 hw
->txf_burst
= 0x100;
153 hw
->tx_jumbo_task_th
= (hw
->max_frame_size
+ 7) >> 3;
154 hw
->tpd_fetch_gap
= 1;
155 hw
->rcb_value
= atl1_rcb_64
;
156 hw
->dma_ord
= atl1_dma_ord_enh
;
157 hw
->dmar_block
= atl1_dma_req_256
;
158 hw
->dmaw_block
= atl1_dma_req_256
;
161 hw
->cmb_rx_timer
= 1; /* about 2us */
162 hw
->cmb_tx_timer
= 1; /* about 2us */
163 hw
->smb_timer
= 100000; /* about 200ms */
165 atomic_set(&adapter
->irq_sem
, 0);
166 spin_lock_init(&adapter
->lock
);
167 spin_lock_init(&adapter
->mb_lock
);
173 * atl1_setup_mem_resources - allocate Tx / RX descriptor resources
174 * @adapter: board private structure
176 * Return 0 on success, negative on failure
178 s32
atl1_setup_ring_resources(struct atl1_adapter
*adapter
)
180 struct atl1_tpd_ring
*tpd_ring
= &adapter
->tpd_ring
;
181 struct atl1_rfd_ring
*rfd_ring
= &adapter
->rfd_ring
;
182 struct atl1_rrd_ring
*rrd_ring
= &adapter
->rrd_ring
;
183 struct atl1_ring_header
*ring_header
= &adapter
->ring_header
;
184 struct pci_dev
*pdev
= adapter
->pdev
;
188 size
= sizeof(struct atl1_buffer
) * (tpd_ring
->count
+ rfd_ring
->count
);
189 tpd_ring
->buffer_info
= kzalloc(size
, GFP_KERNEL
);
190 if (unlikely(!tpd_ring
->buffer_info
)) {
191 dev_err(&pdev
->dev
, "kzalloc failed , size = D%d\n", size
);
194 rfd_ring
->buffer_info
=
195 (struct atl1_buffer
*)(tpd_ring
->buffer_info
+ tpd_ring
->count
);
197 /* real ring DMA buffer */
198 ring_header
->size
= size
= sizeof(struct tx_packet_desc
) *
200 + sizeof(struct rx_free_desc
) * rfd_ring
->count
201 + sizeof(struct rx_return_desc
) * rrd_ring
->count
202 + sizeof(struct coals_msg_block
)
203 + sizeof(struct stats_msg_block
)
204 + 40; /* "40: for 8 bytes align" huh? -- CHS */
206 ring_header
->desc
= pci_alloc_consistent(pdev
, ring_header
->size
,
208 if (unlikely(!ring_header
->desc
)) {
209 dev_err(&pdev
->dev
, "pci_alloc_consistent failed\n");
213 memset(ring_header
->desc
, 0, ring_header
->size
);
216 tpd_ring
->dma
= ring_header
->dma
;
217 offset
= (tpd_ring
->dma
& 0x7) ? (8 - (ring_header
->dma
& 0x7)) : 0;
218 tpd_ring
->dma
+= offset
;
219 tpd_ring
->desc
= (u8
*) ring_header
->desc
+ offset
;
220 tpd_ring
->size
= sizeof(struct tx_packet_desc
) * tpd_ring
->count
;
221 atomic_set(&tpd_ring
->next_to_use
, 0);
222 atomic_set(&tpd_ring
->next_to_clean
, 0);
225 rfd_ring
->dma
= tpd_ring
->dma
+ tpd_ring
->size
;
226 offset
= (rfd_ring
->dma
& 0x7) ? (8 - (rfd_ring
->dma
& 0x7)) : 0;
227 rfd_ring
->dma
+= offset
;
228 rfd_ring
->desc
= (u8
*) tpd_ring
->desc
+ (tpd_ring
->size
+ offset
);
229 rfd_ring
->size
= sizeof(struct rx_free_desc
) * rfd_ring
->count
;
230 rfd_ring
->next_to_clean
= 0;
231 /* rfd_ring->next_to_use = rfd_ring->count - 1; */
232 atomic_set(&rfd_ring
->next_to_use
, 0);
235 rrd_ring
->dma
= rfd_ring
->dma
+ rfd_ring
->size
;
236 offset
= (rrd_ring
->dma
& 0x7) ? (8 - (rrd_ring
->dma
& 0x7)) : 0;
237 rrd_ring
->dma
+= offset
;
238 rrd_ring
->desc
= (u8
*) rfd_ring
->desc
+ (rfd_ring
->size
+ offset
);
239 rrd_ring
->size
= sizeof(struct rx_return_desc
) * rrd_ring
->count
;
240 rrd_ring
->next_to_use
= 0;
241 atomic_set(&rrd_ring
->next_to_clean
, 0);
244 adapter
->cmb
.dma
= rrd_ring
->dma
+ rrd_ring
->size
;
245 offset
= (adapter
->cmb
.dma
& 0x7) ? (8 - (adapter
->cmb
.dma
& 0x7)) : 0;
246 adapter
->cmb
.dma
+= offset
;
248 (struct coals_msg_block
*) ((u8
*) rrd_ring
->desc
+
249 (rrd_ring
->size
+ offset
));
252 adapter
->smb
.dma
= adapter
->cmb
.dma
+ sizeof(struct coals_msg_block
);
253 offset
= (adapter
->smb
.dma
& 0x7) ? (8 - (adapter
->smb
.dma
& 0x7)) : 0;
254 adapter
->smb
.dma
+= offset
;
255 adapter
->smb
.smb
= (struct stats_msg_block
*)
256 ((u8
*) adapter
->cmb
.cmb
+ (sizeof(struct coals_msg_block
) + offset
));
261 kfree(tpd_ring
->buffer_info
);
266 * atl1_irq_enable - Enable default interrupt generation settings
267 * @adapter: board private structure
269 static void atl1_irq_enable(struct atl1_adapter
*adapter
)
271 if (likely(!atomic_dec_and_test(&adapter
->irq_sem
)))
272 iowrite32(IMR_NORMAL_MASK
, adapter
->hw
.hw_addr
+ REG_IMR
);
275 static void atl1_clear_phy_int(struct atl1_adapter
*adapter
)
280 spin_lock_irqsave(&adapter
->lock
, flags
);
281 atl1_read_phy_reg(&adapter
->hw
, 19, &phy_data
);
282 spin_unlock_irqrestore(&adapter
->lock
, flags
);
285 static void atl1_inc_smb(struct atl1_adapter
*adapter
)
287 struct stats_msg_block
*smb
= adapter
->smb
.smb
;
289 /* Fill out the OS statistics structure */
290 adapter
->soft_stats
.rx_packets
+= smb
->rx_ok
;
291 adapter
->soft_stats
.tx_packets
+= smb
->tx_ok
;
292 adapter
->soft_stats
.rx_bytes
+= smb
->rx_byte_cnt
;
293 adapter
->soft_stats
.tx_bytes
+= smb
->tx_byte_cnt
;
294 adapter
->soft_stats
.multicast
+= smb
->rx_mcast
;
295 adapter
->soft_stats
.collisions
+= (smb
->tx_1_col
+
299 adapter
->hw
.max_retry
);
302 adapter
->soft_stats
.rx_errors
+= (smb
->rx_frag
+
307 smb
->rx_rrd_ov
+ smb
->rx_align_err
);
308 adapter
->soft_stats
.rx_fifo_errors
+= smb
->rx_rxf_ov
;
309 adapter
->soft_stats
.rx_length_errors
+= smb
->rx_len_err
;
310 adapter
->soft_stats
.rx_crc_errors
+= smb
->rx_fcs_err
;
311 adapter
->soft_stats
.rx_frame_errors
+= smb
->rx_align_err
;
312 adapter
->soft_stats
.rx_missed_errors
+= (smb
->rx_rrd_ov
+
315 adapter
->soft_stats
.rx_pause
+= smb
->rx_pause
;
316 adapter
->soft_stats
.rx_rrd_ov
+= smb
->rx_rrd_ov
;
317 adapter
->soft_stats
.rx_trunc
+= smb
->rx_sz_ov
;
320 adapter
->soft_stats
.tx_errors
+= (smb
->tx_late_col
+
322 smb
->tx_underrun
+ smb
->tx_trunc
);
323 adapter
->soft_stats
.tx_fifo_errors
+= smb
->tx_underrun
;
324 adapter
->soft_stats
.tx_aborted_errors
+= smb
->tx_abort_col
;
325 adapter
->soft_stats
.tx_window_errors
+= smb
->tx_late_col
;
327 adapter
->soft_stats
.excecol
+= smb
->tx_abort_col
;
328 adapter
->soft_stats
.deffer
+= smb
->tx_defer
;
329 adapter
->soft_stats
.scc
+= smb
->tx_1_col
;
330 adapter
->soft_stats
.mcc
+= smb
->tx_2_col
;
331 adapter
->soft_stats
.latecol
+= smb
->tx_late_col
;
332 adapter
->soft_stats
.tx_underun
+= smb
->tx_underrun
;
333 adapter
->soft_stats
.tx_trunc
+= smb
->tx_trunc
;
334 adapter
->soft_stats
.tx_pause
+= smb
->tx_pause
;
336 adapter
->net_stats
.rx_packets
= adapter
->soft_stats
.rx_packets
;
337 adapter
->net_stats
.tx_packets
= adapter
->soft_stats
.tx_packets
;
338 adapter
->net_stats
.rx_bytes
= adapter
->soft_stats
.rx_bytes
;
339 adapter
->net_stats
.tx_bytes
= adapter
->soft_stats
.tx_bytes
;
340 adapter
->net_stats
.multicast
= adapter
->soft_stats
.multicast
;
341 adapter
->net_stats
.collisions
= adapter
->soft_stats
.collisions
;
342 adapter
->net_stats
.rx_errors
= adapter
->soft_stats
.rx_errors
;
343 adapter
->net_stats
.rx_over_errors
=
344 adapter
->soft_stats
.rx_missed_errors
;
345 adapter
->net_stats
.rx_length_errors
=
346 adapter
->soft_stats
.rx_length_errors
;
347 adapter
->net_stats
.rx_crc_errors
= adapter
->soft_stats
.rx_crc_errors
;
348 adapter
->net_stats
.rx_frame_errors
=
349 adapter
->soft_stats
.rx_frame_errors
;
350 adapter
->net_stats
.rx_fifo_errors
= adapter
->soft_stats
.rx_fifo_errors
;
351 adapter
->net_stats
.rx_missed_errors
=
352 adapter
->soft_stats
.rx_missed_errors
;
353 adapter
->net_stats
.tx_errors
= adapter
->soft_stats
.tx_errors
;
354 adapter
->net_stats
.tx_fifo_errors
= adapter
->soft_stats
.tx_fifo_errors
;
355 adapter
->net_stats
.tx_aborted_errors
=
356 adapter
->soft_stats
.tx_aborted_errors
;
357 adapter
->net_stats
.tx_window_errors
=
358 adapter
->soft_stats
.tx_window_errors
;
359 adapter
->net_stats
.tx_carrier_errors
=
360 adapter
->soft_stats
.tx_carrier_errors
;
363 static void atl1_rx_checksum(struct atl1_adapter
*adapter
,
364 struct rx_return_desc
*rrd
,
367 skb
->ip_summed
= CHECKSUM_NONE
;
369 if (unlikely(rrd
->pkt_flg
& PACKET_FLAG_ERR
)) {
370 if (rrd
->err_flg
& (ERR_FLAG_CRC
| ERR_FLAG_TRUNC
|
371 ERR_FLAG_CODE
| ERR_FLAG_OV
)) {
372 adapter
->hw_csum_err
++;
373 dev_dbg(&adapter
->pdev
->dev
, "rx checksum error\n");
379 if (!(rrd
->pkt_flg
& PACKET_FLAG_IPV4
))
380 /* checksum is invalid, but it's not an IPv4 pkt, so ok */
384 if (likely(!(rrd
->err_flg
&
385 (ERR_FLAG_IP_CHKSUM
| ERR_FLAG_L4_CHKSUM
)))) {
386 skb
->ip_summed
= CHECKSUM_UNNECESSARY
;
387 adapter
->hw_csum_good
++;
391 /* IPv4, but hardware thinks its checksum is wrong */
392 dev_dbg(&adapter
->pdev
->dev
,
393 "hw csum wrong, pkt_flag:%x, err_flag:%x\n",
394 rrd
->pkt_flg
, rrd
->err_flg
);
395 skb
->ip_summed
= CHECKSUM_COMPLETE
;
396 skb
->csum
= htons(rrd
->xsz
.xsum_sz
.rx_chksum
);
397 adapter
->hw_csum_err
++;
402 * atl1_alloc_rx_buffers - Replace used receive buffers
403 * @adapter: address of board private structure
405 static u16
atl1_alloc_rx_buffers(struct atl1_adapter
*adapter
)
407 struct atl1_rfd_ring
*rfd_ring
= &adapter
->rfd_ring
;
408 struct pci_dev
*pdev
= adapter
->pdev
;
410 unsigned long offset
;
411 struct atl1_buffer
*buffer_info
, *next_info
;
414 u16 rfd_next_to_use
, next_next
;
415 struct rx_free_desc
*rfd_desc
;
417 next_next
= rfd_next_to_use
= atomic_read(&rfd_ring
->next_to_use
);
418 if (++next_next
== rfd_ring
->count
)
420 buffer_info
= &rfd_ring
->buffer_info
[rfd_next_to_use
];
421 next_info
= &rfd_ring
->buffer_info
[next_next
];
423 while (!buffer_info
->alloced
&& !next_info
->alloced
) {
424 if (buffer_info
->skb
) {
425 buffer_info
->alloced
= 1;
429 rfd_desc
= ATL1_RFD_DESC(rfd_ring
, rfd_next_to_use
);
431 skb
= dev_alloc_skb(adapter
->rx_buffer_len
+ NET_IP_ALIGN
);
432 if (unlikely(!skb
)) { /* Better luck next round */
433 adapter
->net_stats
.rx_dropped
++;
438 * Make buffer alignment 2 beyond a 16 byte boundary
439 * this will result in a 16 byte aligned IP header after
440 * the 14 byte MAC header is removed
442 skb_reserve(skb
, NET_IP_ALIGN
);
444 buffer_info
->alloced
= 1;
445 buffer_info
->skb
= skb
;
446 buffer_info
->length
= (u16
) adapter
->rx_buffer_len
;
447 page
= virt_to_page(skb
->data
);
448 offset
= (unsigned long)skb
->data
& ~PAGE_MASK
;
449 buffer_info
->dma
= pci_map_page(pdev
, page
, offset
,
450 adapter
->rx_buffer_len
,
452 rfd_desc
->buffer_addr
= cpu_to_le64(buffer_info
->dma
);
453 rfd_desc
->buf_len
= cpu_to_le16(adapter
->rx_buffer_len
);
454 rfd_desc
->coalese
= 0;
457 rfd_next_to_use
= next_next
;
458 if (unlikely(++next_next
== rfd_ring
->count
))
461 buffer_info
= &rfd_ring
->buffer_info
[rfd_next_to_use
];
462 next_info
= &rfd_ring
->buffer_info
[next_next
];
468 * Force memory writes to complete before letting h/w
469 * know there are new descriptors to fetch. (Only
470 * applicable for weak-ordered memory model archs,
474 atomic_set(&rfd_ring
->next_to_use
, (int)rfd_next_to_use
);
479 static void atl1_intr_rx(struct atl1_adapter
*adapter
)
483 u16 rrd_next_to_clean
;
485 struct atl1_rfd_ring
*rfd_ring
= &adapter
->rfd_ring
;
486 struct atl1_rrd_ring
*rrd_ring
= &adapter
->rrd_ring
;
487 struct atl1_buffer
*buffer_info
;
488 struct rx_return_desc
*rrd
;
493 rrd_next_to_clean
= atomic_read(&rrd_ring
->next_to_clean
);
496 rrd
= ATL1_RRD_DESC(rrd_ring
, rrd_next_to_clean
);
498 if (likely(rrd
->xsz
.valid
)) { /* packet valid */
500 /* check rrd status */
501 if (likely(rrd
->num_buf
== 1))
504 /* rrd seems to be bad */
505 if (unlikely(i
-- > 0)) {
506 /* rrd may not be DMAed completely */
507 dev_dbg(&adapter
->pdev
->dev
,
508 "incomplete RRD DMA transfer\n");
513 dev_dbg(&adapter
->pdev
->dev
, "bad RRD\n");
514 /* see if update RFD index */
515 if (rrd
->num_buf
> 1) {
518 (rrd
->xsz
.xsum_sz
.pkt_size
+
519 adapter
->rx_buffer_len
-
520 1) / adapter
->rx_buffer_len
;
521 if (rrd
->num_buf
== num_buf
) {
522 /* clean alloc flag for bad rrd */
523 while (rfd_ring
->next_to_clean
!=
524 (rrd
->buf_indx
+ num_buf
)) {
525 rfd_ring
->buffer_info
[rfd_ring
->
526 next_to_clean
].alloced
= 0;
527 if (++rfd_ring
->next_to_clean
==
538 if (++rrd_next_to_clean
== rrd_ring
->count
)
539 rrd_next_to_clean
= 0;
542 } else { /* current rrd still not be updated */
547 /* clean alloc flag for bad rrd */
548 while (rfd_ring
->next_to_clean
!= rrd
->buf_indx
) {
549 rfd_ring
->buffer_info
[rfd_ring
->next_to_clean
].alloced
=
551 if (++rfd_ring
->next_to_clean
== rfd_ring
->count
)
552 rfd_ring
->next_to_clean
= 0;
555 buffer_info
= &rfd_ring
->buffer_info
[rrd
->buf_indx
];
556 if (++rfd_ring
->next_to_clean
== rfd_ring
->count
)
557 rfd_ring
->next_to_clean
= 0;
559 /* update rrd next to clean */
560 if (++rrd_next_to_clean
== rrd_ring
->count
)
561 rrd_next_to_clean
= 0;
564 if (unlikely(rrd
->pkt_flg
& PACKET_FLAG_ERR
)) {
566 (ERR_FLAG_IP_CHKSUM
| ERR_FLAG_L4_CHKSUM
568 /* packet error, don't need upstream */
569 buffer_info
->alloced
= 0;
576 pci_unmap_page(adapter
->pdev
, buffer_info
->dma
,
577 buffer_info
->length
, PCI_DMA_FROMDEVICE
);
578 skb
= buffer_info
->skb
;
579 length
= le16_to_cpu(rrd
->xsz
.xsum_sz
.pkt_size
);
581 skb_put(skb
, length
- ETHERNET_FCS_SIZE
);
583 /* Receive Checksum Offload */
584 atl1_rx_checksum(adapter
, rrd
, skb
);
585 skb
->protocol
= eth_type_trans(skb
, adapter
->netdev
);
587 if (adapter
->vlgrp
&& (rrd
->pkt_flg
& PACKET_FLAG_VLAN_INS
)) {
588 u16 vlan_tag
= (rrd
->vlan_tag
>> 4) |
589 ((rrd
->vlan_tag
& 7) << 13) |
590 ((rrd
->vlan_tag
& 8) << 9);
591 vlan_hwaccel_rx(skb
, adapter
->vlgrp
, vlan_tag
);
595 /* let protocol layer free skb */
596 buffer_info
->skb
= NULL
;
597 buffer_info
->alloced
= 0;
600 adapter
->netdev
->last_rx
= jiffies
;
603 atomic_set(&rrd_ring
->next_to_clean
, rrd_next_to_clean
);
605 atl1_alloc_rx_buffers(adapter
);
607 /* update mailbox ? */
611 u32 rrd_next_to_clean
;
613 spin_lock(&adapter
->mb_lock
);
615 tpd_next_to_use
= atomic_read(&adapter
->tpd_ring
.next_to_use
);
617 atomic_read(&adapter
->rfd_ring
.next_to_use
);
619 atomic_read(&adapter
->rrd_ring
.next_to_clean
);
620 value
= ((rfd_next_to_use
& MB_RFD_PROD_INDX_MASK
) <<
621 MB_RFD_PROD_INDX_SHIFT
) |
622 ((rrd_next_to_clean
& MB_RRD_CONS_INDX_MASK
) <<
623 MB_RRD_CONS_INDX_SHIFT
) |
624 ((tpd_next_to_use
& MB_TPD_PROD_INDX_MASK
) <<
625 MB_TPD_PROD_INDX_SHIFT
);
626 iowrite32(value
, adapter
->hw
.hw_addr
+ REG_MAILBOX
);
627 spin_unlock(&adapter
->mb_lock
);
631 static void atl1_intr_tx(struct atl1_adapter
*adapter
)
633 struct atl1_tpd_ring
*tpd_ring
= &adapter
->tpd_ring
;
634 struct atl1_buffer
*buffer_info
;
635 u16 sw_tpd_next_to_clean
;
636 u16 cmb_tpd_next_to_clean
;
639 sw_tpd_next_to_clean
= atomic_read(&tpd_ring
->next_to_clean
);
640 cmb_tpd_next_to_clean
= le16_to_cpu(adapter
->cmb
.cmb
->tpd_cons_idx
);
642 while (cmb_tpd_next_to_clean
!= sw_tpd_next_to_clean
) {
643 struct tx_packet_desc
*tpd
;
645 tpd
= ATL1_TPD_DESC(tpd_ring
, sw_tpd_next_to_clean
);
646 buffer_info
= &tpd_ring
->buffer_info
[sw_tpd_next_to_clean
];
647 if (buffer_info
->dma
) {
648 pci_unmap_page(adapter
->pdev
, buffer_info
->dma
,
649 buffer_info
->length
, PCI_DMA_TODEVICE
);
650 buffer_info
->dma
= 0;
653 if (buffer_info
->skb
) {
654 dev_kfree_skb_irq(buffer_info
->skb
);
655 buffer_info
->skb
= NULL
;
657 tpd
->buffer_addr
= 0;
660 if (++sw_tpd_next_to_clean
== tpd_ring
->count
)
661 sw_tpd_next_to_clean
= 0;
663 atomic_set(&tpd_ring
->next_to_clean
, sw_tpd_next_to_clean
);
665 if (netif_queue_stopped(adapter
->netdev
)
666 && netif_carrier_ok(adapter
->netdev
))
667 netif_wake_queue(adapter
->netdev
);
670 static void atl1_check_for_link(struct atl1_adapter
*adapter
)
672 struct net_device
*netdev
= adapter
->netdev
;
675 spin_lock(&adapter
->lock
);
676 adapter
->phy_timer_pending
= false;
677 atl1_read_phy_reg(&adapter
->hw
, MII_BMSR
, &phy_data
);
678 atl1_read_phy_reg(&adapter
->hw
, MII_BMSR
, &phy_data
);
679 spin_unlock(&adapter
->lock
);
681 /* notify upper layer link down ASAP */
682 if (!(phy_data
& BMSR_LSTATUS
)) { /* Link Down */
683 if (netif_carrier_ok(netdev
)) { /* old link state: Up */
684 dev_info(&adapter
->pdev
->dev
, "%s link is down\n",
686 adapter
->link_speed
= SPEED_0
;
687 netif_carrier_off(netdev
);
688 netif_stop_queue(netdev
);
691 schedule_work(&adapter
->link_chg_task
);
695 * atl1_intr - Interrupt Handler
696 * @irq: interrupt number
697 * @data: pointer to a network interface device structure
698 * @pt_regs: CPU registers structure
700 static irqreturn_t
atl1_intr(int irq
, void *data
)
702 /*struct atl1_adapter *adapter = ((struct net_device *)data)->priv;*/
703 struct atl1_adapter
*adapter
= netdev_priv(data
);
708 status
= adapter
->cmb
.cmb
->int_stats
;
715 /* clear CMB interrupt status at once */
716 adapter
->cmb
.cmb
->int_stats
= 0;
718 if (status
& ISR_GPHY
) /* clear phy status */
719 atl1_clear_phy_int(adapter
);
721 /* clear ISR status, and Enable CMB DMA/Disable Interrupt */
722 iowrite32(status
| ISR_DIS_INT
, adapter
->hw
.hw_addr
+ REG_ISR
);
724 /* check if SMB intr */
725 if (status
& ISR_SMB
)
726 atl1_inc_smb(adapter
);
728 /* check if PCIE PHY Link down */
729 if (status
& ISR_PHY_LINKDOWN
) {
730 dev_dbg(&adapter
->pdev
->dev
, "pcie phy link down %x\n",
732 if (netif_running(adapter
->netdev
)) { /* reset MAC */
733 iowrite32(0, adapter
->hw
.hw_addr
+ REG_IMR
);
734 schedule_work(&adapter
->pcie_dma_to_rst_task
);
739 /* check if DMA read/write error ? */
740 if (status
& (ISR_DMAR_TO_RST
| ISR_DMAW_TO_RST
)) {
741 dev_dbg(&adapter
->pdev
->dev
,
742 "pcie DMA r/w error (status = 0x%x)\n",
744 iowrite32(0, adapter
->hw
.hw_addr
+ REG_IMR
);
745 schedule_work(&adapter
->pcie_dma_to_rst_task
);
750 if (status
& ISR_GPHY
) {
751 adapter
->soft_stats
.tx_carrier_errors
++;
752 atl1_check_for_link(adapter
);
756 if (status
& ISR_CMB_TX
)
757 atl1_intr_tx(adapter
);
760 if (unlikely(status
& (ISR_RXF_OV
| ISR_RFD_UNRUN
|
761 ISR_RRD_OV
| ISR_HOST_RFD_UNRUN
|
762 ISR_HOST_RRD_OV
| ISR_CMB_RX
))) {
763 if (status
& (ISR_RXF_OV
| ISR_RFD_UNRUN
|
764 ISR_RRD_OV
| ISR_HOST_RFD_UNRUN
|
766 dev_dbg(&adapter
->pdev
->dev
,
767 "rx exception, ISR = 0x%x\n", status
);
768 atl1_intr_rx(adapter
);
774 } while ((status
= adapter
->cmb
.cmb
->int_stats
));
776 /* re-enable Interrupt */
777 iowrite32(ISR_DIS_SMB
| ISR_DIS_DMA
, adapter
->hw
.hw_addr
+ REG_ISR
);
782 * atl1_set_multi - Multicast and Promiscuous mode set
783 * @netdev: network interface device structure
785 * The set_multi entry point is called whenever the multicast address
786 * list or the network interface flags are updated. This routine is
787 * responsible for configuring the hardware for proper multicast,
788 * promiscuous mode, and all-multi behavior.
790 static void atl1_set_multi(struct net_device
*netdev
)
792 struct atl1_adapter
*adapter
= netdev_priv(netdev
);
793 struct atl1_hw
*hw
= &adapter
->hw
;
794 struct dev_mc_list
*mc_ptr
;
798 /* Check for Promiscuous and All Multicast modes */
799 rctl
= ioread32(hw
->hw_addr
+ REG_MAC_CTRL
);
800 if (netdev
->flags
& IFF_PROMISC
)
801 rctl
|= MAC_CTRL_PROMIS_EN
;
802 else if (netdev
->flags
& IFF_ALLMULTI
) {
803 rctl
|= MAC_CTRL_MC_ALL_EN
;
804 rctl
&= ~MAC_CTRL_PROMIS_EN
;
806 rctl
&= ~(MAC_CTRL_PROMIS_EN
| MAC_CTRL_MC_ALL_EN
);
808 iowrite32(rctl
, hw
->hw_addr
+ REG_MAC_CTRL
);
810 /* clear the old settings from the multicast hash table */
811 iowrite32(0, hw
->hw_addr
+ REG_RX_HASH_TABLE
);
812 iowrite32(0, (hw
->hw_addr
+ REG_RX_HASH_TABLE
) + (1 << 2));
814 /* compute mc addresses' hash value ,and put it into hash table */
815 for (mc_ptr
= netdev
->mc_list
; mc_ptr
; mc_ptr
= mc_ptr
->next
) {
816 hash_value
= atl1_hash_mc_addr(hw
, mc_ptr
->dmi_addr
);
817 atl1_hash_set(hw
, hash_value
);
821 static void atl1_setup_mac_ctrl(struct atl1_adapter
*adapter
)
824 struct atl1_hw
*hw
= &adapter
->hw
;
825 struct net_device
*netdev
= adapter
->netdev
;
826 /* Config MAC CTRL Register */
827 value
= MAC_CTRL_TX_EN
| MAC_CTRL_RX_EN
;
829 if (FULL_DUPLEX
== adapter
->link_duplex
)
830 value
|= MAC_CTRL_DUPLX
;
832 value
|= ((u32
) ((SPEED_1000
== adapter
->link_speed
) ?
833 MAC_CTRL_SPEED_1000
: MAC_CTRL_SPEED_10_100
) <<
834 MAC_CTRL_SPEED_SHIFT
);
836 value
|= (MAC_CTRL_TX_FLOW
| MAC_CTRL_RX_FLOW
);
838 value
|= (MAC_CTRL_ADD_CRC
| MAC_CTRL_PAD
);
839 /* preamble length */
840 value
|= (((u32
) adapter
->hw
.preamble_len
841 & MAC_CTRL_PRMLEN_MASK
) << MAC_CTRL_PRMLEN_SHIFT
);
844 value
|= MAC_CTRL_RMV_VLAN
;
846 if (adapter->rx_csum)
847 value |= MAC_CTRL_RX_CHKSUM_EN;
850 value
|= MAC_CTRL_BC_EN
;
851 if (netdev
->flags
& IFF_PROMISC
)
852 value
|= MAC_CTRL_PROMIS_EN
;
853 else if (netdev
->flags
& IFF_ALLMULTI
)
854 value
|= MAC_CTRL_MC_ALL_EN
;
855 /* value |= MAC_CTRL_LOOPBACK; */
856 iowrite32(value
, hw
->hw_addr
+ REG_MAC_CTRL
);
859 static u32
atl1_check_link(struct atl1_adapter
*adapter
)
861 struct atl1_hw
*hw
= &adapter
->hw
;
862 struct net_device
*netdev
= adapter
->netdev
;
864 u16 speed
, duplex
, phy_data
;
867 /* MII_BMSR must read twice */
868 atl1_read_phy_reg(hw
, MII_BMSR
, &phy_data
);
869 atl1_read_phy_reg(hw
, MII_BMSR
, &phy_data
);
870 if (!(phy_data
& BMSR_LSTATUS
)) { /* link down */
871 if (netif_carrier_ok(netdev
)) { /* old link state: Up */
872 dev_info(&adapter
->pdev
->dev
, "link is down\n");
873 adapter
->link_speed
= SPEED_0
;
874 netif_carrier_off(netdev
);
875 netif_stop_queue(netdev
);
881 ret_val
= atl1_get_speed_and_duplex(hw
, &speed
, &duplex
);
885 switch (hw
->media_type
) {
886 case MEDIA_TYPE_1000M_FULL
:
887 if (speed
!= SPEED_1000
|| duplex
!= FULL_DUPLEX
)
890 case MEDIA_TYPE_100M_FULL
:
891 if (speed
!= SPEED_100
|| duplex
!= FULL_DUPLEX
)
894 case MEDIA_TYPE_100M_HALF
:
895 if (speed
!= SPEED_100
|| duplex
!= HALF_DUPLEX
)
898 case MEDIA_TYPE_10M_FULL
:
899 if (speed
!= SPEED_10
|| duplex
!= FULL_DUPLEX
)
902 case MEDIA_TYPE_10M_HALF
:
903 if (speed
!= SPEED_10
|| duplex
!= HALF_DUPLEX
)
908 /* link result is our setting */
910 if (adapter
->link_speed
!= speed
911 || adapter
->link_duplex
!= duplex
) {
912 adapter
->link_speed
= speed
;
913 adapter
->link_duplex
= duplex
;
914 atl1_setup_mac_ctrl(adapter
);
915 dev_info(&adapter
->pdev
->dev
,
916 "%s link is up %d Mbps %s\n",
917 netdev
->name
, adapter
->link_speed
,
918 adapter
->link_duplex
== FULL_DUPLEX
?
919 "full duplex" : "half duplex");
921 if (!netif_carrier_ok(netdev
)) { /* Link down -> Up */
922 netif_carrier_on(netdev
);
923 netif_wake_queue(netdev
);
928 /* change orignal link status */
929 if (netif_carrier_ok(netdev
)) {
930 adapter
->link_speed
= SPEED_0
;
931 netif_carrier_off(netdev
);
932 netif_stop_queue(netdev
);
935 if (hw
->media_type
!= MEDIA_TYPE_AUTO_SENSOR
&&
936 hw
->media_type
!= MEDIA_TYPE_1000M_FULL
) {
937 switch (hw
->media_type
) {
938 case MEDIA_TYPE_100M_FULL
:
939 phy_data
= MII_CR_FULL_DUPLEX
| MII_CR_SPEED_100
|
942 case MEDIA_TYPE_100M_HALF
:
943 phy_data
= MII_CR_SPEED_100
| MII_CR_RESET
;
945 case MEDIA_TYPE_10M_FULL
:
947 MII_CR_FULL_DUPLEX
| MII_CR_SPEED_10
| MII_CR_RESET
;
949 default: /* MEDIA_TYPE_10M_HALF: */
950 phy_data
= MII_CR_SPEED_10
| MII_CR_RESET
;
953 atl1_write_phy_reg(hw
, MII_BMCR
, phy_data
);
957 /* auto-neg, insert timer to re-config phy */
958 if (!adapter
->phy_timer_pending
) {
959 adapter
->phy_timer_pending
= true;
960 mod_timer(&adapter
->phy_config_timer
, jiffies
+ 3 * HZ
);
966 static void set_flow_ctrl_old(struct atl1_adapter
*adapter
)
970 /* RFD Flow Control */
971 value
= adapter
->rfd_ring
.count
;
977 value
= ((hi
& RXQ_RXF_PAUSE_TH_HI_MASK
) << RXQ_RXF_PAUSE_TH_HI_SHIFT
) |
978 ((lo
& RXQ_RXF_PAUSE_TH_LO_MASK
) << RXQ_RXF_PAUSE_TH_LO_SHIFT
);
979 iowrite32(value
, adapter
->hw
.hw_addr
+ REG_RXQ_RXF_PAUSE_THRESH
);
981 /* RRD Flow Control */
982 value
= adapter
->rrd_ring
.count
;
987 value
= ((hi
& RXQ_RRD_PAUSE_TH_HI_MASK
) << RXQ_RRD_PAUSE_TH_HI_SHIFT
) |
988 ((lo
& RXQ_RRD_PAUSE_TH_LO_MASK
) << RXQ_RRD_PAUSE_TH_LO_SHIFT
);
989 iowrite32(value
, adapter
->hw
.hw_addr
+ REG_RXQ_RRD_PAUSE_THRESH
);
992 static void set_flow_ctrl_new(struct atl1_hw
*hw
)
996 /* RXF Flow Control */
997 value
= ioread32(hw
->hw_addr
+ REG_SRAM_RXF_LEN
);
1004 value
= ((hi
& RXQ_RXF_PAUSE_TH_HI_MASK
) << RXQ_RXF_PAUSE_TH_HI_SHIFT
) |
1005 ((lo
& RXQ_RXF_PAUSE_TH_LO_MASK
) << RXQ_RXF_PAUSE_TH_LO_SHIFT
);
1006 iowrite32(value
, hw
->hw_addr
+ REG_RXQ_RXF_PAUSE_THRESH
);
1008 /* RRD Flow Control */
1009 value
= ioread32(hw
->hw_addr
+ REG_SRAM_RRD_LEN
);
1016 value
= ((hi
& RXQ_RRD_PAUSE_TH_HI_MASK
) << RXQ_RRD_PAUSE_TH_HI_SHIFT
) |
1017 ((lo
& RXQ_RRD_PAUSE_TH_LO_MASK
) << RXQ_RRD_PAUSE_TH_LO_SHIFT
);
1018 iowrite32(value
, hw
->hw_addr
+ REG_RXQ_RRD_PAUSE_THRESH
);
1022 * atl1_configure - Configure Transmit&Receive Unit after Reset
1023 * @adapter: board private structure
1025 * Configure the Tx /Rx unit of the MAC after a reset.
1027 static u32
atl1_configure(struct atl1_adapter
*adapter
)
1029 struct atl1_hw
*hw
= &adapter
->hw
;
1032 /* clear interrupt status */
1033 iowrite32(0xffffffff, adapter
->hw
.hw_addr
+ REG_ISR
);
1035 /* set MAC Address */
1036 value
= (((u32
) hw
->mac_addr
[2]) << 24) |
1037 (((u32
) hw
->mac_addr
[3]) << 16) |
1038 (((u32
) hw
->mac_addr
[4]) << 8) |
1039 (((u32
) hw
->mac_addr
[5]));
1040 iowrite32(value
, hw
->hw_addr
+ REG_MAC_STA_ADDR
);
1041 value
= (((u32
) hw
->mac_addr
[0]) << 8) | (((u32
) hw
->mac_addr
[1]));
1042 iowrite32(value
, hw
->hw_addr
+ (REG_MAC_STA_ADDR
+ 4));
1046 /* HI base address */
1047 iowrite32((u32
) ((adapter
->tpd_ring
.dma
& 0xffffffff00000000ULL
) >> 32),
1048 hw
->hw_addr
+ REG_DESC_BASE_ADDR_HI
);
1049 /* LO base address */
1050 iowrite32((u32
) (adapter
->rfd_ring
.dma
& 0x00000000ffffffffULL
),
1051 hw
->hw_addr
+ REG_DESC_RFD_ADDR_LO
);
1052 iowrite32((u32
) (adapter
->rrd_ring
.dma
& 0x00000000ffffffffULL
),
1053 hw
->hw_addr
+ REG_DESC_RRD_ADDR_LO
);
1054 iowrite32((u32
) (adapter
->tpd_ring
.dma
& 0x00000000ffffffffULL
),
1055 hw
->hw_addr
+ REG_DESC_TPD_ADDR_LO
);
1056 iowrite32((u32
) (adapter
->cmb
.dma
& 0x00000000ffffffffULL
),
1057 hw
->hw_addr
+ REG_DESC_CMB_ADDR_LO
);
1058 iowrite32((u32
) (adapter
->smb
.dma
& 0x00000000ffffffffULL
),
1059 hw
->hw_addr
+ REG_DESC_SMB_ADDR_LO
);
1062 value
= adapter
->rrd_ring
.count
;
1064 value
+= adapter
->rfd_ring
.count
;
1065 iowrite32(value
, hw
->hw_addr
+ REG_DESC_RFD_RRD_RING_SIZE
);
1066 iowrite32(adapter
->tpd_ring
.count
, hw
->hw_addr
+ REG_DESC_TPD_RING_SIZE
);
1069 iowrite32(1, hw
->hw_addr
+ REG_LOAD_PTR
);
1071 /* config Mailbox */
1072 value
= ((atomic_read(&adapter
->tpd_ring
.next_to_use
)
1073 & MB_TPD_PROD_INDX_MASK
) << MB_TPD_PROD_INDX_SHIFT
) |
1074 ((atomic_read(&adapter
->rrd_ring
.next_to_clean
)
1075 & MB_RRD_CONS_INDX_MASK
) << MB_RRD_CONS_INDX_SHIFT
) |
1076 ((atomic_read(&adapter
->rfd_ring
.next_to_use
)
1077 & MB_RFD_PROD_INDX_MASK
) << MB_RFD_PROD_INDX_SHIFT
);
1078 iowrite32(value
, hw
->hw_addr
+ REG_MAILBOX
);
1080 /* config IPG/IFG */
1081 value
= (((u32
) hw
->ipgt
& MAC_IPG_IFG_IPGT_MASK
)
1082 << MAC_IPG_IFG_IPGT_SHIFT
) |
1083 (((u32
) hw
->min_ifg
& MAC_IPG_IFG_MIFG_MASK
)
1084 << MAC_IPG_IFG_MIFG_SHIFT
) |
1085 (((u32
) hw
->ipgr1
& MAC_IPG_IFG_IPGR1_MASK
)
1086 << MAC_IPG_IFG_IPGR1_SHIFT
) |
1087 (((u32
) hw
->ipgr2
& MAC_IPG_IFG_IPGR2_MASK
)
1088 << MAC_IPG_IFG_IPGR2_SHIFT
);
1089 iowrite32(value
, hw
->hw_addr
+ REG_MAC_IPG_IFG
);
1091 /* config Half-Duplex Control */
1092 value
= ((u32
) hw
->lcol
& MAC_HALF_DUPLX_CTRL_LCOL_MASK
) |
1093 (((u32
) hw
->max_retry
& MAC_HALF_DUPLX_CTRL_RETRY_MASK
)
1094 << MAC_HALF_DUPLX_CTRL_RETRY_SHIFT
) |
1095 MAC_HALF_DUPLX_CTRL_EXC_DEF_EN
|
1096 (0xa << MAC_HALF_DUPLX_CTRL_ABEBT_SHIFT
) |
1097 (((u32
) hw
->jam_ipg
& MAC_HALF_DUPLX_CTRL_JAMIPG_MASK
)
1098 << MAC_HALF_DUPLX_CTRL_JAMIPG_SHIFT
);
1099 iowrite32(value
, hw
->hw_addr
+ REG_MAC_HALF_DUPLX_CTRL
);
1101 /* set Interrupt Moderator Timer */
1102 iowrite16(adapter
->imt
, hw
->hw_addr
+ REG_IRQ_MODU_TIMER_INIT
);
1103 iowrite32(MASTER_CTRL_ITIMER_EN
, hw
->hw_addr
+ REG_MASTER_CTRL
);
1105 /* set Interrupt Clear Timer */
1106 iowrite16(adapter
->ict
, hw
->hw_addr
+ REG_CMBDISDMA_TIMER
);
1108 /* set MTU, 4 : VLAN */
1109 iowrite32(hw
->max_frame_size
+ 4, hw
->hw_addr
+ REG_MTU
);
1111 /* jumbo size & rrd retirement timer */
1112 value
= (((u32
) hw
->rx_jumbo_th
& RXQ_JMBOSZ_TH_MASK
)
1113 << RXQ_JMBOSZ_TH_SHIFT
) |
1114 (((u32
) hw
->rx_jumbo_lkah
& RXQ_JMBO_LKAH_MASK
)
1115 << RXQ_JMBO_LKAH_SHIFT
) |
1116 (((u32
) hw
->rrd_ret_timer
& RXQ_RRD_TIMER_MASK
)
1117 << RXQ_RRD_TIMER_SHIFT
);
1118 iowrite32(value
, hw
->hw_addr
+ REG_RXQ_JMBOSZ_RRDTIM
);
1121 switch (hw
->dev_rev
) {
1126 set_flow_ctrl_old(adapter
);
1129 set_flow_ctrl_new(hw
);
1134 value
= (((u32
) hw
->tpd_burst
& TXQ_CTRL_TPD_BURST_NUM_MASK
)
1135 << TXQ_CTRL_TPD_BURST_NUM_SHIFT
) |
1136 (((u32
) hw
->txf_burst
& TXQ_CTRL_TXF_BURST_NUM_MASK
)
1137 << TXQ_CTRL_TXF_BURST_NUM_SHIFT
) |
1138 (((u32
) hw
->tpd_fetch_th
& TXQ_CTRL_TPD_FETCH_TH_MASK
)
1139 << TXQ_CTRL_TPD_FETCH_TH_SHIFT
) | TXQ_CTRL_ENH_MODE
| TXQ_CTRL_EN
;
1140 iowrite32(value
, hw
->hw_addr
+ REG_TXQ_CTRL
);
1142 /* min tpd fetch gap & tx jumbo packet size threshold for taskoffload */
1143 value
= (((u32
) hw
->tx_jumbo_task_th
& TX_JUMBO_TASK_TH_MASK
)
1144 << TX_JUMBO_TASK_TH_SHIFT
) |
1145 (((u32
) hw
->tpd_fetch_gap
& TX_TPD_MIN_IPG_MASK
)
1146 << TX_TPD_MIN_IPG_SHIFT
);
1147 iowrite32(value
, hw
->hw_addr
+ REG_TX_JUMBO_TASK_TH_TPD_IPG
);
1150 value
= (((u32
) hw
->rfd_burst
& RXQ_CTRL_RFD_BURST_NUM_MASK
)
1151 << RXQ_CTRL_RFD_BURST_NUM_SHIFT
) |
1152 (((u32
) hw
->rrd_burst
& RXQ_CTRL_RRD_BURST_THRESH_MASK
)
1153 << RXQ_CTRL_RRD_BURST_THRESH_SHIFT
) |
1154 (((u32
) hw
->rfd_fetch_gap
& RXQ_CTRL_RFD_PREF_MIN_IPG_MASK
)
1155 << RXQ_CTRL_RFD_PREF_MIN_IPG_SHIFT
) |
1156 RXQ_CTRL_CUT_THRU_EN
| RXQ_CTRL_EN
;
1157 iowrite32(value
, hw
->hw_addr
+ REG_RXQ_CTRL
);
1159 /* config DMA Engine */
1160 value
= ((((u32
) hw
->dmar_block
) & DMA_CTRL_DMAR_BURST_LEN_MASK
)
1161 << DMA_CTRL_DMAR_BURST_LEN_SHIFT
) |
1162 ((((u32
) hw
->dmaw_block
) & DMA_CTRL_DMAR_BURST_LEN_MASK
)
1163 << DMA_CTRL_DMAR_BURST_LEN_SHIFT
) |
1164 DMA_CTRL_DMAR_EN
| DMA_CTRL_DMAW_EN
;
1165 value
|= (u32
) hw
->dma_ord
;
1166 if (atl1_rcb_128
== hw
->rcb_value
)
1167 value
|= DMA_CTRL_RCB_VALUE
;
1168 iowrite32(value
, hw
->hw_addr
+ REG_DMA_CTRL
);
1170 /* config CMB / SMB */
1171 value
= hw
->cmb_rrd
| ((u32
) hw
->cmb_tpd
<< 16);
1172 iowrite32(value
, hw
->hw_addr
+ REG_CMB_WRITE_TH
);
1173 value
= hw
->cmb_rx_timer
| ((u32
) hw
->cmb_tx_timer
<< 16);
1174 iowrite32(value
, hw
->hw_addr
+ REG_CMB_WRITE_TIMER
);
1175 iowrite32(hw
->smb_timer
, hw
->hw_addr
+ REG_SMB_TIMER
);
1177 /* --- enable CMB / SMB */
1178 value
= CSMB_CTRL_CMB_EN
| CSMB_CTRL_SMB_EN
;
1179 iowrite32(value
, hw
->hw_addr
+ REG_CSMB_CTRL
);
1181 value
= ioread32(adapter
->hw
.hw_addr
+ REG_ISR
);
1182 if (unlikely((value
& ISR_PHY_LINKDOWN
) != 0))
1183 value
= 1; /* config failed */
1187 /* clear all interrupt status */
1188 iowrite32(0x3fffffff, adapter
->hw
.hw_addr
+ REG_ISR
);
1189 iowrite32(0, adapter
->hw
.hw_addr
+ REG_ISR
);
1194 * atl1_irq_disable - Mask off interrupt generation on the NIC
1195 * @adapter: board private structure
1197 static void atl1_irq_disable(struct atl1_adapter
*adapter
)
1199 atomic_inc(&adapter
->irq_sem
);
1200 iowrite32(0, adapter
->hw
.hw_addr
+ REG_IMR
);
1201 ioread32(adapter
->hw
.hw_addr
+ REG_IMR
);
1202 synchronize_irq(adapter
->pdev
->irq
);
1205 static void atl1_vlan_rx_register(struct net_device
*netdev
,
1206 struct vlan_group
*grp
)
1208 struct atl1_adapter
*adapter
= netdev_priv(netdev
);
1209 unsigned long flags
;
1212 spin_lock_irqsave(&adapter
->lock
, flags
);
1213 /* atl1_irq_disable(adapter); */
1214 adapter
->vlgrp
= grp
;
1217 /* enable VLAN tag insert/strip */
1218 ctrl
= ioread32(adapter
->hw
.hw_addr
+ REG_MAC_CTRL
);
1219 ctrl
|= MAC_CTRL_RMV_VLAN
;
1220 iowrite32(ctrl
, adapter
->hw
.hw_addr
+ REG_MAC_CTRL
);
1222 /* disable VLAN tag insert/strip */
1223 ctrl
= ioread32(adapter
->hw
.hw_addr
+ REG_MAC_CTRL
);
1224 ctrl
&= ~MAC_CTRL_RMV_VLAN
;
1225 iowrite32(ctrl
, adapter
->hw
.hw_addr
+ REG_MAC_CTRL
);
1228 /* atl1_irq_enable(adapter); */
1229 spin_unlock_irqrestore(&adapter
->lock
, flags
);
1232 /* FIXME: justify or remove -- CHS */
1233 static void atl1_vlan_rx_add_vid(struct net_device
*netdev
, u16 vid
)
1235 /* We don't do Vlan filtering */
1239 /* FIXME: this looks wrong too -- CHS */
1240 static void atl1_vlan_rx_kill_vid(struct net_device
*netdev
, u16 vid
)
1242 struct atl1_adapter
*adapter
= netdev_priv(netdev
);
1243 unsigned long flags
;
1245 spin_lock_irqsave(&adapter
->lock
, flags
);
1246 /* atl1_irq_disable(adapter); */
1247 vlan_group_set_device(adapter
->vlgrp
, vid
, NULL
);
1248 /* atl1_irq_enable(adapter); */
1249 spin_unlock_irqrestore(&adapter
->lock
, flags
);
1250 /* We don't do Vlan filtering */
1254 static void atl1_restore_vlan(struct atl1_adapter
*adapter
)
1256 atl1_vlan_rx_register(adapter
->netdev
, adapter
->vlgrp
);
1257 if (adapter
->vlgrp
) {
1259 for (vid
= 0; vid
< VLAN_GROUP_ARRAY_LEN
; vid
++) {
1260 if (!vlan_group_get_device(adapter
->vlgrp
, vid
))
1262 atl1_vlan_rx_add_vid(adapter
->netdev
, vid
);
1267 static u16
tpd_avail(struct atl1_tpd_ring
*tpd_ring
)
1269 u16 next_to_clean
= atomic_read(&tpd_ring
->next_to_clean
);
1270 u16 next_to_use
= atomic_read(&tpd_ring
->next_to_use
);
1271 return ((next_to_clean
>
1272 next_to_use
) ? next_to_clean
- next_to_use
-
1273 1 : tpd_ring
->count
+ next_to_clean
- next_to_use
- 1);
1276 static int atl1_tso(struct atl1_adapter
*adapter
, struct sk_buff
*skb
,
1277 struct tso_param
*tso
)
1279 /* We enter this function holding a spinlock. */
1283 if (skb_shinfo(skb
)->gso_size
) {
1284 if (skb_header_cloned(skb
)) {
1285 err
= pskb_expand_head(skb
, 0, 0, GFP_ATOMIC
);
1290 if (skb
->protocol
== ntohs(ETH_P_IP
)) {
1291 struct iphdr
*iph
= ip_hdr(skb
);
1295 tcp_hdr(skb
)->check
= ~csum_tcpudp_magic(iph
->saddr
,
1299 ipofst
= skb_network_offset(skb
);
1300 if (ipofst
!= ENET_HEADER_SIZE
) /* 802.3 frame */
1301 tso
->tsopl
|= 1 << TSO_PARAM_ETHTYPE_SHIFT
;
1303 tso
->tsopl
|= (iph
->ihl
&
1304 CSUM_PARAM_IPHL_MASK
) << CSUM_PARAM_IPHL_SHIFT
;
1305 tso
->tsopl
|= (tcp_hdrlen(skb
) &
1306 TSO_PARAM_TCPHDRLEN_MASK
) << TSO_PARAM_TCPHDRLEN_SHIFT
;
1307 tso
->tsopl
|= (skb_shinfo(skb
)->gso_size
&
1308 TSO_PARAM_MSS_MASK
) << TSO_PARAM_MSS_SHIFT
;
1309 tso
->tsopl
|= 1 << TSO_PARAM_IPCKSUM_SHIFT
;
1310 tso
->tsopl
|= 1 << TSO_PARAM_TCPCKSUM_SHIFT
;
1311 tso
->tsopl
|= 1 << TSO_PARAM_SEGMENT_SHIFT
;
1318 static int atl1_tx_csum(struct atl1_adapter
*adapter
, struct sk_buff
*skb
,
1319 struct csum_param
*csum
)
1323 if (likely(skb
->ip_summed
== CHECKSUM_PARTIAL
)) {
1324 cso
= skb_transport_offset(skb
);
1325 css
= cso
+ skb
->csum_offset
;
1326 if (unlikely(cso
& 0x1)) {
1327 dev_dbg(&adapter
->pdev
->dev
,
1328 "payload offset not an even number\n");
1331 csum
->csumpl
|= (cso
& CSUM_PARAM_PLOADOFFSET_MASK
) <<
1332 CSUM_PARAM_PLOADOFFSET_SHIFT
;
1333 csum
->csumpl
|= (css
& CSUM_PARAM_XSUMOFFSET_MASK
) <<
1334 CSUM_PARAM_XSUMOFFSET_SHIFT
;
1335 csum
->csumpl
|= 1 << CSUM_PARAM_CUSTOMCKSUM_SHIFT
;
1342 static void atl1_tx_map(struct atl1_adapter
*adapter
,
1343 struct sk_buff
*skb
, bool tcp_seg
)
1345 /* We enter this function holding a spinlock. */
1346 struct atl1_tpd_ring
*tpd_ring
= &adapter
->tpd_ring
;
1347 struct atl1_buffer
*buffer_info
;
1349 int first_buf_len
= skb
->len
;
1350 unsigned long offset
;
1351 unsigned int nr_frags
;
1353 u16 tpd_next_to_use
;
1357 first_buf_len
-= skb
->data_len
;
1358 nr_frags
= skb_shinfo(skb
)->nr_frags
;
1359 tpd_next_to_use
= atomic_read(&tpd_ring
->next_to_use
);
1360 buffer_info
= &tpd_ring
->buffer_info
[tpd_next_to_use
];
1361 if (unlikely(buffer_info
->skb
))
1363 buffer_info
->skb
= NULL
; /* put skb in last TPD */
1367 proto_hdr_len
= skb_transport_offset(skb
) + tcp_hdrlen(skb
);
1368 buffer_info
->length
= proto_hdr_len
;
1369 page
= virt_to_page(skb
->data
);
1370 offset
= (unsigned long)skb
->data
& ~PAGE_MASK
;
1371 buffer_info
->dma
= pci_map_page(adapter
->pdev
, page
,
1372 offset
, proto_hdr_len
,
1375 if (++tpd_next_to_use
== tpd_ring
->count
)
1376 tpd_next_to_use
= 0;
1378 if (first_buf_len
> proto_hdr_len
) {
1379 len12
= first_buf_len
- proto_hdr_len
;
1380 m
= (len12
+ MAX_TX_BUF_LEN
- 1) / MAX_TX_BUF_LEN
;
1381 for (i
= 0; i
< m
; i
++) {
1383 &tpd_ring
->buffer_info
[tpd_next_to_use
];
1384 buffer_info
->skb
= NULL
;
1385 buffer_info
->length
=
1387 len12
) ? MAX_TX_BUF_LEN
: len12
;
1388 len12
-= buffer_info
->length
;
1389 page
= virt_to_page(skb
->data
+
1391 i
* MAX_TX_BUF_LEN
));
1392 offset
= (unsigned long)(skb
->data
+
1394 i
* MAX_TX_BUF_LEN
)) &
1397 pci_map_page(adapter
->pdev
, page
, offset
,
1398 buffer_info
->length
,
1400 if (++tpd_next_to_use
== tpd_ring
->count
)
1401 tpd_next_to_use
= 0;
1406 buffer_info
->length
= first_buf_len
;
1407 page
= virt_to_page(skb
->data
);
1408 offset
= (unsigned long)skb
->data
& ~PAGE_MASK
;
1409 buffer_info
->dma
= pci_map_page(adapter
->pdev
, page
,
1410 offset
, first_buf_len
,
1412 if (++tpd_next_to_use
== tpd_ring
->count
)
1413 tpd_next_to_use
= 0;
1416 for (f
= 0; f
< nr_frags
; f
++) {
1417 struct skb_frag_struct
*frag
;
1420 frag
= &skb_shinfo(skb
)->frags
[f
];
1423 m
= (lenf
+ MAX_TX_BUF_LEN
- 1) / MAX_TX_BUF_LEN
;
1424 for (i
= 0; i
< m
; i
++) {
1425 buffer_info
= &tpd_ring
->buffer_info
[tpd_next_to_use
];
1426 if (unlikely(buffer_info
->skb
))
1428 buffer_info
->skb
= NULL
;
1429 buffer_info
->length
=
1430 (lenf
> MAX_TX_BUF_LEN
) ? MAX_TX_BUF_LEN
: lenf
;
1431 lenf
-= buffer_info
->length
;
1433 pci_map_page(adapter
->pdev
, frag
->page
,
1434 frag
->page_offset
+ i
* MAX_TX_BUF_LEN
,
1435 buffer_info
->length
, PCI_DMA_TODEVICE
);
1437 if (++tpd_next_to_use
== tpd_ring
->count
)
1438 tpd_next_to_use
= 0;
1442 /* last tpd's buffer-info */
1443 buffer_info
->skb
= skb
;
1446 static void atl1_tx_queue(struct atl1_adapter
*adapter
, int count
,
1447 union tpd_descr
*descr
)
1449 /* We enter this function holding a spinlock. */
1450 struct atl1_tpd_ring
*tpd_ring
= &adapter
->tpd_ring
;
1453 struct atl1_buffer
*buffer_info
;
1454 struct tx_packet_desc
*tpd
;
1455 u16 tpd_next_to_use
= atomic_read(&tpd_ring
->next_to_use
);
1457 for (j
= 0; j
< count
; j
++) {
1458 buffer_info
= &tpd_ring
->buffer_info
[tpd_next_to_use
];
1459 tpd
= ATL1_TPD_DESC(&adapter
->tpd_ring
, tpd_next_to_use
);
1460 tpd
->desc
.csum
.csumpu
= descr
->csum
.csumpu
;
1461 tpd
->desc
.csum
.csumpl
= descr
->csum
.csumpl
;
1462 tpd
->desc
.tso
.tsopu
= descr
->tso
.tsopu
;
1463 tpd
->desc
.tso
.tsopl
= descr
->tso
.tsopl
;
1464 tpd
->buffer_addr
= cpu_to_le64(buffer_info
->dma
);
1465 tpd
->desc
.data
= descr
->data
;
1466 tpd
->desc
.csum
.csumpu
|= (cpu_to_le16(buffer_info
->length
) &
1467 CSUM_PARAM_BUFLEN_MASK
) << CSUM_PARAM_BUFLEN_SHIFT
;
1469 val
= (descr
->tso
.tsopl
>> TSO_PARAM_SEGMENT_SHIFT
) &
1470 TSO_PARAM_SEGMENT_MASK
;
1472 tpd
->desc
.tso
.tsopl
|= 1 << TSO_PARAM_HDRFLAG_SHIFT
;
1474 if (j
== (count
- 1))
1475 tpd
->desc
.csum
.csumpl
|= 1 << CSUM_PARAM_EOP_SHIFT
;
1477 if (++tpd_next_to_use
== tpd_ring
->count
)
1478 tpd_next_to_use
= 0;
1481 * Force memory writes to complete before letting h/w
1482 * know there are new descriptors to fetch. (Only
1483 * applicable for weak-ordered memory model archs,
1488 atomic_set(&tpd_ring
->next_to_use
, (int)tpd_next_to_use
);
1491 static void atl1_update_mailbox(struct atl1_adapter
*adapter
)
1493 unsigned long flags
;
1494 u32 tpd_next_to_use
;
1495 u32 rfd_next_to_use
;
1496 u32 rrd_next_to_clean
;
1499 spin_lock_irqsave(&adapter
->mb_lock
, flags
);
1501 tpd_next_to_use
= atomic_read(&adapter
->tpd_ring
.next_to_use
);
1502 rfd_next_to_use
= atomic_read(&adapter
->rfd_ring
.next_to_use
);
1503 rrd_next_to_clean
= atomic_read(&adapter
->rrd_ring
.next_to_clean
);
1505 value
= ((rfd_next_to_use
& MB_RFD_PROD_INDX_MASK
) <<
1506 MB_RFD_PROD_INDX_SHIFT
) |
1507 ((rrd_next_to_clean
& MB_RRD_CONS_INDX_MASK
) <<
1508 MB_RRD_CONS_INDX_SHIFT
) |
1509 ((tpd_next_to_use
& MB_TPD_PROD_INDX_MASK
) <<
1510 MB_TPD_PROD_INDX_SHIFT
);
1511 iowrite32(value
, adapter
->hw
.hw_addr
+ REG_MAILBOX
);
1513 spin_unlock_irqrestore(&adapter
->mb_lock
, flags
);
1516 static int atl1_xmit_frame(struct sk_buff
*skb
, struct net_device
*netdev
)
1518 struct atl1_adapter
*adapter
= netdev_priv(netdev
);
1524 union tpd_descr param
;
1527 unsigned long flags
;
1528 unsigned int nr_frags
= 0;
1529 unsigned int mss
= 0;
1531 unsigned int proto_hdr_len
;
1533 len
-= skb
->data_len
;
1535 if (unlikely(skb
->len
== 0)) {
1536 dev_kfree_skb_any(skb
);
1537 return NETDEV_TX_OK
;
1541 param
.tso
.tsopu
= 0;
1542 param
.tso
.tsopl
= 0;
1543 param
.csum
.csumpu
= 0;
1544 param
.csum
.csumpl
= 0;
1546 /* nr_frags will be nonzero if we're doing scatter/gather (SG) */
1547 nr_frags
= skb_shinfo(skb
)->nr_frags
;
1548 for (f
= 0; f
< nr_frags
; f
++) {
1549 frag_size
= skb_shinfo(skb
)->frags
[f
].size
;
1552 (frag_size
+ MAX_TX_BUF_LEN
- 1) / MAX_TX_BUF_LEN
;
1555 /* mss will be nonzero if we're doing segment offload (TSO/GSO) */
1556 mss
= skb_shinfo(skb
)->gso_size
;
1558 if (skb
->protocol
== htons(ETH_P_IP
)) {
1559 proto_hdr_len
= (skb_transport_offset(skb
) +
1561 if (unlikely(proto_hdr_len
> len
)) {
1562 dev_kfree_skb_any(skb
);
1563 return NETDEV_TX_OK
;
1565 /* need additional TPD ? */
1566 if (proto_hdr_len
!= len
)
1567 count
+= (len
- proto_hdr_len
+
1568 MAX_TX_BUF_LEN
- 1) / MAX_TX_BUF_LEN
;
1572 local_irq_save(flags
);
1573 if (!spin_trylock(&adapter
->lock
)) {
1574 /* Can't get lock - tell upper layer to requeue */
1575 local_irq_restore(flags
);
1576 dev_dbg(&adapter
->pdev
->dev
, "tx locked\n");
1577 return NETDEV_TX_LOCKED
;
1580 if (tpd_avail(&adapter
->tpd_ring
) < count
) {
1581 /* not enough descriptors */
1582 netif_stop_queue(netdev
);
1583 spin_unlock_irqrestore(&adapter
->lock
, flags
);
1584 dev_dbg(&adapter
->pdev
->dev
, "tx busy\n");
1585 return NETDEV_TX_BUSY
;
1590 if (adapter
->vlgrp
&& vlan_tx_tag_present(skb
)) {
1591 vlan_tag
= vlan_tx_tag_get(skb
);
1592 vlan_tag
= (vlan_tag
<< 4) | (vlan_tag
>> 13) |
1593 ((vlan_tag
>> 9) & 0x8);
1594 param
.csum
.csumpl
|= 1 << CSUM_PARAM_INSVLAG_SHIFT
;
1595 param
.csum
.csumpu
|= (vlan_tag
& CSUM_PARAM_VALANTAG_MASK
) <<
1596 CSUM_PARAM_VALAN_SHIFT
;
1599 tso
= atl1_tso(adapter
, skb
, ¶m
.tso
);
1601 spin_unlock_irqrestore(&adapter
->lock
, flags
);
1602 dev_kfree_skb_any(skb
);
1603 return NETDEV_TX_OK
;
1607 ret_val
= atl1_tx_csum(adapter
, skb
, ¶m
.csum
);
1609 spin_unlock_irqrestore(&adapter
->lock
, flags
);
1610 dev_kfree_skb_any(skb
);
1611 return NETDEV_TX_OK
;
1615 val
= (param
.csum
.csumpl
>> CSUM_PARAM_SEGMENT_SHIFT
) &
1616 CSUM_PARAM_SEGMENT_MASK
;
1617 atl1_tx_map(adapter
, skb
, 1 == val
);
1618 atl1_tx_queue(adapter
, count
, ¶m
);
1619 netdev
->trans_start
= jiffies
;
1620 spin_unlock_irqrestore(&adapter
->lock
, flags
);
1621 atl1_update_mailbox(adapter
);
1622 return NETDEV_TX_OK
;
1626 * atl1_get_stats - Get System Network Statistics
1627 * @netdev: network interface device structure
1629 * Returns the address of the device statistics structure.
1630 * The statistics are actually updated from the timer callback.
1632 static struct net_device_stats
*atl1_get_stats(struct net_device
*netdev
)
1634 struct atl1_adapter
*adapter
= netdev_priv(netdev
);
1635 return &adapter
->net_stats
;
1639 * atl1_clean_rx_ring - Free RFD Buffers
1640 * @adapter: board private structure
1642 static void atl1_clean_rx_ring(struct atl1_adapter
*adapter
)
1644 struct atl1_rfd_ring
*rfd_ring
= &adapter
->rfd_ring
;
1645 struct atl1_rrd_ring
*rrd_ring
= &adapter
->rrd_ring
;
1646 struct atl1_buffer
*buffer_info
;
1647 struct pci_dev
*pdev
= adapter
->pdev
;
1651 /* Free all the Rx ring sk_buffs */
1652 for (i
= 0; i
< rfd_ring
->count
; i
++) {
1653 buffer_info
= &rfd_ring
->buffer_info
[i
];
1654 if (buffer_info
->dma
) {
1655 pci_unmap_page(pdev
,
1657 buffer_info
->length
,
1658 PCI_DMA_FROMDEVICE
);
1659 buffer_info
->dma
= 0;
1661 if (buffer_info
->skb
) {
1662 dev_kfree_skb(buffer_info
->skb
);
1663 buffer_info
->skb
= NULL
;
1667 size
= sizeof(struct atl1_buffer
) * rfd_ring
->count
;
1668 memset(rfd_ring
->buffer_info
, 0, size
);
1670 /* Zero out the descriptor ring */
1671 memset(rfd_ring
->desc
, 0, rfd_ring
->size
);
1673 rfd_ring
->next_to_clean
= 0;
1674 atomic_set(&rfd_ring
->next_to_use
, 0);
1676 rrd_ring
->next_to_use
= 0;
1677 atomic_set(&rrd_ring
->next_to_clean
, 0);
1681 * atl1_clean_tx_ring - Free Tx Buffers
1682 * @adapter: board private structure
1684 static void atl1_clean_tx_ring(struct atl1_adapter
*adapter
)
1686 struct atl1_tpd_ring
*tpd_ring
= &adapter
->tpd_ring
;
1687 struct atl1_buffer
*buffer_info
;
1688 struct pci_dev
*pdev
= adapter
->pdev
;
1692 /* Free all the Tx ring sk_buffs */
1693 for (i
= 0; i
< tpd_ring
->count
; i
++) {
1694 buffer_info
= &tpd_ring
->buffer_info
[i
];
1695 if (buffer_info
->dma
) {
1696 pci_unmap_page(pdev
, buffer_info
->dma
,
1697 buffer_info
->length
, PCI_DMA_TODEVICE
);
1698 buffer_info
->dma
= 0;
1702 for (i
= 0; i
< tpd_ring
->count
; i
++) {
1703 buffer_info
= &tpd_ring
->buffer_info
[i
];
1704 if (buffer_info
->skb
) {
1705 dev_kfree_skb_any(buffer_info
->skb
);
1706 buffer_info
->skb
= NULL
;
1710 size
= sizeof(struct atl1_buffer
) * tpd_ring
->count
;
1711 memset(tpd_ring
->buffer_info
, 0, size
);
1713 /* Zero out the descriptor ring */
1714 memset(tpd_ring
->desc
, 0, tpd_ring
->size
);
1716 atomic_set(&tpd_ring
->next_to_use
, 0);
1717 atomic_set(&tpd_ring
->next_to_clean
, 0);
1721 * atl1_free_ring_resources - Free Tx / RX descriptor Resources
1722 * @adapter: board private structure
1724 * Free all transmit software resources
1726 void atl1_free_ring_resources(struct atl1_adapter
*adapter
)
1728 struct pci_dev
*pdev
= adapter
->pdev
;
1729 struct atl1_tpd_ring
*tpd_ring
= &adapter
->tpd_ring
;
1730 struct atl1_rfd_ring
*rfd_ring
= &adapter
->rfd_ring
;
1731 struct atl1_rrd_ring
*rrd_ring
= &adapter
->rrd_ring
;
1732 struct atl1_ring_header
*ring_header
= &adapter
->ring_header
;
1734 atl1_clean_tx_ring(adapter
);
1735 atl1_clean_rx_ring(adapter
);
1737 kfree(tpd_ring
->buffer_info
);
1738 pci_free_consistent(pdev
, ring_header
->size
, ring_header
->desc
,
1741 tpd_ring
->buffer_info
= NULL
;
1742 tpd_ring
->desc
= NULL
;
1745 rfd_ring
->buffer_info
= NULL
;
1746 rfd_ring
->desc
= NULL
;
1749 rrd_ring
->desc
= NULL
;
1753 s32
atl1_up(struct atl1_adapter
*adapter
)
1755 struct net_device
*netdev
= adapter
->netdev
;
1757 int irq_flags
= IRQF_SAMPLE_RANDOM
;
1759 /* hardware has been reset, we need to reload some things */
1760 atl1_set_multi(netdev
);
1761 atl1_restore_vlan(adapter
);
1762 err
= atl1_alloc_rx_buffers(adapter
);
1763 if (unlikely(!err
)) /* no RX BUFFER allocated */
1766 if (unlikely(atl1_configure(adapter
))) {
1771 err
= pci_enable_msi(adapter
->pdev
);
1773 dev_info(&adapter
->pdev
->dev
,
1774 "Unable to enable MSI: %d\n", err
);
1775 irq_flags
|= IRQF_SHARED
;
1778 err
= request_irq(adapter
->pdev
->irq
, &atl1_intr
, irq_flags
,
1779 netdev
->name
, netdev
);
1783 mod_timer(&adapter
->watchdog_timer
, jiffies
);
1784 atl1_irq_enable(adapter
);
1785 atl1_check_link(adapter
);
1788 /* FIXME: unreachable code! -- CHS */
1789 /* free irq disable any interrupt */
1790 iowrite32(0, adapter
->hw
.hw_addr
+ REG_IMR
);
1791 free_irq(adapter
->pdev
->irq
, netdev
);
1794 pci_disable_msi(adapter
->pdev
);
1795 /* free rx_buffers */
1796 atl1_clean_rx_ring(adapter
);
1800 void atl1_down(struct atl1_adapter
*adapter
)
1802 struct net_device
*netdev
= adapter
->netdev
;
1804 del_timer_sync(&adapter
->watchdog_timer
);
1805 del_timer_sync(&adapter
->phy_config_timer
);
1806 adapter
->phy_timer_pending
= false;
1808 atl1_irq_disable(adapter
);
1809 free_irq(adapter
->pdev
->irq
, netdev
);
1810 pci_disable_msi(adapter
->pdev
);
1811 atl1_reset_hw(&adapter
->hw
);
1812 adapter
->cmb
.cmb
->int_stats
= 0;
1814 adapter
->link_speed
= SPEED_0
;
1815 adapter
->link_duplex
= -1;
1816 netif_carrier_off(netdev
);
1817 netif_stop_queue(netdev
);
1819 atl1_clean_tx_ring(adapter
);
1820 atl1_clean_rx_ring(adapter
);
1824 * atl1_change_mtu - Change the Maximum Transfer Unit
1825 * @netdev: network interface device structure
1826 * @new_mtu: new value for maximum frame size
1828 * Returns 0 on success, negative on failure
1830 static int atl1_change_mtu(struct net_device
*netdev
, int new_mtu
)
1832 struct atl1_adapter
*adapter
= netdev_priv(netdev
);
1833 int old_mtu
= netdev
->mtu
;
1834 int max_frame
= new_mtu
+ ENET_HEADER_SIZE
+ ETHERNET_FCS_SIZE
;
1836 if ((max_frame
< MINIMUM_ETHERNET_FRAME_SIZE
) ||
1837 (max_frame
> MAX_JUMBO_FRAME_SIZE
)) {
1838 dev_warn(&adapter
->pdev
->dev
, "invalid MTU setting\n");
1842 adapter
->hw
.max_frame_size
= max_frame
;
1843 adapter
->hw
.tx_jumbo_task_th
= (max_frame
+ 7) >> 3;
1844 adapter
->rx_buffer_len
= (max_frame
+ 7) & ~7;
1845 adapter
->hw
.rx_jumbo_th
= adapter
->rx_buffer_len
/ 8;
1847 netdev
->mtu
= new_mtu
;
1848 if ((old_mtu
!= new_mtu
) && netif_running(netdev
)) {
1857 * atl1_set_mac - Change the Ethernet Address of the NIC
1858 * @netdev: network interface device structure
1859 * @p: pointer to an address structure
1861 * Returns 0 on success, negative on failure
1863 static int atl1_set_mac(struct net_device
*netdev
, void *p
)
1865 struct atl1_adapter
*adapter
= netdev_priv(netdev
);
1866 struct sockaddr
*addr
= p
;
1868 if (netif_running(netdev
))
1871 if (!is_valid_ether_addr(addr
->sa_data
))
1872 return -EADDRNOTAVAIL
;
1874 memcpy(netdev
->dev_addr
, addr
->sa_data
, netdev
->addr_len
);
1875 memcpy(adapter
->hw
.mac_addr
, addr
->sa_data
, netdev
->addr_len
);
1877 atl1_set_mac_addr(&adapter
->hw
);
1882 * atl1_watchdog - Timer Call-back
1883 * @data: pointer to netdev cast into an unsigned long
1885 static void atl1_watchdog(unsigned long data
)
1887 struct atl1_adapter
*adapter
= (struct atl1_adapter
*)data
;
1889 /* Reset the timer */
1890 mod_timer(&adapter
->watchdog_timer
, jiffies
+ 2 * HZ
);
1893 static int mdio_read(struct net_device
*netdev
, int phy_id
, int reg_num
)
1895 struct atl1_adapter
*adapter
= netdev_priv(netdev
);
1898 atl1_read_phy_reg(&adapter
->hw
, reg_num
& 0x1f, &result
);
1903 static void mdio_write(struct net_device
*netdev
, int phy_id
, int reg_num
, int val
)
1905 struct atl1_adapter
*adapter
= netdev_priv(netdev
);
1907 atl1_write_phy_reg(&adapter
->hw
, reg_num
, val
);
1916 static int atl1_mii_ioctl(struct net_device
*netdev
, struct ifreq
*ifr
, int cmd
)
1918 struct atl1_adapter
*adapter
= netdev_priv(netdev
);
1919 unsigned long flags
;
1922 if (!netif_running(netdev
))
1925 spin_lock_irqsave(&adapter
->lock
, flags
);
1926 retval
= generic_mii_ioctl(&adapter
->mii
, if_mii(ifr
), cmd
, NULL
);
1927 spin_unlock_irqrestore(&adapter
->lock
, flags
);
1938 static int atl1_ioctl(struct net_device
*netdev
, struct ifreq
*ifr
, int cmd
)
1944 return atl1_mii_ioctl(netdev
, ifr
, cmd
);
1951 * atl1_tx_timeout - Respond to a Tx Hang
1952 * @netdev: network interface device structure
1954 static void atl1_tx_timeout(struct net_device
*netdev
)
1956 struct atl1_adapter
*adapter
= netdev_priv(netdev
);
1957 /* Do the reset outside of interrupt context */
1958 schedule_work(&adapter
->tx_timeout_task
);
1962 * atl1_phy_config - Timer Call-back
1963 * @data: pointer to netdev cast into an unsigned long
1965 static void atl1_phy_config(unsigned long data
)
1967 struct atl1_adapter
*adapter
= (struct atl1_adapter
*)data
;
1968 struct atl1_hw
*hw
= &adapter
->hw
;
1969 unsigned long flags
;
1971 spin_lock_irqsave(&adapter
->lock
, flags
);
1972 adapter
->phy_timer_pending
= false;
1973 atl1_write_phy_reg(hw
, MII_ADVERTISE
, hw
->mii_autoneg_adv_reg
);
1974 atl1_write_phy_reg(hw
, MII_AT001_CR
, hw
->mii_1000t_ctrl_reg
);
1975 atl1_write_phy_reg(hw
, MII_BMCR
, MII_CR_RESET
| MII_CR_AUTO_NEG_EN
);
1976 spin_unlock_irqrestore(&adapter
->lock
, flags
);
1979 int atl1_reset(struct atl1_adapter
*adapter
)
1983 ret
= atl1_reset_hw(&adapter
->hw
);
1984 if (ret
!= ATL1_SUCCESS
)
1986 return atl1_init_hw(&adapter
->hw
);
1990 * atl1_open - Called when a network interface is made active
1991 * @netdev: network interface device structure
1993 * Returns 0 on success, negative value on failure
1995 * The open entry point is called when a network interface is made
1996 * active by the system (IFF_UP). At this point all resources needed
1997 * for transmit and receive operations are allocated, the interrupt
1998 * handler is registered with the OS, the watchdog timer is started,
1999 * and the stack is notified that the interface is ready.
2001 static int atl1_open(struct net_device
*netdev
)
2003 struct atl1_adapter
*adapter
= netdev_priv(netdev
);
2006 /* allocate transmit descriptors */
2007 err
= atl1_setup_ring_resources(adapter
);
2011 err
= atl1_up(adapter
);
2018 atl1_reset(adapter
);
2023 * atl1_close - Disables a network interface
2024 * @netdev: network interface device structure
2026 * Returns 0, this is not allowed to fail
2028 * The close entry point is called when an interface is de-activated
2029 * by the OS. The hardware is still under the drivers control, but
2030 * needs to be disabled. A global MAC reset is issued to stop the
2031 * hardware, and all transmit and receive resources are freed.
2033 static int atl1_close(struct net_device
*netdev
)
2035 struct atl1_adapter
*adapter
= netdev_priv(netdev
);
2037 atl1_free_ring_resources(adapter
);
2041 #ifdef CONFIG_NET_POLL_CONTROLLER
2042 static void atl1_poll_controller(struct net_device
*netdev
)
2044 disable_irq(netdev
->irq
);
2045 atl1_intr(netdev
->irq
, netdev
);
2046 enable_irq(netdev
->irq
);
2051 * If TPD Buffer size equal to 0, PCIE DMAR_TO_INT
2052 * will assert. We do soft reset <0x1400=1> according
2053 * with the SPEC. BUT, it seemes that PCIE or DMA
2054 * state-machine will not be reset. DMAR_TO_INT will
2055 * assert again and again.
2057 static void atl1_tx_timeout_task(struct work_struct
*work
)
2059 struct atl1_adapter
*adapter
=
2060 container_of(work
, struct atl1_adapter
, tx_timeout_task
);
2061 struct net_device
*netdev
= adapter
->netdev
;
2063 netif_device_detach(netdev
);
2066 netif_device_attach(netdev
);
2070 * atl1_link_chg_task - deal with link change event Out of interrupt context
2072 static void atl1_link_chg_task(struct work_struct
*work
)
2074 struct atl1_adapter
*adapter
=
2075 container_of(work
, struct atl1_adapter
, link_chg_task
);
2076 unsigned long flags
;
2078 spin_lock_irqsave(&adapter
->lock
, flags
);
2079 atl1_check_link(adapter
);
2080 spin_unlock_irqrestore(&adapter
->lock
, flags
);
2084 * atl1_pcie_patch - Patch for PCIE module
2086 static void atl1_pcie_patch(struct atl1_adapter
*adapter
)
2090 iowrite32(value
, adapter
->hw
.hw_addr
+ 0x12FC);
2091 /* pcie flow control mode change */
2092 value
= ioread32(adapter
->hw
.hw_addr
+ 0x1008);
2094 iowrite32(value
, adapter
->hw
.hw_addr
+ 0x1008);
2098 * When ACPI resume on some VIA MotherBoard, the Interrupt Disable bit/0x400
2099 * on PCI Command register is disable.
2100 * The function enable this bit.
2101 * Brackett, 2006/03/15
2103 static void atl1_via_workaround(struct atl1_adapter
*adapter
)
2105 unsigned long value
;
2107 value
= ioread16(adapter
->hw
.hw_addr
+ PCI_COMMAND
);
2108 if (value
& PCI_COMMAND_INTX_DISABLE
)
2109 value
&= ~PCI_COMMAND_INTX_DISABLE
;
2110 iowrite32(value
, adapter
->hw
.hw_addr
+ PCI_COMMAND
);
2114 * atl1_probe - Device Initialization Routine
2115 * @pdev: PCI device information struct
2116 * @ent: entry in atl1_pci_tbl
2118 * Returns 0 on success, negative on failure
2120 * atl1_probe initializes an adapter identified by a pci_dev structure.
2121 * The OS initialization, configuring of the adapter private structure,
2122 * and a hardware reset occur.
2124 static int __devinit
atl1_probe(struct pci_dev
*pdev
,
2125 const struct pci_device_id
*ent
)
2127 struct net_device
*netdev
;
2128 struct atl1_adapter
*adapter
;
2129 static int cards_found
= 0;
2130 bool pci_using_64
= true;
2133 err
= pci_enable_device(pdev
);
2137 err
= pci_set_dma_mask(pdev
, DMA_64BIT_MASK
);
2139 err
= pci_set_dma_mask(pdev
, DMA_32BIT_MASK
);
2141 dev_err(&pdev
->dev
, "no usable DMA configuration\n");
2144 pci_using_64
= false;
2146 /* Mark all PCI regions associated with PCI device
2147 * pdev as being reserved by owner atl1_driver_name
2149 err
= pci_request_regions(pdev
, atl1_driver_name
);
2151 goto err_request_regions
;
2153 /* Enables bus-mastering on the device and calls
2154 * pcibios_set_master to do the needed arch specific settings
2156 pci_set_master(pdev
);
2158 netdev
= alloc_etherdev(sizeof(struct atl1_adapter
));
2161 goto err_alloc_etherdev
;
2163 SET_MODULE_OWNER(netdev
);
2164 SET_NETDEV_DEV(netdev
, &pdev
->dev
);
2166 pci_set_drvdata(pdev
, netdev
);
2167 adapter
= netdev_priv(netdev
);
2168 adapter
->netdev
= netdev
;
2169 adapter
->pdev
= pdev
;
2170 adapter
->hw
.back
= adapter
;
2172 adapter
->hw
.hw_addr
= pci_iomap(pdev
, 0, 0);
2173 if (!adapter
->hw
.hw_addr
) {
2177 /* get device revision number */
2178 adapter
->hw
.dev_rev
= ioread16(adapter
->hw
.hw_addr
+
2179 (REG_MASTER_CTRL
+ 2));
2180 dev_info(&pdev
->dev
, "version %s\n", DRIVER_VERSION
);
2182 /* set default ring resource counts */
2183 adapter
->rfd_ring
.count
= adapter
->rrd_ring
.count
= ATL1_DEFAULT_RFD
;
2184 adapter
->tpd_ring
.count
= ATL1_DEFAULT_TPD
;
2186 adapter
->mii
.dev
= netdev
;
2187 adapter
->mii
.mdio_read
= mdio_read
;
2188 adapter
->mii
.mdio_write
= mdio_write
;
2189 adapter
->mii
.phy_id_mask
= 0x1f;
2190 adapter
->mii
.reg_num_mask
= 0x1f;
2192 netdev
->open
= &atl1_open
;
2193 netdev
->stop
= &atl1_close
;
2194 netdev
->hard_start_xmit
= &atl1_xmit_frame
;
2195 netdev
->get_stats
= &atl1_get_stats
;
2196 netdev
->set_multicast_list
= &atl1_set_multi
;
2197 netdev
->set_mac_address
= &atl1_set_mac
;
2198 netdev
->change_mtu
= &atl1_change_mtu
;
2199 netdev
->do_ioctl
= &atl1_ioctl
;
2200 netdev
->tx_timeout
= &atl1_tx_timeout
;
2201 netdev
->watchdog_timeo
= 5 * HZ
;
2202 #ifdef CONFIG_NET_POLL_CONTROLLER
2203 netdev
->poll_controller
= atl1_poll_controller
;
2205 netdev
->vlan_rx_register
= atl1_vlan_rx_register
;
2206 netdev
->vlan_rx_add_vid
= atl1_vlan_rx_add_vid
;
2207 netdev
->vlan_rx_kill_vid
= atl1_vlan_rx_kill_vid
;
2208 netdev
->ethtool_ops
= &atl1_ethtool_ops
;
2209 adapter
->bd_number
= cards_found
;
2210 adapter
->pci_using_64
= pci_using_64
;
2212 /* setup the private structure */
2213 err
= atl1_sw_init(adapter
);
2217 netdev
->features
= NETIF_F_HW_CSUM
;
2218 netdev
->features
|= NETIF_F_SG
;
2219 netdev
->features
|= (NETIF_F_HW_VLAN_TX
| NETIF_F_HW_VLAN_RX
);
2222 * FIXME - Until tso performance gets fixed, disable the feature.
2223 * Enable it with ethtool -K if desired.
2225 /* netdev->features |= NETIF_F_TSO; */
2228 netdev
->features
|= NETIF_F_HIGHDMA
;
2230 netdev
->features
|= NETIF_F_LLTX
;
2233 * patch for some L1 of old version,
2234 * the final version of L1 may not need these
2237 /* atl1_pcie_patch(adapter); */
2239 /* really reset GPHY core */
2240 iowrite16(0, adapter
->hw
.hw_addr
+ REG_GPHY_ENABLE
);
2243 * reset the controller to
2244 * put the device in a known good starting state
2246 if (atl1_reset_hw(&adapter
->hw
)) {
2251 /* copy the MAC address out of the EEPROM */
2252 atl1_read_mac_addr(&adapter
->hw
);
2253 memcpy(netdev
->dev_addr
, adapter
->hw
.mac_addr
, netdev
->addr_len
);
2255 if (!is_valid_ether_addr(netdev
->dev_addr
)) {
2260 atl1_check_options(adapter
);
2262 /* pre-init the MAC, and setup link */
2263 err
= atl1_init_hw(&adapter
->hw
);
2269 atl1_pcie_patch(adapter
);
2270 /* assume we have no link for now */
2271 netif_carrier_off(netdev
);
2272 netif_stop_queue(netdev
);
2274 init_timer(&adapter
->watchdog_timer
);
2275 adapter
->watchdog_timer
.function
= &atl1_watchdog
;
2276 adapter
->watchdog_timer
.data
= (unsigned long)adapter
;
2278 init_timer(&adapter
->phy_config_timer
);
2279 adapter
->phy_config_timer
.function
= &atl1_phy_config
;
2280 adapter
->phy_config_timer
.data
= (unsigned long)adapter
;
2281 adapter
->phy_timer_pending
= false;
2283 INIT_WORK(&adapter
->tx_timeout_task
, atl1_tx_timeout_task
);
2285 INIT_WORK(&adapter
->link_chg_task
, atl1_link_chg_task
);
2287 INIT_WORK(&adapter
->pcie_dma_to_rst_task
, atl1_tx_timeout_task
);
2289 err
= register_netdev(netdev
);
2294 atl1_via_workaround(adapter
);
2298 pci_iounmap(pdev
, adapter
->hw
.hw_addr
);
2300 free_netdev(netdev
);
2302 pci_release_regions(pdev
);
2304 err_request_regions
:
2305 pci_disable_device(pdev
);
2310 * atl1_remove - Device Removal Routine
2311 * @pdev: PCI device information struct
2313 * atl1_remove is called by the PCI subsystem to alert the driver
2314 * that it should release a PCI device. The could be caused by a
2315 * Hot-Plug event, or because the driver is going to be removed from
2318 static void __devexit
atl1_remove(struct pci_dev
*pdev
)
2320 struct net_device
*netdev
= pci_get_drvdata(pdev
);
2321 struct atl1_adapter
*adapter
;
2322 /* Device not available. Return. */
2326 adapter
= netdev_priv(netdev
);
2328 /* Some atl1 boards lack persistent storage for their MAC, and get it
2329 * from the BIOS during POST. If we've been messing with the MAC
2330 * address, we need to save the permanent one.
2332 if (memcmp(adapter
->hw
.mac_addr
, adapter
->hw
.perm_mac_addr
, ETH_ALEN
)) {
2333 memcpy(adapter
->hw
.mac_addr
, adapter
->hw
.perm_mac_addr
, ETH_ALEN
);
2334 atl1_set_mac_addr(&adapter
->hw
);
2337 iowrite16(0, adapter
->hw
.hw_addr
+ REG_GPHY_ENABLE
);
2338 unregister_netdev(netdev
);
2339 pci_iounmap(pdev
, adapter
->hw
.hw_addr
);
2340 pci_release_regions(pdev
);
2341 free_netdev(netdev
);
2342 pci_disable_device(pdev
);
2346 static int atl1_suspend(struct pci_dev
*pdev
, pm_message_t state
)
2348 struct net_device
*netdev
= pci_get_drvdata(pdev
);
2349 struct atl1_adapter
*adapter
= netdev_priv(netdev
);
2350 struct atl1_hw
*hw
= &adapter
->hw
;
2352 u32 wufc
= adapter
->wol
;
2354 netif_device_detach(netdev
);
2355 if (netif_running(netdev
))
2358 atl1_read_phy_reg(hw
, MII_BMSR
, (u16
*) & ctrl
);
2359 atl1_read_phy_reg(hw
, MII_BMSR
, (u16
*) & ctrl
);
2360 if (ctrl
& BMSR_LSTATUS
)
2361 wufc
&= ~ATL1_WUFC_LNKC
;
2363 /* reduce speed to 10/100M */
2365 atl1_phy_enter_power_saving(hw
);
2366 /* if resume, let driver to re- setup link */
2367 hw
->phy_configured
= false;
2368 atl1_set_mac_addr(hw
);
2369 atl1_set_multi(netdev
);
2372 /* turn on magic packet wol */
2373 if (wufc
& ATL1_WUFC_MAG
)
2374 ctrl
= WOL_MAGIC_EN
| WOL_MAGIC_PME_EN
;
2376 /* turn on Link change WOL */
2377 if (wufc
& ATL1_WUFC_LNKC
)
2378 ctrl
|= (WOL_LINK_CHG_EN
| WOL_LINK_CHG_PME_EN
);
2379 iowrite32(ctrl
, hw
->hw_addr
+ REG_WOL_CTRL
);
2381 /* turn on all-multi mode if wake on multicast is enabled */
2382 ctrl
= ioread32(hw
->hw_addr
+ REG_MAC_CTRL
);
2383 ctrl
&= ~MAC_CTRL_DBG
;
2384 ctrl
&= ~MAC_CTRL_PROMIS_EN
;
2385 if (wufc
& ATL1_WUFC_MC
)
2386 ctrl
|= MAC_CTRL_MC_ALL_EN
;
2388 ctrl
&= ~MAC_CTRL_MC_ALL_EN
;
2390 /* turn on broadcast mode if wake on-BC is enabled */
2391 if (wufc
& ATL1_WUFC_BC
)
2392 ctrl
|= MAC_CTRL_BC_EN
;
2394 ctrl
&= ~MAC_CTRL_BC_EN
;
2397 ctrl
|= MAC_CTRL_RX_EN
;
2398 iowrite32(ctrl
, hw
->hw_addr
+ REG_MAC_CTRL
);
2399 pci_enable_wake(pdev
, PCI_D3hot
, 1);
2400 pci_enable_wake(pdev
, PCI_D3cold
, 1); /* 4 == D3 cold */
2402 iowrite32(0, hw
->hw_addr
+ REG_WOL_CTRL
);
2403 pci_enable_wake(pdev
, PCI_D3hot
, 0);
2404 pci_enable_wake(pdev
, PCI_D3cold
, 0); /* 4 == D3 cold */
2407 pci_save_state(pdev
);
2408 pci_disable_device(pdev
);
2410 pci_set_power_state(pdev
, PCI_D3hot
);
2415 static int atl1_resume(struct pci_dev
*pdev
)
2417 struct net_device
*netdev
= pci_get_drvdata(pdev
);
2418 struct atl1_adapter
*adapter
= netdev_priv(netdev
);
2421 pci_set_power_state(pdev
, 0);
2422 pci_restore_state(pdev
);
2424 ret_val
= pci_enable_device(pdev
);
2425 pci_enable_wake(pdev
, PCI_D3hot
, 0);
2426 pci_enable_wake(pdev
, PCI_D3cold
, 0);
2428 iowrite32(0, adapter
->hw
.hw_addr
+ REG_WOL_CTRL
);
2429 atl1_reset(adapter
);
2431 if (netif_running(netdev
))
2433 netif_device_attach(netdev
);
2435 atl1_via_workaround(adapter
);
2440 #define atl1_suspend NULL
2441 #define atl1_resume NULL
2444 static struct pci_driver atl1_driver
= {
2445 .name
= atl1_driver_name
,
2446 .id_table
= atl1_pci_tbl
,
2447 .probe
= atl1_probe
,
2448 .remove
= __devexit_p(atl1_remove
),
2449 /* Power Managment Hooks */
2450 /* probably broken right now -- CHS */
2451 .suspend
= atl1_suspend
,
2452 .resume
= atl1_resume
2456 * atl1_exit_module - Driver Exit Cleanup Routine
2458 * atl1_exit_module is called just before the driver is removed
2461 static void __exit
atl1_exit_module(void)
2463 pci_unregister_driver(&atl1_driver
);
2467 * atl1_init_module - Driver Registration Routine
2469 * atl1_init_module is the first routine called when the driver is
2470 * loaded. All it does is register with the PCI subsystem.
2472 static int __init
atl1_init_module(void)
2474 return pci_register_driver(&atl1_driver
);
2477 module_init(atl1_init_module
);
2478 module_exit(atl1_exit_module
);