1 /*******************************************************************
2 * ident "$Id: idt77252.c,v 1.2 2001/11/11 08:13:54 ecd Exp $"
5 * $Date: 2001/11/11 08:13:54 $
7 * Copyright (c) 2000 ATecoM GmbH
9 * The author may be reached at ecd@atecom.com.
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
19 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
22 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 * You should have received a copy of the GNU General Public License along
28 * with this program; if not, write to the Free Software Foundation, Inc.,
29 * 675 Mass Ave, Cambridge, MA 02139, USA.
31 *******************************************************************/
32 static char const rcsid
[] =
33 "$Id: idt77252.c,v 1.2 2001/11/11 08:13:54 ecd Exp $";
36 #include <linux/module.h>
37 #include <linux/pci.h>
38 #include <linux/poison.h>
39 #include <linux/skbuff.h>
40 #include <linux/kernel.h>
41 #include <linux/vmalloc.h>
42 #include <linux/netdevice.h>
43 #include <linux/atmdev.h>
44 #include <linux/atm.h>
45 #include <linux/delay.h>
46 #include <linux/init.h>
47 #include <linux/bitops.h>
48 #include <linux/wait.h>
49 #include <linux/jiffies.h>
50 #include <linux/mutex.h>
53 #include <asm/uaccess.h>
54 #include <asm/atomic.h>
55 #include <asm/byteorder.h>
57 #ifdef CONFIG_ATM_IDT77252_USE_SUNI
59 #endif /* CONFIG_ATM_IDT77252_USE_SUNI */
63 #include "idt77252_tables.h"
65 static unsigned int vpibits
= 1;
68 #define ATM_IDT77252_SEND_IDLE 1
74 #define DEBUG_MODULE 1
75 #undef HAVE_EEPROM /* does not work, yet. */
77 #ifdef CONFIG_ATM_IDT77252_DEBUG
78 static unsigned long debug
= DBG_GENERAL
;
82 #define SAR_RX_DELAY (SAR_CFG_RXINT_NODELAY)
88 static struct scq_info
*alloc_scq(struct idt77252_dev
*, int);
89 static void free_scq(struct idt77252_dev
*, struct scq_info
*);
90 static int queue_skb(struct idt77252_dev
*, struct vc_map
*,
91 struct sk_buff
*, int oam
);
92 static void drain_scq(struct idt77252_dev
*, struct vc_map
*);
93 static unsigned long get_free_scd(struct idt77252_dev
*, struct vc_map
*);
94 static void fill_scd(struct idt77252_dev
*, struct scq_info
*, int);
99 static int push_rx_skb(struct idt77252_dev
*,
100 struct sk_buff
*, int queue
);
101 static void recycle_rx_skb(struct idt77252_dev
*, struct sk_buff
*);
102 static void flush_rx_pool(struct idt77252_dev
*, struct rx_pool
*);
103 static void recycle_rx_pool_skb(struct idt77252_dev
*,
105 static void add_rx_skb(struct idt77252_dev
*, int queue
,
106 unsigned int size
, unsigned int count
);
111 static int init_rsq(struct idt77252_dev
*);
112 static void deinit_rsq(struct idt77252_dev
*);
113 static void idt77252_rx(struct idt77252_dev
*);
118 static int init_tsq(struct idt77252_dev
*);
119 static void deinit_tsq(struct idt77252_dev
*);
120 static void idt77252_tx(struct idt77252_dev
*);
126 static void idt77252_dev_close(struct atm_dev
*dev
);
127 static int idt77252_open(struct atm_vcc
*vcc
);
128 static void idt77252_close(struct atm_vcc
*vcc
);
129 static int idt77252_send(struct atm_vcc
*vcc
, struct sk_buff
*skb
);
130 static int idt77252_send_oam(struct atm_vcc
*vcc
, void *cell
,
132 static void idt77252_phy_put(struct atm_dev
*dev
, unsigned char value
,
134 static unsigned char idt77252_phy_get(struct atm_dev
*dev
, unsigned long addr
);
135 static int idt77252_change_qos(struct atm_vcc
*vcc
, struct atm_qos
*qos
,
137 static int idt77252_proc_read(struct atm_dev
*dev
, loff_t
* pos
,
139 static void idt77252_softint(struct work_struct
*work
);
142 static struct atmdev_ops idt77252_ops
=
144 .dev_close
= idt77252_dev_close
,
145 .open
= idt77252_open
,
146 .close
= idt77252_close
,
147 .send
= idt77252_send
,
148 .send_oam
= idt77252_send_oam
,
149 .phy_put
= idt77252_phy_put
,
150 .phy_get
= idt77252_phy_get
,
151 .change_qos
= idt77252_change_qos
,
152 .proc_read
= idt77252_proc_read
,
156 static struct idt77252_dev
*idt77252_chain
= NULL
;
157 static unsigned int idt77252_sram_write_errors
= 0;
159 /*****************************************************************************/
161 /* I/O and Utility Bus */
163 /*****************************************************************************/
166 waitfor_idle(struct idt77252_dev
*card
)
170 stat
= readl(SAR_REG_STAT
);
171 while (stat
& SAR_STAT_CMDBZ
)
172 stat
= readl(SAR_REG_STAT
);
176 read_sram(struct idt77252_dev
*card
, unsigned long addr
)
181 spin_lock_irqsave(&card
->cmd_lock
, flags
);
182 writel(SAR_CMD_READ_SRAM
| (addr
<< 2), SAR_REG_CMD
);
184 value
= readl(SAR_REG_DR0
);
185 spin_unlock_irqrestore(&card
->cmd_lock
, flags
);
190 write_sram(struct idt77252_dev
*card
, unsigned long addr
, u32 value
)
194 if ((idt77252_sram_write_errors
== 0) &&
195 (((addr
> card
->tst
[0] + card
->tst_size
- 2) &&
196 (addr
< card
->tst
[0] + card
->tst_size
)) ||
197 ((addr
> card
->tst
[1] + card
->tst_size
- 2) &&
198 (addr
< card
->tst
[1] + card
->tst_size
)))) {
199 printk("%s: ERROR: TST JMP section at %08lx written: %08x\n",
200 card
->name
, addr
, value
);
203 spin_lock_irqsave(&card
->cmd_lock
, flags
);
204 writel(value
, SAR_REG_DR0
);
205 writel(SAR_CMD_WRITE_SRAM
| (addr
<< 2), SAR_REG_CMD
);
207 spin_unlock_irqrestore(&card
->cmd_lock
, flags
);
211 read_utility(void *dev
, unsigned long ubus_addr
)
213 struct idt77252_dev
*card
= dev
;
218 printk("Error: No such device.\n");
222 spin_lock_irqsave(&card
->cmd_lock
, flags
);
223 writel(SAR_CMD_READ_UTILITY
+ ubus_addr
, SAR_REG_CMD
);
225 value
= readl(SAR_REG_DR0
);
226 spin_unlock_irqrestore(&card
->cmd_lock
, flags
);
231 write_utility(void *dev
, unsigned long ubus_addr
, u8 value
)
233 struct idt77252_dev
*card
= dev
;
237 printk("Error: No such device.\n");
241 spin_lock_irqsave(&card
->cmd_lock
, flags
);
242 writel((u32
) value
, SAR_REG_DR0
);
243 writel(SAR_CMD_WRITE_UTILITY
+ ubus_addr
, SAR_REG_CMD
);
245 spin_unlock_irqrestore(&card
->cmd_lock
, flags
);
249 static u32 rdsrtab
[] =
251 SAR_GP_EECS
| SAR_GP_EESCLK
,
253 SAR_GP_EESCLK
, /* 0 */
255 SAR_GP_EESCLK
, /* 0 */
257 SAR_GP_EESCLK
, /* 0 */
259 SAR_GP_EESCLK
, /* 0 */
261 SAR_GP_EESCLK
, /* 0 */
263 SAR_GP_EESCLK
| SAR_GP_EEDO
, /* 1 */
265 SAR_GP_EESCLK
, /* 0 */
267 SAR_GP_EESCLK
| SAR_GP_EEDO
/* 1 */
270 static u32 wrentab
[] =
272 SAR_GP_EECS
| SAR_GP_EESCLK
,
274 SAR_GP_EESCLK
, /* 0 */
276 SAR_GP_EESCLK
, /* 0 */
278 SAR_GP_EESCLK
, /* 0 */
280 SAR_GP_EESCLK
, /* 0 */
282 SAR_GP_EESCLK
| SAR_GP_EEDO
, /* 1 */
284 SAR_GP_EESCLK
| SAR_GP_EEDO
, /* 1 */
286 SAR_GP_EESCLK
, /* 0 */
288 SAR_GP_EESCLK
/* 0 */
293 SAR_GP_EECS
| SAR_GP_EESCLK
,
295 SAR_GP_EESCLK
, /* 0 */
297 SAR_GP_EESCLK
, /* 0 */
299 SAR_GP_EESCLK
, /* 0 */
301 SAR_GP_EESCLK
, /* 0 */
303 SAR_GP_EESCLK
, /* 0 */
305 SAR_GP_EESCLK
, /* 0 */
307 SAR_GP_EESCLK
| SAR_GP_EEDO
, /* 1 */
309 SAR_GP_EESCLK
| SAR_GP_EEDO
/* 1 */
314 SAR_GP_EECS
| SAR_GP_EESCLK
,
316 SAR_GP_EESCLK
, /* 0 */
318 SAR_GP_EESCLK
, /* 0 */
320 SAR_GP_EESCLK
, /* 0 */
322 SAR_GP_EESCLK
, /* 0 */
324 SAR_GP_EESCLK
, /* 0 */
326 SAR_GP_EESCLK
, /* 0 */
328 SAR_GP_EESCLK
| SAR_GP_EEDO
, /* 1 */
330 SAR_GP_EESCLK
/* 0 */
333 static u32 clktab
[] =
355 idt77252_read_gp(struct idt77252_dev
*card
)
359 gp
= readl(SAR_REG_GP
);
361 printk("RD: %s\n", gp
& SAR_GP_EEDI
? "1" : "0");
367 idt77252_write_gp(struct idt77252_dev
*card
, u32 value
)
372 printk("WR: %s %s %s\n", value
& SAR_GP_EECS
? " " : "/CS",
373 value
& SAR_GP_EESCLK
? "HIGH" : "LOW ",
374 value
& SAR_GP_EEDO
? "1" : "0");
377 spin_lock_irqsave(&card
->cmd_lock
, flags
);
379 writel(value
, SAR_REG_GP
);
380 spin_unlock_irqrestore(&card
->cmd_lock
, flags
);
384 idt77252_eeprom_read_status(struct idt77252_dev
*card
)
390 gp
= idt77252_read_gp(card
) & ~(SAR_GP_EESCLK
|SAR_GP_EECS
|SAR_GP_EEDO
);
392 for (i
= 0; i
< ARRAY_SIZE(rdsrtab
); i
++) {
393 idt77252_write_gp(card
, gp
| rdsrtab
[i
]);
396 idt77252_write_gp(card
, gp
| SAR_GP_EECS
);
400 for (i
= 0, j
= 0; i
< 8; i
++) {
403 idt77252_write_gp(card
, gp
| clktab
[j
++]);
406 byte
|= idt77252_read_gp(card
) & SAR_GP_EEDI
? 1 : 0;
408 idt77252_write_gp(card
, gp
| clktab
[j
++]);
411 idt77252_write_gp(card
, gp
| SAR_GP_EECS
);
418 idt77252_eeprom_read_byte(struct idt77252_dev
*card
, u8 offset
)
424 gp
= idt77252_read_gp(card
) & ~(SAR_GP_EESCLK
|SAR_GP_EECS
|SAR_GP_EEDO
);
426 for (i
= 0; i
< ARRAY_SIZE(rdtab
); i
++) {
427 idt77252_write_gp(card
, gp
| rdtab
[i
]);
430 idt77252_write_gp(card
, gp
| SAR_GP_EECS
);
433 for (i
= 0, j
= 0; i
< 8; i
++) {
434 idt77252_write_gp(card
, gp
| clktab
[j
++] |
435 (offset
& 1 ? SAR_GP_EEDO
: 0));
438 idt77252_write_gp(card
, gp
| clktab
[j
++] |
439 (offset
& 1 ? SAR_GP_EEDO
: 0));
444 idt77252_write_gp(card
, gp
| SAR_GP_EECS
);
448 for (i
= 0, j
= 0; i
< 8; i
++) {
451 idt77252_write_gp(card
, gp
| clktab
[j
++]);
454 byte
|= idt77252_read_gp(card
) & SAR_GP_EEDI
? 1 : 0;
456 idt77252_write_gp(card
, gp
| clktab
[j
++]);
459 idt77252_write_gp(card
, gp
| SAR_GP_EECS
);
466 idt77252_eeprom_write_byte(struct idt77252_dev
*card
, u8 offset
, u8 data
)
471 gp
= idt77252_read_gp(card
) & ~(SAR_GP_EESCLK
|SAR_GP_EECS
|SAR_GP_EEDO
);
473 for (i
= 0; i
< ARRAY_SIZE(wrentab
); i
++) {
474 idt77252_write_gp(card
, gp
| wrentab
[i
]);
477 idt77252_write_gp(card
, gp
| SAR_GP_EECS
);
480 for (i
= 0; i
< ARRAY_SIZE(wrtab
); i
++) {
481 idt77252_write_gp(card
, gp
| wrtab
[i
]);
484 idt77252_write_gp(card
, gp
| SAR_GP_EECS
);
487 for (i
= 0, j
= 0; i
< 8; i
++) {
488 idt77252_write_gp(card
, gp
| clktab
[j
++] |
489 (offset
& 1 ? SAR_GP_EEDO
: 0));
492 idt77252_write_gp(card
, gp
| clktab
[j
++] |
493 (offset
& 1 ? SAR_GP_EEDO
: 0));
498 idt77252_write_gp(card
, gp
| SAR_GP_EECS
);
501 for (i
= 0, j
= 0; i
< 8; i
++) {
502 idt77252_write_gp(card
, gp
| clktab
[j
++] |
503 (data
& 1 ? SAR_GP_EEDO
: 0));
506 idt77252_write_gp(card
, gp
| clktab
[j
++] |
507 (data
& 1 ? SAR_GP_EEDO
: 0));
512 idt77252_write_gp(card
, gp
| SAR_GP_EECS
);
517 idt77252_eeprom_init(struct idt77252_dev
*card
)
521 gp
= idt77252_read_gp(card
) & ~(SAR_GP_EESCLK
|SAR_GP_EECS
|SAR_GP_EEDO
);
523 idt77252_write_gp(card
, gp
| SAR_GP_EECS
| SAR_GP_EESCLK
);
525 idt77252_write_gp(card
, gp
| SAR_GP_EECS
);
527 idt77252_write_gp(card
, gp
| SAR_GP_EECS
| SAR_GP_EESCLK
);
529 idt77252_write_gp(card
, gp
| SAR_GP_EECS
);
532 #endif /* HAVE_EEPROM */
535 #ifdef CONFIG_ATM_IDT77252_DEBUG
537 dump_tct(struct idt77252_dev
*card
, int index
)
542 tct
= (unsigned long) (card
->tct_base
+ index
* SAR_SRAM_TCT_SIZE
);
544 printk("%s: TCT %x:", card
->name
, index
);
545 for (i
= 0; i
< 8; i
++) {
546 printk(" %08x", read_sram(card
, tct
+ i
));
552 idt77252_tx_dump(struct idt77252_dev
*card
)
558 <<<<<<< HEAD
:drivers
/atm
/idt77252
.c
559 printk("%s\n", __FUNCTION__
);
561 printk("%s\n", __func__
);
562 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/atm
/idt77252
.c
563 for (i
= 0; i
< card
->tct_size
; i
++) {
577 printk("%s: Connection %d:\n", card
->name
, vc
->index
);
578 dump_tct(card
, vc
->index
);
584 /*****************************************************************************/
588 /*****************************************************************************/
591 sb_pool_add(struct idt77252_dev
*card
, struct sk_buff
*skb
, int queue
)
593 struct sb_pool
*pool
= &card
->sbpool
[queue
];
597 while (pool
->skb
[index
]) {
598 index
= (index
+ 1) & FBQ_MASK
;
599 if (index
== pool
->index
)
603 pool
->skb
[index
] = skb
;
604 IDT77252_PRV_POOL(skb
) = POOL_HANDLE(queue
, index
);
606 pool
->index
= (index
+ 1) & FBQ_MASK
;
611 sb_pool_remove(struct idt77252_dev
*card
, struct sk_buff
*skb
)
613 unsigned int queue
, index
;
616 handle
= IDT77252_PRV_POOL(skb
);
618 queue
= POOL_QUEUE(handle
);
622 index
= POOL_INDEX(handle
);
623 if (index
> FBQ_SIZE
- 1)
626 card
->sbpool
[queue
].skb
[index
] = NULL
;
629 static struct sk_buff
*
630 sb_pool_skb(struct idt77252_dev
*card
, u32 handle
)
632 unsigned int queue
, index
;
634 queue
= POOL_QUEUE(handle
);
638 index
= POOL_INDEX(handle
);
639 if (index
> FBQ_SIZE
- 1)
642 return card
->sbpool
[queue
].skb
[index
];
645 static struct scq_info
*
646 alloc_scq(struct idt77252_dev
*card
, int class)
648 struct scq_info
*scq
;
650 scq
= kzalloc(sizeof(struct scq_info
), GFP_KERNEL
);
653 scq
->base
= pci_alloc_consistent(card
->pcidev
, SCQ_SIZE
,
655 if (scq
->base
== NULL
) {
659 memset(scq
->base
, 0, SCQ_SIZE
);
661 scq
->next
= scq
->base
;
662 scq
->last
= scq
->base
+ (SCQ_ENTRIES
- 1);
663 atomic_set(&scq
->used
, 0);
665 spin_lock_init(&scq
->lock
);
666 spin_lock_init(&scq
->skblock
);
668 skb_queue_head_init(&scq
->transmit
);
669 skb_queue_head_init(&scq
->pending
);
671 TXPRINTK("idt77252: SCQ: base 0x%p, next 0x%p, last 0x%p, paddr %08llx\n",
672 scq
->base
, scq
->next
, scq
->last
, (unsigned long long)scq
->paddr
);
678 free_scq(struct idt77252_dev
*card
, struct scq_info
*scq
)
683 pci_free_consistent(card
->pcidev
, SCQ_SIZE
,
684 scq
->base
, scq
->paddr
);
686 while ((skb
= skb_dequeue(&scq
->transmit
))) {
687 pci_unmap_single(card
->pcidev
, IDT77252_PRV_PADDR(skb
),
688 skb
->len
, PCI_DMA_TODEVICE
);
690 vcc
= ATM_SKB(skb
)->vcc
;
697 while ((skb
= skb_dequeue(&scq
->pending
))) {
698 pci_unmap_single(card
->pcidev
, IDT77252_PRV_PADDR(skb
),
699 skb
->len
, PCI_DMA_TODEVICE
);
701 vcc
= ATM_SKB(skb
)->vcc
;
713 push_on_scq(struct idt77252_dev
*card
, struct vc_map
*vc
, struct sk_buff
*skb
)
715 struct scq_info
*scq
= vc
->scq
;
720 TXPRINTK("%s: SCQ: next 0x%p\n", card
->name
, scq
->next
);
722 atomic_inc(&scq
->used
);
723 entries
= atomic_read(&scq
->used
);
724 if (entries
> (SCQ_ENTRIES
- 1)) {
725 atomic_dec(&scq
->used
);
729 skb_queue_tail(&scq
->transmit
, skb
);
731 spin_lock_irqsave(&vc
->lock
, flags
);
733 struct atm_vcc
*vcc
= vc
->tx_vcc
;
734 struct sock
*sk
= sk_atm(vcc
);
736 vc
->estimator
->cells
+= (skb
->len
+ 47) / 48;
737 if (atomic_read(&sk
->sk_wmem_alloc
) >
738 (sk
->sk_sndbuf
>> 1)) {
739 u32 cps
= vc
->estimator
->maxcps
;
741 vc
->estimator
->cps
= cps
;
742 vc
->estimator
->avcps
= cps
<< 5;
743 if (vc
->lacr
< vc
->init_er
) {
744 vc
->lacr
= vc
->init_er
;
745 writel(TCMDQ_LACR
| (vc
->lacr
<< 16) |
746 vc
->index
, SAR_REG_TCMDQ
);
750 spin_unlock_irqrestore(&vc
->lock
, flags
);
752 tbd
= &IDT77252_PRV_TBD(skb
);
754 spin_lock_irqsave(&scq
->lock
, flags
);
755 scq
->next
->word_1
= cpu_to_le32(tbd
->word_1
|
756 SAR_TBD_TSIF
| SAR_TBD_GTSI
);
757 scq
->next
->word_2
= cpu_to_le32(tbd
->word_2
);
758 scq
->next
->word_3
= cpu_to_le32(tbd
->word_3
);
759 scq
->next
->word_4
= cpu_to_le32(tbd
->word_4
);
761 if (scq
->next
== scq
->last
)
762 scq
->next
= scq
->base
;
766 write_sram(card
, scq
->scd
,
768 (u32
)((unsigned long)scq
->next
- (unsigned long)scq
->base
));
769 spin_unlock_irqrestore(&scq
->lock
, flags
);
771 scq
->trans_start
= jiffies
;
773 if (test_and_clear_bit(VCF_IDLE
, &vc
->flags
)) {
774 writel(TCMDQ_START_LACR
| (vc
->lacr
<< 16) | vc
->index
,
778 TXPRINTK("%d entries in SCQ used (push).\n", atomic_read(&scq
->used
));
780 XPRINTK("%s: SCQ (after push %2d) head = 0x%x, next = 0x%p.\n",
781 card
->name
, atomic_read(&scq
->used
),
782 read_sram(card
, scq
->scd
+ 1), scq
->next
);
787 if (time_after(jiffies
, scq
->trans_start
+ HZ
)) {
788 printk("%s: Error pushing TBD for %d.%d\n",
789 card
->name
, vc
->tx_vcc
->vpi
, vc
->tx_vcc
->vci
);
790 #ifdef CONFIG_ATM_IDT77252_DEBUG
791 idt77252_tx_dump(card
);
793 scq
->trans_start
= jiffies
;
801 drain_scq(struct idt77252_dev
*card
, struct vc_map
*vc
)
803 struct scq_info
*scq
= vc
->scq
;
807 TXPRINTK("%s: SCQ (before drain %2d) next = 0x%p.\n",
808 card
->name
, atomic_read(&scq
->used
), scq
->next
);
810 skb
= skb_dequeue(&scq
->transmit
);
812 TXPRINTK("%s: freeing skb at %p.\n", card
->name
, skb
);
814 pci_unmap_single(card
->pcidev
, IDT77252_PRV_PADDR(skb
),
815 skb
->len
, PCI_DMA_TODEVICE
);
817 vcc
= ATM_SKB(skb
)->vcc
;
824 atomic_inc(&vcc
->stats
->tx
);
827 atomic_dec(&scq
->used
);
829 spin_lock(&scq
->skblock
);
830 while ((skb
= skb_dequeue(&scq
->pending
))) {
831 if (push_on_scq(card
, vc
, skb
)) {
832 skb_queue_head(&vc
->scq
->pending
, skb
);
836 spin_unlock(&scq
->skblock
);
840 queue_skb(struct idt77252_dev
*card
, struct vc_map
*vc
,
841 struct sk_buff
*skb
, int oam
)
850 printk("%s: invalid skb->len (%d)\n", card
->name
, skb
->len
);
854 TXPRINTK("%s: Sending %d bytes of data.\n",
855 card
->name
, skb
->len
);
857 tbd
= &IDT77252_PRV_TBD(skb
);
858 vcc
= ATM_SKB(skb
)->vcc
;
860 IDT77252_PRV_PADDR(skb
) = pci_map_single(card
->pcidev
, skb
->data
,
861 skb
->len
, PCI_DMA_TODEVICE
);
869 tbd
->word_1
= SAR_TBD_OAM
| ATM_CELL_PAYLOAD
| SAR_TBD_EPDU
;
870 tbd
->word_2
= IDT77252_PRV_PADDR(skb
) + 4;
871 tbd
->word_3
= 0x00000000;
872 tbd
->word_4
= (skb
->data
[0] << 24) | (skb
->data
[1] << 16) |
873 (skb
->data
[2] << 8) | (skb
->data
[3] << 0);
875 if (test_bit(VCF_RSV
, &vc
->flags
))
881 if (test_bit(VCF_RSV
, &vc
->flags
)) {
882 printk("%s: Trying to transmit on reserved VC\n", card
->name
);
895 tbd
->word_1
= SAR_TBD_EPDU
| SAR_TBD_AAL0
|
898 tbd
->word_1
= SAR_TBD_EPDU
| SAR_TBD_AAL34
|
901 tbd
->word_2
= IDT77252_PRV_PADDR(skb
) + 4;
902 tbd
->word_3
= 0x00000000;
903 tbd
->word_4
= (skb
->data
[0] << 24) | (skb
->data
[1] << 16) |
904 (skb
->data
[2] << 8) | (skb
->data
[3] << 0);
908 tbd
->word_1
= SAR_TBD_EPDU
| SAR_TBD_AAL5
| skb
->len
;
909 tbd
->word_2
= IDT77252_PRV_PADDR(skb
);
910 tbd
->word_3
= skb
->len
;
911 tbd
->word_4
= (vcc
->vpi
<< SAR_TBD_VPI_SHIFT
) |
912 (vcc
->vci
<< SAR_TBD_VCI_SHIFT
);
918 printk("%s: Traffic type not supported.\n", card
->name
);
919 error
= -EPROTONOSUPPORT
;
924 spin_lock_irqsave(&vc
->scq
->skblock
, flags
);
925 skb_queue_tail(&vc
->scq
->pending
, skb
);
927 while ((skb
= skb_dequeue(&vc
->scq
->pending
))) {
928 if (push_on_scq(card
, vc
, skb
)) {
929 skb_queue_head(&vc
->scq
->pending
, skb
);
933 spin_unlock_irqrestore(&vc
->scq
->skblock
, flags
);
938 pci_unmap_single(card
->pcidev
, IDT77252_PRV_PADDR(skb
),
939 skb
->len
, PCI_DMA_TODEVICE
);
944 get_free_scd(struct idt77252_dev
*card
, struct vc_map
*vc
)
948 for (i
= 0; i
< card
->scd_size
; i
++) {
949 if (!card
->scd2vc
[i
]) {
950 card
->scd2vc
[i
] = vc
;
952 return card
->scd_base
+ i
* SAR_SRAM_SCD_SIZE
;
959 fill_scd(struct idt77252_dev
*card
, struct scq_info
*scq
, int class)
961 write_sram(card
, scq
->scd
, scq
->paddr
);
962 write_sram(card
, scq
->scd
+ 1, 0x00000000);
963 write_sram(card
, scq
->scd
+ 2, 0xffffffff);
964 write_sram(card
, scq
->scd
+ 3, 0x00000000);
968 clear_scd(struct idt77252_dev
*card
, struct scq_info
*scq
, int class)
973 /*****************************************************************************/
977 /*****************************************************************************/
980 init_rsq(struct idt77252_dev
*card
)
982 struct rsq_entry
*rsqe
;
984 card
->rsq
.base
= pci_alloc_consistent(card
->pcidev
, RSQSIZE
,
986 if (card
->rsq
.base
== NULL
) {
987 printk("%s: can't allocate RSQ.\n", card
->name
);
990 memset(card
->rsq
.base
, 0, RSQSIZE
);
992 card
->rsq
.last
= card
->rsq
.base
+ RSQ_NUM_ENTRIES
- 1;
993 card
->rsq
.next
= card
->rsq
.last
;
994 for (rsqe
= card
->rsq
.base
; rsqe
<= card
->rsq
.last
; rsqe
++)
997 writel((unsigned long) card
->rsq
.last
- (unsigned long) card
->rsq
.base
,
999 writel(card
->rsq
.paddr
, SAR_REG_RSQB
);
1001 IPRINTK("%s: RSQ base at 0x%lx (0x%x).\n", card
->name
,
1002 (unsigned long) card
->rsq
.base
,
1003 readl(SAR_REG_RSQB
));
1004 IPRINTK("%s: RSQ head = 0x%x, base = 0x%x, tail = 0x%x.\n",
1006 readl(SAR_REG_RSQH
),
1007 readl(SAR_REG_RSQB
),
1008 readl(SAR_REG_RSQT
));
1014 deinit_rsq(struct idt77252_dev
*card
)
1016 pci_free_consistent(card
->pcidev
, RSQSIZE
,
1017 card
->rsq
.base
, card
->rsq
.paddr
);
1021 dequeue_rx(struct idt77252_dev
*card
, struct rsq_entry
*rsqe
)
1023 struct atm_vcc
*vcc
;
1024 struct sk_buff
*skb
;
1025 struct rx_pool
*rpp
;
1027 u32 header
, vpi
, vci
;
1031 stat
= le32_to_cpu(rsqe
->word_4
);
1033 if (stat
& SAR_RSQE_IDLE
) {
1034 RXPRINTK("%s: message about inactive connection.\n",
1039 skb
= sb_pool_skb(card
, le32_to_cpu(rsqe
->word_2
));
1041 printk("%s: NULL skb in %s, rsqe: %08x %08x %08x %08x\n",
1042 <<<<<<< HEAD
:drivers
/atm
/idt77252
.c
1043 card
->name
, __FUNCTION__
,
1045 card
->name
, __func__
,
1046 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/atm
/idt77252
.c
1047 le32_to_cpu(rsqe
->word_1
), le32_to_cpu(rsqe
->word_2
),
1048 le32_to_cpu(rsqe
->word_3
), le32_to_cpu(rsqe
->word_4
));
1052 header
= le32_to_cpu(rsqe
->word_1
);
1053 vpi
= (header
>> 16) & 0x00ff;
1054 vci
= (header
>> 0) & 0xffff;
1056 RXPRINTK("%s: SDU for %d.%d received in buffer 0x%p (data 0x%p).\n",
1057 card
->name
, vpi
, vci
, skb
, skb
->data
);
1059 if ((vpi
>= (1 << card
->vpibits
)) || (vci
!= (vci
& card
->vcimask
))) {
1060 printk("%s: SDU received for out-of-range vc %u.%u\n",
1061 card
->name
, vpi
, vci
);
1062 recycle_rx_skb(card
, skb
);
1066 vc
= card
->vcs
[VPCI2VC(card
, vpi
, vci
)];
1067 if (!vc
|| !test_bit(VCF_RX
, &vc
->flags
)) {
1068 printk("%s: SDU received on non RX vc %u.%u\n",
1069 card
->name
, vpi
, vci
);
1070 recycle_rx_skb(card
, skb
);
1076 pci_dma_sync_single_for_cpu(card
->pcidev
, IDT77252_PRV_PADDR(skb
),
1077 skb_end_pointer(skb
) - skb
->data
,
1078 PCI_DMA_FROMDEVICE
);
1080 if ((vcc
->qos
.aal
== ATM_AAL0
) ||
1081 (vcc
->qos
.aal
== ATM_AAL34
)) {
1083 unsigned char *cell
;
1087 for (i
= (stat
& SAR_RSQE_CELLCNT
); i
; i
--) {
1088 if ((sb
= dev_alloc_skb(64)) == NULL
) {
1089 printk("%s: Can't allocate buffers for aal0.\n",
1091 atomic_add(i
, &vcc
->stats
->rx_drop
);
1094 if (!atm_charge(vcc
, sb
->truesize
)) {
1095 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
1097 atomic_add(i
- 1, &vcc
->stats
->rx_drop
);
1101 aal0
= (vpi
<< ATM_HDR_VPI_SHIFT
) |
1102 (vci
<< ATM_HDR_VCI_SHIFT
);
1103 aal0
|= (stat
& SAR_RSQE_EPDU
) ? 0x00000002 : 0;
1104 aal0
|= (stat
& SAR_RSQE_CLP
) ? 0x00000001 : 0;
1106 *((u32
*) sb
->data
) = aal0
;
1107 skb_put(sb
, sizeof(u32
));
1108 memcpy(skb_put(sb
, ATM_CELL_PAYLOAD
),
1109 cell
, ATM_CELL_PAYLOAD
);
1111 ATM_SKB(sb
)->vcc
= vcc
;
1112 __net_timestamp(sb
);
1114 atomic_inc(&vcc
->stats
->rx
);
1116 cell
+= ATM_CELL_PAYLOAD
;
1119 recycle_rx_skb(card
, skb
);
1122 if (vcc
->qos
.aal
!= ATM_AAL5
) {
1123 printk("%s: Unexpected AAL type in dequeue_rx(): %d.\n",
1124 card
->name
, vcc
->qos
.aal
);
1125 recycle_rx_skb(card
, skb
);
1128 skb
->len
= (stat
& SAR_RSQE_CELLCNT
) * ATM_CELL_PAYLOAD
;
1130 rpp
= &vc
->rcv
.rx_pool
;
1132 rpp
->len
+= skb
->len
;
1136 rpp
->last
= &skb
->next
;
1138 if (stat
& SAR_RSQE_EPDU
) {
1139 unsigned char *l1l2
;
1142 l1l2
= (unsigned char *) ((unsigned long) skb
->data
+ skb
->len
- 6);
1144 len
= (l1l2
[0] << 8) | l1l2
[1];
1145 len
= len
? len
: 0x10000;
1147 RXPRINTK("%s: PDU has %d bytes.\n", card
->name
, len
);
1149 if ((len
+ 8 > rpp
->len
) || (len
+ (47 + 8) < rpp
->len
)) {
1150 RXPRINTK("%s: AAL5 PDU size mismatch: %d != %d. "
1152 card
->name
, len
, rpp
->len
, readl(SAR_REG_CDC
));
1153 recycle_rx_pool_skb(card
, rpp
);
1154 atomic_inc(&vcc
->stats
->rx_err
);
1157 if (stat
& SAR_RSQE_CRC
) {
1158 RXPRINTK("%s: AAL5 CRC error.\n", card
->name
);
1159 recycle_rx_pool_skb(card
, rpp
);
1160 atomic_inc(&vcc
->stats
->rx_err
);
1163 if (rpp
->count
> 1) {
1166 skb
= dev_alloc_skb(rpp
->len
);
1168 RXPRINTK("%s: Can't alloc RX skb.\n",
1170 recycle_rx_pool_skb(card
, rpp
);
1171 atomic_inc(&vcc
->stats
->rx_err
);
1174 if (!atm_charge(vcc
, skb
->truesize
)) {
1175 recycle_rx_pool_skb(card
, rpp
);
1180 for (i
= 0; i
< rpp
->count
; i
++) {
1181 memcpy(skb_put(skb
, sb
->len
),
1186 recycle_rx_pool_skb(card
, rpp
);
1189 ATM_SKB(skb
)->vcc
= vcc
;
1190 __net_timestamp(skb
);
1192 vcc
->push(vcc
, skb
);
1193 atomic_inc(&vcc
->stats
->rx
);
1199 flush_rx_pool(card
, rpp
);
1201 if (!atm_charge(vcc
, skb
->truesize
)) {
1202 recycle_rx_skb(card
, skb
);
1206 pci_unmap_single(card
->pcidev
, IDT77252_PRV_PADDR(skb
),
1207 skb_end_pointer(skb
) - skb
->data
,
1208 PCI_DMA_FROMDEVICE
);
1209 sb_pool_remove(card
, skb
);
1212 ATM_SKB(skb
)->vcc
= vcc
;
1213 __net_timestamp(skb
);
1215 vcc
->push(vcc
, skb
);
1216 atomic_inc(&vcc
->stats
->rx
);
1218 if (skb
->truesize
> SAR_FB_SIZE_3
)
1219 add_rx_skb(card
, 3, SAR_FB_SIZE_3
, 1);
1220 else if (skb
->truesize
> SAR_FB_SIZE_2
)
1221 add_rx_skb(card
, 2, SAR_FB_SIZE_2
, 1);
1222 else if (skb
->truesize
> SAR_FB_SIZE_1
)
1223 add_rx_skb(card
, 1, SAR_FB_SIZE_1
, 1);
1225 add_rx_skb(card
, 0, SAR_FB_SIZE_0
, 1);
1231 idt77252_rx(struct idt77252_dev
*card
)
1233 struct rsq_entry
*rsqe
;
1235 if (card
->rsq
.next
== card
->rsq
.last
)
1236 rsqe
= card
->rsq
.base
;
1238 rsqe
= card
->rsq
.next
+ 1;
1240 if (!(le32_to_cpu(rsqe
->word_4
) & SAR_RSQE_VALID
)) {
1241 RXPRINTK("%s: no entry in RSQ.\n", card
->name
);
1246 dequeue_rx(card
, rsqe
);
1248 card
->rsq
.next
= rsqe
;
1249 if (card
->rsq
.next
== card
->rsq
.last
)
1250 rsqe
= card
->rsq
.base
;
1252 rsqe
= card
->rsq
.next
+ 1;
1253 } while (le32_to_cpu(rsqe
->word_4
) & SAR_RSQE_VALID
);
1255 writel((unsigned long) card
->rsq
.next
- (unsigned long) card
->rsq
.base
,
1260 idt77252_rx_raw(struct idt77252_dev
*card
)
1262 struct sk_buff
*queue
;
1264 struct atm_vcc
*vcc
;
1268 if (card
->raw_cell_head
== NULL
) {
1269 u32 handle
= le32_to_cpu(*(card
->raw_cell_hnd
+ 1));
1270 card
->raw_cell_head
= sb_pool_skb(card
, handle
);
1273 queue
= card
->raw_cell_head
;
1277 head
= IDT77252_PRV_PADDR(queue
) + (queue
->data
- queue
->head
- 16);
1278 tail
= readl(SAR_REG_RAWCT
);
1280 pci_dma_sync_single_for_cpu(card
->pcidev
, IDT77252_PRV_PADDR(queue
),
1281 skb_end_pointer(queue
) - queue
->head
- 16,
1282 PCI_DMA_FROMDEVICE
);
1284 while (head
!= tail
) {
1285 unsigned int vpi
, vci
, pti
;
1288 header
= le32_to_cpu(*(u32
*) &queue
->data
[0]);
1290 vpi
= (header
& ATM_HDR_VPI_MASK
) >> ATM_HDR_VPI_SHIFT
;
1291 vci
= (header
& ATM_HDR_VCI_MASK
) >> ATM_HDR_VCI_SHIFT
;
1292 pti
= (header
& ATM_HDR_PTI_MASK
) >> ATM_HDR_PTI_SHIFT
;
1294 #ifdef CONFIG_ATM_IDT77252_DEBUG
1295 if (debug
& DBG_RAW_CELL
) {
1298 printk("%s: raw cell %x.%02x.%04x.%x.%x\n",
1299 card
->name
, (header
>> 28) & 0x000f,
1300 (header
>> 20) & 0x00ff,
1301 (header
>> 4) & 0xffff,
1302 (header
>> 1) & 0x0007,
1303 (header
>> 0) & 0x0001);
1304 for (i
= 16; i
< 64; i
++)
1305 printk(" %02x", queue
->data
[i
]);
1310 if (vpi
>= (1<<card
->vpibits
) || vci
>= (1<<card
->vcibits
)) {
1311 RPRINTK("%s: SDU received for out-of-range vc %u.%u\n",
1312 card
->name
, vpi
, vci
);
1316 vc
= card
->vcs
[VPCI2VC(card
, vpi
, vci
)];
1317 if (!vc
|| !test_bit(VCF_RX
, &vc
->flags
)) {
1318 RPRINTK("%s: SDU received on non RX vc %u.%u\n",
1319 card
->name
, vpi
, vci
);
1325 if (vcc
->qos
.aal
!= ATM_AAL0
) {
1326 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
1327 card
->name
, vpi
, vci
);
1328 atomic_inc(&vcc
->stats
->rx_drop
);
1332 if ((sb
= dev_alloc_skb(64)) == NULL
) {
1333 printk("%s: Can't allocate buffers for AAL0.\n",
1335 atomic_inc(&vcc
->stats
->rx_err
);
1339 if (!atm_charge(vcc
, sb
->truesize
)) {
1340 RXPRINTK("%s: atm_charge() dropped AAL0 packets.\n",
1346 *((u32
*) sb
->data
) = header
;
1347 skb_put(sb
, sizeof(u32
));
1348 memcpy(skb_put(sb
, ATM_CELL_PAYLOAD
), &(queue
->data
[16]),
1351 ATM_SKB(sb
)->vcc
= vcc
;
1352 __net_timestamp(sb
);
1354 atomic_inc(&vcc
->stats
->rx
);
1357 skb_pull(queue
, 64);
1359 head
= IDT77252_PRV_PADDR(queue
)
1360 + (queue
->data
- queue
->head
- 16);
1362 if (queue
->len
< 128) {
1363 struct sk_buff
*next
;
1366 head
= le32_to_cpu(*(u32
*) &queue
->data
[0]);
1367 handle
= le32_to_cpu(*(u32
*) &queue
->data
[4]);
1369 next
= sb_pool_skb(card
, handle
);
1370 recycle_rx_skb(card
, queue
);
1373 card
->raw_cell_head
= next
;
1374 queue
= card
->raw_cell_head
;
1375 pci_dma_sync_single_for_cpu(card
->pcidev
,
1376 IDT77252_PRV_PADDR(queue
),
1377 (skb_end_pointer(queue
) -
1379 PCI_DMA_FROMDEVICE
);
1381 card
->raw_cell_head
= NULL
;
1382 printk("%s: raw cell queue overrun\n",
1391 /*****************************************************************************/
1395 /*****************************************************************************/
1398 init_tsq(struct idt77252_dev
*card
)
1400 struct tsq_entry
*tsqe
;
1402 card
->tsq
.base
= pci_alloc_consistent(card
->pcidev
, RSQSIZE
,
1404 if (card
->tsq
.base
== NULL
) {
1405 printk("%s: can't allocate TSQ.\n", card
->name
);
1408 memset(card
->tsq
.base
, 0, TSQSIZE
);
1410 card
->tsq
.last
= card
->tsq
.base
+ TSQ_NUM_ENTRIES
- 1;
1411 card
->tsq
.next
= card
->tsq
.last
;
1412 for (tsqe
= card
->tsq
.base
; tsqe
<= card
->tsq
.last
; tsqe
++)
1413 tsqe
->word_2
= cpu_to_le32(SAR_TSQE_INVALID
);
1415 writel(card
->tsq
.paddr
, SAR_REG_TSQB
);
1416 writel((unsigned long) card
->tsq
.next
- (unsigned long) card
->tsq
.base
,
1423 deinit_tsq(struct idt77252_dev
*card
)
1425 pci_free_consistent(card
->pcidev
, TSQSIZE
,
1426 card
->tsq
.base
, card
->tsq
.paddr
);
1430 idt77252_tx(struct idt77252_dev
*card
)
1432 struct tsq_entry
*tsqe
;
1433 unsigned int vpi
, vci
;
1437 if (card
->tsq
.next
== card
->tsq
.last
)
1438 tsqe
= card
->tsq
.base
;
1440 tsqe
= card
->tsq
.next
+ 1;
1442 TXPRINTK("idt77252_tx: tsq %p: base %p, next %p, last %p\n", tsqe
,
1443 card
->tsq
.base
, card
->tsq
.next
, card
->tsq
.last
);
1444 TXPRINTK("idt77252_tx: tsqb %08x, tsqt %08x, tsqh %08x, \n",
1445 readl(SAR_REG_TSQB
),
1446 readl(SAR_REG_TSQT
),
1447 readl(SAR_REG_TSQH
));
1449 stat
= le32_to_cpu(tsqe
->word_2
);
1451 if (stat
& SAR_TSQE_INVALID
)
1455 TXPRINTK("tsqe: 0x%p [0x%08x 0x%08x]\n", tsqe
,
1456 le32_to_cpu(tsqe
->word_1
),
1457 le32_to_cpu(tsqe
->word_2
));
1459 switch (stat
& SAR_TSQE_TYPE
) {
1460 case SAR_TSQE_TYPE_TIMER
:
1461 TXPRINTK("%s: Timer RollOver detected.\n", card
->name
);
1464 case SAR_TSQE_TYPE_IDLE
:
1466 conn
= le32_to_cpu(tsqe
->word_1
);
1468 if (SAR_TSQE_TAG(stat
) == 0x10) {
1470 printk("%s: Connection %d halted.\n",
1472 le32_to_cpu(tsqe
->word_1
) & 0x1fff);
1477 vc
= card
->vcs
[conn
& 0x1fff];
1479 printk("%s: could not find VC from conn %d\n",
1480 card
->name
, conn
& 0x1fff);
1484 printk("%s: Connection %d IDLE.\n",
1485 card
->name
, vc
->index
);
1487 set_bit(VCF_IDLE
, &vc
->flags
);
1490 case SAR_TSQE_TYPE_TSR
:
1492 conn
= le32_to_cpu(tsqe
->word_1
);
1494 vc
= card
->vcs
[conn
& 0x1fff];
1496 printk("%s: no VC at index %d\n",
1498 le32_to_cpu(tsqe
->word_1
) & 0x1fff);
1502 drain_scq(card
, vc
);
1505 case SAR_TSQE_TYPE_TBD_COMP
:
1507 conn
= le32_to_cpu(tsqe
->word_1
);
1509 vpi
= (conn
>> SAR_TBD_VPI_SHIFT
) & 0x00ff;
1510 vci
= (conn
>> SAR_TBD_VCI_SHIFT
) & 0xffff;
1512 if (vpi
>= (1 << card
->vpibits
) ||
1513 vci
>= (1 << card
->vcibits
)) {
1514 printk("%s: TBD complete: "
1515 "out of range VPI.VCI %u.%u\n",
1516 card
->name
, vpi
, vci
);
1520 vc
= card
->vcs
[VPCI2VC(card
, vpi
, vci
)];
1522 printk("%s: TBD complete: "
1523 "no VC at VPI.VCI %u.%u\n",
1524 card
->name
, vpi
, vci
);
1528 drain_scq(card
, vc
);
1532 tsqe
->word_2
= cpu_to_le32(SAR_TSQE_INVALID
);
1534 card
->tsq
.next
= tsqe
;
1535 if (card
->tsq
.next
== card
->tsq
.last
)
1536 tsqe
= card
->tsq
.base
;
1538 tsqe
= card
->tsq
.next
+ 1;
1540 TXPRINTK("tsqe: %p: base %p, next %p, last %p\n", tsqe
,
1541 card
->tsq
.base
, card
->tsq
.next
, card
->tsq
.last
);
1543 stat
= le32_to_cpu(tsqe
->word_2
);
1545 } while (!(stat
& SAR_TSQE_INVALID
));
1547 writel((unsigned long)card
->tsq
.next
- (unsigned long)card
->tsq
.base
,
1550 XPRINTK("idt77252_tx-after writel%d: TSQ head = 0x%x, tail = 0x%x, next = 0x%p.\n",
1551 card
->index
, readl(SAR_REG_TSQH
),
1552 readl(SAR_REG_TSQT
), card
->tsq
.next
);
1557 tst_timer(unsigned long data
)
1559 struct idt77252_dev
*card
= (struct idt77252_dev
*)data
;
1560 unsigned long base
, idle
, jump
;
1561 unsigned long flags
;
1565 spin_lock_irqsave(&card
->tst_lock
, flags
);
1567 base
= card
->tst
[card
->tst_index
];
1568 idle
= card
->tst
[card
->tst_index
^ 1];
1570 if (test_bit(TST_SWITCH_WAIT
, &card
->tst_state
)) {
1571 jump
= base
+ card
->tst_size
- 2;
1573 pc
= readl(SAR_REG_NOW
) >> 2;
1574 if ((pc
^ idle
) & ~(card
->tst_size
- 1)) {
1575 mod_timer(&card
->tst_timer
, jiffies
+ 1);
1579 clear_bit(TST_SWITCH_WAIT
, &card
->tst_state
);
1581 card
->tst_index
^= 1;
1582 write_sram(card
, jump
, TSTE_OPC_JMP
| (base
<< 2));
1584 base
= card
->tst
[card
->tst_index
];
1585 idle
= card
->tst
[card
->tst_index
^ 1];
1587 for (e
= 0; e
< card
->tst_size
- 2; e
++) {
1588 if (card
->soft_tst
[e
].tste
& TSTE_PUSH_IDLE
) {
1589 write_sram(card
, idle
+ e
,
1590 card
->soft_tst
[e
].tste
& TSTE_MASK
);
1591 card
->soft_tst
[e
].tste
&= ~(TSTE_PUSH_IDLE
);
1596 if (test_and_clear_bit(TST_SWITCH_PENDING
, &card
->tst_state
)) {
1598 for (e
= 0; e
< card
->tst_size
- 2; e
++) {
1599 if (card
->soft_tst
[e
].tste
& TSTE_PUSH_ACTIVE
) {
1600 write_sram(card
, idle
+ e
,
1601 card
->soft_tst
[e
].tste
& TSTE_MASK
);
1602 card
->soft_tst
[e
].tste
&= ~(TSTE_PUSH_ACTIVE
);
1603 card
->soft_tst
[e
].tste
|= TSTE_PUSH_IDLE
;
1607 jump
= base
+ card
->tst_size
- 2;
1609 write_sram(card
, jump
, TSTE_OPC_NULL
);
1610 set_bit(TST_SWITCH_WAIT
, &card
->tst_state
);
1612 mod_timer(&card
->tst_timer
, jiffies
+ 1);
1616 spin_unlock_irqrestore(&card
->tst_lock
, flags
);
1620 __fill_tst(struct idt77252_dev
*card
, struct vc_map
*vc
,
1621 int n
, unsigned int opc
)
1623 unsigned long cl
, avail
;
1628 avail
= card
->tst_size
- 2;
1629 for (e
= 0; e
< avail
; e
++) {
1630 if (card
->soft_tst
[e
].vc
== NULL
)
1634 printk("%s: No free TST entries found\n", card
->name
);
1638 NPRINTK("%s: conn %d: first TST entry at %d.\n",
1639 card
->name
, vc
? vc
->index
: -1, e
);
1643 data
= opc
& TSTE_OPC_MASK
;
1644 if (vc
&& (opc
!= TSTE_OPC_NULL
))
1645 data
= opc
| vc
->index
;
1647 idle
= card
->tst
[card
->tst_index
^ 1];
1653 if ((cl
>= avail
) && (card
->soft_tst
[e
].vc
== NULL
)) {
1655 card
->soft_tst
[e
].vc
= vc
;
1657 card
->soft_tst
[e
].vc
= (void *)-1;
1659 card
->soft_tst
[e
].tste
= data
;
1660 if (timer_pending(&card
->tst_timer
))
1661 card
->soft_tst
[e
].tste
|= TSTE_PUSH_ACTIVE
;
1663 write_sram(card
, idle
+ e
, data
);
1664 card
->soft_tst
[e
].tste
|= TSTE_PUSH_IDLE
;
1667 cl
-= card
->tst_size
;
1680 fill_tst(struct idt77252_dev
*card
, struct vc_map
*vc
, int n
, unsigned int opc
)
1682 unsigned long flags
;
1685 spin_lock_irqsave(&card
->tst_lock
, flags
);
1687 res
= __fill_tst(card
, vc
, n
, opc
);
1689 set_bit(TST_SWITCH_PENDING
, &card
->tst_state
);
1690 if (!timer_pending(&card
->tst_timer
))
1691 mod_timer(&card
->tst_timer
, jiffies
+ 1);
1693 spin_unlock_irqrestore(&card
->tst_lock
, flags
);
1698 __clear_tst(struct idt77252_dev
*card
, struct vc_map
*vc
)
1703 idle
= card
->tst
[card
->tst_index
^ 1];
1705 for (e
= 0; e
< card
->tst_size
- 2; e
++) {
1706 if (card
->soft_tst
[e
].vc
== vc
) {
1707 card
->soft_tst
[e
].vc
= NULL
;
1709 card
->soft_tst
[e
].tste
= TSTE_OPC_VAR
;
1710 if (timer_pending(&card
->tst_timer
))
1711 card
->soft_tst
[e
].tste
|= TSTE_PUSH_ACTIVE
;
1713 write_sram(card
, idle
+ e
, TSTE_OPC_VAR
);
1714 card
->soft_tst
[e
].tste
|= TSTE_PUSH_IDLE
;
1723 clear_tst(struct idt77252_dev
*card
, struct vc_map
*vc
)
1725 unsigned long flags
;
1728 spin_lock_irqsave(&card
->tst_lock
, flags
);
1730 res
= __clear_tst(card
, vc
);
1732 set_bit(TST_SWITCH_PENDING
, &card
->tst_state
);
1733 if (!timer_pending(&card
->tst_timer
))
1734 mod_timer(&card
->tst_timer
, jiffies
+ 1);
1736 spin_unlock_irqrestore(&card
->tst_lock
, flags
);
1741 change_tst(struct idt77252_dev
*card
, struct vc_map
*vc
,
1742 int n
, unsigned int opc
)
1744 unsigned long flags
;
1747 spin_lock_irqsave(&card
->tst_lock
, flags
);
1749 __clear_tst(card
, vc
);
1750 res
= __fill_tst(card
, vc
, n
, opc
);
1752 set_bit(TST_SWITCH_PENDING
, &card
->tst_state
);
1753 if (!timer_pending(&card
->tst_timer
))
1754 mod_timer(&card
->tst_timer
, jiffies
+ 1);
1756 spin_unlock_irqrestore(&card
->tst_lock
, flags
);
1762 set_tct(struct idt77252_dev
*card
, struct vc_map
*vc
)
1766 tct
= (unsigned long) (card
->tct_base
+ vc
->index
* SAR_SRAM_TCT_SIZE
);
1768 switch (vc
->class) {
1770 OPRINTK("%s: writing TCT at 0x%lx, SCD 0x%lx.\n",
1771 card
->name
, tct
, vc
->scq
->scd
);
1773 write_sram(card
, tct
+ 0, TCT_CBR
| vc
->scq
->scd
);
1774 write_sram(card
, tct
+ 1, 0);
1775 write_sram(card
, tct
+ 2, 0);
1776 write_sram(card
, tct
+ 3, 0);
1777 write_sram(card
, tct
+ 4, 0);
1778 write_sram(card
, tct
+ 5, 0);
1779 write_sram(card
, tct
+ 6, 0);
1780 write_sram(card
, tct
+ 7, 0);
1784 OPRINTK("%s: writing TCT at 0x%lx, SCD 0x%lx.\n",
1785 card
->name
, tct
, vc
->scq
->scd
);
1787 write_sram(card
, tct
+ 0, TCT_UBR
| vc
->scq
->scd
);
1788 write_sram(card
, tct
+ 1, 0);
1789 write_sram(card
, tct
+ 2, TCT_TSIF
);
1790 write_sram(card
, tct
+ 3, TCT_HALT
| TCT_IDLE
);
1791 write_sram(card
, tct
+ 4, 0);
1792 write_sram(card
, tct
+ 5, vc
->init_er
);
1793 write_sram(card
, tct
+ 6, 0);
1794 write_sram(card
, tct
+ 7, TCT_FLAG_UBR
);
1806 /*****************************************************************************/
1810 /*****************************************************************************/
1812 static __inline__
int
1813 idt77252_fbq_level(struct idt77252_dev
*card
, int queue
)
1815 return (readl(SAR_REG_STAT
) >> (16 + (queue
<< 2))) & 0x0f;
1818 static __inline__
int
1819 idt77252_fbq_full(struct idt77252_dev
*card
, int queue
)
1821 return (readl(SAR_REG_STAT
) >> (16 + (queue
<< 2))) == 0x0f;
1825 push_rx_skb(struct idt77252_dev
*card
, struct sk_buff
*skb
, int queue
)
1827 unsigned long flags
;
1831 skb
->data
= skb
->head
;
1832 skb_reset_tail_pointer(skb
);
1835 skb_reserve(skb
, 16);
1839 skb_put(skb
, SAR_FB_SIZE_0
);
1842 skb_put(skb
, SAR_FB_SIZE_1
);
1845 skb_put(skb
, SAR_FB_SIZE_2
);
1848 skb_put(skb
, SAR_FB_SIZE_3
);
1854 if (idt77252_fbq_full(card
, queue
))
1857 memset(&skb
->data
[(skb
->len
& ~(0x3f)) - 64], 0, 2 * sizeof(u32
));
1859 handle
= IDT77252_PRV_POOL(skb
);
1860 addr
= IDT77252_PRV_PADDR(skb
);
1862 spin_lock_irqsave(&card
->cmd_lock
, flags
);
1863 writel(handle
, card
->fbq
[queue
]);
1864 writel(addr
, card
->fbq
[queue
]);
1865 spin_unlock_irqrestore(&card
->cmd_lock
, flags
);
1871 add_rx_skb(struct idt77252_dev
*card
, int queue
,
1872 unsigned int size
, unsigned int count
)
1874 struct sk_buff
*skb
;
1879 skb
= dev_alloc_skb(size
);
1883 if (sb_pool_add(card
, skb
, queue
)) {
1884 <<<<<<< HEAD
:drivers
/atm
/idt77252
.c
1885 printk("%s: SB POOL full\n", __FUNCTION__
);
1887 printk("%s: SB POOL full\n", __func__
);
1888 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/atm
/idt77252
.c
1892 paddr
= pci_map_single(card
->pcidev
, skb
->data
,
1893 skb_end_pointer(skb
) - skb
->data
,
1894 PCI_DMA_FROMDEVICE
);
1895 IDT77252_PRV_PADDR(skb
) = paddr
;
1897 if (push_rx_skb(card
, skb
, queue
)) {
1898 <<<<<<< HEAD
:drivers
/atm
/idt77252
.c
1899 printk("%s: FB QUEUE full\n", __FUNCTION__
);
1901 printk("%s: FB QUEUE full\n", __func__
);
1902 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/atm
/idt77252
.c
1910 pci_unmap_single(card
->pcidev
, IDT77252_PRV_PADDR(skb
),
1911 skb_end_pointer(skb
) - skb
->data
, PCI_DMA_FROMDEVICE
);
1913 handle
= IDT77252_PRV_POOL(skb
);
1914 card
->sbpool
[POOL_QUEUE(handle
)].skb
[POOL_INDEX(handle
)] = NULL
;
1922 recycle_rx_skb(struct idt77252_dev
*card
, struct sk_buff
*skb
)
1924 u32 handle
= IDT77252_PRV_POOL(skb
);
1927 pci_dma_sync_single_for_device(card
->pcidev
, IDT77252_PRV_PADDR(skb
),
1928 skb_end_pointer(skb
) - skb
->data
,
1929 PCI_DMA_FROMDEVICE
);
1931 err
= push_rx_skb(card
, skb
, POOL_QUEUE(handle
));
1933 pci_unmap_single(card
->pcidev
, IDT77252_PRV_PADDR(skb
),
1934 skb_end_pointer(skb
) - skb
->data
,
1935 PCI_DMA_FROMDEVICE
);
1936 sb_pool_remove(card
, skb
);
1942 flush_rx_pool(struct idt77252_dev
*card
, struct rx_pool
*rpp
)
1947 rpp
->last
= &rpp
->first
;
1951 recycle_rx_pool_skb(struct idt77252_dev
*card
, struct rx_pool
*rpp
)
1953 struct sk_buff
*skb
, *next
;
1957 for (i
= 0; i
< rpp
->count
; i
++) {
1960 recycle_rx_skb(card
, skb
);
1963 flush_rx_pool(card
, rpp
);
1966 /*****************************************************************************/
1970 /*****************************************************************************/
1973 idt77252_phy_put(struct atm_dev
*dev
, unsigned char value
, unsigned long addr
)
1975 write_utility(dev
->dev_data
, 0x100 + (addr
& 0x1ff), value
);
1978 static unsigned char
1979 idt77252_phy_get(struct atm_dev
*dev
, unsigned long addr
)
1981 return read_utility(dev
->dev_data
, 0x100 + (addr
& 0x1ff));
1985 idt77252_send_skb(struct atm_vcc
*vcc
, struct sk_buff
*skb
, int oam
)
1987 struct atm_dev
*dev
= vcc
->dev
;
1988 struct idt77252_dev
*card
= dev
->dev_data
;
1989 struct vc_map
*vc
= vcc
->dev_data
;
1993 printk("%s: NULL connection in send().\n", card
->name
);
1994 atomic_inc(&vcc
->stats
->tx_err
);
1998 if (!test_bit(VCF_TX
, &vc
->flags
)) {
1999 printk("%s: Trying to transmit on a non-tx VC.\n", card
->name
);
2000 atomic_inc(&vcc
->stats
->tx_err
);
2005 switch (vcc
->qos
.aal
) {
2011 printk("%s: Unsupported AAL: %d\n", card
->name
, vcc
->qos
.aal
);
2012 atomic_inc(&vcc
->stats
->tx_err
);
2017 if (skb_shinfo(skb
)->nr_frags
!= 0) {
2018 printk("%s: No scatter-gather yet.\n", card
->name
);
2019 atomic_inc(&vcc
->stats
->tx_err
);
2023 ATM_SKB(skb
)->vcc
= vcc
;
2025 err
= queue_skb(card
, vc
, skb
, oam
);
2027 atomic_inc(&vcc
->stats
->tx_err
);
2036 idt77252_send(struct atm_vcc
*vcc
, struct sk_buff
*skb
)
2038 return idt77252_send_skb(vcc
, skb
, 0);
2042 idt77252_send_oam(struct atm_vcc
*vcc
, void *cell
, int flags
)
2044 struct atm_dev
*dev
= vcc
->dev
;
2045 struct idt77252_dev
*card
= dev
->dev_data
;
2046 struct sk_buff
*skb
;
2048 skb
= dev_alloc_skb(64);
2050 printk("%s: Out of memory in send_oam().\n", card
->name
);
2051 atomic_inc(&vcc
->stats
->tx_err
);
2054 atomic_add(skb
->truesize
, &sk_atm(vcc
)->sk_wmem_alloc
);
2056 memcpy(skb_put(skb
, 52), cell
, 52);
2058 return idt77252_send_skb(vcc
, skb
, 1);
2061 static __inline__
unsigned int
2062 idt77252_fls(unsigned int x
)
2068 if (x
& 0xffff0000) {
2090 idt77252_int_to_atmfp(unsigned int rate
)
2096 e
= idt77252_fls(rate
) - 1;
2098 m
= (rate
- (1 << e
)) << (9 - e
);
2100 m
= (rate
- (1 << e
));
2102 m
= (rate
- (1 << e
)) >> (e
- 9);
2103 return 0x4000 | (e
<< 9) | m
;
2107 idt77252_rate_logindex(struct idt77252_dev
*card
, int pcr
)
2111 afp
= idt77252_int_to_atmfp(pcr
< 0 ? -pcr
: pcr
);
2113 return rate_to_log
[(afp
>> 5) & 0x1ff];
2114 return rate_to_log
[((afp
>> 5) + 1) & 0x1ff];
2118 idt77252_est_timer(unsigned long data
)
2120 struct vc_map
*vc
= (struct vc_map
*)data
;
2121 struct idt77252_dev
*card
= vc
->card
;
2122 struct rate_estimator
*est
;
2123 unsigned long flags
;
2128 spin_lock_irqsave(&vc
->lock
, flags
);
2129 est
= vc
->estimator
;
2133 ncells
= est
->cells
;
2135 rate
= ((u32
)(ncells
- est
->last_cells
)) << (7 - est
->interval
);
2136 est
->last_cells
= ncells
;
2137 est
->avcps
+= ((long)rate
- (long)est
->avcps
) >> est
->ewma_log
;
2138 est
->cps
= (est
->avcps
+ 0x1f) >> 5;
2141 if (cps
< (est
->maxcps
>> 4))
2142 cps
= est
->maxcps
>> 4;
2144 lacr
= idt77252_rate_logindex(card
, cps
);
2145 if (lacr
> vc
->max_er
)
2148 if (lacr
!= vc
->lacr
) {
2150 writel(TCMDQ_LACR
|(vc
->lacr
<< 16)|vc
->index
, SAR_REG_TCMDQ
);
2153 est
->timer
.expires
= jiffies
+ ((HZ
/ 4) << est
->interval
);
2154 add_timer(&est
->timer
);
2157 spin_unlock_irqrestore(&vc
->lock
, flags
);
2160 static struct rate_estimator
*
2161 idt77252_init_est(struct vc_map
*vc
, int pcr
)
2163 struct rate_estimator
*est
;
2165 est
= kzalloc(sizeof(struct rate_estimator
), GFP_KERNEL
);
2168 est
->maxcps
= pcr
< 0 ? -pcr
: pcr
;
2169 est
->cps
= est
->maxcps
;
2170 est
->avcps
= est
->cps
<< 5;
2172 est
->interval
= 2; /* XXX: make this configurable */
2173 est
->ewma_log
= 2; /* XXX: make this configurable */
2174 init_timer(&est
->timer
);
2175 est
->timer
.data
= (unsigned long)vc
;
2176 est
->timer
.function
= idt77252_est_timer
;
2178 est
->timer
.expires
= jiffies
+ ((HZ
/ 4) << est
->interval
);
2179 add_timer(&est
->timer
);
2185 idt77252_init_cbr(struct idt77252_dev
*card
, struct vc_map
*vc
,
2186 struct atm_vcc
*vcc
, struct atm_qos
*qos
)
2188 int tst_free
, tst_used
, tst_entries
;
2189 unsigned long tmpl
, modl
;
2192 if ((qos
->txtp
.max_pcr
== 0) &&
2193 (qos
->txtp
.pcr
== 0) && (qos
->txtp
.min_pcr
== 0)) {
2194 printk("%s: trying to open a CBR VC with cell rate = 0\n",
2200 tst_free
= card
->tst_free
;
2201 if (test_bit(VCF_TX
, &vc
->flags
))
2202 tst_used
= vc
->ntste
;
2203 tst_free
+= tst_used
;
2205 tcr
= atm_pcr_goal(&qos
->txtp
);
2206 tcra
= tcr
>= 0 ? tcr
: -tcr
;
2208 TXPRINTK("%s: CBR target cell rate = %d\n", card
->name
, tcra
);
2210 tmpl
= (unsigned long) tcra
* ((unsigned long) card
->tst_size
- 2);
2211 modl
= tmpl
% (unsigned long)card
->utopia_pcr
;
2213 tst_entries
= (int) (tmpl
/ card
->utopia_pcr
);
2217 } else if (tcr
== 0) {
2218 tst_entries
= tst_free
- SAR_TST_RESERVED
;
2219 if (tst_entries
<= 0) {
2220 printk("%s: no CBR bandwidth free.\n", card
->name
);
2225 if (tst_entries
== 0) {
2226 printk("%s: selected CBR bandwidth < granularity.\n",
2231 if (tst_entries
> (tst_free
- SAR_TST_RESERVED
)) {
2232 printk("%s: not enough CBR bandwidth free.\n", card
->name
);
2236 vc
->ntste
= tst_entries
;
2238 card
->tst_free
= tst_free
- tst_entries
;
2239 if (test_bit(VCF_TX
, &vc
->flags
)) {
2240 if (tst_used
== tst_entries
)
2243 OPRINTK("%s: modify %d -> %d entries in TST.\n",
2244 card
->name
, tst_used
, tst_entries
);
2245 change_tst(card
, vc
, tst_entries
, TSTE_OPC_CBR
);
2249 OPRINTK("%s: setting %d entries in TST.\n", card
->name
, tst_entries
);
2250 fill_tst(card
, vc
, tst_entries
, TSTE_OPC_CBR
);
2255 idt77252_init_ubr(struct idt77252_dev
*card
, struct vc_map
*vc
,
2256 struct atm_vcc
*vcc
, struct atm_qos
*qos
)
2258 unsigned long flags
;
2261 spin_lock_irqsave(&vc
->lock
, flags
);
2262 if (vc
->estimator
) {
2263 del_timer(&vc
->estimator
->timer
);
2264 kfree(vc
->estimator
);
2265 vc
->estimator
= NULL
;
2267 spin_unlock_irqrestore(&vc
->lock
, flags
);
2269 tcr
= atm_pcr_goal(&qos
->txtp
);
2271 tcr
= card
->link_pcr
;
2273 vc
->estimator
= idt77252_init_est(vc
, tcr
);
2275 vc
->class = SCHED_UBR
;
2276 vc
->init_er
= idt77252_rate_logindex(card
, tcr
);
2277 vc
->lacr
= vc
->init_er
;
2279 vc
->max_er
= vc
->init_er
;
2287 idt77252_init_tx(struct idt77252_dev
*card
, struct vc_map
*vc
,
2288 struct atm_vcc
*vcc
, struct atm_qos
*qos
)
2292 if (test_bit(VCF_TX
, &vc
->flags
))
2295 switch (qos
->txtp
.traffic_class
) {
2297 vc
->class = SCHED_CBR
;
2301 vc
->class = SCHED_UBR
;
2307 return -EPROTONOSUPPORT
;
2310 vc
->scq
= alloc_scq(card
, vc
->class);
2312 printk("%s: can't get SCQ.\n", card
->name
);
2316 vc
->scq
->scd
= get_free_scd(card
, vc
);
2317 if (vc
->scq
->scd
== 0) {
2318 printk("%s: no SCD available.\n", card
->name
);
2319 free_scq(card
, vc
->scq
);
2323 fill_scd(card
, vc
->scq
, vc
->class);
2325 if (set_tct(card
, vc
)) {
2326 printk("%s: class %d not supported.\n",
2327 card
->name
, qos
->txtp
.traffic_class
);
2329 card
->scd2vc
[vc
->scd_index
] = NULL
;
2330 free_scq(card
, vc
->scq
);
2331 return -EPROTONOSUPPORT
;
2334 switch (vc
->class) {
2336 error
= idt77252_init_cbr(card
, vc
, vcc
, qos
);
2338 card
->scd2vc
[vc
->scd_index
] = NULL
;
2339 free_scq(card
, vc
->scq
);
2343 clear_bit(VCF_IDLE
, &vc
->flags
);
2344 writel(TCMDQ_START
| vc
->index
, SAR_REG_TCMDQ
);
2348 error
= idt77252_init_ubr(card
, vc
, vcc
, qos
);
2350 card
->scd2vc
[vc
->scd_index
] = NULL
;
2351 free_scq(card
, vc
->scq
);
2355 set_bit(VCF_IDLE
, &vc
->flags
);
2360 set_bit(VCF_TX
, &vc
->flags
);
2365 idt77252_init_rx(struct idt77252_dev
*card
, struct vc_map
*vc
,
2366 struct atm_vcc
*vcc
, struct atm_qos
*qos
)
2368 unsigned long flags
;
2372 if (test_bit(VCF_RX
, &vc
->flags
))
2376 set_bit(VCF_RX
, &vc
->flags
);
2378 if ((vcc
->vci
== 3) || (vcc
->vci
== 4))
2381 flush_rx_pool(card
, &vc
->rcv
.rx_pool
);
2383 rcte
|= SAR_RCTE_CONNECTOPEN
;
2384 rcte
|= SAR_RCTE_RAWCELLINTEN
;
2388 rcte
|= SAR_RCTE_RCQ
;
2391 rcte
|= SAR_RCTE_OAM
; /* Let SAR drop Video */
2394 rcte
|= SAR_RCTE_AAL34
;
2397 rcte
|= SAR_RCTE_AAL5
;
2400 rcte
|= SAR_RCTE_RCQ
;
2404 if (qos
->aal
!= ATM_AAL5
)
2405 rcte
|= SAR_RCTE_FBP_1
;
2406 else if (qos
->rxtp
.max_sdu
> SAR_FB_SIZE_2
)
2407 rcte
|= SAR_RCTE_FBP_3
;
2408 else if (qos
->rxtp
.max_sdu
> SAR_FB_SIZE_1
)
2409 rcte
|= SAR_RCTE_FBP_2
;
2410 else if (qos
->rxtp
.max_sdu
> SAR_FB_SIZE_0
)
2411 rcte
|= SAR_RCTE_FBP_1
;
2413 rcte
|= SAR_RCTE_FBP_01
;
2415 addr
= card
->rct_base
+ (vc
->index
<< 2);
2417 OPRINTK("%s: writing RCT at 0x%lx\n", card
->name
, addr
);
2418 write_sram(card
, addr
, rcte
);
2420 spin_lock_irqsave(&card
->cmd_lock
, flags
);
2421 writel(SAR_CMD_OPEN_CONNECTION
| (addr
<< 2), SAR_REG_CMD
);
2423 spin_unlock_irqrestore(&card
->cmd_lock
, flags
);
2429 idt77252_open(struct atm_vcc
*vcc
)
2431 struct atm_dev
*dev
= vcc
->dev
;
2432 struct idt77252_dev
*card
= dev
->dev_data
;
2438 short vpi
= vcc
->vpi
;
2440 if (vpi
== ATM_VPI_UNSPEC
|| vci
== ATM_VCI_UNSPEC
)
2443 if (vpi
>= (1 << card
->vpibits
)) {
2444 printk("%s: unsupported VPI: %d\n", card
->name
, vpi
);
2448 if (vci
>= (1 << card
->vcibits
)) {
2449 printk("%s: unsupported VCI: %d\n", card
->name
, vci
);
2453 set_bit(ATM_VF_ADDR
, &vcc
->flags
);
2455 mutex_lock(&card
->mutex
);
2457 OPRINTK("%s: opening vpi.vci: %d.%d\n", card
->name
, vpi
, vci
);
2459 switch (vcc
->qos
.aal
) {
2465 printk("%s: Unsupported AAL: %d\n", card
->name
, vcc
->qos
.aal
);
2466 mutex_unlock(&card
->mutex
);
2467 return -EPROTONOSUPPORT
;
2470 index
= VPCI2VC(card
, vpi
, vci
);
2471 if (!card
->vcs
[index
]) {
2472 card
->vcs
[index
] = kzalloc(sizeof(struct vc_map
), GFP_KERNEL
);
2473 if (!card
->vcs
[index
]) {
2474 printk("%s: can't alloc vc in open()\n", card
->name
);
2475 mutex_unlock(&card
->mutex
);
2478 card
->vcs
[index
]->card
= card
;
2479 card
->vcs
[index
]->index
= index
;
2481 spin_lock_init(&card
->vcs
[index
]->lock
);
2483 vc
= card
->vcs
[index
];
2487 IPRINTK("%s: idt77252_open: vc = %d (%d.%d) %s/%s (max RX SDU: %u)\n",
2488 card
->name
, vc
->index
, vcc
->vpi
, vcc
->vci
,
2489 vcc
->qos
.rxtp
.traffic_class
!= ATM_NONE
? "rx" : "--",
2490 vcc
->qos
.txtp
.traffic_class
!= ATM_NONE
? "tx" : "--",
2491 vcc
->qos
.rxtp
.max_sdu
);
2494 if (vcc
->qos
.txtp
.traffic_class
!= ATM_NONE
&&
2495 test_bit(VCF_TX
, &vc
->flags
))
2497 if (vcc
->qos
.rxtp
.traffic_class
!= ATM_NONE
&&
2498 test_bit(VCF_RX
, &vc
->flags
))
2502 printk("%s: %s vci already in use.\n", card
->name
,
2503 inuse
== 1 ? "tx" : inuse
== 2 ? "rx" : "tx and rx");
2504 mutex_unlock(&card
->mutex
);
2508 if (vcc
->qos
.txtp
.traffic_class
!= ATM_NONE
) {
2509 error
= idt77252_init_tx(card
, vc
, vcc
, &vcc
->qos
);
2511 mutex_unlock(&card
->mutex
);
2516 if (vcc
->qos
.rxtp
.traffic_class
!= ATM_NONE
) {
2517 error
= idt77252_init_rx(card
, vc
, vcc
, &vcc
->qos
);
2519 mutex_unlock(&card
->mutex
);
2524 set_bit(ATM_VF_READY
, &vcc
->flags
);
2526 mutex_unlock(&card
->mutex
);
2531 idt77252_close(struct atm_vcc
*vcc
)
2533 struct atm_dev
*dev
= vcc
->dev
;
2534 struct idt77252_dev
*card
= dev
->dev_data
;
2535 struct vc_map
*vc
= vcc
->dev_data
;
2536 unsigned long flags
;
2538 unsigned long timeout
;
2540 mutex_lock(&card
->mutex
);
2542 IPRINTK("%s: idt77252_close: vc = %d (%d.%d)\n",
2543 card
->name
, vc
->index
, vcc
->vpi
, vcc
->vci
);
2545 clear_bit(ATM_VF_READY
, &vcc
->flags
);
2547 if (vcc
->qos
.rxtp
.traffic_class
!= ATM_NONE
) {
2549 spin_lock_irqsave(&vc
->lock
, flags
);
2550 clear_bit(VCF_RX
, &vc
->flags
);
2552 spin_unlock_irqrestore(&vc
->lock
, flags
);
2554 if ((vcc
->vci
== 3) || (vcc
->vci
== 4))
2557 addr
= card
->rct_base
+ vc
->index
* SAR_SRAM_RCT_SIZE
;
2559 spin_lock_irqsave(&card
->cmd_lock
, flags
);
2560 writel(SAR_CMD_CLOSE_CONNECTION
| (addr
<< 2), SAR_REG_CMD
);
2562 spin_unlock_irqrestore(&card
->cmd_lock
, flags
);
2564 if (vc
->rcv
.rx_pool
.count
) {
2565 DPRINTK("%s: closing a VC with pending rx buffers.\n",
2568 recycle_rx_pool_skb(card
, &vc
->rcv
.rx_pool
);
2573 if (vcc
->qos
.txtp
.traffic_class
!= ATM_NONE
) {
2575 spin_lock_irqsave(&vc
->lock
, flags
);
2576 clear_bit(VCF_TX
, &vc
->flags
);
2577 clear_bit(VCF_IDLE
, &vc
->flags
);
2578 clear_bit(VCF_RSV
, &vc
->flags
);
2581 if (vc
->estimator
) {
2582 del_timer(&vc
->estimator
->timer
);
2583 kfree(vc
->estimator
);
2584 vc
->estimator
= NULL
;
2586 spin_unlock_irqrestore(&vc
->lock
, flags
);
2589 while (atomic_read(&vc
->scq
->used
) > 0) {
2590 timeout
= msleep_interruptible(timeout
);
2595 printk("%s: SCQ drain timeout: %u used\n",
2596 card
->name
, atomic_read(&vc
->scq
->used
));
2598 writel(TCMDQ_HALT
| vc
->index
, SAR_REG_TCMDQ
);
2599 clear_scd(card
, vc
->scq
, vc
->class);
2601 if (vc
->class == SCHED_CBR
) {
2602 clear_tst(card
, vc
);
2603 card
->tst_free
+= vc
->ntste
;
2607 card
->scd2vc
[vc
->scd_index
] = NULL
;
2608 free_scq(card
, vc
->scq
);
2611 mutex_unlock(&card
->mutex
);
2615 idt77252_change_qos(struct atm_vcc
*vcc
, struct atm_qos
*qos
, int flags
)
2617 struct atm_dev
*dev
= vcc
->dev
;
2618 struct idt77252_dev
*card
= dev
->dev_data
;
2619 struct vc_map
*vc
= vcc
->dev_data
;
2622 mutex_lock(&card
->mutex
);
2624 if (qos
->txtp
.traffic_class
!= ATM_NONE
) {
2625 if (!test_bit(VCF_TX
, &vc
->flags
)) {
2626 error
= idt77252_init_tx(card
, vc
, vcc
, qos
);
2630 switch (qos
->txtp
.traffic_class
) {
2632 error
= idt77252_init_cbr(card
, vc
, vcc
, qos
);
2638 error
= idt77252_init_ubr(card
, vc
, vcc
, qos
);
2642 if (!test_bit(VCF_IDLE
, &vc
->flags
)) {
2643 writel(TCMDQ_LACR
| (vc
->lacr
<< 16) |
2644 vc
->index
, SAR_REG_TCMDQ
);
2650 error
= -EOPNOTSUPP
;
2656 if ((qos
->rxtp
.traffic_class
!= ATM_NONE
) &&
2657 !test_bit(VCF_RX
, &vc
->flags
)) {
2658 error
= idt77252_init_rx(card
, vc
, vcc
, qos
);
2663 memcpy(&vcc
->qos
, qos
, sizeof(struct atm_qos
));
2665 set_bit(ATM_VF_HASQOS
, &vcc
->flags
);
2668 mutex_unlock(&card
->mutex
);
2673 idt77252_proc_read(struct atm_dev
*dev
, loff_t
* pos
, char *page
)
2675 struct idt77252_dev
*card
= dev
->dev_data
;
2680 return sprintf(page
, "IDT77252 Interrupts:\n");
2682 return sprintf(page
, "TSIF: %lu\n", card
->irqstat
[15]);
2684 return sprintf(page
, "TXICP: %lu\n", card
->irqstat
[14]);
2686 return sprintf(page
, "TSQF: %lu\n", card
->irqstat
[12]);
2688 return sprintf(page
, "TMROF: %lu\n", card
->irqstat
[11]);
2690 return sprintf(page
, "PHYI: %lu\n", card
->irqstat
[10]);
2692 return sprintf(page
, "FBQ3A: %lu\n", card
->irqstat
[8]);
2694 return sprintf(page
, "FBQ2A: %lu\n", card
->irqstat
[7]);
2696 return sprintf(page
, "RSQF: %lu\n", card
->irqstat
[6]);
2698 return sprintf(page
, "EPDU: %lu\n", card
->irqstat
[5]);
2700 return sprintf(page
, "RAWCF: %lu\n", card
->irqstat
[4]);
2702 return sprintf(page
, "FBQ1A: %lu\n", card
->irqstat
[3]);
2704 return sprintf(page
, "FBQ0A: %lu\n", card
->irqstat
[2]);
2706 return sprintf(page
, "RSQAF: %lu\n", card
->irqstat
[1]);
2708 return sprintf(page
, "IDT77252 Transmit Connection Table:\n");
2710 for (i
= 0; i
< card
->tct_size
; i
++) {
2712 struct atm_vcc
*vcc
;
2729 p
+= sprintf(p
, " %4u: %u.%u: ", i
, vcc
->vpi
, vcc
->vci
);
2730 tct
= (unsigned long) (card
->tct_base
+ i
* SAR_SRAM_TCT_SIZE
);
2732 for (i
= 0; i
< 8; i
++)
2733 p
+= sprintf(p
, " %08x", read_sram(card
, tct
+ i
));
2734 p
+= sprintf(p
, "\n");
2740 /*****************************************************************************/
2742 /* Interrupt handler */
2744 /*****************************************************************************/
2747 idt77252_collect_stat(struct idt77252_dev
*card
)
2751 cdc
= readl(SAR_REG_CDC
);
2752 vpec
= readl(SAR_REG_VPEC
);
2753 icc
= readl(SAR_REG_ICC
);
2756 printk("%s:", card
->name
);
2758 if (cdc
& 0x7f0000) {
2762 if (cdc
& (1 << 22)) {
2763 printk("%sRM ID", s
);
2766 if (cdc
& (1 << 21)) {
2767 printk("%sCON TAB", s
);
2770 if (cdc
& (1 << 20)) {
2771 printk("%sNO FB", s
);
2774 if (cdc
& (1 << 19)) {
2775 printk("%sOAM CRC", s
);
2778 if (cdc
& (1 << 18)) {
2779 printk("%sRM CRC", s
);
2782 if (cdc
& (1 << 17)) {
2783 printk("%sRM FIFO", s
);
2786 if (cdc
& (1 << 16)) {
2787 printk("%sRX FIFO", s
);
2793 printk(" CDC %04x, VPEC %04x, ICC: %04x\n",
2794 cdc
& 0xffff, vpec
& 0xffff, icc
& 0xffff);
2799 idt77252_interrupt(int irq
, void *dev_id
)
2801 struct idt77252_dev
*card
= dev_id
;
2804 stat
= readl(SAR_REG_STAT
) & 0xffff;
2805 if (!stat
) /* no interrupt for us */
2808 if (test_and_set_bit(IDT77252_BIT_INTERRUPT
, &card
->flags
)) {
2809 printk("%s: Re-entering irq_handler()\n", card
->name
);
2813 writel(stat
, SAR_REG_STAT
); /* reset interrupt */
2815 if (stat
& SAR_STAT_TSIF
) { /* entry written to TSQ */
2816 INTPRINTK("%s: TSIF\n", card
->name
);
2817 card
->irqstat
[15]++;
2820 if (stat
& SAR_STAT_TXICP
) { /* Incomplete CS-PDU has */
2821 INTPRINTK("%s: TXICP\n", card
->name
);
2822 card
->irqstat
[14]++;
2823 #ifdef CONFIG_ATM_IDT77252_DEBUG
2824 idt77252_tx_dump(card
);
2827 if (stat
& SAR_STAT_TSQF
) { /* TSQ 7/8 full */
2828 INTPRINTK("%s: TSQF\n", card
->name
);
2829 card
->irqstat
[12]++;
2832 if (stat
& SAR_STAT_TMROF
) { /* Timer overflow */
2833 INTPRINTK("%s: TMROF\n", card
->name
);
2834 card
->irqstat
[11]++;
2835 idt77252_collect_stat(card
);
2838 if (stat
& SAR_STAT_EPDU
) { /* Got complete CS-PDU */
2839 INTPRINTK("%s: EPDU\n", card
->name
);
2843 if (stat
& SAR_STAT_RSQAF
) { /* RSQ is 7/8 full */
2844 INTPRINTK("%s: RSQAF\n", card
->name
);
2848 if (stat
& SAR_STAT_RSQF
) { /* RSQ is full */
2849 INTPRINTK("%s: RSQF\n", card
->name
);
2853 if (stat
& SAR_STAT_RAWCF
) { /* Raw cell received */
2854 INTPRINTK("%s: RAWCF\n", card
->name
);
2856 idt77252_rx_raw(card
);
2859 if (stat
& SAR_STAT_PHYI
) { /* PHY device interrupt */
2860 INTPRINTK("%s: PHYI", card
->name
);
2861 card
->irqstat
[10]++;
2862 if (card
->atmdev
->phy
&& card
->atmdev
->phy
->interrupt
)
2863 card
->atmdev
->phy
->interrupt(card
->atmdev
);
2866 if (stat
& (SAR_STAT_FBQ0A
| SAR_STAT_FBQ1A
|
2867 SAR_STAT_FBQ2A
| SAR_STAT_FBQ3A
)) {
2869 writel(readl(SAR_REG_CFG
) & ~(SAR_CFG_FBIE
), SAR_REG_CFG
);
2871 INTPRINTK("%s: FBQA: %04x\n", card
->name
, stat
);
2873 if (stat
& SAR_STAT_FBQ0A
)
2875 if (stat
& SAR_STAT_FBQ1A
)
2877 if (stat
& SAR_STAT_FBQ2A
)
2879 if (stat
& SAR_STAT_FBQ3A
)
2882 schedule_work(&card
->tqueue
);
2886 clear_bit(IDT77252_BIT_INTERRUPT
, &card
->flags
);
2891 idt77252_softint(struct work_struct
*work
)
2893 struct idt77252_dev
*card
=
2894 container_of(work
, struct idt77252_dev
, tqueue
);
2898 for (done
= 1; ; done
= 1) {
2899 stat
= readl(SAR_REG_STAT
) >> 16;
2901 if ((stat
& 0x0f) < SAR_FBQ0_HIGH
) {
2902 add_rx_skb(card
, 0, SAR_FB_SIZE_0
, 32);
2907 if ((stat
& 0x0f) < SAR_FBQ1_HIGH
) {
2908 add_rx_skb(card
, 1, SAR_FB_SIZE_1
, 32);
2913 if ((stat
& 0x0f) < SAR_FBQ2_HIGH
) {
2914 add_rx_skb(card
, 2, SAR_FB_SIZE_2
, 32);
2919 if ((stat
& 0x0f) < SAR_FBQ3_HIGH
) {
2920 add_rx_skb(card
, 3, SAR_FB_SIZE_3
, 32);
2928 writel(readl(SAR_REG_CFG
) | SAR_CFG_FBIE
, SAR_REG_CFG
);
2933 open_card_oam(struct idt77252_dev
*card
)
2935 unsigned long flags
;
2942 for (vpi
= 0; vpi
< (1 << card
->vpibits
); vpi
++) {
2943 for (vci
= 3; vci
< 5; vci
++) {
2944 index
= VPCI2VC(card
, vpi
, vci
);
2946 vc
= kzalloc(sizeof(struct vc_map
), GFP_KERNEL
);
2948 printk("%s: can't alloc vc\n", card
->name
);
2952 card
->vcs
[index
] = vc
;
2954 flush_rx_pool(card
, &vc
->rcv
.rx_pool
);
2956 rcte
= SAR_RCTE_CONNECTOPEN
|
2957 SAR_RCTE_RAWCELLINTEN
|
2961 addr
= card
->rct_base
+ (vc
->index
<< 2);
2962 write_sram(card
, addr
, rcte
);
2964 spin_lock_irqsave(&card
->cmd_lock
, flags
);
2965 writel(SAR_CMD_OPEN_CONNECTION
| (addr
<< 2),
2968 spin_unlock_irqrestore(&card
->cmd_lock
, flags
);
2976 close_card_oam(struct idt77252_dev
*card
)
2978 unsigned long flags
;
2984 for (vpi
= 0; vpi
< (1 << card
->vpibits
); vpi
++) {
2985 for (vci
= 3; vci
< 5; vci
++) {
2986 index
= VPCI2VC(card
, vpi
, vci
);
2987 vc
= card
->vcs
[index
];
2989 addr
= card
->rct_base
+ vc
->index
* SAR_SRAM_RCT_SIZE
;
2991 spin_lock_irqsave(&card
->cmd_lock
, flags
);
2992 writel(SAR_CMD_CLOSE_CONNECTION
| (addr
<< 2),
2995 spin_unlock_irqrestore(&card
->cmd_lock
, flags
);
2997 if (vc
->rcv
.rx_pool
.count
) {
2998 DPRINTK("%s: closing a VC "
2999 "with pending rx buffers.\n",
3002 recycle_rx_pool_skb(card
, &vc
->rcv
.rx_pool
);
3009 open_card_ubr0(struct idt77252_dev
*card
)
3013 vc
= kzalloc(sizeof(struct vc_map
), GFP_KERNEL
);
3015 printk("%s: can't alloc vc\n", card
->name
);
3019 vc
->class = SCHED_UBR0
;
3021 vc
->scq
= alloc_scq(card
, vc
->class);
3023 printk("%s: can't get SCQ.\n", card
->name
);
3027 card
->scd2vc
[0] = vc
;
3029 vc
->scq
->scd
= card
->scd_base
;
3031 fill_scd(card
, vc
->scq
, vc
->class);
3033 write_sram(card
, card
->tct_base
+ 0, TCT_UBR
| card
->scd_base
);
3034 write_sram(card
, card
->tct_base
+ 1, 0);
3035 write_sram(card
, card
->tct_base
+ 2, 0);
3036 write_sram(card
, card
->tct_base
+ 3, 0);
3037 write_sram(card
, card
->tct_base
+ 4, 0);
3038 write_sram(card
, card
->tct_base
+ 5, 0);
3039 write_sram(card
, card
->tct_base
+ 6, 0);
3040 write_sram(card
, card
->tct_base
+ 7, TCT_FLAG_UBR
);
3042 clear_bit(VCF_IDLE
, &vc
->flags
);
3043 writel(TCMDQ_START
| 0, SAR_REG_TCMDQ
);
3048 idt77252_dev_open(struct idt77252_dev
*card
)
3052 if (!test_bit(IDT77252_BIT_INIT
, &card
->flags
)) {
3053 printk("%s: SAR not yet initialized.\n", card
->name
);
3057 conf
= SAR_CFG_RXPTH
| /* enable receive path */
3058 SAR_RX_DELAY
| /* interrupt on complete PDU */
3059 SAR_CFG_RAWIE
| /* interrupt enable on raw cells */
3060 SAR_CFG_RQFIE
| /* interrupt on RSQ almost full */
3061 SAR_CFG_TMOIE
| /* interrupt on timer overflow */
3062 SAR_CFG_FBIE
| /* interrupt on low free buffers */
3063 SAR_CFG_TXEN
| /* transmit operation enable */
3064 SAR_CFG_TXINT
| /* interrupt on transmit status */
3065 SAR_CFG_TXUIE
| /* interrupt on transmit underrun */
3066 SAR_CFG_TXSFI
| /* interrupt on TSQ almost full */
3067 SAR_CFG_PHYIE
/* enable PHY interrupts */
3070 #ifdef CONFIG_ATM_IDT77252_RCV_ALL
3071 /* Test RAW cell receive. */
3072 conf
|= SAR_CFG_VPECA
;
3075 writel(readl(SAR_REG_CFG
) | conf
, SAR_REG_CFG
);
3077 if (open_card_oam(card
)) {
3078 printk("%s: Error initializing OAM.\n", card
->name
);
3082 if (open_card_ubr0(card
)) {
3083 printk("%s: Error initializing UBR0.\n", card
->name
);
3087 IPRINTK("%s: opened IDT77252 ABR SAR.\n", card
->name
);
3092 idt77252_dev_close(struct atm_dev
*dev
)
3094 struct idt77252_dev
*card
= dev
->dev_data
;
3097 close_card_oam(card
);
3099 conf
= SAR_CFG_RXPTH
| /* enable receive path */
3100 SAR_RX_DELAY
| /* interrupt on complete PDU */
3101 SAR_CFG_RAWIE
| /* interrupt enable on raw cells */
3102 SAR_CFG_RQFIE
| /* interrupt on RSQ almost full */
3103 SAR_CFG_TMOIE
| /* interrupt on timer overflow */
3104 SAR_CFG_FBIE
| /* interrupt on low free buffers */
3105 SAR_CFG_TXEN
| /* transmit operation enable */
3106 SAR_CFG_TXINT
| /* interrupt on transmit status */
3107 SAR_CFG_TXUIE
| /* interrupt on xmit underrun */
3108 SAR_CFG_TXSFI
/* interrupt on TSQ almost full */
3111 writel(readl(SAR_REG_CFG
) & ~(conf
), SAR_REG_CFG
);
3113 DIPRINTK("%s: closed IDT77252 ABR SAR.\n", card
->name
);
3117 /*****************************************************************************/
3119 /* Initialisation and Deinitialization of IDT77252 */
3121 /*****************************************************************************/
3125 deinit_card(struct idt77252_dev
*card
)
3127 struct sk_buff
*skb
;
3130 if (!test_bit(IDT77252_BIT_INIT
, &card
->flags
)) {
3131 printk("%s: SAR not yet initialized.\n", card
->name
);
3134 DIPRINTK("idt77252: deinitialize card %u\n", card
->index
);
3136 writel(0, SAR_REG_CFG
);
3139 atm_dev_deregister(card
->atmdev
);
3141 for (i
= 0; i
< 4; i
++) {
3142 for (j
= 0; j
< FBQ_SIZE
; j
++) {
3143 skb
= card
->sbpool
[i
].skb
[j
];
3145 pci_unmap_single(card
->pcidev
,
3146 IDT77252_PRV_PADDR(skb
),
3147 (skb_end_pointer(skb
) -
3149 PCI_DMA_FROMDEVICE
);
3150 card
->sbpool
[i
].skb
[j
] = NULL
;
3156 vfree(card
->soft_tst
);
3158 vfree(card
->scd2vc
);
3162 if (card
->raw_cell_hnd
) {
3163 pci_free_consistent(card
->pcidev
, 2 * sizeof(u32
),
3164 card
->raw_cell_hnd
, card
->raw_cell_paddr
);
3167 if (card
->rsq
.base
) {
3168 DIPRINTK("%s: Release RSQ ...\n", card
->name
);
3172 if (card
->tsq
.base
) {
3173 DIPRINTK("%s: Release TSQ ...\n", card
->name
);
3177 DIPRINTK("idt77252: Release IRQ.\n");
3178 free_irq(card
->pcidev
->irq
, card
);
3180 for (i
= 0; i
< 4; i
++) {
3182 iounmap(card
->fbq
[i
]);
3186 iounmap(card
->membase
);
3188 clear_bit(IDT77252_BIT_INIT
, &card
->flags
);
3189 DIPRINTK("%s: Card deinitialized.\n", card
->name
);
3193 static int __devinit
3194 init_sram(struct idt77252_dev
*card
)
3198 for (i
= 0; i
< card
->sramsize
; i
+= 4)
3199 write_sram(card
, (i
>> 2), 0);
3201 /* set SRAM layout for THIS card */
3202 if (card
->sramsize
== (512 * 1024)) {
3203 card
->tct_base
= SAR_SRAM_TCT_128_BASE
;
3204 card
->tct_size
= (SAR_SRAM_TCT_128_TOP
- card
->tct_base
+ 1)
3205 / SAR_SRAM_TCT_SIZE
;
3206 card
->rct_base
= SAR_SRAM_RCT_128_BASE
;
3207 card
->rct_size
= (SAR_SRAM_RCT_128_TOP
- card
->rct_base
+ 1)
3208 / SAR_SRAM_RCT_SIZE
;
3209 card
->rt_base
= SAR_SRAM_RT_128_BASE
;
3210 card
->scd_base
= SAR_SRAM_SCD_128_BASE
;
3211 card
->scd_size
= (SAR_SRAM_SCD_128_TOP
- card
->scd_base
+ 1)
3212 / SAR_SRAM_SCD_SIZE
;
3213 card
->tst
[0] = SAR_SRAM_TST1_128_BASE
;
3214 card
->tst
[1] = SAR_SRAM_TST2_128_BASE
;
3215 card
->tst_size
= SAR_SRAM_TST1_128_TOP
- card
->tst
[0] + 1;
3216 card
->abrst_base
= SAR_SRAM_ABRSTD_128_BASE
;
3217 card
->abrst_size
= SAR_ABRSTD_SIZE_8K
;
3218 card
->fifo_base
= SAR_SRAM_FIFO_128_BASE
;
3219 card
->fifo_size
= SAR_RXFD_SIZE_32K
;
3221 card
->tct_base
= SAR_SRAM_TCT_32_BASE
;
3222 card
->tct_size
= (SAR_SRAM_TCT_32_TOP
- card
->tct_base
+ 1)
3223 / SAR_SRAM_TCT_SIZE
;
3224 card
->rct_base
= SAR_SRAM_RCT_32_BASE
;
3225 card
->rct_size
= (SAR_SRAM_RCT_32_TOP
- card
->rct_base
+ 1)
3226 / SAR_SRAM_RCT_SIZE
;
3227 card
->rt_base
= SAR_SRAM_RT_32_BASE
;
3228 card
->scd_base
= SAR_SRAM_SCD_32_BASE
;
3229 card
->scd_size
= (SAR_SRAM_SCD_32_TOP
- card
->scd_base
+ 1)
3230 / SAR_SRAM_SCD_SIZE
;
3231 card
->tst
[0] = SAR_SRAM_TST1_32_BASE
;
3232 card
->tst
[1] = SAR_SRAM_TST2_32_BASE
;
3233 card
->tst_size
= (SAR_SRAM_TST1_32_TOP
- card
->tst
[0] + 1);
3234 card
->abrst_base
= SAR_SRAM_ABRSTD_32_BASE
;
3235 card
->abrst_size
= SAR_ABRSTD_SIZE_1K
;
3236 card
->fifo_base
= SAR_SRAM_FIFO_32_BASE
;
3237 card
->fifo_size
= SAR_RXFD_SIZE_4K
;
3240 /* Initialize TCT */
3241 for (i
= 0; i
< card
->tct_size
; i
++) {
3242 write_sram(card
, i
* SAR_SRAM_TCT_SIZE
+ 0, 0);
3243 write_sram(card
, i
* SAR_SRAM_TCT_SIZE
+ 1, 0);
3244 write_sram(card
, i
* SAR_SRAM_TCT_SIZE
+ 2, 0);
3245 write_sram(card
, i
* SAR_SRAM_TCT_SIZE
+ 3, 0);
3246 write_sram(card
, i
* SAR_SRAM_TCT_SIZE
+ 4, 0);
3247 write_sram(card
, i
* SAR_SRAM_TCT_SIZE
+ 5, 0);
3248 write_sram(card
, i
* SAR_SRAM_TCT_SIZE
+ 6, 0);
3249 write_sram(card
, i
* SAR_SRAM_TCT_SIZE
+ 7, 0);
3252 /* Initialize RCT */
3253 for (i
= 0; i
< card
->rct_size
; i
++) {
3254 write_sram(card
, card
->rct_base
+ i
* SAR_SRAM_RCT_SIZE
,
3255 (u32
) SAR_RCTE_RAWCELLINTEN
);
3256 write_sram(card
, card
->rct_base
+ i
* SAR_SRAM_RCT_SIZE
+ 1,
3258 write_sram(card
, card
->rct_base
+ i
* SAR_SRAM_RCT_SIZE
+ 2,
3260 write_sram(card
, card
->rct_base
+ i
* SAR_SRAM_RCT_SIZE
+ 3,
3264 writel((SAR_FBQ0_LOW
<< 28) | 0x00000000 | 0x00000000 |
3265 (SAR_FB_SIZE_0
/ 48), SAR_REG_FBQS0
);
3266 writel((SAR_FBQ1_LOW
<< 28) | 0x00000000 | 0x00000000 |
3267 (SAR_FB_SIZE_1
/ 48), SAR_REG_FBQS1
);
3268 writel((SAR_FBQ2_LOW
<< 28) | 0x00000000 | 0x00000000 |
3269 (SAR_FB_SIZE_2
/ 48), SAR_REG_FBQS2
);
3270 writel((SAR_FBQ3_LOW
<< 28) | 0x00000000 | 0x00000000 |
3271 (SAR_FB_SIZE_3
/ 48), SAR_REG_FBQS3
);
3273 /* Initialize rate table */
3274 for (i
= 0; i
< 256; i
++) {
3275 write_sram(card
, card
->rt_base
+ i
, log_to_rate
[i
]);
3278 for (i
= 0; i
< 128; i
++) {
3281 tmp
= rate_to_log
[(i
<< 2) + 0] << 0;
3282 tmp
|= rate_to_log
[(i
<< 2) + 1] << 8;
3283 tmp
|= rate_to_log
[(i
<< 2) + 2] << 16;
3284 tmp
|= rate_to_log
[(i
<< 2) + 3] << 24;
3285 write_sram(card
, card
->rt_base
+ 256 + i
, tmp
);
3288 #if 0 /* Fill RDF and AIR tables. */
3289 for (i
= 0; i
< 128; i
++) {
3292 tmp
= RDF
[0][(i
<< 1) + 0] << 16;
3293 tmp
|= RDF
[0][(i
<< 1) + 1] << 0;
3294 write_sram(card
, card
->rt_base
+ 512 + i
, tmp
);
3297 for (i
= 0; i
< 128; i
++) {
3300 tmp
= AIR
[0][(i
<< 1) + 0] << 16;
3301 tmp
|= AIR
[0][(i
<< 1) + 1] << 0;
3302 write_sram(card
, card
->rt_base
+ 640 + i
, tmp
);
3306 IPRINTK("%s: initialize rate table ...\n", card
->name
);
3307 writel(card
->rt_base
<< 2, SAR_REG_RTBL
);
3309 /* Initialize TSTs */
3310 IPRINTK("%s: initialize TST ...\n", card
->name
);
3311 card
->tst_free
= card
->tst_size
- 2; /* last two are jumps */
3313 for (i
= card
->tst
[0]; i
< card
->tst
[0] + card
->tst_size
- 2; i
++)
3314 write_sram(card
, i
, TSTE_OPC_VAR
);
3315 write_sram(card
, i
++, TSTE_OPC_JMP
| (card
->tst
[0] << 2));
3316 idt77252_sram_write_errors
= 1;
3317 write_sram(card
, i
++, TSTE_OPC_JMP
| (card
->tst
[1] << 2));
3318 idt77252_sram_write_errors
= 0;
3319 for (i
= card
->tst
[1]; i
< card
->tst
[1] + card
->tst_size
- 2; i
++)
3320 write_sram(card
, i
, TSTE_OPC_VAR
);
3321 write_sram(card
, i
++, TSTE_OPC_JMP
| (card
->tst
[1] << 2));
3322 idt77252_sram_write_errors
= 1;
3323 write_sram(card
, i
++, TSTE_OPC_JMP
| (card
->tst
[0] << 2));
3324 idt77252_sram_write_errors
= 0;
3326 card
->tst_index
= 0;
3327 writel(card
->tst
[0] << 2, SAR_REG_TSTB
);
3329 /* Initialize ABRSTD and Receive FIFO */
3330 IPRINTK("%s: initialize ABRSTD ...\n", card
->name
);
3331 writel(card
->abrst_size
| (card
->abrst_base
<< 2),
3334 IPRINTK("%s: initialize receive fifo ...\n", card
->name
);
3335 writel(card
->fifo_size
| (card
->fifo_base
<< 2),
3338 IPRINTK("%s: SRAM initialization complete.\n", card
->name
);
3342 static int __devinit
3343 init_card(struct atm_dev
*dev
)
3345 struct idt77252_dev
*card
= dev
->dev_data
;
3346 struct pci_dev
*pcidev
= card
->pcidev
;
3347 unsigned long tmpl
, modl
;
3348 unsigned int linkrate
, rsvdcr
;
3349 unsigned int tst_entries
;
3350 struct net_device
*tmp
;
3358 if (test_bit(IDT77252_BIT_INIT
, &card
->flags
)) {
3359 printk("Error: SAR already initialized.\n");
3363 /*****************************************************************/
3364 /* P C I C O N F I G U R A T I O N */
3365 /*****************************************************************/
3367 /* Set PCI Retry-Timeout and TRDY timeout */
3368 IPRINTK("%s: Checking PCI retries.\n", card
->name
);
3369 if (pci_read_config_byte(pcidev
, 0x40, &pci_byte
) != 0) {
3370 printk("%s: can't read PCI retry timeout.\n", card
->name
);
3374 if (pci_byte
!= 0) {
3375 IPRINTK("%s: PCI retry timeout: %d, set to 0.\n",
3376 card
->name
, pci_byte
);
3377 if (pci_write_config_byte(pcidev
, 0x40, 0) != 0) {
3378 printk("%s: can't set PCI retry timeout.\n",
3384 IPRINTK("%s: Checking PCI TRDY.\n", card
->name
);
3385 if (pci_read_config_byte(pcidev
, 0x41, &pci_byte
) != 0) {
3386 printk("%s: can't read PCI TRDY timeout.\n", card
->name
);
3390 if (pci_byte
!= 0) {
3391 IPRINTK("%s: PCI TRDY timeout: %d, set to 0.\n",
3392 card
->name
, pci_byte
);
3393 if (pci_write_config_byte(pcidev
, 0x41, 0) != 0) {
3394 printk("%s: can't set PCI TRDY timeout.\n", card
->name
);
3399 /* Reset Timer register */
3400 if (readl(SAR_REG_STAT
) & SAR_STAT_TMROF
) {
3401 printk("%s: resetting timer overflow.\n", card
->name
);
3402 writel(SAR_STAT_TMROF
, SAR_REG_STAT
);
3404 IPRINTK("%s: Request IRQ ... ", card
->name
);
3405 if (request_irq(pcidev
->irq
, idt77252_interrupt
, IRQF_DISABLED
|IRQF_SHARED
,
3406 card
->name
, card
) != 0) {
3407 printk("%s: can't allocate IRQ.\n", card
->name
);
3411 IPRINTK("got %d.\n", pcidev
->irq
);
3413 /*****************************************************************/
3414 /* C H E C K A N D I N I T S R A M */
3415 /*****************************************************************/
3417 IPRINTK("%s: Initializing SRAM\n", card
->name
);
3419 /* preset size of connecton table, so that init_sram() knows about it */
3420 conf
= SAR_CFG_TX_FIFO_SIZE_9
| /* Use maximum fifo size */
3421 SAR_CFG_RXSTQ_SIZE_8k
| /* Receive Status Queue is 8k */
3422 SAR_CFG_IDLE_CLP
| /* Set CLP on idle cells */
3423 #ifndef ATM_IDT77252_SEND_IDLE
3424 SAR_CFG_NO_IDLE
| /* Do not send idle cells */
3428 if (card
->sramsize
== (512 * 1024))
3429 conf
|= SAR_CFG_CNTBL_1k
;
3431 conf
|= SAR_CFG_CNTBL_512
;
3435 conf
|= SAR_CFG_VPVCS_0
;
3439 conf
|= SAR_CFG_VPVCS_1
;
3442 conf
|= SAR_CFG_VPVCS_2
;
3445 conf
|= SAR_CFG_VPVCS_8
;
3449 writel(readl(SAR_REG_CFG
) | conf
, SAR_REG_CFG
);
3451 if (init_sram(card
) < 0)
3454 /********************************************************************/
3455 /* A L L O C R A M A N D S E T V A R I O U S T H I N G S */
3456 /********************************************************************/
3457 /* Initialize TSQ */
3458 if (0 != init_tsq(card
)) {
3462 /* Initialize RSQ */
3463 if (0 != init_rsq(card
)) {
3468 card
->vpibits
= vpibits
;
3469 if (card
->sramsize
== (512 * 1024)) {
3470 card
->vcibits
= 10 - card
->vpibits
;
3472 card
->vcibits
= 9 - card
->vpibits
;
3476 for (k
= 0, i
= 1; k
< card
->vcibits
; k
++) {
3481 IPRINTK("%s: Setting VPI/VCI mask to zero.\n", card
->name
);
3482 writel(0, SAR_REG_VPM
);
3484 /* Little Endian Order */
3485 writel(0, SAR_REG_GP
);
3487 /* Initialize RAW Cell Handle Register */
3488 card
->raw_cell_hnd
= pci_alloc_consistent(card
->pcidev
, 2 * sizeof(u32
),
3489 &card
->raw_cell_paddr
);
3490 if (!card
->raw_cell_hnd
) {
3491 printk("%s: memory allocation failure.\n", card
->name
);
3495 memset(card
->raw_cell_hnd
, 0, 2 * sizeof(u32
));
3496 writel(card
->raw_cell_paddr
, SAR_REG_RAWHND
);
3497 IPRINTK("%s: raw cell handle is at 0x%p.\n", card
->name
,
3498 card
->raw_cell_hnd
);
3500 size
= sizeof(struct vc_map
*) * card
->tct_size
;
3501 IPRINTK("%s: allocate %d byte for VC map.\n", card
->name
, size
);
3502 if (NULL
== (card
->vcs
= vmalloc(size
))) {
3503 printk("%s: memory allocation failure.\n", card
->name
);
3507 memset(card
->vcs
, 0, size
);
3509 size
= sizeof(struct vc_map
*) * card
->scd_size
;
3510 IPRINTK("%s: allocate %d byte for SCD to VC mapping.\n",
3512 if (NULL
== (card
->scd2vc
= vmalloc(size
))) {
3513 printk("%s: memory allocation failure.\n", card
->name
);
3517 memset(card
->scd2vc
, 0, size
);
3519 size
= sizeof(struct tst_info
) * (card
->tst_size
- 2);
3520 IPRINTK("%s: allocate %d byte for TST to VC mapping.\n",
3522 if (NULL
== (card
->soft_tst
= vmalloc(size
))) {
3523 printk("%s: memory allocation failure.\n", card
->name
);
3527 for (i
= 0; i
< card
->tst_size
- 2; i
++) {
3528 card
->soft_tst
[i
].tste
= TSTE_OPC_VAR
;
3529 card
->soft_tst
[i
].vc
= NULL
;
3532 if (dev
->phy
== NULL
) {
3533 printk("%s: No LT device defined.\n", card
->name
);
3537 if (dev
->phy
->ioctl
== NULL
) {
3538 printk("%s: LT had no IOCTL funtion defined.\n", card
->name
);
3543 #ifdef CONFIG_ATM_IDT77252_USE_SUNI
3545 * this is a jhs hack to get around special functionality in the
3546 * phy driver for the atecom hardware; the functionality doesn't
3547 * exist in the linux atm suni driver
3549 * it isn't the right way to do things, but as the guy from NIST
3550 * said, talking about their measurement of the fine structure
3551 * constant, "it's good enough for government work."
3553 linkrate
= 149760000;
3556 card
->link_pcr
= (linkrate
/ 8 / 53);
3557 printk("%s: Linkrate on ATM line : %u bit/s, %u cell/s.\n",
3558 card
->name
, linkrate
, card
->link_pcr
);
3560 #ifdef ATM_IDT77252_SEND_IDLE
3561 card
->utopia_pcr
= card
->link_pcr
;
3563 card
->utopia_pcr
= (160000000 / 8 / 54);
3567 if (card
->utopia_pcr
> card
->link_pcr
)
3568 rsvdcr
= card
->utopia_pcr
- card
->link_pcr
;
3570 tmpl
= (unsigned long) rsvdcr
* ((unsigned long) card
->tst_size
- 2);
3571 modl
= tmpl
% (unsigned long)card
->utopia_pcr
;
3572 tst_entries
= (int) (tmpl
/ (unsigned long)card
->utopia_pcr
);
3575 card
->tst_free
-= tst_entries
;
3576 fill_tst(card
, NULL
, tst_entries
, TSTE_OPC_NULL
);
3579 idt77252_eeprom_init(card
);
3580 printk("%s: EEPROM: %02x:", card
->name
,
3581 idt77252_eeprom_read_status(card
));
3583 for (i
= 0; i
< 0x80; i
++) {
3585 idt77252_eeprom_read_byte(card
, i
)
3589 #endif /* HAVE_EEPROM */
3594 sprintf(tname
, "eth%d", card
->index
);
3595 tmp
= dev_get_by_name(&init_net
, tname
); /* jhs: was "tmp = dev_get(tname);" */
3597 memcpy(card
->atmdev
->esi
, tmp
->dev_addr
, 6);
3599 printk("%s: ESI %02x:%02x:%02x:%02x:%02x:%02x\n",
3600 card
->name
, card
->atmdev
->esi
[0], card
->atmdev
->esi
[1],
3601 card
->atmdev
->esi
[2], card
->atmdev
->esi
[3],
3602 card
->atmdev
->esi
[4], card
->atmdev
->esi
[5]);
3608 /* Set Maximum Deficit Count for now. */
3609 writel(0xffff, SAR_REG_MDFCT
);
3611 set_bit(IDT77252_BIT_INIT
, &card
->flags
);
3613 XPRINTK("%s: IDT77252 ABR SAR initialization complete.\n", card
->name
);
3618 /*****************************************************************************/
3620 /* Probing of IDT77252 ABR SAR */
3622 /*****************************************************************************/
3625 static int __devinit
3626 idt77252_preset(struct idt77252_dev
*card
)
3630 /*****************************************************************/
3631 /* P C I C O N F I G U R A T I O N */
3632 /*****************************************************************/
3634 XPRINTK("%s: Enable PCI master and memory access for SAR.\n",
3636 if (pci_read_config_word(card
->pcidev
, PCI_COMMAND
, &pci_command
)) {
3637 printk("%s: can't read PCI_COMMAND.\n", card
->name
);
3641 if (!(pci_command
& PCI_COMMAND_IO
)) {
3642 printk("%s: PCI_COMMAND: %04x (???)\n",
3643 card
->name
, pci_command
);
3647 pci_command
|= (PCI_COMMAND_MEMORY
| PCI_COMMAND_MASTER
);
3648 if (pci_write_config_word(card
->pcidev
, PCI_COMMAND
, pci_command
)) {
3649 printk("%s: can't write PCI_COMMAND.\n", card
->name
);
3653 /*****************************************************************/
3654 /* G E N E R I C R E S E T */
3655 /*****************************************************************/
3657 /* Software reset */
3658 writel(SAR_CFG_SWRST
, SAR_REG_CFG
);
3660 writel(0, SAR_REG_CFG
);
3662 IPRINTK("%s: Software resetted.\n", card
->name
);
3667 static unsigned long __devinit
3668 probe_sram(struct idt77252_dev
*card
)
3672 writel(0, SAR_REG_DR0
);
3673 writel(SAR_CMD_WRITE_SRAM
| (0 << 2), SAR_REG_CMD
);
3675 for (addr
= 0x4000; addr
< 0x80000; addr
+= 0x4000) {
3676 writel(ATM_POISON
, SAR_REG_DR0
);
3677 writel(SAR_CMD_WRITE_SRAM
| (addr
<< 2), SAR_REG_CMD
);
3679 writel(SAR_CMD_READ_SRAM
| (0 << 2), SAR_REG_CMD
);
3680 data
= readl(SAR_REG_DR0
);
3686 return addr
* sizeof(u32
);
3689 static int __devinit
3690 idt77252_init_one(struct pci_dev
*pcidev
, const struct pci_device_id
*id
)
3692 static struct idt77252_dev
**last
= &idt77252_chain
;
3693 static int index
= 0;
3695 unsigned long membase
, srambase
;
3696 struct idt77252_dev
*card
;
3697 struct atm_dev
*dev
;
3701 if ((err
= pci_enable_device(pcidev
))) {
3702 printk("idt77252: can't enable PCI device at %s\n", pci_name(pcidev
));
3706 card
= kzalloc(sizeof(struct idt77252_dev
), GFP_KERNEL
);
3708 printk("idt77252-%d: can't allocate private data\n", index
);
3710 goto err_out_disable_pdev
;
3712 card
->revision
= pcidev
->revision
;
3713 card
->index
= index
;
3714 card
->pcidev
= pcidev
;
3715 sprintf(card
->name
, "idt77252-%d", card
->index
);
3717 INIT_WORK(&card
->tqueue
, idt77252_softint
);
3719 membase
= pci_resource_start(pcidev
, 1);
3720 srambase
= pci_resource_start(pcidev
, 2);
3722 mutex_init(&card
->mutex
);
3723 spin_lock_init(&card
->cmd_lock
);
3724 spin_lock_init(&card
->tst_lock
);
3726 init_timer(&card
->tst_timer
);
3727 card
->tst_timer
.data
= (unsigned long)card
;
3728 card
->tst_timer
.function
= tst_timer
;
3730 /* Do the I/O remapping... */
3731 card
->membase
= ioremap(membase
, 1024);
3732 if (!card
->membase
) {
3733 printk("%s: can't ioremap() membase\n", card
->name
);
3735 goto err_out_free_card
;
3738 if (idt77252_preset(card
)) {
3739 printk("%s: preset failed\n", card
->name
);
3741 goto err_out_iounmap
;
3744 dev
= atm_dev_register("idt77252", &idt77252_ops
, -1, NULL
);
3746 printk("%s: can't register atm device\n", card
->name
);
3748 goto err_out_iounmap
;
3750 dev
->dev_data
= card
;
3753 #ifdef CONFIG_ATM_IDT77252_USE_SUNI
3756 printk("%s: can't init SUNI\n", card
->name
);
3758 goto err_out_deinit_card
;
3760 #endif /* CONFIG_ATM_IDT77252_USE_SUNI */
3762 card
->sramsize
= probe_sram(card
);
3764 for (i
= 0; i
< 4; i
++) {
3765 card
->fbq
[i
] = ioremap(srambase
| 0x200000 | (i
<< 18), 4);
3766 if (!card
->fbq
[i
]) {
3767 printk("%s: can't ioremap() FBQ%d\n", card
->name
, i
);
3769 goto err_out_deinit_card
;
3773 printk("%s: ABR SAR (Rev %c): MEM %08lx SRAM %08lx [%u KB]\n",
3774 card
->name
, ((card
->revision
> 1) && (card
->revision
< 25)) ?
3775 'A' + card
->revision
- 1 : '?', membase
, srambase
,
3776 card
->sramsize
/ 1024);
3778 if (init_card(dev
)) {
3779 printk("%s: init_card failed\n", card
->name
);
3781 goto err_out_deinit_card
;
3784 dev
->ci_range
.vpi_bits
= card
->vpibits
;
3785 dev
->ci_range
.vci_bits
= card
->vcibits
;
3786 dev
->link_rate
= card
->link_pcr
;
3788 if (dev
->phy
->start
)
3789 dev
->phy
->start(dev
);
3791 if (idt77252_dev_open(card
)) {
3792 printk("%s: dev_open failed\n", card
->name
);
3805 dev
->phy
->stop(dev
);
3807 err_out_deinit_card
:
3811 iounmap(card
->membase
);
3816 err_out_disable_pdev
:
3817 pci_disable_device(pcidev
);
3821 static struct pci_device_id idt77252_pci_tbl
[] =
3823 { PCI_VENDOR_ID_IDT
, PCI_DEVICE_ID_IDT_IDT77252
,
3824 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
3828 MODULE_DEVICE_TABLE(pci
, idt77252_pci_tbl
);
3830 static struct pci_driver idt77252_driver
= {
3832 .id_table
= idt77252_pci_tbl
,
3833 .probe
= idt77252_init_one
,
3836 static int __init
idt77252_init(void)
3838 struct sk_buff
*skb
;
3840 <<<<<<< HEAD
:drivers
/atm
/idt77252
.c
3841 printk("%s: at %p\n", __FUNCTION__
, idt77252_init
);
3843 printk("%s: at %p\n", __func__
, idt77252_init
);
3844 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/atm
/idt77252
.c
3846 if (sizeof(skb
->cb
) < sizeof(struct atm_skb_data
) +
3847 sizeof(struct idt77252_skb_prv
)) {
3848 printk(KERN_ERR
"%s: skb->cb is too small (%lu < %lu)\n",
3849 <<<<<<< HEAD
:drivers
/atm
/idt77252
.c
3850 __FUNCTION__
, (unsigned long) sizeof(skb
->cb
),
3852 __func__
, (unsigned long) sizeof(skb
->cb
),
3853 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/atm
/idt77252
.c
3854 (unsigned long) sizeof(struct atm_skb_data
) +
3855 sizeof(struct idt77252_skb_prv
));
3859 return pci_register_driver(&idt77252_driver
);
3862 static void __exit
idt77252_exit(void)
3864 struct idt77252_dev
*card
;
3865 struct atm_dev
*dev
;
3867 pci_unregister_driver(&idt77252_driver
);
3869 while (idt77252_chain
) {
3870 card
= idt77252_chain
;
3872 idt77252_chain
= card
->next
;
3875 dev
->phy
->stop(dev
);
3877 pci_disable_device(card
->pcidev
);
3881 DIPRINTK("idt77252: finished cleanup-module().\n");
3884 module_init(idt77252_init
);
3885 module_exit(idt77252_exit
);
3887 MODULE_LICENSE("GPL");
3889 module_param(vpibits
, uint
, 0);
3890 MODULE_PARM_DESC(vpibits
, "number of VPI bits supported (0, 1, or 2)");
3891 #ifdef CONFIG_ATM_IDT77252_DEBUG
3892 module_param(debug
, ulong
, 0644);
3893 MODULE_PARM_DESC(debug
, "debug bitmap, see drivers/atm/idt77252.h");
3896 MODULE_AUTHOR("Eddie C. Dost <ecd@atecom.com>");
3897 MODULE_DESCRIPTION("IDT77252 ABR SAR Driver");