Lines Matching refs:fore200e
66 #include "fore200e.h"
71 #define FORE200E "fore200e: "
154 fore200e_chunk_alloc(struct fore200e* fore200e, struct chunk* chunk, int size, int alignment, int direction)
174 chunk->dma_addr = fore200e->bus->dma_map(fore200e, chunk->align_addr, chunk->align_size, direction);
183 fore200e_chunk_free(struct fore200e* fore200e, struct chunk* chunk)
185 fore200e->bus->dma_unmap(fore200e, chunk->dma_addr, chunk->dma_size, chunk->direction);
200 fore200e_poll(struct fore200e* fore200e, volatile u32* addr, u32 val, int msecs)
222 fore200e_io_poll(struct fore200e* fore200e, volatile u32 __iomem *addr, u32 val, int msecs)
228 if ((ok = (fore200e->bus->read(addr) == val)))
235 fore200e->bus->read(addr), val);
243 fore200e_free_rx_buf(struct fore200e* fore200e)
251 if ((buffer = fore200e->host_bsq[ scheme ][ magn ].buffer) != NULL) {
258 fore200e_chunk_free(fore200e, data);
267 fore200e_uninit_bs_queue(struct fore200e* fore200e)
274 struct chunk* status = &fore200e->host_bsq[ scheme ][ magn ].status;
275 struct chunk* rbd_block = &fore200e->host_bsq[ scheme ][ magn ].rbd_block;
278 fore200e->bus->dma_chunk_free(fore200e, status);
281 fore200e->bus->dma_chunk_free(fore200e, rbd_block);
288 fore200e_reset(struct fore200e* fore200e, int diag)
292 fore200e->cp_monitor = fore200e->virt_base + FORE200E_CP_MONITOR_OFFSET;
294 fore200e->bus->write(BSTAT_COLD_START, &fore200e->cp_monitor->bstat);
296 fore200e->bus->reset(fore200e);
299 ok = fore200e_io_poll(fore200e, &fore200e->cp_monitor->bstat, BSTAT_SELFTEST_OK, 1000);
302 printk(FORE200E "device %s self-test failed\n", fore200e->name);
306 printk(FORE200E "device %s self-test passed\n", fore200e->name);
308 fore200e->state = FORE200E_STATE_RESET;
316 fore200e_shutdown(struct fore200e* fore200e)
319 fore200e->name, fore200e->phys_base,
320 fore200e_irq_itoa(fore200e->irq));
322 if (fore200e->state > FORE200E_STATE_RESET) {
324 fore200e_reset(fore200e, 0);
328 switch(fore200e->state) {
331 kfree(fore200e->stats);
334 free_irq(fore200e->irq, fore200e->atm_dev);
337 fore200e_free_rx_buf(fore200e);
340 fore200e_uninit_bs_queue(fore200e);
343 fore200e->bus->dma_chunk_free(fore200e, &fore200e->host_rxq.status);
344 fore200e->bus->dma_chunk_free(fore200e, &fore200e->host_rxq.rpd);
347 fore200e->bus->dma_chunk_free(fore200e, &fore200e->host_txq.status);
348 fore200e->bus->dma_chunk_free(fore200e, &fore200e->host_txq.tpd);
351 fore200e->bus->dma_chunk_free(fore200e, &fore200e->host_cmdq.status);
363 fore200e->bus->unmap(fore200e);
369 atm_dev_deregister(fore200e->atm_dev);
397 fore200e_pca_dma_map(struct fore200e* fore200e, void* virt_addr, int size, int direction)
399 u32 dma_addr = pci_map_single((struct pci_dev*)fore200e->bus_dev, virt_addr, size, direction);
409 fore200e_pca_dma_unmap(struct fore200e* fore200e, u32 dma_addr, int size, int direction)
414 pci_unmap_single((struct pci_dev*)fore200e->bus_dev, dma_addr, size, direction);
419 fore200e_pca_dma_sync_for_cpu(struct fore200e* fore200e, u32 dma_addr, int size, int direction)
423 pci_dma_sync_single_for_cpu((struct pci_dev*)fore200e->bus_dev, dma_addr, size, direction);
427 fore200e_pca_dma_sync_for_device(struct fore200e* fore200e, u32 dma_addr, int size, int direction)
431 pci_dma_sync_single_for_device((struct pci_dev*)fore200e->bus_dev, dma_addr, size, direction);
439 fore200e_pca_dma_chunk_alloc(struct fore200e* fore200e, struct chunk* chunk,
444 chunk->alloc_addr = pci_alloc_consistent((struct pci_dev*)fore200e->bus_dev,
460 fore200e_pca_dma_chunk_free(struct fore200e* fore200e, struct chunk* chunk)
462 pci_free_consistent((struct pci_dev*)fore200e->bus_dev,
470 fore200e_pca_irq_check(struct fore200e* fore200e)
473 int irq_posted = readl(fore200e->regs.pca.psr);
476 if (irq_posted && (readl(fore200e->regs.pca.hcr) & PCA200E_HCR_OUTFULL)) {
477 DPRINTK(2,"FIFO OUT full, device %d\n", fore200e->atm_dev->number);
486 fore200e_pca_irq_ack(struct fore200e* fore200e)
488 writel(PCA200E_HCR_CLRINTR, fore200e->regs.pca.hcr);
493 fore200e_pca_reset(struct fore200e* fore200e)
495 writel(PCA200E_HCR_RESET, fore200e->regs.pca.hcr);
497 writel(0, fore200e->regs.pca.hcr);
502 fore200e_pca_map(struct fore200e* fore200e)
504 DPRINTK(2, "device %s being mapped in memory\n", fore200e->name);
506 fore200e->virt_base = ioremap(fore200e->phys_base, PCA200E_IOSPACE_LENGTH);
508 if (fore200e->virt_base == NULL) {
509 printk(FORE200E "can't map device %s\n", fore200e->name);
513 DPRINTK(1, "device %s mapped to 0x%p\n", fore200e->name, fore200e->virt_base);
516 fore200e->regs.pca.hcr = fore200e->virt_base + PCA200E_HCR_OFFSET;
517 fore200e->regs.pca.imr = fore200e->virt_base + PCA200E_IMR_OFFSET;
518 fore200e->regs.pca.psr = fore200e->virt_base + PCA200E_PSR_OFFSET;
520 fore200e->state = FORE200E_STATE_MAP;
526 fore200e_pca_unmap(struct fore200e* fore200e)
528 DPRINTK(2, "device %s being unmapped from memory\n", fore200e->name);
530 if (fore200e->virt_base != NULL)
531 iounmap(fore200e->virt_base);
536 fore200e_pca_configure(struct fore200e* fore200e)
538 struct pci_dev* pci_dev = (struct pci_dev*)fore200e->bus_dev;
541 DPRINTK(2, "device %s being configured\n", fore200e->name);
565 fore200e->state = FORE200E_STATE_CONFIGURE;
571 fore200e_pca_prom_read(struct fore200e* fore200e, struct prom_data* prom)
573 struct host_cmdq* cmdq = &fore200e->host_cmdq;
584 prom_dma = fore200e->bus->dma_map(fore200e, prom, sizeof(struct prom_data), DMA_FROM_DEVICE);
586 fore200e->bus->write(prom_dma, &entry->cp_entry->cmd.prom_block.prom_haddr);
590 fore200e->bus->write(*(u32*)&opcode, (u32 __iomem *)&entry->cp_entry->cmd.prom_block.opcode);
592 ok = fore200e_poll(fore200e, entry->status, STATUS_COMPLETE, 400);
596 fore200e->bus->dma_unmap(fore200e, prom_dma, sizeof(struct prom_data), DMA_FROM_DEVICE);
599 printk(FORE200E "unable to get PROM data from device %s\n", fore200e->name);
617 fore200e_pca_proc_read(struct fore200e* fore200e, char *page)
619 struct pci_dev* pci_dev = (struct pci_dev*)fore200e->bus_dev;
640 static u32 fore200e_sba_dma_map(struct fore200e *fore200e, void* virt_addr, int size, int direction)
642 struct platform_device *op = fore200e->bus_dev;
653 static void fore200e_sba_dma_unmap(struct fore200e *fore200e, u32 dma_addr, int size, int direction)
655 struct platform_device *op = fore200e->bus_dev;
663 static void fore200e_sba_dma_sync_for_cpu(struct fore200e *fore200e, u32 dma_addr, int size, int direction)
665 struct platform_device *op = fore200e->bus_dev;
672 static void fore200e_sba_dma_sync_for_device(struct fore200e *fore200e, u32 dma_addr, int size, int direction)
674 struct platform_device *op = fore200e->bus_dev;
684 static int fore200e_sba_dma_chunk_alloc(struct fore200e *fore200e, struct chunk *chunk,
687 struct platform_device *op = fore200e->bus_dev;
704 static void fore200e_sba_dma_chunk_free(struct fore200e *fore200e, struct chunk *chunk)
706 struct platform_device *op = fore200e->bus_dev;
712 static void fore200e_sba_irq_enable(struct fore200e *fore200e)
714 u32 hcr = fore200e->bus->read(fore200e->regs.sba.hcr) & SBA200E_HCR_STICKY;
715 fore200e->bus->write(hcr | SBA200E_HCR_INTR_ENA, fore200e->regs.sba.hcr);
718 static int fore200e_sba_irq_check(struct fore200e *fore200e)
720 return fore200e->bus->read(fore200e->regs.sba.hcr) & SBA200E_HCR_INTR_REQ;
723 static void fore200e_sba_irq_ack(struct fore200e *fore200e)
725 u32 hcr = fore200e->bus->read(fore200e->regs.sba.hcr) & SBA200E_HCR_STICKY;
726 fore200e->bus->write(hcr | SBA200E_HCR_INTR_CLR, fore200e->regs.sba.hcr);
729 static void fore200e_sba_reset(struct fore200e *fore200e)
731 fore200e->bus->write(SBA200E_HCR_RESET, fore200e->regs.sba.hcr);
733 fore200e->bus->write(0, fore200e->regs.sba.hcr);
736 static int __init fore200e_sba_map(struct fore200e *fore200e)
738 struct platform_device *op = fore200e->bus_dev;
742 fore200e->regs.sba.hcr = of_ioremap(&op->resource[0], 0, SBA200E_HCR_LENGTH, "SBA HCR");
743 fore200e->regs.sba.bsr = of_ioremap(&op->resource[1], 0, SBA200E_BSR_LENGTH, "SBA BSR");
744 fore200e->regs.sba.isr = of_ioremap(&op->resource[2], 0, SBA200E_ISR_LENGTH, "SBA ISR");
745 fore200e->virt_base = of_ioremap(&op->resource[3], 0, SBA200E_RAM_LENGTH, "SBA RAM");
747 if (!fore200e->virt_base) {
748 printk(FORE200E "unable to map RAM of device %s\n", fore200e->name);
752 DPRINTK(1, "device %s mapped to 0x%p\n", fore200e->name, fore200e->virt_base);
754 fore200e->bus->write(0x02, fore200e->regs.sba.isr);
762 fore200e->state = FORE200E_STATE_MAP;
766 static void fore200e_sba_unmap(struct fore200e *fore200e)
768 struct platform_device *op = fore200e->bus_dev;
770 of_iounmap(&op->resource[0], fore200e->regs.sba.hcr, SBA200E_HCR_LENGTH);
771 of_iounmap(&op->resource[1], fore200e->regs.sba.bsr, SBA200E_BSR_LENGTH);
772 of_iounmap(&op->resource[2], fore200e->regs.sba.isr, SBA200E_ISR_LENGTH);
773 of_iounmap(&op->resource[3], fore200e->virt_base, SBA200E_RAM_LENGTH);
776 static int __init fore200e_sba_configure(struct fore200e *fore200e)
778 fore200e->state = FORE200E_STATE_CONFIGURE;
782 static int __init fore200e_sba_prom_read(struct fore200e *fore200e, struct prom_data *prom)
784 struct platform_device *op = fore200e->bus_dev;
806 static int fore200e_sba_proc_read(struct fore200e *fore200e, char *page)
808 struct platform_device *op = fore200e->bus_dev;
820 fore200e_tx_irq(struct fore200e* fore200e)
822 struct host_txq* txq = &fore200e->host_txq;
827 if (fore200e->host_txq.txing == 0)
845 fore200e->bus->dma_unmap(fore200e, entry->tpd->tsd[ 0 ].buffer, entry->tpd->tsd[ 0 ].length,
855 fore200e->atm_dev->number);
878 fore200e->atm_dev->number);
907 fore200e->host_txq.txing--;
957 fore200e_supply(struct fore200e* fore200e)
968 bsq = &fore200e->host_bsq[ scheme ][ magn ];
1007 fore200e->bus->write(entry->rbd_block_dma, &entry->cp_entry->rbd_block_haddr);
1015 fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rpd)
1069 fore200e->bus->dma_sync_for_cpu(fore200e, buffer->data.dma_addr, rpd->rsd[ i ].length, DMA_FROM_DEVICE);
1074 fore200e->bus->dma_sync_for_device(fore200e, buffer->data.dma_addr, rpd->rsd[ i ].length, DMA_FROM_DEVICE);
1109 fore200e_collect_rpd(struct fore200e* fore200e, struct rpd* rpd)
1120 bsq = &fore200e->host_bsq[ buffer->scheme ][ buffer->magn ];
1142 fore200e_rx_irq(struct fore200e* fore200e)
1144 struct host_rxq* rxq = &fore200e->host_rxq;
1157 vc_map = FORE200E_VC_MAP(fore200e, entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
1163 fore200e->atm_dev->number,
1172 fore200e_push_rpd(fore200e, vcc, entry->rpd);
1176 fore200e->atm_dev->number,
1184 fore200e_collect_rpd(fore200e, entry->rpd);
1187 fore200e->bus->write(entry->rpd_dma, &entry->cp_entry->rpd_haddr);
1190 fore200e_supply(fore200e);
1197 fore200e_irq(struct fore200e* fore200e)
1201 spin_lock_irqsave(&fore200e->q_lock, flags);
1202 fore200e_rx_irq(fore200e);
1203 spin_unlock_irqrestore(&fore200e->q_lock, flags);
1205 spin_lock_irqsave(&fore200e->q_lock, flags);
1206 fore200e_tx_irq(fore200e);
1207 spin_unlock_irqrestore(&fore200e->q_lock, flags);
1215 struct fore200e* fore200e = FORE200E_DEV((struct atm_dev*)dev);
1217 if (fore200e->bus->irq_check(fore200e) == 0) {
1219 DPRINTK(3, "interrupt NOT triggered by device %d\n", fore200e->atm_dev->number);
1222 DPRINTK(3, "interrupt triggered by device %d\n", fore200e->atm_dev->number);
1225 tasklet_schedule(&fore200e->tx_tasklet);
1226 tasklet_schedule(&fore200e->rx_tasklet);
1228 fore200e_irq(fore200e);
1231 fore200e->bus->irq_ack(fore200e);
1240 struct fore200e* fore200e = (struct fore200e*) data;
1243 DPRINTK(3, "tx tasklet scheduled for device %d\n", fore200e->atm_dev->number);
1245 spin_lock_irqsave(&fore200e->q_lock, flags);
1246 fore200e_tx_irq(fore200e);
1247 spin_unlock_irqrestore(&fore200e->q_lock, flags);
1254 struct fore200e* fore200e = (struct fore200e*) data;
1257 DPRINTK(3, "rx tasklet scheduled for device %d\n", fore200e->atm_dev->number);
1259 spin_lock_irqsave(&fore200e->q_lock, flags);
1260 fore200e_rx_irq((struct fore200e*) data);
1261 spin_unlock_irqrestore(&fore200e->q_lock, flags);
1280 fore200e_activate_vcin(struct fore200e* fore200e, int activate, struct atm_vcc* vcc, int mtu)
1282 struct host_cmdq* cmdq = &fore200e->host_cmdq;
1316 fore200e->bus->write(mtu, &entry->cp_entry->cmd.activate_block.mtu);
1317 fore200e->bus->write(*(u32*)&vpvc, (u32 __iomem *)&entry->cp_entry->cmd.activate_block.vpvc);
1318 fore200e->bus->write(*(u32*)&activ_opcode, (u32 __iomem *)&entry->cp_entry->cmd.activate_block.opcode);
1321 fore200e->bus->write(*(u32*)&vpvc, (u32 __iomem *)&entry->cp_entry->cmd.deactivate_block.vpvc);
1322 fore200e->bus->write(*(u32*)&deactiv_opcode, (u32 __iomem *)&entry->cp_entry->cmd.deactivate_block.opcode);
1325 ok = fore200e_poll(fore200e, entry->status, STATUS_COMPLETE, 400);
1363 struct fore200e* fore200e = FORE200E_DEV(vcc->dev);
1373 spin_lock_irqsave(&fore200e->q_lock, flags);
1375 vc_map = FORE200E_VC_MAP(fore200e, vpi, vci);
1378 spin_unlock_irqrestore(&fore200e->q_lock, flags);
1381 fore200e->atm_dev->number, vpi, vci);
1388 spin_unlock_irqrestore(&fore200e->q_lock, flags);
1407 mutex_lock(&fore200e->rate_mtx);
1408 if (fore200e->available_cell_rate < vcc->qos.txtp.max_pcr) {
1409 mutex_unlock(&fore200e->rate_mtx);
1417 fore200e->available_cell_rate -= vcc->qos.txtp.max_pcr;
1418 mutex_unlock(&fore200e->rate_mtx);
1428 if (fore200e_activate_vcin(fore200e, 1, vcc, vcc->qos.rxtp.max_sdu) < 0) {
1437 fore200e->available_cell_rate += vcc->qos.txtp.max_pcr;
1460 vc_map->incarn = ++fore200e->incarn_count;
1472 struct fore200e* fore200e = FORE200E_DEV(vcc->dev);
1485 fore200e_activate_vcin(fore200e, 0, vcc, 0);
1487 spin_lock_irqsave(&fore200e->q_lock, flags);
1489 vc_map = FORE200E_VC_MAP(fore200e, vcc->vpi, vcc->vci);
1499 spin_unlock_irqrestore(&fore200e->q_lock, flags);
1504 mutex_lock(&fore200e->rate_mtx);
1505 fore200e->available_cell_rate += vcc->qos.txtp.max_pcr;
1506 mutex_unlock(&fore200e->rate_mtx);
1522 struct fore200e* fore200e = FORE200E_DEV(vcc->dev);
1525 struct host_txq* txq = &fore200e->host_txq;
1540 ASSERT(fore200e);
1566 DPRINTK(2, "misaligned tx PDU on device %s\n", fore200e->name);
1574 DPRINTK(2, "incomplete tx AAL0 PDU on device %s\n", fore200e->name);
1599 vc_map = FORE200E_VC_MAP(fore200e, vcc->vpi, vcc->vci);
1604 spin_lock_irqsave(&fore200e->q_lock, flags);
1611 fore200e_tx_irq(fore200e);
1615 spin_unlock_irqrestore(&fore200e->q_lock, flags);
1625 fore200e->tx_sat++;
1627 fore200e->name, fore200e->cp_queues->heartbeat);
1648 tpd->tsd[ 0 ].buffer = fore200e->bus->dma_map(fore200e, data, tx_len, DMA_TO_DEVICE);
1698 fore200e->bus->write(*(u32*)&tpd_haddr, (u32 __iomem *)&entry->cp_entry->tpd_haddr);
1700 spin_unlock_irqrestore(&fore200e->q_lock, flags);
1707 fore200e_getstats(struct fore200e* fore200e)
1709 struct host_cmdq* cmdq = &fore200e->host_cmdq;
1715 if (fore200e->stats == NULL) {
1716 fore200e->stats = kzalloc(sizeof(struct stats), GFP_KERNEL | GFP_DMA);
1717 if (fore200e->stats == NULL)
1721 stats_dma_addr = fore200e->bus->dma_map(fore200e, fore200e->stats,
1729 fore200e->bus->write(stats_dma_addr, &entry->cp_entry->cmd.stats_block.stats_haddr);
1733 fore200e->bus->write(*(u32*)&opcode, (u32 __iomem *)&entry->cp_entry->cmd.stats_block.opcode);
1735 ok = fore200e_poll(fore200e, entry->status, STATUS_COMPLETE, 400);
1739 fore200e->bus->dma_unmap(fore200e, stats_dma_addr, sizeof(struct stats), DMA_FROM_DEVICE);
1742 printk(FORE200E "unable to get statistics from device %s\n", fore200e->name);
1753 /* struct fore200e* fore200e = FORE200E_DEV(vcc->dev); */
1765 /* struct fore200e* fore200e = FORE200E_DEV(vcc->dev); */
1777 fore200e_set_oc3(struct fore200e* fore200e, u32 reg, u32 value, u32 mask)
1779 struct host_cmdq* cmdq = &fore200e->host_cmdq;
1793 fore200e->bus->write(0, &entry->cp_entry->cmd.oc3_block.regs_haddr);
1797 fore200e->bus->write(*(u32*)&opcode, (u32 __iomem *)&entry->cp_entry->cmd.oc3_block.opcode);
1799 ok = fore200e_poll(fore200e, entry->status, STATUS_COMPLETE, 400);
1804 printk(FORE200E "unable to set OC-3 reg 0x%02x of device %s\n", reg, fore200e->name);
1813 fore200e_setloop(struct fore200e* fore200e, int loop_mode)
1840 error = fore200e_set_oc3(fore200e, SUNI_MCT, mct_value, mct_mask);
1842 fore200e->loop_mode = loop_mode;
1849 fore200e_fetch_stats(struct fore200e* fore200e, struct sonet_stats __user *arg)
1853 if (fore200e_getstats(fore200e) < 0)
1856 tmp.section_bip = be32_to_cpu(fore200e->stats->oc3.section_bip8_errors);
1857 tmp.line_bip = be32_to_cpu(fore200e->stats->oc3.line_bip24_errors);
1858 tmp.path_bip = be32_to_cpu(fore200e->stats->oc3.path_bip8_errors);
1859 tmp.line_febe = be32_to_cpu(fore200e->stats->oc3.line_febe_errors);
1860 tmp.path_febe = be32_to_cpu(fore200e->stats->oc3.path_febe_errors);
1861 tmp.corr_hcs = be32_to_cpu(fore200e->stats->oc3.corr_hcs_errors);
1862 tmp.uncorr_hcs = be32_to_cpu(fore200e->stats->oc3.ucorr_hcs_errors);
1863 tmp.tx_cells = be32_to_cpu(fore200e->stats->aal0.cells_transmitted) +
1864 be32_to_cpu(fore200e->stats->aal34.cells_transmitted) +
1865 be32_to_cpu(fore200e->stats->aal5.cells_transmitted);
1866 tmp.rx_cells = be32_to_cpu(fore200e->stats->aal0.cells_received) +
1867 be32_to_cpu(fore200e->stats->aal34.cells_received) +
1868 be32_to_cpu(fore200e->stats->aal5.cells_received);
1880 struct fore200e* fore200e = FORE200E_DEV(dev);
1887 return fore200e_fetch_stats(fore200e, (struct sonet_stats __user *)arg);
1893 return fore200e_setloop(fore200e, (int)(unsigned long)arg);
1896 return put_user(fore200e->loop_mode, (int __user *)arg) ? -EFAULT : 0;
1910 struct fore200e* fore200e = FORE200E_DEV(vcc->dev);
1926 flags, fore200e->available_cell_rate);
1930 mutex_lock(&fore200e->rate_mtx);
1931 if (fore200e->available_cell_rate + vcc->qos.txtp.max_pcr < qos->txtp.max_pcr) {
1932 mutex_unlock(&fore200e->rate_mtx);
1936 fore200e->available_cell_rate += vcc->qos.txtp.max_pcr;
1937 fore200e->available_cell_rate -= qos->txtp.max_pcr;
1939 mutex_unlock(&fore200e->rate_mtx);
1956 fore200e_irq_request(struct fore200e* fore200e)
1958 if (request_irq(fore200e->irq, fore200e_interrupt, IRQF_SHARED, fore200e->name, fore200e->atm_dev) < 0) {
1961 fore200e_irq_itoa(fore200e->irq), fore200e->name);
1966 fore200e_irq_itoa(fore200e->irq), fore200e->name);
1969 tasklet_init(&fore200e->tx_tasklet, fore200e_tx_tasklet, (unsigned long)fore200e);
1970 tasklet_init(&fore200e->rx_tasklet, fore200e_rx_tasklet, (unsigned long)fore200e);
1973 fore200e->state = FORE200E_STATE_IRQ;
1979 fore200e_get_esi(struct fore200e* fore200e)
1987 ok = fore200e->bus->prom_read(fore200e, prom);
1994 fore200e->name,
1999 fore200e->esi[ i ] = fore200e->atm_dev->esi[ i ] = prom->mac_addr[ i + 2 ];
2009 fore200e_alloc_rx_buf(struct fore200e* fore200e)
2019 bsq = &fore200e->host_bsq[ scheme ][ magn ];
2044 if (fore200e_chunk_alloc(fore200e,
2045 &buffer[ i ].data, size, fore200e->bus->buffer_alignment,
2049 fore200e_chunk_free(fore200e, &buffer[ --i ].data);
2068 fore200e->state = FORE200E_STATE_ALLOC_BUF;
2074 fore200e_init_bs_queue(struct fore200e* fore200e)
2086 bsq = &fore200e->host_bsq[ scheme ][ magn ];
2089 if (fore200e->bus->dma_chunk_alloc(fore200e,
2093 fore200e->bus->status_alignment) < 0) {
2098 if (fore200e->bus->dma_chunk_alloc(fore200e,
2102 fore200e->bus->descr_alignment) < 0) {
2104 fore200e->bus->dma_chunk_free(fore200e, &bsq->status);
2109 cp_entry = fore200e->virt_base +
2110 fore200e->bus->read(&fore200e->cp_queues->cp_bsq[ scheme ][ magn ]);
2125 fore200e->bus->write(FORE200E_DMA_INDEX(bsq->status.dma_addr, enum status, i),
2131 fore200e->state = FORE200E_STATE_INIT_BSQ;
2137 fore200e_init_rx_queue(struct fore200e* fore200e)
2139 struct host_rxq* rxq = &fore200e->host_rxq;
2146 if (fore200e->bus->dma_chunk_alloc(fore200e,
2150 fore200e->bus->status_alignment) < 0) {
2155 if (fore200e->bus->dma_chunk_alloc(fore200e,
2159 fore200e->bus->descr_alignment) < 0) {
2161 fore200e->bus->dma_chunk_free(fore200e, &rxq->status);
2166 cp_entry = fore200e->virt_base + fore200e->bus->read(&fore200e->cp_queues->cp_rxq);
2181 fore200e->bus->write(FORE200E_DMA_INDEX(rxq->status.dma_addr, enum status, i),
2184 fore200e->bus->write(FORE200E_DMA_INDEX(rxq->rpd.dma_addr, struct rpd, i),
2191 fore200e->state = FORE200E_STATE_INIT_RXQ;
2197 fore200e_init_tx_queue(struct fore200e* fore200e)
2199 struct host_txq* txq = &fore200e->host_txq;
2206 if (fore200e->bus->dma_chunk_alloc(fore200e,
2210 fore200e->bus->status_alignment) < 0) {
2215 if (fore200e->bus->dma_chunk_alloc(fore200e,
2219 fore200e->bus->descr_alignment) < 0) {
2221 fore200e->bus->dma_chunk_free(fore200e, &txq->status);
2226 cp_entry = fore200e->virt_base + fore200e->bus->read(&fore200e->cp_queues->cp_txq);
2241 fore200e->bus->write(FORE200E_DMA_INDEX(txq->status.dma_addr, enum status, i),
2254 fore200e->state = FORE200E_STATE_INIT_TXQ;
2260 fore200e_init_cmd_queue(struct fore200e* fore200e)
2262 struct host_cmdq* cmdq = &fore200e->host_cmdq;
2269 if (fore200e->bus->dma_chunk_alloc(fore200e,
2273 fore200e->bus->status_alignment) < 0) {
2278 cp_entry = fore200e->virt_base + fore200e->bus->read(&fore200e->cp_queues->cp_cmdq);
2289 fore200e->bus->write(FORE200E_DMA_INDEX(cmdq->status.dma_addr, enum status, i),
2296 fore200e->state = FORE200E_STATE_INIT_CMDQ;
2302 fore200e_param_bs_queue(struct fore200e* fore200e,
2306 struct bs_spec __iomem * bs_spec = &fore200e->cp_queues->init.bs_spec[ scheme ][ magn ];
2308 fore200e->bus->write(queue_length, &bs_spec->queue_length);
2309 fore200e->bus->write(fore200e_rx_buf_size[ scheme ][ magn ], &bs_spec->buffer_size);
2310 fore200e->bus->write(pool_size, &bs_spec->pool_size);
2311 fore200e->bus->write(supply_blksize, &bs_spec->supply_blksize);
2316 fore200e_initialize(struct fore200e* fore200e)
2321 DPRINTK(2, "device %s being initialized\n", fore200e->name);
2323 mutex_init(&fore200e->rate_mtx);
2324 spin_lock_init(&fore200e->q_lock);
2326 cpq = fore200e->cp_queues = fore200e->virt_base + FORE200E_CP_QUEUES_OFFSET;
2329 fore200e->bus->write(1, &cpq->imask);
2331 if (fore200e->bus->irq_enable)
2332 fore200e->bus->irq_enable(fore200e);
2334 fore200e->bus->write(NBR_CONNECT, &cpq->init.num_connect);
2336 fore200e->bus->write(QUEUE_SIZE_CMD, &cpq->init.cmd_queue_len);
2337 fore200e->bus->write(QUEUE_SIZE_RX, &cpq->init.rx_queue_len);
2338 fore200e->bus->write(QUEUE_SIZE_TX, &cpq->init.tx_queue_len);
2340 fore200e->bus->write(RSD_EXTENSION, &cpq->init.rsd_extension);
2341 fore200e->bus->write(TSD_EXTENSION, &cpq->init.tsd_extension);
2345 fore200e_param_bs_queue(fore200e, scheme, magn,
2351 fore200e->bus->write(STATUS_PENDING, &cpq->init.status);
2352 fore200e->bus->write(OPCODE_INITIALIZE, &cpq->init.opcode);
2354 ok = fore200e_io_poll(fore200e, &cpq->init.status, STATUS_COMPLETE, 3000);
2356 printk(FORE200E "device %s initialization failed\n", fore200e->name);
2360 printk(FORE200E "device %s initialized\n", fore200e->name);
2362 fore200e->state = FORE200E_STATE_INITIALIZE;
2368 fore200e_monitor_putc(struct fore200e* fore200e, char c)
2370 struct cp_monitor __iomem * monitor = fore200e->cp_monitor;
2372 fore200e->bus->write(((u32) c) | FORE200E_CP_MONITOR_UART_AVAIL, &monitor->soft_uart.send);
2377 fore200e_monitor_getc(struct fore200e* fore200e)
2379 struct cp_monitor __iomem * monitor = fore200e->cp_monitor;
2385 c = (int) fore200e->bus->read(&monitor->soft_uart.recv);
2389 fore200e->bus->write(FORE200E_CP_MONITOR_UART_FREE, &monitor->soft_uart.recv);
2399 fore200e_monitor_puts(struct fore200e* fore200e, char* str)
2404 while (fore200e_monitor_getc(fore200e) >= 0);
2406 fore200e_monitor_putc(fore200e, *str++);
2409 while (fore200e_monitor_getc(fore200e) >= 0);
2419 fore200e_load_and_start_fw(struct fore200e* fore200e)
2430 if (strcmp(fore200e->bus->model_name, "PCA-200E") == 0)
2431 device = &((struct pci_dev *) fore200e->bus_dev)->dev;
2433 else if (strcmp(fore200e->bus->model_name, "SBA-200E") == 0)
2434 device = &((struct platform_device *) fore200e->bus_dev)->dev;
2439 sprintf(buf, "%s%s", fore200e->bus->proc_name, FW_EXT);
2441 printk(FORE200E "problem loading firmware image %s\n", fore200e->bus->model_name);
2448 load_addr = fore200e->virt_base + le32_to_cpu(fw_header->load_offset);
2451 fore200e->name, load_addr, fw_size);
2454 printk(FORE200E "corrupted %s firmware image\n", fore200e->bus->model_name);
2459 fore200e->bus->write(le32_to_cpu(*fw_data), load_addr);
2461 DPRINTK(2, "device %s firmware being started\n", fore200e->name);
2469 fore200e_monitor_puts(fore200e, buf);
2471 if (fore200e_io_poll(fore200e, &fore200e->cp_monitor->bstat, BSTAT_CP_RUNNING, 1000) == 0) {
2472 printk(FORE200E "device %s firmware didn't start\n", fore200e->name);
2476 printk(FORE200E "device %s firmware started\n", fore200e->name);
2478 fore200e->state = FORE200E_STATE_START_FW;
2488 fore200e_register(struct fore200e* fore200e)
2492 DPRINTK(2, "device %s being registered\n", fore200e->name);
2494 atm_dev = atm_dev_register(fore200e->bus->proc_name, &fore200e_ops, -1,
2497 printk(FORE200E "unable to register device %s\n", fore200e->name);
2501 atm_dev->dev_data = fore200e;
2502 fore200e->atm_dev = atm_dev;
2507 fore200e->available_cell_rate = ATM_OC3_PCR;
2509 fore200e->state = FORE200E_STATE_REGISTER;
2515 fore200e_init(struct fore200e* fore200e)
2517 if (fore200e_register(fore200e) < 0)
2520 if (fore200e->bus->configure(fore200e) < 0)
2523 if (fore200e->bus->map(fore200e) < 0)
2526 if (fore200e_reset(fore200e, 1) < 0)
2529 if (fore200e_load_and_start_fw(fore200e) < 0)
2532 if (fore200e_initialize(fore200e) < 0)
2535 if (fore200e_init_cmd_queue(fore200e) < 0)
2538 if (fore200e_init_tx_queue(fore200e) < 0)
2541 if (fore200e_init_rx_queue(fore200e) < 0)
2544 if (fore200e_init_bs_queue(fore200e) < 0)
2547 if (fore200e_alloc_rx_buf(fore200e) < 0)
2550 if (fore200e_get_esi(fore200e) < 0)
2553 if (fore200e_irq_request(fore200e) < 0)
2556 fore200e_supply(fore200e);
2559 fore200e->state = FORE200E_STATE_COMPLETE;
2568 struct fore200e *fore200e;
2572 fore200e = kzalloc(sizeof(struct fore200e), GFP_KERNEL);
2573 if (!fore200e)
2576 fore200e->bus = bus;
2577 fore200e->bus_dev = op;
2578 fore200e->irq = op->archdata.irqs[0];
2579 fore200e->phys_base = op->resource[0].start;
2581 sprintf(fore200e->name, "%s-%d", bus->model_name, index);
2583 err = fore200e_init(fore200e);
2585 fore200e_shutdown(fore200e);
2586 kfree(fore200e);
2591 dev_set_drvdata(&op->dev, fore200e);
2598 struct fore200e *fore200e = dev_get_drvdata(&op->dev);
2600 fore200e_shutdown(fore200e);
2601 kfree(fore200e);
2631 struct fore200e* fore200e;
2640 fore200e = kzalloc(sizeof(struct fore200e), GFP_KERNEL);
2641 if (fore200e == NULL) {
2646 fore200e->bus = bus;
2647 fore200e->bus_dev = pci_dev;
2648 fore200e->irq = pci_dev->irq;
2649 fore200e->phys_base = pci_resource_start(pci_dev, 0);
2651 sprintf(fore200e->name, "%s-%d", bus->model_name, index - 1);
2656 fore200e->bus->model_name,
2657 fore200e->phys_base, fore200e_irq_itoa(fore200e->irq));
2659 sprintf(fore200e->name, "%s-%d", bus->model_name, index);
2661 err = fore200e_init(fore200e);
2663 fore200e_shutdown(fore200e);
2668 pci_set_drvdata(pci_dev, fore200e);
2674 kfree(fore200e);
2683 struct fore200e *fore200e;
2685 fore200e = pci_get_drvdata(pci_dev);
2687 fore200e_shutdown(fore200e);
2688 kfree(fore200e);
2746 struct fore200e* fore200e = FORE200E_DEV(dev);
2754 if (fore200e_getstats(fore200e) < 0)
2759 " internal name:\t\t%s\n", fore200e->name);
2762 if (fore200e->bus->proc_read)
2763 len += fore200e->bus->proc_read(fore200e, page + len);
2771 fore200e_irq_itoa(fore200e->irq),
2772 (void*)fore200e->phys_base,
2773 fore200e->virt_base,
2774 fore200e->esi,
2775 fore200e->esi[4] * 256 + fore200e->esi[5]);
2786 fore200e->host_bsq[ BUFFER_SCHEME_ONE ][ BUFFER_MAGN_SMALL ].freebuf_count,
2787 fore200e->host_bsq[ BUFFER_SCHEME_ONE ][ BUFFER_MAGN_LARGE ].freebuf_count,
2788 fore200e->host_bsq[ BUFFER_SCHEME_TWO ][ BUFFER_MAGN_SMALL ].freebuf_count,
2789 fore200e->host_bsq[ BUFFER_SCHEME_TWO ][ BUFFER_MAGN_LARGE ].freebuf_count);
2792 u32 hb = fore200e->bus->read(&fore200e->cp_queues->heartbeat);
2823 u32 fw_release = fore200e->bus->read(&fore200e->cp_queues->fw_release);
2824 u32 mon960_release = fore200e->bus->read(&fore200e->cp_queues->mon960_release);
2825 u32 oc3_revision = fore200e->bus->read(&fore200e->cp_queues->oc3_revision);
2826 u32 media_index = FORE200E_MEDIA_INDEX(fore200e->bus->read(&fore200e->cp_queues->media_type));
2832 switch (fore200e->loop_mode) {
2856 struct cp_monitor __iomem * cp_monitor = fore200e->cp_monitor;
2863 fore200e->bus->read(&cp_monitor->mon_version),
2864 fore200e->bus->read(&cp_monitor->bstat));
2874 be32_to_cpu(fore200e->stats->phy.crc_header_errors),
2875 be32_to_cpu(fore200e->stats->phy.framing_errors));
2887 be32_to_cpu(fore200e->stats->oc3.section_bip8_errors),
2888 be32_to_cpu(fore200e->stats->oc3.path_bip8_errors),
2889 be32_to_cpu(fore200e->stats->oc3.line_bip24_errors),
2890 be32_to_cpu(fore200e->stats->oc3.line_febe_errors),
2891 be32_to_cpu(fore200e->stats->oc3.path_febe_errors),
2892 be32_to_cpu(fore200e->stats->oc3.corr_hcs_errors),
2893 be32_to_cpu(fore200e->stats->oc3.ucorr_hcs_errors));
2904 be32_to_cpu(fore200e->stats->atm.cells_transmitted),
2905 be32_to_cpu(fore200e->stats->atm.cells_received),
2906 be32_to_cpu(fore200e->stats->atm.vpi_bad_range),
2907 be32_to_cpu(fore200e->stats->atm.vpi_no_conn),
2908 be32_to_cpu(fore200e->stats->atm.vci_bad_range),
2909 be32_to_cpu(fore200e->stats->atm.vci_no_conn));
2917 be32_to_cpu(fore200e->stats->aal0.cells_transmitted),
2918 be32_to_cpu(fore200e->stats->aal0.cells_received),
2919 be32_to_cpu(fore200e->stats->aal0.cells_dropped));
2935 be32_to_cpu(fore200e->stats->aal34.cells_transmitted),
2936 be32_to_cpu(fore200e->stats->aal34.cells_received),
2937 be32_to_cpu(fore200e->stats->aal34.cells_dropped),
2938 be32_to_cpu(fore200e->stats->aal34.cells_crc_errors),
2939 be32_to_cpu(fore200e->stats->aal34.cells_protocol_errors),
2940 be32_to_cpu(fore200e->stats->aal34.cspdus_transmitted),
2941 be32_to_cpu(fore200e->stats->aal34.cspdus_received),
2942 be32_to_cpu(fore200e->stats->aal34.cspdus_dropped),
2943 be32_to_cpu(fore200e->stats->aal34.cspdus_protocol_errors));
2959 be32_to_cpu(fore200e->stats->aal5.cells_transmitted),
2960 be32_to_cpu(fore200e->stats->aal5.cells_received),
2961 be32_to_cpu(fore200e->stats->aal5.cells_dropped),
2962 be32_to_cpu(fore200e->stats->aal5.congestion_experienced),
2963 be32_to_cpu(fore200e->stats->aal5.cspdus_transmitted),
2964 be32_to_cpu(fore200e->stats->aal5.cspdus_received),
2965 be32_to_cpu(fore200e->stats->aal5.cspdus_dropped),
2966 be32_to_cpu(fore200e->stats->aal5.cspdus_crc_errors),
2967 be32_to_cpu(fore200e->stats->aal5.cspdus_protocol_errors));
2978 be32_to_cpu(fore200e->stats->aux.small_b1_failed),
2979 be32_to_cpu(fore200e->stats->aux.large_b1_failed),
2980 be32_to_cpu(fore200e->stats->aux.small_b2_failed),
2981 be32_to_cpu(fore200e->stats->aux.large_b2_failed),
2982 be32_to_cpu(fore200e->stats->aux.rpd_alloc_failed),
2983 fore200e->tx_sat);
2988 fore200e->stats->aux.receive_carrier ? "ON" : "OFF!");
2998 vcc = fore200e->vc_map[i].vcc;
3003 spin_lock_irqsave(&fore200e->q_lock, flags);
3021 spin_unlock_irqrestore(&fore200e->q_lock, flags);
3025 spin_unlock_irqrestore(&fore200e->q_lock, flags);