• Home
  • Raw
  • Download

Lines Matching +full:vcc +full:- +full:p

122 static int idt77252_open(struct atm_vcc *vcc);
123 static void idt77252_close(struct atm_vcc *vcc);
124 static int idt77252_send(struct atm_vcc *vcc, struct sk_buff *skb);
125 static int idt77252_send_oam(struct atm_vcc *vcc, void *cell,
130 static int idt77252_change_qos(struct atm_vcc *vcc, struct atm_qos *qos,
176 spin_lock_irqsave(&card->cmd_lock, flags); in read_sram()
180 spin_unlock_irqrestore(&card->cmd_lock, flags); in read_sram()
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()
202 spin_unlock_irqrestore(&card->cmd_lock, flags); in write_sram()
214 return -1; in read_utility()
217 spin_lock_irqsave(&card->cmd_lock, flags); in read_utility()
221 spin_unlock_irqrestore(&card->cmd_lock, flags); in read_utility()
236 spin_lock_irqsave(&card->cmd_lock, flags); in write_utility()
240 spin_unlock_irqrestore(&card->cmd_lock, flags); in write_utility()
372 spin_lock_irqsave(&card->cmd_lock, flags); in idt77252_write_gp()
375 spin_unlock_irqrestore(&card->cmd_lock, flags); in idt77252_write_gp()
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()
549 struct atm_vcc *vcc; in idt77252_tx_dump() local
554 for (i = 0; i < card->tct_size; i++) { in idt77252_tx_dump()
555 vc = card->vcs[i]; in idt77252_tx_dump()
559 vcc = NULL; in idt77252_tx_dump()
560 if (vc->rx_vcc) in idt77252_tx_dump()
561 vcc = vc->rx_vcc; in idt77252_tx_dump()
562 else if (vc->tx_vcc) in idt77252_tx_dump()
563 vcc = vc->tx_vcc; in idt77252_tx_dump()
565 if (!vcc) 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()
584 struct sb_pool *pool = &card->sbpool[queue]; in sb_pool_add()
587 index = pool->index; in sb_pool_add()
588 while (pool->skb[index]) { in sb_pool_add()
590 if (index == pool->index) in sb_pool_add()
591 return -ENOBUFS; in sb_pool_add()
594 pool->skb[index] = skb; in sb_pool_add()
597 pool->index = (index + 1) & FBQ_MASK; in sb_pool_add()
614 if (index > FBQ_SIZE - 1) in sb_pool_remove()
617 card->sbpool[queue].skb[index] = NULL; in sb_pool_remove()
630 if (index > FBQ_SIZE - 1) in sb_pool_skb()
633 return card->sbpool[queue].skb[index]; in sb_pool_skb()
644 scq->base = dma_alloc_coherent(&card->pcidev->dev, SCQ_SIZE, in alloc_scq()
645 &scq->paddr, GFP_KERNEL); in alloc_scq()
646 if (scq->base == NULL) { in alloc_scq()
651 scq->next = scq->base; in alloc_scq()
652 scq->last = scq->base + (SCQ_ENTRIES - 1); in alloc_scq()
653 atomic_set(&scq->used, 0); in alloc_scq()
655 spin_lock_init(&scq->lock); in alloc_scq()
656 spin_lock_init(&scq->skblock); in alloc_scq()
658 skb_queue_head_init(&scq->transmit); in alloc_scq()
659 skb_queue_head_init(&scq->pending); in alloc_scq()
661 TXPRINTK("idt77252: SCQ: base 0x%p, next 0x%p, last 0x%p, paddr %08llx\n", in alloc_scq()
662 scq->base, scq->next, scq->last, (unsigned long long)scq->paddr); in alloc_scq()
671 struct atm_vcc *vcc; in free_scq() local
673 dma_free_coherent(&card->pcidev->dev, SCQ_SIZE, in free_scq()
674 scq->base, scq->paddr); in free_scq()
676 while ((skb = skb_dequeue(&scq->transmit))) { in free_scq()
677 dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), in free_scq()
678 skb->len, DMA_TO_DEVICE); in free_scq()
680 vcc = ATM_SKB(skb)->vcc; in free_scq()
681 if (vcc->pop) in free_scq()
682 vcc->pop(vcc, skb); in free_scq()
687 while ((skb = skb_dequeue(&scq->pending))) { in free_scq()
688 dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), in free_scq()
689 skb->len, DMA_TO_DEVICE); in free_scq()
691 vcc = ATM_SKB(skb)->vcc; in free_scq()
692 if (vcc->pop) in free_scq()
693 vcc->pop(vcc, skb); in free_scq()
705 struct scq_info *scq = vc->scq; in push_on_scq()
710 TXPRINTK("%s: SCQ: next 0x%p\n", card->name, scq->next); in push_on_scq()
712 atomic_inc(&scq->used); in push_on_scq()
713 entries = atomic_read(&scq->used); in push_on_scq()
714 if (entries > (SCQ_ENTRIES - 1)) { in push_on_scq()
715 atomic_dec(&scq->used); in push_on_scq()
719 skb_queue_tail(&scq->transmit, skb); in push_on_scq()
721 spin_lock_irqsave(&vc->lock, flags); in push_on_scq()
722 if (vc->estimator) { in push_on_scq()
723 struct atm_vcc *vcc = vc->tx_vcc; in push_on_scq() local
724 struct sock *sk = sk_atm(vcc); in push_on_scq()
726 vc->estimator->cells += (skb->len + 47) / 48; in push_on_scq()
727 if (refcount_read(&sk->sk_wmem_alloc) > in push_on_scq()
728 (sk->sk_sndbuf >> 1)) { in push_on_scq()
729 u32 cps = vc->estimator->maxcps; in push_on_scq()
731 vc->estimator->cps = cps; in push_on_scq()
732 vc->estimator->avcps = cps << 5; in push_on_scq()
733 if (vc->lacr < vc->init_er) { in push_on_scq()
734 vc->lacr = vc->init_er; in push_on_scq()
735 writel(TCMDQ_LACR | (vc->lacr << 16) | in push_on_scq()
736 vc->index, SAR_REG_TCMDQ); in push_on_scq()
740 spin_unlock_irqrestore(&vc->lock, flags); in push_on_scq()
744 spin_lock_irqsave(&scq->lock, flags); in push_on_scq()
745 scq->next->word_1 = cpu_to_le32(tbd->word_1 | in push_on_scq()
747 scq->next->word_2 = cpu_to_le32(tbd->word_2); in push_on_scq()
748 scq->next->word_3 = cpu_to_le32(tbd->word_3); in push_on_scq()
749 scq->next->word_4 = cpu_to_le32(tbd->word_4); in push_on_scq()
751 if (scq->next == scq->last) in push_on_scq()
752 scq->next = scq->base; in push_on_scq()
754 scq->next++; in push_on_scq()
756 write_sram(card, scq->scd, in push_on_scq()
757 scq->paddr + in push_on_scq()
758 (u32)((unsigned long)scq->next - (unsigned long)scq->base)); in push_on_scq()
759 spin_unlock_irqrestore(&scq->lock, flags); in push_on_scq()
761 scq->trans_start = jiffies; in push_on_scq()
763 if (test_and_clear_bit(VCF_IDLE, &vc->flags)) { in push_on_scq()
764 writel(TCMDQ_START_LACR | (vc->lacr << 16) | vc->index, in push_on_scq()
768 TXPRINTK("%d entries in SCQ used (push).\n", atomic_read(&scq->used)); in push_on_scq()
770 XPRINTK("%s: SCQ (after push %2d) head = 0x%x, next = 0x%p.\n", 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()
777 if (time_after(jiffies, scq->trans_start + HZ)) { in push_on_scq()
779 card->name, vc->tx_vcc->vpi, vc->tx_vcc->vci); in push_on_scq()
783 scq->trans_start = jiffies; in push_on_scq()
786 return -ENOBUFS; in push_on_scq()
793 struct scq_info *scq = vc->scq; in drain_scq()
795 struct atm_vcc *vcc; in drain_scq() local
797 TXPRINTK("%s: SCQ (before drain %2d) next = 0x%p.\n", in drain_scq()
798 card->name, atomic_read(&scq->used), scq->next); in drain_scq()
800 skb = skb_dequeue(&scq->transmit); 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()
805 skb->len, DMA_TO_DEVICE); in drain_scq()
807 vcc = ATM_SKB(skb)->vcc; in drain_scq()
809 if (vcc->pop) in drain_scq()
810 vcc->pop(vcc, skb); in drain_scq()
814 atomic_inc(&vcc->stats->tx); in drain_scq()
817 atomic_dec(&scq->used); in drain_scq()
819 spin_lock(&scq->skblock); in drain_scq()
820 while ((skb = skb_dequeue(&scq->pending))) { in drain_scq()
822 skb_queue_head(&vc->scq->pending, skb); in drain_scq()
826 spin_unlock(&scq->skblock); in drain_scq()
833 struct atm_vcc *vcc; in queue_skb() local
840 if (skb->len == 0) { in queue_skb()
841 printk("%s: invalid skb->len (%d)\n", card->name, skb->len); in queue_skb()
842 return -EINVAL; in queue_skb()
846 card->name, skb->len); in queue_skb()
849 vcc = ATM_SKB(skb)->vcc; in queue_skb()
850 word4 = (skb->data[0] << 24) | (skb->data[1] << 16) | in queue_skb()
851 (skb->data[2] << 8) | (skb->data[3] << 0); in queue_skb()
853 IDT77252_PRV_PADDR(skb) = dma_map_single(&card->pcidev->dev, skb->data, in queue_skb()
854 skb->len, DMA_TO_DEVICE); in queue_skb()
856 error = -EINVAL; in queue_skb()
859 if (skb->len != 52) in queue_skb()
862 tbd->word_1 = SAR_TBD_OAM | ATM_CELL_PAYLOAD | SAR_TBD_EPDU; in queue_skb()
863 tbd->word_2 = IDT77252_PRV_PADDR(skb) + 4; in queue_skb()
864 tbd->word_3 = 0x00000000; in queue_skb()
865 tbd->word_4 = word4; in queue_skb()
867 if (test_bit(VCF_RSV, &vc->flags)) in queue_skb()
868 vc = card->vcs[0]; in queue_skb()
873 if (test_bit(VCF_RSV, &vc->flags)) { in queue_skb()
874 printk("%s: Trying to transmit on reserved VC\n", card->name); in queue_skb()
878 aal = vcc->qos.aal; in queue_skb()
883 if (skb->len > 52) in queue_skb()
887 tbd->word_1 = SAR_TBD_EPDU | SAR_TBD_AAL0 | in queue_skb()
890 tbd->word_1 = SAR_TBD_EPDU | SAR_TBD_AAL34 | in queue_skb()
893 tbd->word_2 = IDT77252_PRV_PADDR(skb) + 4; in queue_skb()
894 tbd->word_3 = 0x00000000; in queue_skb()
895 tbd->word_4 = word4; in queue_skb()
899 tbd->word_1 = SAR_TBD_EPDU | SAR_TBD_AAL5 | skb->len; in queue_skb()
900 tbd->word_2 = IDT77252_PRV_PADDR(skb); in queue_skb()
901 tbd->word_3 = skb->len; in queue_skb()
902 tbd->word_4 = (vcc->vpi << SAR_TBD_VPI_SHIFT) | in queue_skb()
903 (vcc->vci << SAR_TBD_VCI_SHIFT); in queue_skb()
909 printk("%s: Traffic type not supported.\n", card->name); in queue_skb()
910 error = -EPROTONOSUPPORT; in queue_skb()
915 spin_lock_irqsave(&vc->scq->skblock, flags); in queue_skb()
916 skb_queue_tail(&vc->scq->pending, skb); in queue_skb()
918 while ((skb = skb_dequeue(&vc->scq->pending))) { in queue_skb()
920 skb_queue_head(&vc->scq->pending, skb); in queue_skb()
924 spin_unlock_irqrestore(&vc->scq->skblock, flags); in queue_skb()
929 dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), in queue_skb()
930 skb->len, DMA_TO_DEVICE); in queue_skb()
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()
942 vc->scd_index = i; in get_free_scd()
943 return card->scd_base + i * SAR_SRAM_SCD_SIZE; in get_free_scd()
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()
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()
979 return -1; 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()
985 rsqe->word_4 = 0; 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()
1006 dma_free_coherent(&card->pcidev->dev, RSQSIZE, in deinit_rsq()
1007 card->rsq.base, card->rsq.paddr); in deinit_rsq()
1013 struct atm_vcc *vcc; in dequeue_rx() local
1021 stat = le32_to_cpu(rsqe->word_4); in dequeue_rx()
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()
1033 le32_to_cpu(rsqe->word_1), le32_to_cpu(rsqe->word_2), in dequeue_rx()
1034 le32_to_cpu(rsqe->word_3), le32_to_cpu(rsqe->word_4)); in dequeue_rx()
1038 header = le32_to_cpu(rsqe->word_1); in dequeue_rx()
1042 RXPRINTK("%s: SDU for %d.%d received in buffer 0x%p (data 0x%p).\n", 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()
1046 printk("%s: SDU received for out-of-range vc %u.%u\n", in dequeue_rx()
1047 card->name, vpi, vci); in dequeue_rx()
1052 vc = card->vcs[VPCI2VC(card, vpi, vci)]; in dequeue_rx()
1053 if (!vc || !test_bit(VCF_RX, &vc->flags)) { in dequeue_rx()
1055 card->name, vpi, vci); in dequeue_rx()
1060 vcc = vc->rx_vcc; in dequeue_rx()
1062 dma_sync_single_for_cpu(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), in dequeue_rx()
1063 skb_end_pointer(skb) - skb->data, in dequeue_rx()
1066 if ((vcc->qos.aal == ATM_AAL0) || in dequeue_rx()
1067 (vcc->qos.aal == ATM_AAL34)) { in dequeue_rx()
1072 cell = skb->data; in dequeue_rx()
1073 for (i = (stat & SAR_RSQE_CELLCNT); i; i--) { in dequeue_rx()
1076 card->name); in dequeue_rx()
1077 atomic_add(i, &vcc->stats->rx_drop); in dequeue_rx()
1080 if (!atm_charge(vcc, sb->truesize)) { in dequeue_rx()
1082 card->name); in dequeue_rx()
1083 atomic_add(i - 1, &vcc->stats->rx_drop); in dequeue_rx()
1092 *((u32 *) sb->data) = aal0; in dequeue_rx()
1096 ATM_SKB(sb)->vcc = vcc; in dequeue_rx()
1098 vcc->push(vcc, sb); in dequeue_rx()
1099 atomic_inc(&vcc->stats->rx); in dequeue_rx()
1107 if (vcc->qos.aal != ATM_AAL5) { in dequeue_rx()
1109 card->name, vcc->qos.aal); in dequeue_rx()
1113 skb->len = (stat & SAR_RSQE_CELLCNT) * ATM_CELL_PAYLOAD; in dequeue_rx()
1115 rpp = &vc->rcv.rx_pool; in dequeue_rx()
1117 __skb_queue_tail(&rpp->queue, skb); in dequeue_rx()
1118 rpp->len += skb->len; in dequeue_rx()
1124 l1l2 = (unsigned char *) ((unsigned long) skb->data + skb->len - 6); in dequeue_rx()
1129 RXPRINTK("%s: PDU has %d bytes.\n", card->name, len); in dequeue_rx()
1131 if ((len + 8 > rpp->len) || (len + (47 + 8) < rpp->len)) { in dequeue_rx()
1134 card->name, len, rpp->len, readl(SAR_REG_CDC)); in dequeue_rx()
1136 atomic_inc(&vcc->stats->rx_err); in dequeue_rx()
1140 RXPRINTK("%s: AAL5 CRC error.\n", card->name); in dequeue_rx()
1142 atomic_inc(&vcc->stats->rx_err); in dequeue_rx()
1145 if (skb_queue_len(&rpp->queue) > 1) { in dequeue_rx()
1148 skb = dev_alloc_skb(rpp->len); in dequeue_rx()
1151 card->name); in dequeue_rx()
1153 atomic_inc(&vcc->stats->rx_err); in dequeue_rx()
1156 if (!atm_charge(vcc, skb->truesize)) { in dequeue_rx()
1161 skb_queue_walk(&rpp->queue, sb) in dequeue_rx()
1162 skb_put_data(skb, sb->data, sb->len); in dequeue_rx()
1167 ATM_SKB(skb)->vcc = vcc; in dequeue_rx()
1170 vcc->push(vcc, skb); in dequeue_rx()
1171 atomic_inc(&vcc->stats->rx); in dequeue_rx()
1178 if (!atm_charge(vcc, skb->truesize)) { in dequeue_rx()
1183 dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), in dequeue_rx()
1184 skb_end_pointer(skb) - skb->data, in dequeue_rx()
1189 ATM_SKB(skb)->vcc = vcc; in dequeue_rx()
1192 truesize = skb->truesize; in dequeue_rx()
1193 vcc->push(vcc, skb); in dequeue_rx()
1194 atomic_inc(&vcc->stats->rx); in dequeue_rx()
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()
1218 if (!(le32_to_cpu(rsqe->word_4) & SAR_RSQE_VALID)) { in idt77252_rx()
1219 RXPRINTK("%s: no entry in RSQ.\n", card->name); in idt77252_rx()
1225 rsqe->word_4 = 0; 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()
1231 } while (le32_to_cpu(rsqe->word_4) & SAR_RSQE_VALID); in idt77252_rx()
1233 writel((unsigned long) card->rsq.next - (unsigned long) card->rsq.base, in idt77252_rx()
1242 struct atm_vcc *vcc; in idt77252_rx_raw() local
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()
1255 head = IDT77252_PRV_PADDR(queue) + (queue->data - queue->head - 16); in idt77252_rx_raw()
1258 dma_sync_single_for_cpu(&card->pcidev->dev, IDT77252_PRV_PADDR(queue), in idt77252_rx_raw()
1259 skb_end_offset(queue) - 16, in idt77252_rx_raw()
1266 header = le32_to_cpu(*(u32 *) &queue->data[0]); in idt77252_rx_raw()
1276 card->name, (header >> 28) & 0x000f, in idt77252_rx_raw()
1282 printk(" %02x", queue->data[i]); in idt77252_rx_raw()
1287 if (vpi >= (1<<card->vpibits) || vci >= (1<<card->vcibits)) { in idt77252_rx_raw()
1288 RPRINTK("%s: SDU received for out-of-range vc %u.%u\n", 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()
1294 if (!vc || !test_bit(VCF_RX, &vc->flags)) { in idt77252_rx_raw()
1296 card->name, vpi, vci); in idt77252_rx_raw()
1300 vcc = vc->rx_vcc; in idt77252_rx_raw()
1302 if (vcc->qos.aal != ATM_AAL0) { in idt77252_rx_raw()
1304 card->name, vpi, vci); in idt77252_rx_raw()
1305 atomic_inc(&vcc->stats->rx_drop); in idt77252_rx_raw()
1311 card->name); in idt77252_rx_raw()
1312 atomic_inc(&vcc->stats->rx_err); in idt77252_rx_raw()
1316 if (!atm_charge(vcc, sb->truesize)) { in idt77252_rx_raw()
1318 card->name); in idt77252_rx_raw()
1323 *((u32 *) sb->data) = header; in idt77252_rx_raw()
1325 skb_put_data(sb, &(queue->data[16]), ATM_CELL_PAYLOAD); in idt77252_rx_raw()
1327 ATM_SKB(sb)->vcc = vcc; in idt77252_rx_raw()
1329 vcc->push(vcc, sb); in idt77252_rx_raw()
1330 atomic_inc(&vcc->stats->rx); in idt77252_rx_raw()
1336 + (queue->data - queue->head - 16); in idt77252_rx_raw()
1338 if (queue->len < 128) { in idt77252_rx_raw()
1342 head = le32_to_cpu(*(u32 *) &queue->data[0]); in idt77252_rx_raw()
1343 handle = le32_to_cpu(*(u32 *) &queue->data[4]); 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()
1353 (skb_end_pointer(queue) - in idt77252_rx_raw()
1354 queue->data), in idt77252_rx_raw()
1357 card->raw_cell_head = NULL; in idt77252_rx_raw()
1359 card->name); in idt77252_rx_raw()
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()
1382 return -1; 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()
1388 tsqe->word_2 = cpu_to_le32(SAR_TSQE_INVALID); 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()
1400 dma_free_coherent(&card->pcidev->dev, TSQSIZE, in deinit_tsq()
1401 card->tsq.base, card->tsq.paddr); in deinit_tsq()
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()
1417 TXPRINTK("idt77252_tx: tsq %p: base %p, next %p, last %p\n", tsqe, in idt77252_tx()
1418 card->tsq.base, card->tsq.next, card->tsq.last); in idt77252_tx()
1424 stat = le32_to_cpu(tsqe->word_2); in idt77252_tx()
1430 TXPRINTK("tsqe: 0x%p [0x%08x 0x%08x]\n", tsqe, in idt77252_tx()
1431 le32_to_cpu(tsqe->word_1), in idt77252_tx()
1432 le32_to_cpu(tsqe->word_2)); in idt77252_tx()
1436 TXPRINTK("%s: Timer RollOver detected.\n", card->name); in idt77252_tx()
1441 conn = le32_to_cpu(tsqe->word_1); in idt77252_tx()
1446 card->name, in idt77252_tx()
1447 le32_to_cpu(tsqe->word_1) & 0x1fff); 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()
1462 set_bit(VCF_IDLE, &vc->flags); in idt77252_tx()
1467 conn = le32_to_cpu(tsqe->word_1); in idt77252_tx()
1469 vc = card->vcs[conn & 0x1fff]; in idt77252_tx()
1472 card->name, in idt77252_tx()
1473 le32_to_cpu(tsqe->word_1) & 0x1fff); in idt77252_tx()
1482 conn = le32_to_cpu(tsqe->word_1); 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()
1507 tsqe->word_2 = cpu_to_le32(SAR_TSQE_INVALID); 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()
1515 TXPRINTK("tsqe: %p: base %p, next %p, last %p\n", tsqe, in idt77252_tx()
1516 card->tsq.base, card->tsq.next, card->tsq.last); in idt77252_tx()
1518 stat = le32_to_cpu(tsqe->word_2); in idt77252_tx()
1522 writel((unsigned long)card->tsq.next - (unsigned long)card->tsq.base, in idt77252_tx()
1525 XPRINTK("idt77252_tx-after writel%d: TSQ head = 0x%x, tail = 0x%x, next = 0x%p.\n", in idt77252_tx()
1526 card->index, readl(SAR_REG_TSQH), in idt77252_tx()
1527 readl(SAR_REG_TSQT), card->tsq.next); in idt77252_tx()
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()
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()
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()
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()
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()
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()
1610 return -1; in __fill_tst()
1614 card->name, vc ? vc->index : -1, e); in __fill_tst()
1620 data = opc | vc->index; 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()
1639 card->soft_tst[e].tste |= TSTE_PUSH_IDLE; in __fill_tst()
1642 cl -= card->tst_size; in __fill_tst()
1643 r--; in __fill_tst()
1660 spin_lock_irqsave(&card->tst_lock, flags); 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()
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()
1689 card->soft_tst[e].tste |= TSTE_PUSH_IDLE; in __clear_tst()
1703 spin_lock_irqsave(&card->tst_lock, flags); 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()
1722 spin_lock_irqsave(&card->tst_lock, flags); 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()
1741 tct = (unsigned long) (card->tct_base + vc->index * SAR_SRAM_TCT_SIZE); in set_tct()
1743 switch (vc->class) { 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()
1760 card->name, tct, vc->scq->scd); in set_tct()
1762 write_sram(card, tct + 0, TCT_UBR | vc->scq->scd); in set_tct()
1767 write_sram(card, tct + 5, vc->init_er); in set_tct()
1775 return -ENOSYS; in set_tct()
1806 skb->data = skb->head; in push_rx_skb()
1808 skb->len = 0; in push_rx_skb()
1826 return -1; in push_rx_skb()
1830 return -1; in push_rx_skb()
1832 memset(&skb->data[(skb->len & ~(0x3f)) - 64], 0, 2 * sizeof(u32)); in push_rx_skb()
1837 spin_lock_irqsave(&card->cmd_lock, flags); in push_rx_skb()
1838 writel(handle, card->fbq[queue]); in push_rx_skb()
1839 writel(addr, card->fbq[queue]); in push_rx_skb()
1840 spin_unlock_irqrestore(&card->cmd_lock, flags); in push_rx_skb()
1853 while (count--) { in add_rx_skb()
1863 paddr = dma_map_single(&card->pcidev->dev, skb->data, in add_rx_skb()
1864 skb_end_pointer(skb) - skb->data, in add_rx_skb()
1877 dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), in add_rx_skb()
1878 skb_end_pointer(skb) - skb->data, DMA_FROM_DEVICE); in add_rx_skb()
1881 card->sbpool[POOL_QUEUE(handle)].skb[POOL_INDEX(handle)] = NULL; in add_rx_skb()
1894 dma_sync_single_for_device(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), in recycle_rx_skb()
1895 skb_end_pointer(skb) - skb->data, in recycle_rx_skb()
1900 dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), in recycle_rx_skb()
1901 skb_end_pointer(skb) - skb->data, in recycle_rx_skb()
1911 skb_queue_head_init(&rpp->queue); in flush_rx_pool()
1912 rpp->len = 0; in flush_rx_pool()
1920 skb_queue_walk_safe(&rpp->queue, skb, tmp) in recycle_rx_pool_skb()
1935 write_utility(dev->dev_data, 0x100 + (addr & 0x1ff), value); in idt77252_phy_put()
1941 return read_utility(dev->dev_data, 0x100 + (addr & 0x1ff)); in idt77252_phy_get()
1945 idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam) in idt77252_send_skb() argument
1947 struct atm_dev *dev = vcc->dev; in idt77252_send_skb()
1948 struct idt77252_dev *card = dev->dev_data; in idt77252_send_skb()
1949 struct vc_map *vc = vcc->dev_data; in idt77252_send_skb()
1953 printk("%s: NULL connection in send().\n", card->name); in idt77252_send_skb()
1954 atomic_inc(&vcc->stats->tx_err); in idt77252_send_skb()
1956 return -EINVAL; in idt77252_send_skb()
1958 if (!test_bit(VCF_TX, &vc->flags)) { in idt77252_send_skb()
1959 printk("%s: Trying to transmit on a non-tx VC.\n", card->name); in idt77252_send_skb()
1960 atomic_inc(&vcc->stats->tx_err); in idt77252_send_skb()
1962 return -EINVAL; in idt77252_send_skb()
1965 switch (vcc->qos.aal) { in idt77252_send_skb()
1971 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal); in idt77252_send_skb()
1972 atomic_inc(&vcc->stats->tx_err); in idt77252_send_skb()
1974 return -EINVAL; in idt77252_send_skb()
1977 if (skb_shinfo(skb)->nr_frags != 0) { in idt77252_send_skb()
1978 printk("%s: No scatter-gather yet.\n", card->name); in idt77252_send_skb()
1979 atomic_inc(&vcc->stats->tx_err); in idt77252_send_skb()
1981 return -EINVAL; in idt77252_send_skb()
1983 ATM_SKB(skb)->vcc = vcc; in idt77252_send_skb()
1987 atomic_inc(&vcc->stats->tx_err); in idt77252_send_skb()
1995 static int idt77252_send(struct atm_vcc *vcc, struct sk_buff *skb) in idt77252_send() argument
1997 return idt77252_send_skb(vcc, skb, 0); in idt77252_send()
2001 idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags) in idt77252_send_oam() argument
2003 struct atm_dev *dev = vcc->dev; in idt77252_send_oam()
2004 struct idt77252_dev *card = dev->dev_data; in idt77252_send_oam()
2009 printk("%s: Out of memory in send_oam().\n", card->name); in idt77252_send_oam()
2010 atomic_inc(&vcc->stats->tx_err); in idt77252_send_oam()
2011 return -ENOMEM; in idt77252_send_oam()
2013 refcount_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc); in idt77252_send_oam()
2017 return idt77252_send_skb(vcc, skb, 1); in idt77252_send_oam()
2055 e = idt77252_fls(rate) - 1; in idt77252_int_to_atmfp()
2057 m = (rate - (1 << e)) << (9 - e); in idt77252_int_to_atmfp()
2059 m = (rate - (1 << e)); in idt77252_int_to_atmfp()
2061 m = (rate - (1 << e)) >> (e - 9); in idt77252_int_to_atmfp()
2070 afp = idt77252_int_to_atmfp(pcr < 0 ? -pcr : pcr); in idt77252_rate_logindex()
2080 struct vc_map *vc = est->vc; in idt77252_est_timer()
2081 struct idt77252_dev *card = vc->card; in idt77252_est_timer()
2087 spin_lock_irqsave(&vc->lock, flags); in idt77252_est_timer()
2088 if (!vc->estimator) in idt77252_est_timer()
2090 ncells = est->cells; in idt77252_est_timer()
2092 rate = ((u32)(ncells - est->last_cells)) << (7 - est->interval); in idt77252_est_timer()
2093 est->last_cells = ncells; in idt77252_est_timer()
2094 est->avcps += ((long)rate - (long)est->avcps) >> est->ewma_log; in idt77252_est_timer()
2095 est->cps = (est->avcps + 0x1f) >> 5; in idt77252_est_timer()
2097 cps = est->cps; in idt77252_est_timer()
2098 if (cps < (est->maxcps >> 4)) in idt77252_est_timer()
2099 cps = est->maxcps >> 4; in idt77252_est_timer()
2102 if (lacr > vc->max_er) in idt77252_est_timer()
2103 lacr = vc->max_er; in idt77252_est_timer()
2105 if (lacr != vc->lacr) { in idt77252_est_timer()
2106 vc->lacr = lacr; in idt77252_est_timer()
2107 writel(TCMDQ_LACR|(vc->lacr << 16)|vc->index, SAR_REG_TCMDQ); in idt77252_est_timer()
2110 est->timer.expires = jiffies + ((HZ / 4) << est->interval); in idt77252_est_timer()
2111 add_timer(&est->timer); in idt77252_est_timer()
2114 spin_unlock_irqrestore(&vc->lock, flags); in idt77252_est_timer()
2125 est->maxcps = pcr < 0 ? -pcr : pcr; in idt77252_init_est()
2126 est->cps = est->maxcps; in idt77252_init_est()
2127 est->avcps = est->cps << 5; in idt77252_init_est()
2128 est->vc = vc; in idt77252_init_est()
2130 est->interval = 2; /* XXX: make this configurable */ in idt77252_init_est()
2131 est->ewma_log = 2; /* XXX: make this configurable */ in idt77252_init_est()
2132 timer_setup(&est->timer, idt77252_est_timer, 0); in idt77252_init_est()
2133 mod_timer(&est->timer, jiffies + ((HZ / 4) << est->interval)); in idt77252_init_est()
2140 struct atm_vcc *vcc, struct atm_qos *qos) in idt77252_init_cbr() argument
2146 if ((qos->txtp.max_pcr == 0) && in idt77252_init_cbr()
2147 (qos->txtp.pcr == 0) && (qos->txtp.min_pcr == 0)) { in idt77252_init_cbr()
2149 card->name); in idt77252_init_cbr()
2150 return -EINVAL; in idt77252_init_cbr()
2154 tst_free = card->tst_free; in idt77252_init_cbr()
2155 if (test_bit(VCF_TX, &vc->flags)) in idt77252_init_cbr()
2156 tst_used = vc->ntste; in idt77252_init_cbr()
2159 tcr = atm_pcr_goal(&qos->txtp); in idt77252_init_cbr()
2160 tcra = tcr >= 0 ? tcr : -tcr; in idt77252_init_cbr()
2162 TXPRINTK("%s: CBR target cell rate = %d\n", card->name, tcra); in idt77252_init_cbr()
2164 tmpl = (unsigned long) tcra * ((unsigned long) card->tst_size - 2); in idt77252_init_cbr()
2165 modl = tmpl % (unsigned long)card->utopia_pcr; in idt77252_init_cbr()
2167 tst_entries = (int) (tmpl / card->utopia_pcr); in idt77252_init_cbr()
2172 tst_entries = tst_free - SAR_TST_RESERVED; in idt77252_init_cbr()
2174 printk("%s: no CBR bandwidth free.\n", card->name); in idt77252_init_cbr()
2175 return -ENOSR; in idt77252_init_cbr()
2181 card->name); in idt77252_init_cbr()
2182 return -EINVAL; in idt77252_init_cbr()
2185 if (tst_entries > (tst_free - SAR_TST_RESERVED)) { in idt77252_init_cbr()
2186 printk("%s: not enough CBR bandwidth free.\n", card->name); in idt77252_init_cbr()
2187 return -ENOSR; in idt77252_init_cbr()
2190 vc->ntste = tst_entries; in idt77252_init_cbr()
2192 card->tst_free = tst_free - tst_entries; in idt77252_init_cbr()
2193 if (test_bit(VCF_TX, &vc->flags)) { in idt77252_init_cbr()
2197 OPRINTK("%s: modify %d -> %d entries in TST.\n", in idt77252_init_cbr()
2198 card->name, tst_used, tst_entries); in idt77252_init_cbr()
2203 OPRINTK("%s: setting %d entries in TST.\n", card->name, tst_entries); in idt77252_init_cbr()
2210 struct atm_vcc *vcc, struct atm_qos *qos) in idt77252_init_ubr() argument
2216 spin_lock_irqsave(&vc->lock, flags); in idt77252_init_ubr()
2217 if (vc->estimator) { in idt77252_init_ubr()
2218 est = vc->estimator; in idt77252_init_ubr()
2219 vc->estimator = NULL; in idt77252_init_ubr()
2221 spin_unlock_irqrestore(&vc->lock, flags); in idt77252_init_ubr()
2223 del_timer_sync(&est->timer); in idt77252_init_ubr()
2227 tcr = atm_pcr_goal(&qos->txtp); in idt77252_init_ubr()
2229 tcr = card->link_pcr; in idt77252_init_ubr()
2231 vc->estimator = idt77252_init_est(vc, tcr); in idt77252_init_ubr()
2233 vc->class = SCHED_UBR; in idt77252_init_ubr()
2234 vc->init_er = idt77252_rate_logindex(card, tcr); in idt77252_init_ubr()
2235 vc->lacr = vc->init_er; in idt77252_init_ubr()
2237 vc->max_er = vc->init_er; in idt77252_init_ubr()
2239 vc->max_er = 0xff; in idt77252_init_ubr()
2246 struct atm_vcc *vcc, struct atm_qos *qos) in idt77252_init_tx() argument
2250 if (test_bit(VCF_TX, &vc->flags)) in idt77252_init_tx()
2251 return -EBUSY; in idt77252_init_tx()
2253 switch (qos->txtp.traffic_class) { in idt77252_init_tx()
2255 vc->class = SCHED_CBR; in idt77252_init_tx()
2259 vc->class = SCHED_UBR; in idt77252_init_tx()
2265 return -EPROTONOSUPPORT; in idt77252_init_tx()
2268 vc->scq = alloc_scq(card, vc->class); in idt77252_init_tx()
2269 if (!vc->scq) { in idt77252_init_tx()
2270 printk("%s: can't get SCQ.\n", card->name); in idt77252_init_tx()
2271 return -ENOMEM; in idt77252_init_tx()
2274 vc->scq->scd = get_free_scd(card, vc); in idt77252_init_tx()
2275 if (vc->scq->scd == 0) { in idt77252_init_tx()
2276 printk("%s: no SCD available.\n", card->name); in idt77252_init_tx()
2277 free_scq(card, vc->scq); in idt77252_init_tx()
2278 return -ENOMEM; in idt77252_init_tx()
2281 fill_scd(card, vc->scq, vc->class); in idt77252_init_tx()
2285 card->name, qos->txtp.traffic_class); in idt77252_init_tx()
2287 card->scd2vc[vc->scd_index] = NULL; in idt77252_init_tx()
2288 free_scq(card, vc->scq); in idt77252_init_tx()
2289 return -EPROTONOSUPPORT; in idt77252_init_tx()
2292 switch (vc->class) { in idt77252_init_tx()
2294 error = idt77252_init_cbr(card, vc, vcc, qos); in idt77252_init_tx()
2296 card->scd2vc[vc->scd_index] = NULL; in idt77252_init_tx()
2297 free_scq(card, vc->scq); in idt77252_init_tx()
2301 clear_bit(VCF_IDLE, &vc->flags); in idt77252_init_tx()
2302 writel(TCMDQ_START | vc->index, SAR_REG_TCMDQ); in idt77252_init_tx()
2306 error = idt77252_init_ubr(card, vc, vcc, qos); in idt77252_init_tx()
2308 card->scd2vc[vc->scd_index] = NULL; in idt77252_init_tx()
2309 free_scq(card, vc->scq); in idt77252_init_tx()
2313 set_bit(VCF_IDLE, &vc->flags); in idt77252_init_tx()
2317 vc->tx_vcc = vcc; in idt77252_init_tx()
2318 set_bit(VCF_TX, &vc->flags); in idt77252_init_tx()
2324 struct atm_vcc *vcc, struct atm_qos *qos) in idt77252_init_rx() argument
2330 if (test_bit(VCF_RX, &vc->flags)) in idt77252_init_rx()
2331 return -EBUSY; in idt77252_init_rx()
2333 vc->rx_vcc = vcc; in idt77252_init_rx()
2334 set_bit(VCF_RX, &vc->flags); in idt77252_init_rx()
2336 if ((vcc->vci == 3) || (vcc->vci == 4)) in idt77252_init_rx()
2339 flush_rx_pool(card, &vc->rcv.rx_pool); in idt77252_init_rx()
2344 switch (qos->aal) { in idt77252_init_rx()
2362 if (qos->aal != ATM_AAL5) in idt77252_init_rx()
2364 else if (qos->rxtp.max_sdu > SAR_FB_SIZE_2) in idt77252_init_rx()
2366 else if (qos->rxtp.max_sdu > SAR_FB_SIZE_1) in idt77252_init_rx()
2368 else if (qos->rxtp.max_sdu > SAR_FB_SIZE_0) in idt77252_init_rx()
2373 addr = card->rct_base + (vc->index << 2); in idt77252_init_rx()
2375 OPRINTK("%s: writing RCT at 0x%lx\n", card->name, addr); in idt77252_init_rx()
2378 spin_lock_irqsave(&card->cmd_lock, flags); in idt77252_init_rx()
2381 spin_unlock_irqrestore(&card->cmd_lock, flags); in idt77252_init_rx()
2387 idt77252_open(struct atm_vcc *vcc) in idt77252_open() argument
2389 struct atm_dev *dev = vcc->dev; in idt77252_open()
2390 struct idt77252_dev *card = dev->dev_data; in idt77252_open()
2395 int vci = vcc->vci; in idt77252_open()
2396 short vpi = vcc->vpi; in idt77252_open()
2401 if (vpi >= (1 << card->vpibits)) { in idt77252_open()
2402 printk("%s: unsupported VPI: %d\n", card->name, vpi); in idt77252_open()
2403 return -EINVAL; in idt77252_open()
2406 if (vci >= (1 << card->vcibits)) { in idt77252_open()
2407 printk("%s: unsupported VCI: %d\n", card->name, vci); in idt77252_open()
2408 return -EINVAL; in idt77252_open()
2411 set_bit(ATM_VF_ADDR, &vcc->flags); in idt77252_open()
2413 mutex_lock(&card->mutex); in idt77252_open()
2415 OPRINTK("%s: opening vpi.vci: %d.%d\n", card->name, vpi, vci); in idt77252_open()
2417 switch (vcc->qos.aal) { in idt77252_open()
2423 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal); in idt77252_open()
2424 mutex_unlock(&card->mutex); in idt77252_open()
2425 return -EPROTONOSUPPORT; in idt77252_open()
2429 if (!card->vcs[index]) { in idt77252_open()
2430 card->vcs[index] = kzalloc(sizeof(struct vc_map), GFP_KERNEL); in idt77252_open()
2431 if (!card->vcs[index]) { in idt77252_open()
2432 printk("%s: can't alloc vc in open()\n", card->name); in idt77252_open()
2433 mutex_unlock(&card->mutex); in idt77252_open()
2434 return -ENOMEM; in idt77252_open()
2436 card->vcs[index]->card = card; in idt77252_open()
2437 card->vcs[index]->index = index; in idt77252_open()
2439 spin_lock_init(&card->vcs[index]->lock); in idt77252_open()
2441 vc = card->vcs[index]; in idt77252_open()
2443 vcc->dev_data = vc; in idt77252_open()
2446 card->name, vc->index, vcc->vpi, vcc->vci, in idt77252_open()
2447 vcc->qos.rxtp.traffic_class != ATM_NONE ? "rx" : "--", in idt77252_open()
2448 vcc->qos.txtp.traffic_class != ATM_NONE ? "tx" : "--", in idt77252_open()
2449 vcc->qos.rxtp.max_sdu); in idt77252_open()
2452 if (vcc->qos.txtp.traffic_class != ATM_NONE && in idt77252_open()
2453 test_bit(VCF_TX, &vc->flags)) in idt77252_open()
2455 if (vcc->qos.rxtp.traffic_class != ATM_NONE && in idt77252_open()
2456 test_bit(VCF_RX, &vc->flags)) in idt77252_open()
2460 printk("%s: %s vci already in use.\n", card->name, in idt77252_open()
2462 mutex_unlock(&card->mutex); in idt77252_open()
2463 return -EADDRINUSE; in idt77252_open()
2466 if (vcc->qos.txtp.traffic_class != ATM_NONE) { in idt77252_open()
2467 error = idt77252_init_tx(card, vc, vcc, &vcc->qos); in idt77252_open()
2469 mutex_unlock(&card->mutex); in idt77252_open()
2474 if (vcc->qos.rxtp.traffic_class != ATM_NONE) { in idt77252_open()
2475 error = idt77252_init_rx(card, vc, vcc, &vcc->qos); in idt77252_open()
2477 mutex_unlock(&card->mutex); in idt77252_open()
2482 set_bit(ATM_VF_READY, &vcc->flags); in idt77252_open()
2484 mutex_unlock(&card->mutex); in idt77252_open()
2489 idt77252_close(struct atm_vcc *vcc) in idt77252_close() argument
2491 struct atm_dev *dev = vcc->dev; in idt77252_close()
2492 struct idt77252_dev *card = dev->dev_data; in idt77252_close()
2493 struct vc_map *vc = vcc->dev_data; in idt77252_close()
2498 mutex_lock(&card->mutex); in idt77252_close()
2501 card->name, vc->index, vcc->vpi, vcc->vci); in idt77252_close()
2503 clear_bit(ATM_VF_READY, &vcc->flags); in idt77252_close()
2505 if (vcc->qos.rxtp.traffic_class != ATM_NONE) { in idt77252_close()
2507 spin_lock_irqsave(&vc->lock, flags); in idt77252_close()
2508 clear_bit(VCF_RX, &vc->flags); in idt77252_close()
2509 vc->rx_vcc = NULL; in idt77252_close()
2510 spin_unlock_irqrestore(&vc->lock, flags); in idt77252_close()
2512 if ((vcc->vci == 3) || (vcc->vci == 4)) in idt77252_close()
2515 addr = card->rct_base + vc->index * SAR_SRAM_RCT_SIZE; in idt77252_close()
2517 spin_lock_irqsave(&card->cmd_lock, flags); in idt77252_close()
2520 spin_unlock_irqrestore(&card->cmd_lock, flags); in idt77252_close()
2522 if (skb_queue_len(&vc->rcv.rx_pool.queue) != 0) { in idt77252_close()
2524 card->name); in idt77252_close()
2526 recycle_rx_pool_skb(card, &vc->rcv.rx_pool); in idt77252_close()
2531 if (vcc->qos.txtp.traffic_class != ATM_NONE) { in idt77252_close()
2533 spin_lock_irqsave(&vc->lock, flags); in idt77252_close()
2534 clear_bit(VCF_TX, &vc->flags); in idt77252_close()
2535 clear_bit(VCF_IDLE, &vc->flags); in idt77252_close()
2536 clear_bit(VCF_RSV, &vc->flags); in idt77252_close()
2537 vc->tx_vcc = NULL; in idt77252_close()
2539 if (vc->estimator) { in idt77252_close()
2540 del_timer(&vc->estimator->timer); in idt77252_close()
2541 kfree(vc->estimator); in idt77252_close()
2542 vc->estimator = NULL; in idt77252_close()
2544 spin_unlock_irqrestore(&vc->lock, flags); in idt77252_close()
2547 while (atomic_read(&vc->scq->used) > 0) { in idt77252_close()
2551 card->name, atomic_read(&vc->scq->used)); in idt77252_close()
2556 writel(TCMDQ_HALT | vc->index, SAR_REG_TCMDQ); in idt77252_close()
2557 clear_scd(card, vc->scq, vc->class); in idt77252_close()
2559 if (vc->class == SCHED_CBR) { in idt77252_close()
2561 card->tst_free += vc->ntste; in idt77252_close()
2562 vc->ntste = 0; in idt77252_close()
2565 card->scd2vc[vc->scd_index] = NULL; in idt77252_close()
2566 free_scq(card, vc->scq); in idt77252_close()
2569 mutex_unlock(&card->mutex); in idt77252_close()
2573 idt77252_change_qos(struct atm_vcc *vcc, struct atm_qos *qos, int flags) in idt77252_change_qos() argument
2575 struct atm_dev *dev = vcc->dev; in idt77252_change_qos()
2576 struct idt77252_dev *card = dev->dev_data; in idt77252_change_qos()
2577 struct vc_map *vc = vcc->dev_data; in idt77252_change_qos()
2580 mutex_lock(&card->mutex); in idt77252_change_qos()
2582 if (qos->txtp.traffic_class != ATM_NONE) { in idt77252_change_qos()
2583 if (!test_bit(VCF_TX, &vc->flags)) { in idt77252_change_qos()
2584 error = idt77252_init_tx(card, vc, vcc, qos); in idt77252_change_qos()
2588 switch (qos->txtp.traffic_class) { in idt77252_change_qos()
2590 error = idt77252_init_cbr(card, vc, vcc, qos); in idt77252_change_qos()
2596 error = idt77252_init_ubr(card, vc, vcc, qos); in idt77252_change_qos()
2600 if (!test_bit(VCF_IDLE, &vc->flags)) { in idt77252_change_qos()
2601 writel(TCMDQ_LACR | (vc->lacr << 16) | in idt77252_change_qos()
2602 vc->index, SAR_REG_TCMDQ); in idt77252_change_qos()
2608 error = -EOPNOTSUPP; in idt77252_change_qos()
2614 if ((qos->rxtp.traffic_class != ATM_NONE) && in idt77252_change_qos()
2615 !test_bit(VCF_RX, &vc->flags)) { in idt77252_change_qos()
2616 error = idt77252_init_rx(card, vc, vcc, qos); in idt77252_change_qos()
2621 memcpy(&vcc->qos, qos, sizeof(struct atm_qos)); in idt77252_change_qos()
2623 set_bit(ATM_VF_HASQOS, &vcc->flags); in idt77252_change_qos()
2626 mutex_unlock(&card->mutex); in idt77252_change_qos()
2633 struct idt77252_dev *card = dev->dev_data; in idt77252_proc_read()
2637 if (!left--) in idt77252_proc_read()
2639 if (!left--) in idt77252_proc_read()
2640 return sprintf(page, "TSIF: %lu\n", card->irqstat[15]); in idt77252_proc_read()
2641 if (!left--) in idt77252_proc_read()
2642 return sprintf(page, "TXICP: %lu\n", card->irqstat[14]); in idt77252_proc_read()
2643 if (!left--) in idt77252_proc_read()
2644 return sprintf(page, "TSQF: %lu\n", card->irqstat[12]); in idt77252_proc_read()
2645 if (!left--) in idt77252_proc_read()
2646 return sprintf(page, "TMROF: %lu\n", card->irqstat[11]); in idt77252_proc_read()
2647 if (!left--) in idt77252_proc_read()
2648 return sprintf(page, "PHYI: %lu\n", card->irqstat[10]); in idt77252_proc_read()
2649 if (!left--) in idt77252_proc_read()
2650 return sprintf(page, "FBQ3A: %lu\n", card->irqstat[8]); in idt77252_proc_read()
2651 if (!left--) in idt77252_proc_read()
2652 return sprintf(page, "FBQ2A: %lu\n", card->irqstat[7]); in idt77252_proc_read()
2653 if (!left--) in idt77252_proc_read()
2654 return sprintf(page, "RSQF: %lu\n", card->irqstat[6]); in idt77252_proc_read()
2655 if (!left--) in idt77252_proc_read()
2656 return sprintf(page, "EPDU: %lu\n", card->irqstat[5]); in idt77252_proc_read()
2657 if (!left--) in idt77252_proc_read()
2658 return sprintf(page, "RAWCF: %lu\n", card->irqstat[4]); in idt77252_proc_read()
2659 if (!left--) in idt77252_proc_read()
2660 return sprintf(page, "FBQ1A: %lu\n", card->irqstat[3]); in idt77252_proc_read()
2661 if (!left--) in idt77252_proc_read()
2662 return sprintf(page, "FBQ0A: %lu\n", card->irqstat[2]); in idt77252_proc_read()
2663 if (!left--) in idt77252_proc_read()
2664 return sprintf(page, "RSQAF: %lu\n", card->irqstat[1]); in idt77252_proc_read()
2665 if (!left--) in idt77252_proc_read()
2668 for (i = 0; i < card->tct_size; i++) { in idt77252_proc_read()
2670 struct atm_vcc *vcc; in idt77252_proc_read() local
2672 char *p; in idt77252_proc_read() local
2674 vc = card->vcs[i]; in idt77252_proc_read()
2678 vcc = NULL; in idt77252_proc_read()
2679 if (vc->tx_vcc) in idt77252_proc_read()
2680 vcc = vc->tx_vcc; in idt77252_proc_read()
2681 if (!vcc) in idt77252_proc_read()
2683 if (left--) in idt77252_proc_read()
2686 p = page; in idt77252_proc_read()
2687 p += sprintf(p, " %4u: %u.%u: ", i, vcc->vpi, vcc->vci); in idt77252_proc_read()
2688 tct = (unsigned long) (card->tct_base + i * SAR_SRAM_TCT_SIZE); in idt77252_proc_read()
2691 p += sprintf(p, " %08x", read_sram(card, tct + i)); in idt77252_proc_read()
2692 p += sprintf(p, "\n"); in idt77252_proc_read()
2693 return p - page; in idt77252_proc_read()
2723 if (test_and_set_bit(IDT77252_BIT_INTERRUPT, &card->flags)) { in idt77252_interrupt()
2724 printk("%s: Re-entering irq_handler()\n", card->name); in idt77252_interrupt()
2731 INTPRINTK("%s: TSIF\n", card->name); in idt77252_interrupt()
2732 card->irqstat[15]++; in idt77252_interrupt()
2735 if (stat & SAR_STAT_TXICP) { /* Incomplete CS-PDU has */ in idt77252_interrupt()
2736 INTPRINTK("%s: TXICP\n", card->name); in idt77252_interrupt()
2737 card->irqstat[14]++; in idt77252_interrupt()
2743 INTPRINTK("%s: TSQF\n", card->name); in idt77252_interrupt()
2744 card->irqstat[12]++; in idt77252_interrupt()
2748 INTPRINTK("%s: TMROF\n", card->name); in idt77252_interrupt()
2749 card->irqstat[11]++; in idt77252_interrupt()
2753 if (stat & SAR_STAT_EPDU) { /* Got complete CS-PDU */ in idt77252_interrupt()
2754 INTPRINTK("%s: EPDU\n", card->name); in idt77252_interrupt()
2755 card->irqstat[5]++; in idt77252_interrupt()
2759 INTPRINTK("%s: RSQAF\n", card->name); in idt77252_interrupt()
2760 card->irqstat[1]++; in idt77252_interrupt()
2764 INTPRINTK("%s: RSQF\n", card->name); in idt77252_interrupt()
2765 card->irqstat[6]++; in idt77252_interrupt()
2769 INTPRINTK("%s: RAWCF\n", card->name); in idt77252_interrupt()
2770 card->irqstat[4]++; in idt77252_interrupt()
2775 INTPRINTK("%s: PHYI", card->name); in idt77252_interrupt()
2776 card->irqstat[10]++; in idt77252_interrupt()
2777 if (card->atmdev->phy && card->atmdev->phy->interrupt) in idt77252_interrupt()
2778 card->atmdev->phy->interrupt(card->atmdev); in idt77252_interrupt()
2786 INTPRINTK("%s: FBQA: %04x\n", card->name, stat); in idt77252_interrupt()
2789 card->irqstat[2]++; in idt77252_interrupt()
2791 card->irqstat[3]++; in idt77252_interrupt()
2793 card->irqstat[7]++; in idt77252_interrupt()
2795 card->irqstat[8]++; in idt77252_interrupt()
2797 schedule_work(&card->tqueue); in idt77252_interrupt()
2801 clear_bit(IDT77252_BIT_INTERRUPT, &card->flags); in idt77252_interrupt()
2857 for (vpi = 0; vpi < (1 << card->vpibits); vpi++) { in open_card_oam()
2863 printk("%s: can't alloc vc\n", card->name); in open_card_oam()
2864 return -ENOMEM; in open_card_oam()
2866 vc->index = index; in open_card_oam()
2867 card->vcs[index] = vc; in open_card_oam()
2869 flush_rx_pool(card, &vc->rcv.rx_pool); in open_card_oam()
2876 addr = card->rct_base + (vc->index << 2); in open_card_oam()
2879 spin_lock_irqsave(&card->cmd_lock, flags); in open_card_oam()
2883 spin_unlock_irqrestore(&card->cmd_lock, flags); in open_card_oam()
2899 for (vpi = 0; vpi < (1 << card->vpibits); vpi++) { in close_card_oam()
2902 vc = card->vcs[index]; in close_card_oam()
2904 addr = card->rct_base + vc->index * SAR_SRAM_RCT_SIZE; in close_card_oam()
2906 spin_lock_irqsave(&card->cmd_lock, flags); in close_card_oam()
2910 spin_unlock_irqrestore(&card->cmd_lock, flags); in close_card_oam()
2912 if (skb_queue_len(&vc->rcv.rx_pool.queue) != 0) { in close_card_oam()
2915 card->name); in close_card_oam()
2917 recycle_rx_pool_skb(card, &vc->rcv.rx_pool); in close_card_oam()
2931 printk("%s: can't alloc vc\n", card->name); in open_card_ubr0()
2932 return -ENOMEM; in open_card_ubr0()
2934 card->vcs[0] = vc; in open_card_ubr0()
2935 vc->class = SCHED_UBR0; in open_card_ubr0()
2937 vc->scq = alloc_scq(card, vc->class); in open_card_ubr0()
2938 if (!vc->scq) { in open_card_ubr0()
2939 printk("%s: can't get SCQ.\n", card->name); in open_card_ubr0()
2940 kfree(card->vcs[0]); in open_card_ubr0()
2941 card->vcs[0] = NULL; in open_card_ubr0()
2942 return -ENOMEM; in open_card_ubr0()
2945 card->scd2vc[0] = vc; in open_card_ubr0()
2946 vc->scd_index = 0; in open_card_ubr0()
2947 vc->scq->scd = card->scd_base; in open_card_ubr0()
2949 fill_scd(card, vc->scq, vc->class); in open_card_ubr0()
2951 write_sram(card, card->tct_base + 0, TCT_UBR | card->scd_base); in open_card_ubr0()
2952 write_sram(card, card->tct_base + 1, 0); in open_card_ubr0()
2953 write_sram(card, card->tct_base + 2, 0); in open_card_ubr0()
2954 write_sram(card, card->tct_base + 3, 0); in open_card_ubr0()
2955 write_sram(card, card->tct_base + 4, 0); in open_card_ubr0()
2956 write_sram(card, card->tct_base + 5, 0); in open_card_ubr0()
2957 write_sram(card, card->tct_base + 6, 0); in open_card_ubr0()
2958 write_sram(card, card->tct_base + 7, TCT_FLAG_UBR); in open_card_ubr0()
2960 clear_bit(VCF_IDLE, &vc->flags); in open_card_ubr0()
2968 struct vc_map *vc = card->vcs[0]; in close_card_ubr0()
2970 free_scq(card, vc->scq); in close_card_ubr0()
2979 if (!test_bit(IDT77252_BIT_INIT, &card->flags)) { in idt77252_dev_open()
2980 printk("%s: SAR not yet initialized.\n", card->name); in idt77252_dev_open()
2981 return -1; in idt77252_dev_open()
3005 printk("%s: Error initializing OAM.\n", card->name); in idt77252_dev_open()
3006 return -1; in idt77252_dev_open()
3010 printk("%s: Error initializing UBR0.\n", card->name); in idt77252_dev_open()
3011 return -1; in idt77252_dev_open()
3014 IPRINTK("%s: opened IDT77252 ABR SAR.\n", card->name); in idt77252_dev_open()
3020 struct idt77252_dev *card = dev->dev_data; in idt77252_dev_close()
3040 DIPRINTK("%s: closed IDT77252 ABR SAR.\n", card->name); in idt77252_dev_close()
3057 if (!test_bit(IDT77252_BIT_INIT, &card->flags)) { in deinit_card()
3058 printk("%s: SAR not yet initialized.\n", card->name); in deinit_card()
3061 DIPRINTK("idt77252: deinitialize card %u\n", card->index); in deinit_card()
3065 if (card->atmdev) in deinit_card()
3066 atm_dev_deregister(card->atmdev); in deinit_card()
3070 skb = card->sbpool[i].skb[j]; in deinit_card()
3072 dma_unmap_single(&card->pcidev->dev, in deinit_card()
3074 (skb_end_pointer(skb) - in deinit_card()
3075 skb->data), in deinit_card()
3077 card->sbpool[i].skb[j] = NULL; in deinit_card()
3083 vfree(card->soft_tst); in deinit_card()
3085 vfree(card->scd2vc); in deinit_card()
3087 vfree(card->vcs); in deinit_card()
3089 if (card->raw_cell_hnd) { in deinit_card()
3090 dma_free_coherent(&card->pcidev->dev, 2 * sizeof(u32), in deinit_card()
3091 card->raw_cell_hnd, card->raw_cell_paddr); in deinit_card()
3094 if (card->rsq.base) { in deinit_card()
3095 DIPRINTK("%s: Release RSQ ...\n", card->name); in deinit_card()
3099 if (card->tsq.base) { in deinit_card()
3100 DIPRINTK("%s: Release TSQ ...\n", card->name); in deinit_card()
3105 free_irq(card->pcidev->irq, card); in deinit_card()
3108 if (card->fbq[i]) in deinit_card()
3109 iounmap(card->fbq[i]); in deinit_card()
3112 if (card->membase) in deinit_card()
3113 iounmap(card->membase); in deinit_card()
3115 clear_bit(IDT77252_BIT_INIT, &card->flags); in deinit_card()
3116 DIPRINTK("%s: Card deinitialized.\n", card->name); in deinit_card()
3124 for (i = 0; i < card->sramsize; i += 4) in init_sram()
3128 if (card->sramsize == (512 * 1024)) { in init_sram()
3129 card->tct_base = SAR_SRAM_TCT_128_BASE; in init_sram()
3130 card->tct_size = (SAR_SRAM_TCT_128_TOP - card->tct_base + 1) in init_sram()
3132 card->rct_base = SAR_SRAM_RCT_128_BASE; in init_sram()
3133 card->rct_size = (SAR_SRAM_RCT_128_TOP - card->rct_base + 1) in init_sram()
3135 card->rt_base = SAR_SRAM_RT_128_BASE; in init_sram()
3136 card->scd_base = SAR_SRAM_SCD_128_BASE; in init_sram()
3137 card->scd_size = (SAR_SRAM_SCD_128_TOP - card->scd_base + 1) in init_sram()
3139 card->tst[0] = SAR_SRAM_TST1_128_BASE; in init_sram()
3140 card->tst[1] = SAR_SRAM_TST2_128_BASE; in init_sram()
3141 card->tst_size = SAR_SRAM_TST1_128_TOP - card->tst[0] + 1; in init_sram()
3142 card->abrst_base = SAR_SRAM_ABRSTD_128_BASE; in init_sram()
3143 card->abrst_size = SAR_ABRSTD_SIZE_8K; in init_sram()
3144 card->fifo_base = SAR_SRAM_FIFO_128_BASE; in init_sram()
3145 card->fifo_size = SAR_RXFD_SIZE_32K; in init_sram()
3147 card->tct_base = SAR_SRAM_TCT_32_BASE; in init_sram()
3148 card->tct_size = (SAR_SRAM_TCT_32_TOP - card->tct_base + 1) in init_sram()
3150 card->rct_base = SAR_SRAM_RCT_32_BASE; in init_sram()
3151 card->rct_size = (SAR_SRAM_RCT_32_TOP - card->rct_base + 1) in init_sram()
3153 card->rt_base = SAR_SRAM_RT_32_BASE; in init_sram()
3154 card->scd_base = SAR_SRAM_SCD_32_BASE; in init_sram()
3155 card->scd_size = (SAR_SRAM_SCD_32_TOP - card->scd_base + 1) in init_sram()
3157 card->tst[0] = SAR_SRAM_TST1_32_BASE; in init_sram()
3158 card->tst[1] = SAR_SRAM_TST2_32_BASE; in init_sram()
3159 card->tst_size = (SAR_SRAM_TST1_32_TOP - card->tst[0] + 1); in init_sram()
3160 card->abrst_base = SAR_SRAM_ABRSTD_32_BASE; in init_sram()
3161 card->abrst_size = SAR_ABRSTD_SIZE_1K; in init_sram()
3162 card->fifo_base = SAR_SRAM_FIFO_32_BASE; in init_sram()
3163 card->fifo_size = SAR_RXFD_SIZE_4K; in init_sram()
3167 for (i = 0; i < card->tct_size; i++) { in init_sram()
3179 for (i = 0; i < card->rct_size; i++) { in init_sram()
3180 write_sram(card, card->rct_base + i * SAR_SRAM_RCT_SIZE, in init_sram()
3182 write_sram(card, card->rct_base + i * SAR_SRAM_RCT_SIZE + 1, in init_sram()
3184 write_sram(card, card->rct_base + i * SAR_SRAM_RCT_SIZE + 2, in init_sram()
3186 write_sram(card, card->rct_base + i * SAR_SRAM_RCT_SIZE + 3, in init_sram()
3197 write_sram(card, card->rt_base + i, log_to_rate[i]); in init_sram()
3207 write_sram(card, card->rt_base + 256 + i, tmp); in init_sram()
3216 write_sram(card, card->rt_base + 512 + i, tmp); in init_sram()
3224 write_sram(card, card->rt_base + 640 + i, tmp); in init_sram()
3228 IPRINTK("%s: initialize rate table ...\n", card->name); in init_sram()
3229 writel(card->rt_base << 2, SAR_REG_RTBL); in init_sram()
3232 IPRINTK("%s: initialize TST ...\n", card->name); in init_sram()
3233 card->tst_free = card->tst_size - 2; /* last two are jumps */ in init_sram()
3235 for (i = card->tst[0]; i < card->tst[0] + card->tst_size - 2; i++) in init_sram()
3237 write_sram(card, i++, TSTE_OPC_JMP | (card->tst[0] << 2)); in init_sram()
3239 write_sram(card, i++, TSTE_OPC_JMP | (card->tst[1] << 2)); in init_sram()
3241 for (i = card->tst[1]; i < card->tst[1] + card->tst_size - 2; i++) in init_sram()
3243 write_sram(card, i++, TSTE_OPC_JMP | (card->tst[1] << 2)); in init_sram()
3245 write_sram(card, i++, TSTE_OPC_JMP | (card->tst[0] << 2)); in init_sram()
3248 card->tst_index = 0; in init_sram()
3249 writel(card->tst[0] << 2, SAR_REG_TSTB); in init_sram()
3252 IPRINTK("%s: initialize ABRSTD ...\n", card->name); in init_sram()
3253 writel(card->abrst_size | (card->abrst_base << 2), in init_sram()
3256 IPRINTK("%s: initialize receive fifo ...\n", card->name); in init_sram()
3257 writel(card->fifo_size | (card->fifo_base << 2), in init_sram()
3260 IPRINTK("%s: SRAM initialization complete.\n", card->name); in init_sram()
3265 struct idt77252_dev *card = dev->dev_data; in init_card()
3266 struct pci_dev *pcidev = card->pcidev; in init_card()
3278 if (test_bit(IDT77252_BIT_INIT, &card->flags)) { in init_card()
3280 return -1; in init_card()
3284 /* P C I C O N F I G U R A T I O N */ in init_card()
3287 /* Set PCI Retry-Timeout and TRDY timeout */ in init_card()
3288 IPRINTK("%s: Checking PCI retries.\n", card->name); in init_card()
3290 printk("%s: can't read PCI retry timeout.\n", card->name); in init_card()
3292 return -1; in init_card()
3296 card->name, pci_byte); in init_card()
3299 card->name); in init_card()
3301 return -1; in init_card()
3304 IPRINTK("%s: Checking PCI TRDY.\n", card->name); in init_card()
3306 printk("%s: can't read PCI TRDY timeout.\n", card->name); in init_card()
3308 return -1; in init_card()
3312 card->name, pci_byte); in init_card()
3314 printk("%s: can't set PCI TRDY timeout.\n", card->name); in init_card()
3316 return -1; in init_card()
3321 printk("%s: resetting timer overflow.\n", card->name); in init_card()
3324 IPRINTK("%s: Request IRQ ... ", card->name); in init_card()
3325 if (request_irq(pcidev->irq, idt77252_interrupt, IRQF_SHARED, in init_card()
3326 card->name, card) != 0) { in init_card()
3327 printk("%s: can't allocate IRQ.\n", card->name); in init_card()
3329 return -1; in init_card()
3331 IPRINTK("got %d.\n", pcidev->irq); in init_card()
3337 IPRINTK("%s: Initializing SRAM\n", card->name); in init_card()
3348 if (card->sramsize == (512 * 1024)) in init_card()
3379 return -1; in init_card()
3384 return -1; in init_card()
3387 card->vpibits = vpibits; in init_card()
3388 if (card->sramsize == (512 * 1024)) { in init_card()
3389 card->vcibits = 10 - card->vpibits; in init_card()
3391 card->vcibits = 9 - card->vpibits; in init_card()
3394 card->vcimask = 0; in init_card()
3395 for (k = 0, i = 1; k < card->vcibits; k++) { in init_card()
3396 card->vcimask |= i; in init_card()
3400 IPRINTK("%s: Setting VPI/VCI mask to zero.\n", card->name); in init_card()
3407 card->raw_cell_hnd = dma_alloc_coherent(&card->pcidev->dev, in init_card()
3409 &card->raw_cell_paddr, in init_card()
3411 if (!card->raw_cell_hnd) { in init_card()
3412 printk("%s: memory allocation failure.\n", card->name); in init_card()
3414 return -1; in init_card()
3416 writel(card->raw_cell_paddr, SAR_REG_RAWHND); in init_card()
3417 IPRINTK("%s: raw cell handle is at 0x%p.\n", card->name, in init_card()
3418 card->raw_cell_hnd); in init_card()
3420 size = sizeof(struct vc_map *) * card->tct_size; in init_card()
3421 IPRINTK("%s: allocate %d byte for VC map.\n", card->name, size); in init_card()
3422 card->vcs = vzalloc(size); in init_card()
3423 if (!card->vcs) { in init_card()
3424 printk("%s: memory allocation failure.\n", card->name); in init_card()
3426 return -1; in init_card()
3429 size = sizeof(struct vc_map *) * card->scd_size; in init_card()
3431 card->name, size); in init_card()
3432 card->scd2vc = vzalloc(size); in init_card()
3433 if (!card->scd2vc) { in init_card()
3434 printk("%s: memory allocation failure.\n", card->name); in init_card()
3436 return -1; in init_card()
3439 size = sizeof(struct tst_info) * (card->tst_size - 2); in init_card()
3441 card->name, size); in init_card()
3442 card->soft_tst = vmalloc(size); in init_card()
3443 if (!card->soft_tst) { in init_card()
3444 printk("%s: memory allocation failure.\n", card->name); in init_card()
3446 return -1; in init_card()
3448 for (i = 0; i < card->tst_size - 2; i++) { in init_card()
3449 card->soft_tst[i].tste = TSTE_OPC_VAR; in init_card()
3450 card->soft_tst[i].vc = NULL; in init_card()
3453 if (dev->phy == NULL) { in init_card()
3454 printk("%s: No LT device defined.\n", card->name); in init_card()
3456 return -1; in init_card()
3458 if (dev->phy->ioctl == NULL) { in init_card()
3459 printk("%s: LT had no IOCTL function defined.\n", card->name); in init_card()
3461 return -1; in init_card()
3477 card->link_pcr = (linkrate / 8 / 53); in init_card()
3479 card->name, linkrate, card->link_pcr); in init_card()
3482 card->utopia_pcr = card->link_pcr; in init_card()
3484 card->utopia_pcr = (160000000 / 8 / 54); in init_card()
3488 if (card->utopia_pcr > card->link_pcr) in init_card()
3489 rsvdcr = card->utopia_pcr - card->link_pcr; in init_card()
3491 tmpl = (unsigned long) rsvdcr * ((unsigned long) card->tst_size - 2); in init_card()
3492 modl = tmpl % (unsigned long)card->utopia_pcr; in init_card()
3493 tst_entries = (int) (tmpl / (unsigned long)card->utopia_pcr); in init_card()
3496 card->tst_free -= tst_entries; in init_card()
3501 printk("%s: EEPROM: %02x:", card->name, in init_card()
3515 sprintf(tname, "eth%d", card->index); in init_card()
3518 memcpy(card->atmdev->esi, tmp->dev_addr, 6); in init_card()
3520 printk("%s: ESI %pM\n", card->name, card->atmdev->esi); in init_card()
3529 set_bit(IDT77252_BIT_INIT, &card->flags); in init_card()
3531 XPRINTK("%s: IDT77252 ABR SAR initialization complete.\n", card->name); in init_card()
3548 /* P C I C O N F I G U R A T I O N */ in idt77252_preset()
3552 card->name); in idt77252_preset()
3553 if (pci_read_config_word(card->pcidev, PCI_COMMAND, &pci_command)) { in idt77252_preset()
3554 printk("%s: can't read PCI_COMMAND.\n", card->name); in idt77252_preset()
3556 return -1; in idt77252_preset()
3560 card->name, pci_command); in idt77252_preset()
3562 return (-1); in idt77252_preset()
3565 if (pci_write_config_word(card->pcidev, PCI_COMMAND, pci_command)) { in idt77252_preset()
3566 printk("%s: can't write PCI_COMMAND.\n", card->name); in idt77252_preset()
3568 return -1; in idt77252_preset()
3579 IPRINTK("%s: Software resetted.\n", card->name); in idt77252_preset()
3622 if ((err = dma_set_mask_and_coherent(&pcidev->dev, DMA_BIT_MASK(32)))) { in idt77252_init_one()
3629 printk("idt77252-%d: can't allocate private data\n", index); in idt77252_init_one()
3630 err = -ENOMEM; in idt77252_init_one()
3633 card->revision = pcidev->revision; in idt77252_init_one()
3634 card->index = index; in idt77252_init_one()
3635 card->pcidev = pcidev; in idt77252_init_one()
3636 sprintf(card->name, "idt77252-%d", card->index); in idt77252_init_one()
3638 INIT_WORK(&card->tqueue, idt77252_softint); in idt77252_init_one()
3643 mutex_init(&card->mutex); in idt77252_init_one()
3644 spin_lock_init(&card->cmd_lock); in idt77252_init_one()
3645 spin_lock_init(&card->tst_lock); in idt77252_init_one()
3647 timer_setup(&card->tst_timer, tst_timer, 0); in idt77252_init_one()
3650 card->membase = ioremap(membase, 1024); in idt77252_init_one()
3651 if (!card->membase) { in idt77252_init_one()
3652 printk("%s: can't ioremap() membase\n", card->name); in idt77252_init_one()
3653 err = -EIO; in idt77252_init_one()
3658 printk("%s: preset failed\n", card->name); in idt77252_init_one()
3659 err = -EIO; in idt77252_init_one()
3663 dev = atm_dev_register("idt77252", &pcidev->dev, &idt77252_ops, -1, in idt77252_init_one()
3666 printk("%s: can't register atm device\n", card->name); in idt77252_init_one()
3667 err = -EIO; in idt77252_init_one()
3670 dev->dev_data = card; in idt77252_init_one()
3671 card->atmdev = dev; in idt77252_init_one()
3675 if (!dev->phy) { in idt77252_init_one()
3676 printk("%s: can't init SUNI\n", card->name); in idt77252_init_one()
3677 err = -EIO; in idt77252_init_one()
3682 card->sramsize = probe_sram(card); in idt77252_init_one()
3685 card->fbq[i] = ioremap(srambase | 0x200000 | (i << 18), 4); in idt77252_init_one()
3686 if (!card->fbq[i]) { in idt77252_init_one()
3687 printk("%s: can't ioremap() FBQ%d\n", card->name, i); in idt77252_init_one()
3688 err = -EIO; in idt77252_init_one()
3694 card->name, ((card->revision > 1) && (card->revision < 25)) ? in idt77252_init_one()
3695 'A' + card->revision - 1 : '?', membase, srambase, in idt77252_init_one()
3696 card->sramsize / 1024); in idt77252_init_one()
3699 printk("%s: init_card failed\n", card->name); in idt77252_init_one()
3700 err = -EIO; in idt77252_init_one()
3704 dev->ci_range.vpi_bits = card->vpibits; in idt77252_init_one()
3705 dev->ci_range.vci_bits = card->vcibits; in idt77252_init_one()
3706 dev->link_rate = card->link_pcr; in idt77252_init_one()
3708 if (dev->phy->start) in idt77252_init_one()
3709 dev->phy->start(dev); in idt77252_init_one()
3712 printk("%s: dev_open failed\n", card->name); in idt77252_init_one()
3713 err = -EIO; in idt77252_init_one()
3718 last = &card->next; in idt77252_init_one()
3724 if (dev->phy->stop) in idt77252_init_one()
3725 dev->phy->stop(dev); in idt77252_init_one()
3731 iounmap(card->membase); in idt77252_init_one()
3759 printk("%s: at %p\n", __func__, idt77252_init); in idt77252_init()
3761 if (sizeof(skb->cb) < sizeof(struct atm_skb_data) + in idt77252_init()
3763 printk(KERN_ERR "%s: skb->cb is too small (%lu < %lu)\n", in idt77252_init()
3764 __func__, (unsigned long) sizeof(skb->cb), in idt77252_init()
3767 return -EIO; in idt77252_init()
3782 dev = card->atmdev; in idt77252_exit()
3783 idt77252_chain = card->next; in idt77252_exit()
3784 del_timer_sync(&card->tst_timer); in idt77252_exit()
3786 if (dev->phy->stop) in idt77252_exit()
3787 dev->phy->stop(dev); in idt77252_exit()
3789 pci_disable_device(card->pcidev); in idt77252_exit()
3793 DIPRINTK("idt77252: finished cleanup-module().\n"); in idt77252_exit()