Lines Matching full:card
161 waitfor_idle(struct idt77252_dev *card) in waitfor_idle() argument
171 read_sram(struct idt77252_dev *card, unsigned long addr) in read_sram() argument
176 spin_lock_irqsave(&card->cmd_lock, flags); in read_sram()
178 waitfor_idle(card); in read_sram()
180 spin_unlock_irqrestore(&card->cmd_lock, flags); in read_sram()
185 write_sram(struct idt77252_dev *card, unsigned long addr, u32 value) in write_sram() argument
190 (((addr > card->tst[0] + card->tst_size - 2) && in write_sram()
191 (addr < card->tst[0] + card->tst_size)) || in write_sram()
192 ((addr > card->tst[1] + card->tst_size - 2) && in write_sram()
193 (addr < card->tst[1] + card->tst_size)))) { in write_sram()
195 card->name, addr, value); in write_sram()
198 spin_lock_irqsave(&card->cmd_lock, flags); in write_sram()
201 waitfor_idle(card); in write_sram()
202 spin_unlock_irqrestore(&card->cmd_lock, flags); in write_sram()
208 struct idt77252_dev *card = dev; in read_utility() local
212 if (!card) { in read_utility()
217 spin_lock_irqsave(&card->cmd_lock, flags); in read_utility()
219 waitfor_idle(card); in read_utility()
221 spin_unlock_irqrestore(&card->cmd_lock, flags); in read_utility()
228 struct idt77252_dev *card = dev; in write_utility() local
231 if (!card) { in write_utility()
236 spin_lock_irqsave(&card->cmd_lock, flags); in write_utility()
239 waitfor_idle(card); in write_utility()
240 spin_unlock_irqrestore(&card->cmd_lock, flags); in write_utility()
350 idt77252_read_gp(struct idt77252_dev *card) in idt77252_read_gp() argument
362 idt77252_write_gp(struct idt77252_dev *card, u32 value) in idt77252_write_gp() argument
372 spin_lock_irqsave(&card->cmd_lock, flags); in idt77252_write_gp()
373 waitfor_idle(card); in idt77252_write_gp()
375 spin_unlock_irqrestore(&card->cmd_lock, flags); in idt77252_write_gp()
379 idt77252_eeprom_read_status(struct idt77252_dev *card) in idt77252_eeprom_read_status() argument
385 gp = idt77252_read_gp(card) & ~(SAR_GP_EESCLK|SAR_GP_EECS|SAR_GP_EEDO); in idt77252_eeprom_read_status()
388 idt77252_write_gp(card, gp | rdsrtab[i]); in idt77252_eeprom_read_status()
391 idt77252_write_gp(card, gp | SAR_GP_EECS); in idt77252_eeprom_read_status()
398 idt77252_write_gp(card, gp | clktab[j++]); in idt77252_eeprom_read_status()
401 byte |= idt77252_read_gp(card) & SAR_GP_EEDI ? 1 : 0; in idt77252_eeprom_read_status()
403 idt77252_write_gp(card, gp | clktab[j++]); in idt77252_eeprom_read_status()
406 idt77252_write_gp(card, gp | SAR_GP_EECS); in idt77252_eeprom_read_status()
413 idt77252_eeprom_read_byte(struct idt77252_dev *card, u8 offset) in idt77252_eeprom_read_byte() argument
419 gp = idt77252_read_gp(card) & ~(SAR_GP_EESCLK|SAR_GP_EECS|SAR_GP_EEDO); in idt77252_eeprom_read_byte()
422 idt77252_write_gp(card, gp | rdtab[i]); in idt77252_eeprom_read_byte()
425 idt77252_write_gp(card, gp | SAR_GP_EECS); in idt77252_eeprom_read_byte()
429 idt77252_write_gp(card, gp | clktab[j++] | in idt77252_eeprom_read_byte()
433 idt77252_write_gp(card, gp | clktab[j++] | in idt77252_eeprom_read_byte()
439 idt77252_write_gp(card, gp | SAR_GP_EECS); in idt77252_eeprom_read_byte()
446 idt77252_write_gp(card, gp | clktab[j++]); in idt77252_eeprom_read_byte()
449 byte |= idt77252_read_gp(card) & SAR_GP_EEDI ? 1 : 0; in idt77252_eeprom_read_byte()
451 idt77252_write_gp(card, gp | clktab[j++]); in idt77252_eeprom_read_byte()
454 idt77252_write_gp(card, gp | SAR_GP_EECS); in idt77252_eeprom_read_byte()
461 idt77252_eeprom_write_byte(struct idt77252_dev *card, u8 offset, u8 data) in idt77252_eeprom_write_byte() argument
466 gp = idt77252_read_gp(card) & ~(SAR_GP_EESCLK|SAR_GP_EECS|SAR_GP_EEDO); in idt77252_eeprom_write_byte()
469 idt77252_write_gp(card, gp | wrentab[i]); in idt77252_eeprom_write_byte()
472 idt77252_write_gp(card, gp | SAR_GP_EECS); in idt77252_eeprom_write_byte()
476 idt77252_write_gp(card, gp | wrtab[i]); in idt77252_eeprom_write_byte()
479 idt77252_write_gp(card, gp | SAR_GP_EECS); in idt77252_eeprom_write_byte()
483 idt77252_write_gp(card, gp | clktab[j++] | in idt77252_eeprom_write_byte()
487 idt77252_write_gp(card, gp | clktab[j++] | in idt77252_eeprom_write_byte()
493 idt77252_write_gp(card, gp | SAR_GP_EECS); in idt77252_eeprom_write_byte()
497 idt77252_write_gp(card, gp | clktab[j++] | in idt77252_eeprom_write_byte()
501 idt77252_write_gp(card, gp | clktab[j++] | in idt77252_eeprom_write_byte()
507 idt77252_write_gp(card, gp | SAR_GP_EECS); in idt77252_eeprom_write_byte()
512 idt77252_eeprom_init(struct idt77252_dev *card) in idt77252_eeprom_init() argument
516 gp = idt77252_read_gp(card) & ~(SAR_GP_EESCLK|SAR_GP_EECS|SAR_GP_EEDO); in idt77252_eeprom_init()
518 idt77252_write_gp(card, gp | SAR_GP_EECS | SAR_GP_EESCLK); in idt77252_eeprom_init()
520 idt77252_write_gp(card, gp | SAR_GP_EECS); in idt77252_eeprom_init()
522 idt77252_write_gp(card, gp | SAR_GP_EECS | SAR_GP_EESCLK); in idt77252_eeprom_init()
524 idt77252_write_gp(card, gp | SAR_GP_EECS); in idt77252_eeprom_init()
532 dump_tct(struct idt77252_dev *card, int index) in dump_tct() argument
537 tct = (unsigned long) (card->tct_base + index * SAR_SRAM_TCT_SIZE); in dump_tct()
539 printk("%s: TCT %x:", card->name, index); in dump_tct()
541 printk(" %08x", read_sram(card, tct + i)); in dump_tct()
547 idt77252_tx_dump(struct idt77252_dev *card) in idt77252_tx_dump() argument
554 for (i = 0; i < card->tct_size; i++) { in idt77252_tx_dump()
555 vc = card->vcs[i]; in idt77252_tx_dump()
568 printk("%s: Connection %d:\n", card->name, vc->index); in idt77252_tx_dump()
569 dump_tct(card, vc->index); in idt77252_tx_dump()
582 sb_pool_add(struct idt77252_dev *card, struct sk_buff *skb, int queue) in sb_pool_add() argument
584 struct sb_pool *pool = &card->sbpool[queue]; in sb_pool_add()
602 sb_pool_remove(struct idt77252_dev *card, struct sk_buff *skb) in sb_pool_remove() argument
617 card->sbpool[queue].skb[index] = NULL; in sb_pool_remove()
621 sb_pool_skb(struct idt77252_dev *card, u32 handle) in sb_pool_skb() argument
633 return card->sbpool[queue].skb[index]; in sb_pool_skb()
637 alloc_scq(struct idt77252_dev *card, int class) in alloc_scq() argument
644 scq->base = dma_alloc_coherent(&card->pcidev->dev, SCQ_SIZE, in alloc_scq()
668 free_scq(struct idt77252_dev *card, struct scq_info *scq) in free_scq() argument
673 dma_free_coherent(&card->pcidev->dev, SCQ_SIZE, in free_scq()
677 dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), in free_scq()
688 dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), in free_scq()
703 push_on_scq(struct idt77252_dev *card, struct vc_map *vc, struct sk_buff *skb) in push_on_scq() argument
710 TXPRINTK("%s: SCQ: next 0x%p\n", card->name, scq->next); in push_on_scq()
756 write_sram(card, scq->scd, in push_on_scq()
771 card->name, atomic_read(&scq->used), in push_on_scq()
772 read_sram(card, scq->scd + 1), scq->next); in push_on_scq()
779 card->name, vc->tx_vcc->vpi, vc->tx_vcc->vci); in push_on_scq()
781 idt77252_tx_dump(card); in push_on_scq()
791 drain_scq(struct idt77252_dev *card, struct vc_map *vc) in drain_scq() argument
798 card->name, atomic_read(&scq->used), scq->next); in drain_scq()
802 TXPRINTK("%s: freeing skb at %p.\n", card->name, skb); in drain_scq()
804 dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), in drain_scq()
821 if (push_on_scq(card, vc, skb)) { in drain_scq()
830 queue_skb(struct idt77252_dev *card, struct vc_map *vc, in queue_skb() argument
841 printk("%s: invalid skb->len (%d)\n", card->name, skb->len); in queue_skb()
846 card->name, skb->len); in queue_skb()
853 IDT77252_PRV_PADDR(skb) = dma_map_single(&card->pcidev->dev, skb->data, in queue_skb()
868 vc = card->vcs[0]; in queue_skb()
874 printk("%s: Trying to transmit on reserved VC\n", card->name); in queue_skb()
909 printk("%s: Traffic type not supported.\n", card->name); in queue_skb()
919 if (push_on_scq(card, vc, skb)) { in queue_skb()
929 dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), in queue_skb()
935 get_free_scd(struct idt77252_dev *card, struct vc_map *vc) in get_free_scd() argument
939 for (i = 0; i < card->scd_size; i++) { in get_free_scd()
940 if (!card->scd2vc[i]) { in get_free_scd()
941 card->scd2vc[i] = vc; in get_free_scd()
943 return card->scd_base + i * SAR_SRAM_SCD_SIZE; in get_free_scd()
950 fill_scd(struct idt77252_dev *card, struct scq_info *scq, int class) in fill_scd() argument
952 write_sram(card, scq->scd, scq->paddr); in fill_scd()
953 write_sram(card, scq->scd + 1, 0x00000000); in fill_scd()
954 write_sram(card, scq->scd + 2, 0xffffffff); in fill_scd()
955 write_sram(card, scq->scd + 3, 0x00000000); in fill_scd()
959 clear_scd(struct idt77252_dev *card, struct scq_info *scq, int class) in clear_scd() argument
971 init_rsq(struct idt77252_dev *card) in init_rsq() argument
975 card->rsq.base = dma_alloc_coherent(&card->pcidev->dev, RSQSIZE, in init_rsq()
976 &card->rsq.paddr, GFP_KERNEL); in init_rsq()
977 if (card->rsq.base == NULL) { in init_rsq()
978 printk("%s: can't allocate RSQ.\n", card->name); in init_rsq()
982 card->rsq.last = card->rsq.base + RSQ_NUM_ENTRIES - 1; in init_rsq()
983 card->rsq.next = card->rsq.last; in init_rsq()
984 for (rsqe = card->rsq.base; rsqe <= card->rsq.last; rsqe++) in init_rsq()
987 writel((unsigned long) card->rsq.last - (unsigned long) card->rsq.base, in init_rsq()
989 writel(card->rsq.paddr, SAR_REG_RSQB); in init_rsq()
991 IPRINTK("%s: RSQ base at 0x%lx (0x%x).\n", card->name, in init_rsq()
992 (unsigned long) card->rsq.base, in init_rsq()
995 card->name, in init_rsq()
1004 deinit_rsq(struct idt77252_dev *card) in deinit_rsq() argument
1006 dma_free_coherent(&card->pcidev->dev, RSQSIZE, in deinit_rsq()
1007 card->rsq.base, card->rsq.paddr); in deinit_rsq()
1011 dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe) in dequeue_rx() argument
1025 card->name); in dequeue_rx()
1029 skb = sb_pool_skb(card, le32_to_cpu(rsqe->word_2)); in dequeue_rx()
1032 card->name, __func__, in dequeue_rx()
1043 card->name, vpi, vci, skb, skb->data); in dequeue_rx()
1045 if ((vpi >= (1 << card->vpibits)) || (vci != (vci & card->vcimask))) { in dequeue_rx()
1047 card->name, vpi, vci); in dequeue_rx()
1048 recycle_rx_skb(card, skb); in dequeue_rx()
1052 vc = card->vcs[VPCI2VC(card, vpi, vci)]; in dequeue_rx()
1055 card->name, vpi, vci); in dequeue_rx()
1056 recycle_rx_skb(card, skb); in dequeue_rx()
1062 dma_sync_single_for_cpu(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), in dequeue_rx()
1076 card->name); in dequeue_rx()
1082 card->name); in dequeue_rx()
1104 recycle_rx_skb(card, skb); in dequeue_rx()
1109 card->name, vcc->qos.aal); in dequeue_rx()
1110 recycle_rx_skb(card, skb); in dequeue_rx()
1129 RXPRINTK("%s: PDU has %d bytes.\n", card->name, len); in dequeue_rx()
1134 card->name, len, rpp->len, readl(SAR_REG_CDC)); in dequeue_rx()
1135 recycle_rx_pool_skb(card, rpp); in dequeue_rx()
1140 RXPRINTK("%s: AAL5 CRC error.\n", card->name); in dequeue_rx()
1141 recycle_rx_pool_skb(card, rpp); in dequeue_rx()
1151 card->name); in dequeue_rx()
1152 recycle_rx_pool_skb(card, rpp); in dequeue_rx()
1157 recycle_rx_pool_skb(card, rpp); in dequeue_rx()
1164 recycle_rx_pool_skb(card, rpp); in dequeue_rx()
1176 flush_rx_pool(card, rpp); in dequeue_rx()
1179 recycle_rx_skb(card, skb); in dequeue_rx()
1183 dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), in dequeue_rx()
1186 sb_pool_remove(card, skb); in dequeue_rx()
1197 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1); in dequeue_rx()
1199 add_rx_skb(card, 2, SAR_FB_SIZE_2, 1); in dequeue_rx()
1201 add_rx_skb(card, 1, SAR_FB_SIZE_1, 1); in dequeue_rx()
1203 add_rx_skb(card, 0, SAR_FB_SIZE_0, 1); in dequeue_rx()
1209 idt77252_rx(struct idt77252_dev *card) in idt77252_rx() argument
1213 if (card->rsq.next == card->rsq.last) in idt77252_rx()
1214 rsqe = card->rsq.base; in idt77252_rx()
1216 rsqe = card->rsq.next + 1; in idt77252_rx()
1219 RXPRINTK("%s: no entry in RSQ.\n", card->name); in idt77252_rx()
1224 dequeue_rx(card, rsqe); in idt77252_rx()
1226 card->rsq.next = rsqe; in idt77252_rx()
1227 if (card->rsq.next == card->rsq.last) in idt77252_rx()
1228 rsqe = card->rsq.base; in idt77252_rx()
1230 rsqe = card->rsq.next + 1; in idt77252_rx()
1233 writel((unsigned long) card->rsq.next - (unsigned long) card->rsq.base, in idt77252_rx()
1238 idt77252_rx_raw(struct idt77252_dev *card) in idt77252_rx_raw() argument
1246 if (card->raw_cell_head == NULL) { in idt77252_rx_raw()
1247 u32 handle = le32_to_cpu(*(card->raw_cell_hnd + 1)); in idt77252_rx_raw()
1248 card->raw_cell_head = sb_pool_skb(card, handle); in idt77252_rx_raw()
1251 queue = card->raw_cell_head; in idt77252_rx_raw()
1258 dma_sync_single_for_cpu(&card->pcidev->dev, IDT77252_PRV_PADDR(queue), in idt77252_rx_raw()
1276 card->name, (header >> 28) & 0x000f, in idt77252_rx_raw()
1287 if (vpi >= (1<<card->vpibits) || vci >= (1<<card->vcibits)) { in idt77252_rx_raw()
1289 card->name, vpi, vci); in idt77252_rx_raw()
1293 vc = card->vcs[VPCI2VC(card, vpi, vci)]; in idt77252_rx_raw()
1296 card->name, vpi, vci); in idt77252_rx_raw()
1304 card->name, vpi, vci); in idt77252_rx_raw()
1311 card->name); in idt77252_rx_raw()
1318 card->name); in idt77252_rx_raw()
1345 next = sb_pool_skb(card, handle); in idt77252_rx_raw()
1346 recycle_rx_skb(card, queue); in idt77252_rx_raw()
1349 card->raw_cell_head = next; in idt77252_rx_raw()
1350 queue = card->raw_cell_head; in idt77252_rx_raw()
1351 dma_sync_single_for_cpu(&card->pcidev->dev, in idt77252_rx_raw()
1357 card->raw_cell_head = NULL; in idt77252_rx_raw()
1359 card->name); in idt77252_rx_raw()
1374 init_tsq(struct idt77252_dev *card) in init_tsq() argument
1378 card->tsq.base = dma_alloc_coherent(&card->pcidev->dev, RSQSIZE, in init_tsq()
1379 &card->tsq.paddr, GFP_KERNEL); in init_tsq()
1380 if (card->tsq.base == NULL) { in init_tsq()
1381 printk("%s: can't allocate TSQ.\n", card->name); in init_tsq()
1385 card->tsq.last = card->tsq.base + TSQ_NUM_ENTRIES - 1; in init_tsq()
1386 card->tsq.next = card->tsq.last; in init_tsq()
1387 for (tsqe = card->tsq.base; tsqe <= card->tsq.last; tsqe++) in init_tsq()
1390 writel(card->tsq.paddr, SAR_REG_TSQB); in init_tsq()
1391 writel((unsigned long) card->tsq.next - (unsigned long) card->tsq.base, in init_tsq()
1398 deinit_tsq(struct idt77252_dev *card) in deinit_tsq() argument
1400 dma_free_coherent(&card->pcidev->dev, TSQSIZE, in deinit_tsq()
1401 card->tsq.base, card->tsq.paddr); in deinit_tsq()
1405 idt77252_tx(struct idt77252_dev *card) in idt77252_tx() argument
1412 if (card->tsq.next == card->tsq.last) in idt77252_tx()
1413 tsqe = card->tsq.base; in idt77252_tx()
1415 tsqe = card->tsq.next + 1; in idt77252_tx()
1418 card->tsq.base, card->tsq.next, card->tsq.last); in idt77252_tx()
1436 TXPRINTK("%s: Timer RollOver detected.\n", card->name); in idt77252_tx()
1446 card->name, in idt77252_tx()
1452 vc = card->vcs[conn & 0x1fff]; in idt77252_tx()
1455 card->name, conn & 0x1fff); in idt77252_tx()
1460 card->name, vc->index); in idt77252_tx()
1469 vc = card->vcs[conn & 0x1fff]; in idt77252_tx()
1472 card->name, in idt77252_tx()
1477 drain_scq(card, vc); in idt77252_tx()
1487 if (vpi >= (1 << card->vpibits) || in idt77252_tx()
1488 vci >= (1 << card->vcibits)) { in idt77252_tx()
1491 card->name, vpi, vci); in idt77252_tx()
1495 vc = card->vcs[VPCI2VC(card, vpi, vci)]; in idt77252_tx()
1499 card->name, vpi, vci); in idt77252_tx()
1503 drain_scq(card, vc); in idt77252_tx()
1509 card->tsq.next = tsqe; in idt77252_tx()
1510 if (card->tsq.next == card->tsq.last) in idt77252_tx()
1511 tsqe = card->tsq.base; in idt77252_tx()
1513 tsqe = card->tsq.next + 1; in idt77252_tx()
1516 card->tsq.base, card->tsq.next, card->tsq.last); in idt77252_tx()
1522 writel((unsigned long)card->tsq.next - (unsigned long)card->tsq.base, in idt77252_tx()
1526 card->index, readl(SAR_REG_TSQH), in idt77252_tx()
1527 readl(SAR_REG_TSQT), card->tsq.next); in idt77252_tx()
1534 struct idt77252_dev *card = from_timer(card, t, tst_timer); in tst_timer() local
1540 spin_lock_irqsave(&card->tst_lock, flags); in tst_timer()
1542 base = card->tst[card->tst_index]; in tst_timer()
1543 idle = card->tst[card->tst_index ^ 1]; in tst_timer()
1545 if (test_bit(TST_SWITCH_WAIT, &card->tst_state)) { in tst_timer()
1546 jump = base + card->tst_size - 2; in tst_timer()
1549 if ((pc ^ idle) & ~(card->tst_size - 1)) { in tst_timer()
1550 mod_timer(&card->tst_timer, jiffies + 1); in tst_timer()
1554 clear_bit(TST_SWITCH_WAIT, &card->tst_state); in tst_timer()
1556 card->tst_index ^= 1; in tst_timer()
1557 write_sram(card, jump, TSTE_OPC_JMP | (base << 2)); in tst_timer()
1559 base = card->tst[card->tst_index]; in tst_timer()
1560 idle = card->tst[card->tst_index ^ 1]; in tst_timer()
1562 for (e = 0; e < card->tst_size - 2; e++) { in tst_timer()
1563 if (card->soft_tst[e].tste & TSTE_PUSH_IDLE) { in tst_timer()
1564 write_sram(card, idle + e, in tst_timer()
1565 card->soft_tst[e].tste & TSTE_MASK); in tst_timer()
1566 card->soft_tst[e].tste &= ~(TSTE_PUSH_IDLE); in tst_timer()
1571 if (test_and_clear_bit(TST_SWITCH_PENDING, &card->tst_state)) { in tst_timer()
1573 for (e = 0; e < card->tst_size - 2; e++) { in tst_timer()
1574 if (card->soft_tst[e].tste & TSTE_PUSH_ACTIVE) { in tst_timer()
1575 write_sram(card, idle + e, in tst_timer()
1576 card->soft_tst[e].tste & TSTE_MASK); in tst_timer()
1577 card->soft_tst[e].tste &= ~(TSTE_PUSH_ACTIVE); in tst_timer()
1578 card->soft_tst[e].tste |= TSTE_PUSH_IDLE; in tst_timer()
1582 jump = base + card->tst_size - 2; in tst_timer()
1584 write_sram(card, jump, TSTE_OPC_NULL); in tst_timer()
1585 set_bit(TST_SWITCH_WAIT, &card->tst_state); in tst_timer()
1587 mod_timer(&card->tst_timer, jiffies + 1); in tst_timer()
1591 spin_unlock_irqrestore(&card->tst_lock, flags); in tst_timer()
1595 __fill_tst(struct idt77252_dev *card, struct vc_map *vc, in __fill_tst() argument
1603 avail = card->tst_size - 2; in __fill_tst()
1605 if (card->soft_tst[e].vc == NULL) in __fill_tst()
1609 printk("%s: No free TST entries found\n", card->name); in __fill_tst()
1614 card->name, vc ? vc->index : -1, e); in __fill_tst()
1622 idle = card->tst[card->tst_index ^ 1]; in __fill_tst()
1628 if ((cl >= avail) && (card->soft_tst[e].vc == NULL)) { in __fill_tst()
1630 card->soft_tst[e].vc = vc; in __fill_tst()
1632 card->soft_tst[e].vc = (void *)-1; in __fill_tst()
1634 card->soft_tst[e].tste = data; in __fill_tst()
1635 if (timer_pending(&card->tst_timer)) in __fill_tst()
1636 card->soft_tst[e].tste |= TSTE_PUSH_ACTIVE; in __fill_tst()
1638 write_sram(card, idle + e, data); in __fill_tst()
1639 card->soft_tst[e].tste |= TSTE_PUSH_IDLE; in __fill_tst()
1642 cl -= card->tst_size; in __fill_tst()
1655 fill_tst(struct idt77252_dev *card, struct vc_map *vc, int n, unsigned int opc) in fill_tst() argument
1660 spin_lock_irqsave(&card->tst_lock, flags); in fill_tst()
1662 res = __fill_tst(card, vc, n, opc); in fill_tst()
1664 set_bit(TST_SWITCH_PENDING, &card->tst_state); in fill_tst()
1665 if (!timer_pending(&card->tst_timer)) in fill_tst()
1666 mod_timer(&card->tst_timer, jiffies + 1); in fill_tst()
1668 spin_unlock_irqrestore(&card->tst_lock, flags); in fill_tst()
1673 __clear_tst(struct idt77252_dev *card, struct vc_map *vc) in __clear_tst() argument
1678 idle = card->tst[card->tst_index ^ 1]; in __clear_tst()
1680 for (e = 0; e < card->tst_size - 2; e++) { in __clear_tst()
1681 if (card->soft_tst[e].vc == vc) { in __clear_tst()
1682 card->soft_tst[e].vc = NULL; in __clear_tst()
1684 card->soft_tst[e].tste = TSTE_OPC_VAR; in __clear_tst()
1685 if (timer_pending(&card->tst_timer)) in __clear_tst()
1686 card->soft_tst[e].tste |= TSTE_PUSH_ACTIVE; in __clear_tst()
1688 write_sram(card, idle + e, TSTE_OPC_VAR); in __clear_tst()
1689 card->soft_tst[e].tste |= TSTE_PUSH_IDLE; in __clear_tst()
1698 clear_tst(struct idt77252_dev *card, struct vc_map *vc) in clear_tst() argument
1703 spin_lock_irqsave(&card->tst_lock, flags); in clear_tst()
1705 res = __clear_tst(card, vc); in clear_tst()
1707 set_bit(TST_SWITCH_PENDING, &card->tst_state); in clear_tst()
1708 if (!timer_pending(&card->tst_timer)) in clear_tst()
1709 mod_timer(&card->tst_timer, jiffies + 1); in clear_tst()
1711 spin_unlock_irqrestore(&card->tst_lock, flags); in clear_tst()
1716 change_tst(struct idt77252_dev *card, struct vc_map *vc, in change_tst() argument
1722 spin_lock_irqsave(&card->tst_lock, flags); in change_tst()
1724 __clear_tst(card, vc); in change_tst()
1725 res = __fill_tst(card, vc, n, opc); in change_tst()
1727 set_bit(TST_SWITCH_PENDING, &card->tst_state); in change_tst()
1728 if (!timer_pending(&card->tst_timer)) in change_tst()
1729 mod_timer(&card->tst_timer, jiffies + 1); in change_tst()
1731 spin_unlock_irqrestore(&card->tst_lock, flags); in change_tst()
1737 set_tct(struct idt77252_dev *card, struct vc_map *vc) in set_tct() argument
1741 tct = (unsigned long) (card->tct_base + vc->index * SAR_SRAM_TCT_SIZE); in set_tct()
1746 card->name, tct, vc->scq->scd); in set_tct()
1748 write_sram(card, tct + 0, TCT_CBR | vc->scq->scd); in set_tct()
1749 write_sram(card, tct + 1, 0); in set_tct()
1750 write_sram(card, tct + 2, 0); in set_tct()
1751 write_sram(card, tct + 3, 0); in set_tct()
1752 write_sram(card, tct + 4, 0); in set_tct()
1753 write_sram(card, tct + 5, 0); in set_tct()
1754 write_sram(card, tct + 6, 0); in set_tct()
1755 write_sram(card, tct + 7, 0); in set_tct()
1760 card->name, tct, vc->scq->scd); in set_tct()
1762 write_sram(card, tct + 0, TCT_UBR | vc->scq->scd); in set_tct()
1763 write_sram(card, tct + 1, 0); in set_tct()
1764 write_sram(card, tct + 2, TCT_TSIF); in set_tct()
1765 write_sram(card, tct + 3, TCT_HALT | TCT_IDLE); in set_tct()
1766 write_sram(card, tct + 4, 0); in set_tct()
1767 write_sram(card, tct + 5, vc->init_er); in set_tct()
1768 write_sram(card, tct + 6, 0); in set_tct()
1769 write_sram(card, tct + 7, TCT_FLAG_UBR); in set_tct()
1788 idt77252_fbq_full(struct idt77252_dev *card, int queue) in idt77252_fbq_full() argument
1794 push_rx_skb(struct idt77252_dev *card, struct sk_buff *skb, int queue) in push_rx_skb() argument
1823 if (idt77252_fbq_full(card, queue)) in push_rx_skb()
1831 spin_lock_irqsave(&card->cmd_lock, flags); in push_rx_skb()
1832 writel(handle, card->fbq[queue]); in push_rx_skb()
1833 writel(addr, card->fbq[queue]); in push_rx_skb()
1834 spin_unlock_irqrestore(&card->cmd_lock, flags); in push_rx_skb()
1840 add_rx_skb(struct idt77252_dev *card, int queue, in add_rx_skb() argument
1852 if (sb_pool_add(card, skb, queue)) { in add_rx_skb()
1857 paddr = dma_map_single(&card->pcidev->dev, skb->data, in add_rx_skb()
1862 if (push_rx_skb(card, skb, queue)) { in add_rx_skb()
1871 dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), in add_rx_skb()
1875 card->sbpool[POOL_QUEUE(handle)].skb[POOL_INDEX(handle)] = NULL; in add_rx_skb()
1883 recycle_rx_skb(struct idt77252_dev *card, struct sk_buff *skb) in recycle_rx_skb() argument
1888 dma_sync_single_for_device(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), in recycle_rx_skb()
1892 err = push_rx_skb(card, skb, POOL_QUEUE(handle)); in recycle_rx_skb()
1894 dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), in recycle_rx_skb()
1897 sb_pool_remove(card, skb); in recycle_rx_skb()
1903 flush_rx_pool(struct idt77252_dev *card, struct rx_pool *rpp) in flush_rx_pool() argument
1910 recycle_rx_pool_skb(struct idt77252_dev *card, struct rx_pool *rpp) in recycle_rx_pool_skb() argument
1915 recycle_rx_skb(card, skb); in recycle_rx_pool_skb()
1917 flush_rx_pool(card, rpp); in recycle_rx_pool_skb()
1942 struct idt77252_dev *card = dev->dev_data; in idt77252_send_skb() local
1947 printk("%s: NULL connection in send().\n", card->name); in idt77252_send_skb()
1953 printk("%s: Trying to transmit on a non-tx VC.\n", card->name); in idt77252_send_skb()
1965 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal); in idt77252_send_skb()
1972 printk("%s: No scatter-gather yet.\n", card->name); in idt77252_send_skb()
1979 err = queue_skb(card, vc, skb, oam); in idt77252_send_skb()
1998 struct idt77252_dev *card = dev->dev_data; in idt77252_send_oam() local
2003 printk("%s: Out of memory in send_oam().\n", card->name); in idt77252_send_oam()
2060 idt77252_rate_logindex(struct idt77252_dev *card, int pcr) in idt77252_rate_logindex() argument
2075 struct idt77252_dev *card = vc->card; in idt77252_est_timer() local
2095 lacr = idt77252_rate_logindex(card, cps); in idt77252_est_timer()
2133 idt77252_init_cbr(struct idt77252_dev *card, struct vc_map *vc, in idt77252_init_cbr() argument
2143 card->name); in idt77252_init_cbr()
2148 tst_free = card->tst_free; in idt77252_init_cbr()
2156 TXPRINTK("%s: CBR target cell rate = %d\n", card->name, tcra); in idt77252_init_cbr()
2158 tmpl = (unsigned long) tcra * ((unsigned long) card->tst_size - 2); in idt77252_init_cbr()
2159 modl = tmpl % (unsigned long)card->utopia_pcr; in idt77252_init_cbr()
2161 tst_entries = (int) (tmpl / card->utopia_pcr); in idt77252_init_cbr()
2168 printk("%s: no CBR bandwidth free.\n", card->name); in idt77252_init_cbr()
2175 card->name); in idt77252_init_cbr()
2180 printk("%s: not enough CBR bandwidth free.\n", card->name); in idt77252_init_cbr()
2186 card->tst_free = tst_free - tst_entries; in idt77252_init_cbr()
2192 card->name, tst_used, tst_entries); in idt77252_init_cbr()
2193 change_tst(card, vc, tst_entries, TSTE_OPC_CBR); in idt77252_init_cbr()
2197 OPRINTK("%s: setting %d entries in TST.\n", card->name, tst_entries); in idt77252_init_cbr()
2198 fill_tst(card, vc, tst_entries, TSTE_OPC_CBR); in idt77252_init_cbr()
2203 idt77252_init_ubr(struct idt77252_dev *card, struct vc_map *vc, in idt77252_init_ubr() argument
2223 tcr = card->link_pcr; in idt77252_init_ubr()
2228 vc->init_er = idt77252_rate_logindex(card, tcr); in idt77252_init_ubr()
2239 idt77252_init_tx(struct idt77252_dev *card, struct vc_map *vc, in idt77252_init_tx() argument
2262 vc->scq = alloc_scq(card, vc->class); in idt77252_init_tx()
2264 printk("%s: can't get SCQ.\n", card->name); in idt77252_init_tx()
2268 vc->scq->scd = get_free_scd(card, vc); in idt77252_init_tx()
2270 printk("%s: no SCD available.\n", card->name); in idt77252_init_tx()
2271 free_scq(card, vc->scq); in idt77252_init_tx()
2275 fill_scd(card, vc->scq, vc->class); in idt77252_init_tx()
2277 if (set_tct(card, vc)) { in idt77252_init_tx()
2279 card->name, qos->txtp.traffic_class); in idt77252_init_tx()
2281 card->scd2vc[vc->scd_index] = NULL; in idt77252_init_tx()
2282 free_scq(card, vc->scq); in idt77252_init_tx()
2288 error = idt77252_init_cbr(card, vc, vcc, qos); in idt77252_init_tx()
2290 card->scd2vc[vc->scd_index] = NULL; in idt77252_init_tx()
2291 free_scq(card, vc->scq); in idt77252_init_tx()
2300 error = idt77252_init_ubr(card, vc, vcc, qos); in idt77252_init_tx()
2302 card->scd2vc[vc->scd_index] = NULL; in idt77252_init_tx()
2303 free_scq(card, vc->scq); in idt77252_init_tx()
2317 idt77252_init_rx(struct idt77252_dev *card, struct vc_map *vc, in idt77252_init_rx() argument
2333 flush_rx_pool(card, &vc->rcv.rx_pool); in idt77252_init_rx()
2367 addr = card->rct_base + (vc->index << 2); in idt77252_init_rx()
2369 OPRINTK("%s: writing RCT at 0x%lx\n", card->name, addr); in idt77252_init_rx()
2370 write_sram(card, addr, rcte); in idt77252_init_rx()
2372 spin_lock_irqsave(&card->cmd_lock, flags); in idt77252_init_rx()
2374 waitfor_idle(card); in idt77252_init_rx()
2375 spin_unlock_irqrestore(&card->cmd_lock, flags); in idt77252_init_rx()
2384 struct idt77252_dev *card = dev->dev_data; in idt77252_open() local
2395 if (vpi >= (1 << card->vpibits)) { in idt77252_open()
2396 printk("%s: unsupported VPI: %d\n", card->name, vpi); in idt77252_open()
2400 if (vci >= (1 << card->vcibits)) { in idt77252_open()
2401 printk("%s: unsupported VCI: %d\n", card->name, vci); in idt77252_open()
2407 mutex_lock(&card->mutex); in idt77252_open()
2409 OPRINTK("%s: opening vpi.vci: %d.%d\n", card->name, vpi, vci); in idt77252_open()
2417 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal); in idt77252_open()
2418 mutex_unlock(&card->mutex); in idt77252_open()
2422 index = VPCI2VC(card, vpi, vci); in idt77252_open()
2423 if (!card->vcs[index]) { in idt77252_open()
2424 card->vcs[index] = kzalloc(sizeof(struct vc_map), GFP_KERNEL); in idt77252_open()
2425 if (!card->vcs[index]) { in idt77252_open()
2426 printk("%s: can't alloc vc in open()\n", card->name); in idt77252_open()
2427 mutex_unlock(&card->mutex); in idt77252_open()
2430 card->vcs[index]->card = card; in idt77252_open()
2431 card->vcs[index]->index = index; in idt77252_open()
2433 spin_lock_init(&card->vcs[index]->lock); in idt77252_open()
2435 vc = card->vcs[index]; in idt77252_open()
2440 card->name, vc->index, vcc->vpi, vcc->vci, in idt77252_open()
2454 printk("%s: %s vci already in use.\n", card->name, in idt77252_open()
2456 mutex_unlock(&card->mutex); in idt77252_open()
2461 error = idt77252_init_tx(card, vc, vcc, &vcc->qos); in idt77252_open()
2463 mutex_unlock(&card->mutex); in idt77252_open()
2469 error = idt77252_init_rx(card, vc, vcc, &vcc->qos); in idt77252_open()
2471 mutex_unlock(&card->mutex); in idt77252_open()
2478 mutex_unlock(&card->mutex); in idt77252_open()
2486 struct idt77252_dev *card = dev->dev_data; in idt77252_close() local
2492 mutex_lock(&card->mutex); in idt77252_close()
2495 card->name, vc->index, vcc->vpi, vcc->vci); in idt77252_close()
2509 addr = card->rct_base + vc->index * SAR_SRAM_RCT_SIZE; in idt77252_close()
2511 spin_lock_irqsave(&card->cmd_lock, flags); in idt77252_close()
2513 waitfor_idle(card); in idt77252_close()
2514 spin_unlock_irqrestore(&card->cmd_lock, flags); in idt77252_close()
2518 card->name); in idt77252_close()
2520 recycle_rx_pool_skb(card, &vc->rcv.rx_pool); in idt77252_close()
2545 card->name, atomic_read(&vc->scq->used)); in idt77252_close()
2551 clear_scd(card, vc->scq, vc->class); in idt77252_close()
2554 clear_tst(card, vc); in idt77252_close()
2555 card->tst_free += vc->ntste; in idt77252_close()
2559 card->scd2vc[vc->scd_index] = NULL; in idt77252_close()
2560 free_scq(card, vc->scq); in idt77252_close()
2563 mutex_unlock(&card->mutex); in idt77252_close()
2570 struct idt77252_dev *card = dev->dev_data; in idt77252_change_qos() local
2574 mutex_lock(&card->mutex); in idt77252_change_qos()
2578 error = idt77252_init_tx(card, vc, vcc, qos); in idt77252_change_qos()
2584 error = idt77252_init_cbr(card, vc, vcc, qos); in idt77252_change_qos()
2590 error = idt77252_init_ubr(card, vc, vcc, qos); in idt77252_change_qos()
2610 error = idt77252_init_rx(card, vc, vcc, qos); in idt77252_change_qos()
2620 mutex_unlock(&card->mutex); in idt77252_change_qos()
2627 struct idt77252_dev *card = dev->dev_data; in idt77252_proc_read() local
2634 return sprintf(page, "TSIF: %lu\n", card->irqstat[15]); in idt77252_proc_read()
2636 return sprintf(page, "TXICP: %lu\n", card->irqstat[14]); in idt77252_proc_read()
2638 return sprintf(page, "TSQF: %lu\n", card->irqstat[12]); in idt77252_proc_read()
2640 return sprintf(page, "TMROF: %lu\n", card->irqstat[11]); in idt77252_proc_read()
2642 return sprintf(page, "PHYI: %lu\n", card->irqstat[10]); in idt77252_proc_read()
2644 return sprintf(page, "FBQ3A: %lu\n", card->irqstat[8]); in idt77252_proc_read()
2646 return sprintf(page, "FBQ2A: %lu\n", card->irqstat[7]); in idt77252_proc_read()
2648 return sprintf(page, "RSQF: %lu\n", card->irqstat[6]); in idt77252_proc_read()
2650 return sprintf(page, "EPDU: %lu\n", card->irqstat[5]); in idt77252_proc_read()
2652 return sprintf(page, "RAWCF: %lu\n", card->irqstat[4]); in idt77252_proc_read()
2654 return sprintf(page, "FBQ1A: %lu\n", card->irqstat[3]); in idt77252_proc_read()
2656 return sprintf(page, "FBQ0A: %lu\n", card->irqstat[2]); in idt77252_proc_read()
2658 return sprintf(page, "RSQAF: %lu\n", card->irqstat[1]); in idt77252_proc_read()
2662 for (i = 0; i < card->tct_size; i++) { in idt77252_proc_read()
2668 vc = card->vcs[i]; in idt77252_proc_read()
2682 tct = (unsigned long) (card->tct_base + i * SAR_SRAM_TCT_SIZE); in idt77252_proc_read()
2685 p += sprintf(p, " %08x", read_sram(card, tct + i)); in idt77252_proc_read()
2699 idt77252_collect_stat(struct idt77252_dev *card) in idt77252_collect_stat() argument
2710 struct idt77252_dev *card = dev_id; in idt77252_interrupt() local
2717 if (test_and_set_bit(IDT77252_BIT_INTERRUPT, &card->flags)) { in idt77252_interrupt()
2718 printk("%s: Re-entering irq_handler()\n", card->name); in idt77252_interrupt()
2725 INTPRINTK("%s: TSIF\n", card->name); in idt77252_interrupt()
2726 card->irqstat[15]++; in idt77252_interrupt()
2727 idt77252_tx(card); in idt77252_interrupt()
2730 INTPRINTK("%s: TXICP\n", card->name); in idt77252_interrupt()
2731 card->irqstat[14]++; in idt77252_interrupt()
2733 idt77252_tx_dump(card); in idt77252_interrupt()
2737 INTPRINTK("%s: TSQF\n", card->name); in idt77252_interrupt()
2738 card->irqstat[12]++; in idt77252_interrupt()
2739 idt77252_tx(card); in idt77252_interrupt()
2742 INTPRINTK("%s: TMROF\n", card->name); in idt77252_interrupt()
2743 card->irqstat[11]++; in idt77252_interrupt()
2744 idt77252_collect_stat(card); in idt77252_interrupt()
2748 INTPRINTK("%s: EPDU\n", card->name); in idt77252_interrupt()
2749 card->irqstat[5]++; in idt77252_interrupt()
2750 idt77252_rx(card); in idt77252_interrupt()
2753 INTPRINTK("%s: RSQAF\n", card->name); in idt77252_interrupt()
2754 card->irqstat[1]++; in idt77252_interrupt()
2755 idt77252_rx(card); in idt77252_interrupt()
2758 INTPRINTK("%s: RSQF\n", card->name); in idt77252_interrupt()
2759 card->irqstat[6]++; in idt77252_interrupt()
2760 idt77252_rx(card); in idt77252_interrupt()
2763 INTPRINTK("%s: RAWCF\n", card->name); in idt77252_interrupt()
2764 card->irqstat[4]++; in idt77252_interrupt()
2765 idt77252_rx_raw(card); in idt77252_interrupt()
2769 INTPRINTK("%s: PHYI", card->name); in idt77252_interrupt()
2770 card->irqstat[10]++; in idt77252_interrupt()
2771 if (card->atmdev->phy && card->atmdev->phy->interrupt) in idt77252_interrupt()
2772 card->atmdev->phy->interrupt(card->atmdev); in idt77252_interrupt()
2780 INTPRINTK("%s: FBQA: %04x\n", card->name, stat); in idt77252_interrupt()
2783 card->irqstat[2]++; in idt77252_interrupt()
2785 card->irqstat[3]++; in idt77252_interrupt()
2787 card->irqstat[7]++; in idt77252_interrupt()
2789 card->irqstat[8]++; in idt77252_interrupt()
2791 schedule_work(&card->tqueue); in idt77252_interrupt()
2795 clear_bit(IDT77252_BIT_INTERRUPT, &card->flags); in idt77252_interrupt()
2802 struct idt77252_dev *card = in idt77252_softint() local
2811 add_rx_skb(card, 0, SAR_FB_SIZE_0, 32); in idt77252_softint()
2817 add_rx_skb(card, 1, SAR_FB_SIZE_1, 32); in idt77252_softint()
2823 add_rx_skb(card, 2, SAR_FB_SIZE_2, 32); in idt77252_softint()
2829 add_rx_skb(card, 3, SAR_FB_SIZE_3, 32); in idt77252_softint()
2842 open_card_oam(struct idt77252_dev *card) in open_card_oam() argument
2851 for (vpi = 0; vpi < (1 << card->vpibits); vpi++) { in open_card_oam()
2853 index = VPCI2VC(card, vpi, vci); in open_card_oam()
2857 printk("%s: can't alloc vc\n", card->name); in open_card_oam()
2861 card->vcs[index] = vc; in open_card_oam()
2863 flush_rx_pool(card, &vc->rcv.rx_pool); in open_card_oam()
2870 addr = card->rct_base + (vc->index << 2); in open_card_oam()
2871 write_sram(card, addr, rcte); in open_card_oam()
2873 spin_lock_irqsave(&card->cmd_lock, flags); in open_card_oam()
2876 waitfor_idle(card); in open_card_oam()
2877 spin_unlock_irqrestore(&card->cmd_lock, flags); in open_card_oam()
2885 close_card_oam(struct idt77252_dev *card) in close_card_oam() argument
2893 for (vpi = 0; vpi < (1 << card->vpibits); vpi++) { in close_card_oam()
2895 index = VPCI2VC(card, vpi, vci); in close_card_oam()
2896 vc = card->vcs[index]; in close_card_oam()
2898 addr = card->rct_base + vc->index * SAR_SRAM_RCT_SIZE; in close_card_oam()
2900 spin_lock_irqsave(&card->cmd_lock, flags); in close_card_oam()
2903 waitfor_idle(card); in close_card_oam()
2904 spin_unlock_irqrestore(&card->cmd_lock, flags); in close_card_oam()
2909 card->name); in close_card_oam()
2911 recycle_rx_pool_skb(card, &vc->rcv.rx_pool); in close_card_oam()
2919 open_card_ubr0(struct idt77252_dev *card) in open_card_ubr0() argument
2925 printk("%s: can't alloc vc\n", card->name); in open_card_ubr0()
2928 card->vcs[0] = vc; in open_card_ubr0()
2931 vc->scq = alloc_scq(card, vc->class); in open_card_ubr0()
2933 printk("%s: can't get SCQ.\n", card->name); in open_card_ubr0()
2934 kfree(card->vcs[0]); in open_card_ubr0()
2935 card->vcs[0] = NULL; in open_card_ubr0()
2939 card->scd2vc[0] = vc; in open_card_ubr0()
2941 vc->scq->scd = card->scd_base; in open_card_ubr0()
2943 fill_scd(card, vc->scq, vc->class); in open_card_ubr0()
2945 write_sram(card, card->tct_base + 0, TCT_UBR | card->scd_base); in open_card_ubr0()
2946 write_sram(card, card->tct_base + 1, 0); in open_card_ubr0()
2947 write_sram(card, card->tct_base + 2, 0); in open_card_ubr0()
2948 write_sram(card, card->tct_base + 3, 0); in open_card_ubr0()
2949 write_sram(card, card->tct_base + 4, 0); in open_card_ubr0()
2950 write_sram(card, card->tct_base + 5, 0); in open_card_ubr0()
2951 write_sram(card, card->tct_base + 6, 0); in open_card_ubr0()
2952 write_sram(card, card->tct_base + 7, TCT_FLAG_UBR); in open_card_ubr0()
2960 close_card_ubr0(struct idt77252_dev *card) in close_card_ubr0() argument
2962 struct vc_map *vc = card->vcs[0]; in close_card_ubr0()
2964 free_scq(card, vc->scq); in close_card_ubr0()
2969 idt77252_dev_open(struct idt77252_dev *card) in idt77252_dev_open() argument
2973 if (!test_bit(IDT77252_BIT_INIT, &card->flags)) { in idt77252_dev_open()
2974 printk("%s: SAR not yet initialized.\n", card->name); in idt77252_dev_open()
2998 if (open_card_oam(card)) { in idt77252_dev_open()
2999 printk("%s: Error initializing OAM.\n", card->name); in idt77252_dev_open()
3003 if (open_card_ubr0(card)) { in idt77252_dev_open()
3004 printk("%s: Error initializing UBR0.\n", card->name); in idt77252_dev_open()
3008 IPRINTK("%s: opened IDT77252 ABR SAR.\n", card->name); in idt77252_dev_open()
3014 struct idt77252_dev *card = dev->dev_data; in idt77252_dev_close() local
3017 close_card_ubr0(card); in idt77252_dev_close()
3018 close_card_oam(card); in idt77252_dev_close()
3034 DIPRINTK("%s: closed IDT77252 ABR SAR.\n", card->name); in idt77252_dev_close()
3046 deinit_card(struct idt77252_dev *card) in deinit_card() argument
3051 if (!test_bit(IDT77252_BIT_INIT, &card->flags)) { in deinit_card()
3052 printk("%s: SAR not yet initialized.\n", card->name); in deinit_card()
3055 DIPRINTK("idt77252: deinitialize card %u\n", card->index); in deinit_card()
3059 if (card->atmdev) in deinit_card()
3060 atm_dev_deregister(card->atmdev); in deinit_card()
3064 skb = card->sbpool[i].skb[j]; in deinit_card()
3066 dma_unmap_single(&card->pcidev->dev, in deinit_card()
3071 card->sbpool[i].skb[j] = NULL; in deinit_card()
3077 vfree(card->soft_tst); in deinit_card()
3079 vfree(card->scd2vc); in deinit_card()
3081 vfree(card->vcs); in deinit_card()
3083 if (card->raw_cell_hnd) { in deinit_card()
3084 dma_free_coherent(&card->pcidev->dev, 2 * sizeof(u32), in deinit_card()
3085 card->raw_cell_hnd, card->raw_cell_paddr); in deinit_card()
3088 if (card->rsq.base) { in deinit_card()
3089 DIPRINTK("%s: Release RSQ ...\n", card->name); in deinit_card()
3090 deinit_rsq(card); in deinit_card()
3093 if (card->tsq.base) { in deinit_card()
3094 DIPRINTK("%s: Release TSQ ...\n", card->name); in deinit_card()
3095 deinit_tsq(card); in deinit_card()
3099 free_irq(card->pcidev->irq, card); in deinit_card()
3102 if (card->fbq[i]) in deinit_card()
3103 iounmap(card->fbq[i]); in deinit_card()
3106 if (card->membase) in deinit_card()
3107 iounmap(card->membase); in deinit_card()
3109 clear_bit(IDT77252_BIT_INIT, &card->flags); in deinit_card()
3110 DIPRINTK("%s: Card deinitialized.\n", card->name); in deinit_card()
3114 static void init_sram(struct idt77252_dev *card) in init_sram() argument
3118 for (i = 0; i < card->sramsize; i += 4) in init_sram()
3119 write_sram(card, (i >> 2), 0); in init_sram()
3121 /* set SRAM layout for THIS card */ in init_sram()
3122 if (card->sramsize == (512 * 1024)) { in init_sram()
3123 card->tct_base = SAR_SRAM_TCT_128_BASE; in init_sram()
3124 card->tct_size = (SAR_SRAM_TCT_128_TOP - card->tct_base + 1) in init_sram()
3126 card->rct_base = SAR_SRAM_RCT_128_BASE; in init_sram()
3127 card->rct_size = (SAR_SRAM_RCT_128_TOP - card->rct_base + 1) in init_sram()
3129 card->rt_base = SAR_SRAM_RT_128_BASE; in init_sram()
3130 card->scd_base = SAR_SRAM_SCD_128_BASE; in init_sram()
3131 card->scd_size = (SAR_SRAM_SCD_128_TOP - card->scd_base + 1) in init_sram()
3133 card->tst[0] = SAR_SRAM_TST1_128_BASE; in init_sram()
3134 card->tst[1] = SAR_SRAM_TST2_128_BASE; in init_sram()
3135 card->tst_size = SAR_SRAM_TST1_128_TOP - card->tst[0] + 1; in init_sram()
3136 card->abrst_base = SAR_SRAM_ABRSTD_128_BASE; in init_sram()
3137 card->abrst_size = SAR_ABRSTD_SIZE_8K; in init_sram()
3138 card->fifo_base = SAR_SRAM_FIFO_128_BASE; in init_sram()
3139 card->fifo_size = SAR_RXFD_SIZE_32K; in init_sram()
3141 card->tct_base = SAR_SRAM_TCT_32_BASE; in init_sram()
3142 card->tct_size = (SAR_SRAM_TCT_32_TOP - card->tct_base + 1) in init_sram()
3144 card->rct_base = SAR_SRAM_RCT_32_BASE; in init_sram()
3145 card->rct_size = (SAR_SRAM_RCT_32_TOP - card->rct_base + 1) in init_sram()
3147 card->rt_base = SAR_SRAM_RT_32_BASE; in init_sram()
3148 card->scd_base = SAR_SRAM_SCD_32_BASE; in init_sram()
3149 card->scd_size = (SAR_SRAM_SCD_32_TOP - card->scd_base + 1) in init_sram()
3151 card->tst[0] = SAR_SRAM_TST1_32_BASE; in init_sram()
3152 card->tst[1] = SAR_SRAM_TST2_32_BASE; in init_sram()
3153 card->tst_size = (SAR_SRAM_TST1_32_TOP - card->tst[0] + 1); in init_sram()
3154 card->abrst_base = SAR_SRAM_ABRSTD_32_BASE; in init_sram()
3155 card->abrst_size = SAR_ABRSTD_SIZE_1K; in init_sram()
3156 card->fifo_base = SAR_SRAM_FIFO_32_BASE; in init_sram()
3157 card->fifo_size = SAR_RXFD_SIZE_4K; in init_sram()
3161 for (i = 0; i < card->tct_size; i++) { in init_sram()
3162 write_sram(card, i * SAR_SRAM_TCT_SIZE + 0, 0); in init_sram()
3163 write_sram(card, i * SAR_SRAM_TCT_SIZE + 1, 0); in init_sram()
3164 write_sram(card, i * SAR_SRAM_TCT_SIZE + 2, 0); in init_sram()
3165 write_sram(card, i * SAR_SRAM_TCT_SIZE + 3, 0); in init_sram()
3166 write_sram(card, i * SAR_SRAM_TCT_SIZE + 4, 0); in init_sram()
3167 write_sram(card, i * SAR_SRAM_TCT_SIZE + 5, 0); in init_sram()
3168 write_sram(card, i * SAR_SRAM_TCT_SIZE + 6, 0); in init_sram()
3169 write_sram(card, i * SAR_SRAM_TCT_SIZE + 7, 0); in init_sram()
3173 for (i = 0; i < card->rct_size; i++) { in init_sram()
3174 write_sram(card, card->rct_base + i * SAR_SRAM_RCT_SIZE, in init_sram()
3176 write_sram(card, card->rct_base + i * SAR_SRAM_RCT_SIZE + 1, in init_sram()
3178 write_sram(card, card->rct_base + i * SAR_SRAM_RCT_SIZE + 2, in init_sram()
3180 write_sram(card, card->rct_base + i * SAR_SRAM_RCT_SIZE + 3, in init_sram()
3191 write_sram(card, card->rt_base + i, log_to_rate[i]); in init_sram()
3201 write_sram(card, card->rt_base + 256 + i, tmp); in init_sram()
3210 write_sram(card, card->rt_base + 512 + i, tmp); in init_sram()
3218 write_sram(card, card->rt_base + 640 + i, tmp); in init_sram()
3222 IPRINTK("%s: initialize rate table ...\n", card->name); in init_sram()
3223 writel(card->rt_base << 2, SAR_REG_RTBL); in init_sram()
3226 IPRINTK("%s: initialize TST ...\n", card->name); in init_sram()
3227 card->tst_free = card->tst_size - 2; /* last two are jumps */ in init_sram()
3229 for (i = card->tst[0]; i < card->tst[0] + card->tst_size - 2; i++) in init_sram()
3230 write_sram(card, i, TSTE_OPC_VAR); in init_sram()
3231 write_sram(card, i++, TSTE_OPC_JMP | (card->tst[0] << 2)); in init_sram()
3233 write_sram(card, i++, TSTE_OPC_JMP | (card->tst[1] << 2)); in init_sram()
3235 for (i = card->tst[1]; i < card->tst[1] + card->tst_size - 2; i++) in init_sram()
3236 write_sram(card, i, TSTE_OPC_VAR); in init_sram()
3237 write_sram(card, i++, TSTE_OPC_JMP | (card->tst[1] << 2)); in init_sram()
3239 write_sram(card, i++, TSTE_OPC_JMP | (card->tst[0] << 2)); in init_sram()
3242 card->tst_index = 0; in init_sram()
3243 writel(card->tst[0] << 2, SAR_REG_TSTB); in init_sram()
3246 IPRINTK("%s: initialize ABRSTD ...\n", card->name); in init_sram()
3247 writel(card->abrst_size | (card->abrst_base << 2), in init_sram()
3250 IPRINTK("%s: initialize receive fifo ...\n", card->name); in init_sram()
3251 writel(card->fifo_size | (card->fifo_base << 2), in init_sram()
3254 IPRINTK("%s: SRAM initialization complete.\n", card->name); in init_sram()
3259 struct idt77252_dev *card = dev->dev_data; in init_card() local
3260 struct pci_dev *pcidev = card->pcidev; in init_card()
3272 if (test_bit(IDT77252_BIT_INIT, &card->flags)) { in init_card()
3282 IPRINTK("%s: Checking PCI retries.\n", card->name); in init_card()
3284 printk("%s: can't read PCI retry timeout.\n", card->name); in init_card()
3285 deinit_card(card); in init_card()
3290 card->name, pci_byte); in init_card()
3293 card->name); in init_card()
3294 deinit_card(card); in init_card()
3298 IPRINTK("%s: Checking PCI TRDY.\n", card->name); in init_card()
3300 printk("%s: can't read PCI TRDY timeout.\n", card->name); in init_card()
3301 deinit_card(card); in init_card()
3306 card->name, pci_byte); in init_card()
3308 printk("%s: can't set PCI TRDY timeout.\n", card->name); in init_card()
3309 deinit_card(card); in init_card()
3315 printk("%s: resetting timer overflow.\n", card->name); in init_card()
3318 IPRINTK("%s: Request IRQ ... ", card->name); in init_card()
3320 card->name, card) != 0) { in init_card()
3321 printk("%s: can't allocate IRQ.\n", card->name); in init_card()
3322 deinit_card(card); in init_card()
3331 IPRINTK("%s: Initializing SRAM\n", card->name); in init_card()
3342 if (card->sramsize == (512 * 1024)) in init_card()
3365 init_sram(card); in init_card()
3371 if (0 != init_tsq(card)) { in init_card()
3372 deinit_card(card); in init_card()
3376 if (0 != init_rsq(card)) { in init_card()
3377 deinit_card(card); in init_card()
3381 card->vpibits = vpibits; in init_card()
3382 if (card->sramsize == (512 * 1024)) { in init_card()
3383 card->vcibits = 10 - card->vpibits; in init_card()
3385 card->vcibits = 9 - card->vpibits; in init_card()
3388 card->vcimask = 0; in init_card()
3389 for (k = 0, i = 1; k < card->vcibits; k++) { in init_card()
3390 card->vcimask |= i; in init_card()
3394 IPRINTK("%s: Setting VPI/VCI mask to zero.\n", card->name); in init_card()
3401 card->raw_cell_hnd = dma_alloc_coherent(&card->pcidev->dev, in init_card()
3403 &card->raw_cell_paddr, in init_card()
3405 if (!card->raw_cell_hnd) { in init_card()
3406 printk("%s: memory allocation failure.\n", card->name); in init_card()
3407 deinit_card(card); in init_card()
3410 writel(card->raw_cell_paddr, SAR_REG_RAWHND); in init_card()
3411 IPRINTK("%s: raw cell handle is at 0x%p.\n", card->name, in init_card()
3412 card->raw_cell_hnd); in init_card()
3414 size = sizeof(struct vc_map *) * card->tct_size; in init_card()
3415 IPRINTK("%s: allocate %d byte for VC map.\n", card->name, size); in init_card()
3416 card->vcs = vzalloc(size); in init_card()
3417 if (!card->vcs) { in init_card()
3418 printk("%s: memory allocation failure.\n", card->name); in init_card()
3419 deinit_card(card); in init_card()
3423 size = sizeof(struct vc_map *) * card->scd_size; in init_card()
3425 card->name, size); in init_card()
3426 card->scd2vc = vzalloc(size); in init_card()
3427 if (!card->scd2vc) { in init_card()
3428 printk("%s: memory allocation failure.\n", card->name); in init_card()
3429 deinit_card(card); in init_card()
3433 size = sizeof(struct tst_info) * (card->tst_size - 2); in init_card()
3435 card->name, size); in init_card()
3436 card->soft_tst = vmalloc(size); in init_card()
3437 if (!card->soft_tst) { in init_card()
3438 printk("%s: memory allocation failure.\n", card->name); in init_card()
3439 deinit_card(card); in init_card()
3442 for (i = 0; i < card->tst_size - 2; i++) { in init_card()
3443 card->soft_tst[i].tste = TSTE_OPC_VAR; in init_card()
3444 card->soft_tst[i].vc = NULL; in init_card()
3448 printk("%s: No LT device defined.\n", card->name); in init_card()
3449 deinit_card(card); in init_card()
3453 printk("%s: LT had no IOCTL function defined.\n", card->name); in init_card()
3454 deinit_card(card); in init_card()
3471 card->link_pcr = (linkrate / 8 / 53); in init_card()
3473 card->name, linkrate, card->link_pcr); in init_card()
3476 card->utopia_pcr = card->link_pcr; in init_card()
3478 card->utopia_pcr = (160000000 / 8 / 54); in init_card()
3482 if (card->utopia_pcr > card->link_pcr) in init_card()
3483 rsvdcr = card->utopia_pcr - card->link_pcr; in init_card()
3485 tmpl = (unsigned long) rsvdcr * ((unsigned long) card->tst_size - 2); in init_card()
3486 modl = tmpl % (unsigned long)card->utopia_pcr; in init_card()
3487 tst_entries = (int) (tmpl / (unsigned long)card->utopia_pcr); in init_card()
3490 card->tst_free -= tst_entries; in init_card()
3491 fill_tst(card, NULL, tst_entries, TSTE_OPC_NULL); in init_card()
3494 idt77252_eeprom_init(card); in init_card()
3495 printk("%s: EEPROM: %02x:", card->name, in init_card()
3496 idt77252_eeprom_read_status(card)); in init_card()
3500 idt77252_eeprom_read_byte(card, i) in init_card()
3509 sprintf(tname, "eth%d", card->index); in init_card()
3512 memcpy(card->atmdev->esi, tmp->dev_addr, 6); in init_card()
3514 printk("%s: ESI %pM\n", card->name, card->atmdev->esi); in init_card()
3523 set_bit(IDT77252_BIT_INIT, &card->flags); in init_card()
3525 XPRINTK("%s: IDT77252 ABR SAR initialization complete.\n", card->name); in init_card()
3537 static int idt77252_preset(struct idt77252_dev *card) in idt77252_preset() argument
3546 card->name); in idt77252_preset()
3547 if (pci_read_config_word(card->pcidev, PCI_COMMAND, &pci_command)) { in idt77252_preset()
3548 printk("%s: can't read PCI_COMMAND.\n", card->name); in idt77252_preset()
3549 deinit_card(card); in idt77252_preset()
3554 card->name, pci_command); in idt77252_preset()
3555 deinit_card(card); in idt77252_preset()
3559 if (pci_write_config_word(card->pcidev, PCI_COMMAND, pci_command)) { in idt77252_preset()
3560 printk("%s: can't write PCI_COMMAND.\n", card->name); in idt77252_preset()
3561 deinit_card(card); in idt77252_preset()
3573 IPRINTK("%s: Software resetted.\n", card->name); in idt77252_preset()
3578 static unsigned long probe_sram(struct idt77252_dev *card) in probe_sram() argument
3606 struct idt77252_dev *card; in idt77252_init_one() local
3621 card = kzalloc(sizeof(struct idt77252_dev), GFP_KERNEL); in idt77252_init_one()
3622 if (!card) { in idt77252_init_one()
3627 card->revision = pcidev->revision; in idt77252_init_one()
3628 card->index = index; in idt77252_init_one()
3629 card->pcidev = pcidev; in idt77252_init_one()
3630 sprintf(card->name, "idt77252-%d", card->index); in idt77252_init_one()
3632 INIT_WORK(&card->tqueue, idt77252_softint); in idt77252_init_one()
3637 mutex_init(&card->mutex); in idt77252_init_one()
3638 spin_lock_init(&card->cmd_lock); in idt77252_init_one()
3639 spin_lock_init(&card->tst_lock); in idt77252_init_one()
3641 timer_setup(&card->tst_timer, tst_timer, 0); in idt77252_init_one()
3644 card->membase = ioremap(membase, 1024); in idt77252_init_one()
3645 if (!card->membase) { in idt77252_init_one()
3646 printk("%s: can't ioremap() membase\n", card->name); in idt77252_init_one()
3651 if (idt77252_preset(card)) { in idt77252_init_one()
3652 printk("%s: preset failed\n", card->name); in idt77252_init_one()
3660 printk("%s: can't register atm device\n", card->name); in idt77252_init_one()
3664 dev->dev_data = card; in idt77252_init_one()
3665 card->atmdev = dev; in idt77252_init_one()
3670 printk("%s: can't init SUNI\n", card->name); in idt77252_init_one()
3676 card->sramsize = probe_sram(card); in idt77252_init_one()
3679 card->fbq[i] = ioremap(srambase | 0x200000 | (i << 18), 4); in idt77252_init_one()
3680 if (!card->fbq[i]) { in idt77252_init_one()
3681 printk("%s: can't ioremap() FBQ%d\n", card->name, i); in idt77252_init_one()
3688 card->name, ((card->revision > 1) && (card->revision < 25)) ? in idt77252_init_one()
3689 'A' + card->revision - 1 : '?', membase, srambase, in idt77252_init_one()
3690 card->sramsize / 1024); in idt77252_init_one()
3693 printk("%s: init_card failed\n", card->name); in idt77252_init_one()
3698 dev->ci_range.vpi_bits = card->vpibits; in idt77252_init_one()
3699 dev->ci_range.vci_bits = card->vcibits; in idt77252_init_one()
3700 dev->link_rate = card->link_pcr; in idt77252_init_one()
3705 if (idt77252_dev_open(card)) { in idt77252_init_one()
3706 printk("%s: dev_open failed\n", card->name); in idt77252_init_one()
3711 *last = card; in idt77252_init_one()
3712 last = &card->next; in idt77252_init_one()
3722 deinit_card(card); in idt77252_init_one()
3725 iounmap(card->membase); in idt77252_init_one()
3728 kfree(card); in idt77252_init_one()
3760 struct idt77252_dev *card; in idt77252_exit() local
3766 card = idt77252_chain; in idt77252_exit()
3767 dev = card->atmdev; in idt77252_exit()
3768 idt77252_chain = card->next; in idt77252_exit()
3769 timer_shutdown_sync(&card->tst_timer); in idt77252_exit()
3773 deinit_card(card); in idt77252_exit()
3774 pci_disable_device(card->pcidev); in idt77252_exit()
3775 kfree(card); in idt77252_exit()