Lines Matching refs:lanai
302 static void vci_bitfield_iterate(struct lanai_dev *lanai, in vci_bitfield_iterate() argument
309 func(lanai, vci); in vci_bitfield_iterate()
468 static inline bus_addr_t reg_addr(const struct lanai_dev *lanai, in reg_addr() argument
471 return lanai->base + reg; in reg_addr()
474 static inline u32 reg_read(const struct lanai_dev *lanai, in reg_read() argument
478 t = readl(reg_addr(lanai, reg)); in reg_read()
479 RWDEBUG("R [0x%08X] 0x%02X = 0x%08X\n", (unsigned int) lanai->base, in reg_read()
484 static inline void reg_write(const struct lanai_dev *lanai, u32 val, in reg_write() argument
487 RWDEBUG("W [0x%08X] 0x%02X < 0x%08X\n", (unsigned int) lanai->base, in reg_write()
489 writel(val, reg_addr(lanai, reg)); in reg_write()
492 static inline void conf1_write(const struct lanai_dev *lanai) in conf1_write() argument
494 reg_write(lanai, lanai->conf1, Config1_Reg); in conf1_write()
497 static inline void conf2_write(const struct lanai_dev *lanai) in conf2_write() argument
499 reg_write(lanai, lanai->conf2, Config2_Reg); in conf2_write()
503 static inline void conf2_write_if_powerup(const struct lanai_dev *lanai) in conf2_write_if_powerup() argument
506 if (unlikely((lanai->conf1 & CONFIG1_POWERDOWN) != 0)) in conf2_write_if_powerup()
509 conf2_write(lanai); in conf2_write_if_powerup()
512 static inline void reset_board(const struct lanai_dev *lanai) in reset_board() argument
515 reg_write(lanai, 0, Reset_Reg); in reset_board()
535 static inline bus_addr_t sram_addr(const struct lanai_dev *lanai, int offset) in sram_addr() argument
537 return lanai->base + SRAM_START + offset; in sram_addr()
540 static inline u32 sram_read(const struct lanai_dev *lanai, int offset) in sram_read() argument
542 return readl(sram_addr(lanai, offset)); in sram_read()
545 static inline void sram_write(const struct lanai_dev *lanai, in sram_write() argument
548 writel(val, sram_addr(lanai, offset)); in sram_write()
551 static int sram_test_word(const struct lanai_dev *lanai, int offset, in sram_test_word() argument
555 sram_write(lanai, pattern, offset); in sram_test_word()
556 readback = sram_read(lanai, offset); in sram_test_word()
561 lanai->number, offset, in sram_test_word()
566 static int sram_test_pass(const struct lanai_dev *lanai, u32 pattern) in sram_test_pass() argument
570 result = sram_test_word(lanai, offset, pattern); in sram_test_pass()
574 static int sram_test_and_clear(const struct lanai_dev *lanai) in sram_test_and_clear() argument
579 if ((result = sram_test_pass(lanai, 0x5555)) != 0) in sram_test_and_clear()
581 if ((result = sram_test_pass(lanai, 0xAAAA)) != 0) in sram_test_and_clear()
585 return sram_test_pass(lanai, 0x0000); in sram_test_and_clear()
640 static inline bus_addr_t cardvcc_addr(const struct lanai_dev *lanai, in cardvcc_addr() argument
643 return sram_addr(lanai, vci * CARDVCC_SIZE); in cardvcc_addr()
762 static void lanai_shutdown_tx_vci(struct lanai_dev *lanai, in lanai_shutdown_tx_vci() argument
775 __clear_bit(lvcc->vci, lanai->backlog_vccs); in lanai_shutdown_tx_vci()
817 static inline int aal0_buffer_allocate(struct lanai_dev *lanai) in aal0_buffer_allocate() argument
820 lanai_buf_allocate(&lanai->aal0buf, AAL0_RX_BUFFER_SIZE, 80, in aal0_buffer_allocate()
821 lanai->pci); in aal0_buffer_allocate()
822 return (lanai->aal0buf.start == NULL) ? -ENOMEM : 0; in aal0_buffer_allocate()
825 static inline void aal0_buffer_free(struct lanai_dev *lanai) in aal0_buffer_free() argument
828 lanai_buf_deallocate(&lanai->aal0buf, lanai->pci); in aal0_buffer_free()
850 static int eeprom_read(struct lanai_dev *lanai) in eeprom_read() argument
853 lanai->number); in eeprom_read()
854 memset(&lanai->eeprom[EEPROM_MAC], 0, 6); in eeprom_read()
858 static int eeprom_validate(struct lanai_dev *lanai) in eeprom_validate() argument
860 lanai->serialno = 0; in eeprom_validate()
861 lanai->magicno = EEPROM_MAGIC_VALUE; in eeprom_validate()
867 static int eeprom_read(struct lanai_dev *lanai) in eeprom_read() argument
872 #define set_config1(x) do { lanai->conf1 = x; conf1_write(lanai); \ in eeprom_read()
874 #define clock_h() set_config1(lanai->conf1 | CONFIG1_PROMCLK) in eeprom_read()
875 #define clock_l() set_config1(lanai->conf1 &~ CONFIG1_PROMCLK) in eeprom_read()
876 #define data_h() set_config1(lanai->conf1 | CONFIG1_PROMDATA) in eeprom_read()
877 #define data_l() set_config1(lanai->conf1 &~ CONFIG1_PROMDATA) in eeprom_read()
879 #define read_pin() (reg_read(lanai, Status_Reg) & STATUS_PROMDATA) in eeprom_read()
890 tmp = (lanai->conf1 & ~CONFIG1_PROMDATA) | in eeprom_read()
892 if (lanai->conf1 != tmp) { in eeprom_read()
915 lanai->eeprom[address] = data; in eeprom_read()
924 lanai->number, address); in eeprom_read()
937 static inline u32 eeprom_be4(const struct lanai_dev *lanai, int address) in eeprom_be4() argument
939 return be32_to_cpup((const u32 *) &lanai->eeprom[address]); in eeprom_be4()
943 static int eeprom_validate(struct lanai_dev *lanai) in eeprom_validate() argument
947 const u8 *e = lanai->eeprom; in eeprom_validate()
967 "(wanted 0x%02X, got 0x%02X)\n", lanai->number, in eeprom_validate()
974 "bad (wanted 0x%02X, got 0x%02X)\n", lanai->number, in eeprom_validate()
983 "(0x%02X, inverse 0x%02X)\n", lanai->number, in eeprom_validate()
990 lanai->serialno = eeprom_be4(lanai, EEPROM_SERIAL); in eeprom_validate()
991 v = eeprom_be4(lanai, EEPROM_SERIAL_REV); in eeprom_validate()
992 if ((lanai->serialno ^ v) != 0xFFFFFFFF) { in eeprom_validate()
994 "don't match (0x%08X, inverse 0x%08X)\n", lanai->number, in eeprom_validate()
995 (unsigned int) lanai->serialno, (unsigned int) v); in eeprom_validate()
998 DPRINTK("eeprom: Serial number = %d\n", (unsigned int) lanai->serialno); in eeprom_validate()
1000 lanai->magicno = eeprom_be4(lanai, EEPROM_MAGIC); in eeprom_validate()
1001 v = eeprom_be4(lanai, EEPROM_MAGIC_REV); in eeprom_validate()
1002 if ((lanai->magicno ^ v) != 0xFFFFFFFF) { in eeprom_validate()
1004 "don't match (0x%08X, inverse 0x%08X)\n", lanai->number, in eeprom_validate()
1005 lanai->magicno, v); in eeprom_validate()
1008 DPRINTK("eeprom: Magic number = 0x%08X\n", lanai->magicno); in eeprom_validate()
1009 if (lanai->magicno != EEPROM_MAGIC_VALUE) in eeprom_validate()
1012 lanai->number, (unsigned int) lanai->magicno, in eeprom_validate()
1019 static inline const u8 *eeprom_mac(const struct lanai_dev *lanai) in eeprom_mac() argument
1021 return &lanai->eeprom[EEPROM_MAC]; in eeprom_mac()
1051 static inline u32 intr_pending(const struct lanai_dev *lanai) in intr_pending() argument
1053 return reg_read(lanai, IntStatusMasked_Reg); in intr_pending()
1056 static inline void intr_enable(const struct lanai_dev *lanai, u32 i) in intr_enable() argument
1058 reg_write(lanai, i, IntControlEna_Reg); in intr_enable()
1061 static inline void intr_disable(const struct lanai_dev *lanai, u32 i) in intr_disable() argument
1063 reg_write(lanai, i, IntControlDis_Reg); in intr_disable()
1075 static void lanai_check_status(struct lanai_dev *lanai) in lanai_check_status() argument
1077 u32 new = reg_read(lanai, Status_Reg); in lanai_check_status()
1078 u32 changes = new ^ lanai->status; in lanai_check_status()
1079 lanai->status = new; in lanai_check_status()
1082 status_message(lanai->number, name, new & flag) in lanai_check_status()
1095 static void pcistatus_check(struct lanai_dev *lanai, int clearonly) in pcistatus_check() argument
1099 result = pci_read_config_word(lanai->pci, PCI_STATUS, &s); in pcistatus_check()
1102 "%d\n", lanai->number, result); in pcistatus_check()
1110 result = pci_write_config_word(lanai->pci, PCI_STATUS, s); in pcistatus_check()
1113 "%d\n", lanai->number, result); in pcistatus_check()
1118 pcistatus_got(lanai->number, name); \ in pcistatus_check()
1119 ++lanai->stats.pcierr_##stat; \ in pcistatus_check()
1232 static inline void lanai_endtx(struct lanai_dev *lanai, in lanai_endtx() argument
1248 spin_lock(&lanai->endtxlock); in lanai_endtx()
1255 for (i = 0; reg_read(lanai, Status_Reg) & STATUS_BUTTBUSY; i++) { in lanai_endtx()
1258 "always busy!\n", lanai->number); in lanai_endtx()
1269 reg_write(lanai, (ptr << 12) | lvcc->vci, Butt_Reg); in lanai_endtx()
1270 spin_unlock(&lanai->endtxlock); in lanai_endtx()
1277 static void lanai_send_one_aal5(struct lanai_dev *lanai, in lanai_send_one_aal5() argument
1291 lanai_endtx(lanai, lvcc); in lanai_send_one_aal5()
1297 static void vcc_tx_unqueue_aal5(struct lanai_dev *lanai, in vcc_tx_unqueue_aal5() argument
1316 lanai_send_one_aal5(lanai, lvcc, skb, n); in vcc_tx_unqueue_aal5()
1321 __clear_bit(lvcc->vci, lanai->backlog_vccs); in vcc_tx_unqueue_aal5()
1326 static void vcc_tx_aal5(struct lanai_dev *lanai, struct lanai_vcc *lvcc, in vcc_tx_aal5() argument
1337 __set_bit(lvcc->vci, lanai->backlog_vccs); in vcc_tx_aal5()
1342 lanai_send_one_aal5(lanai, lvcc, skb, n); in vcc_tx_aal5()
1345 static void vcc_tx_unqueue_aal0(struct lanai_dev *lanai, in vcc_tx_unqueue_aal0() argument
1352 static void vcc_tx_aal0(struct lanai_dev *lanai, struct lanai_vcc *lvcc, in vcc_tx_aal0() argument
1422 static void vcc_rx_aal0(struct lanai_dev *lanai) in vcc_rx_aal0() argument
1438 static int vcc_table_allocate(struct lanai_dev *lanai) in vcc_table_allocate() argument
1441 APRINTK((lanai->num_vci) * sizeof(struct lanai_vcc *) <= PAGE_SIZE, in vcc_table_allocate()
1443 lanai->vccs = (struct lanai_vcc **) get_zeroed_page(GFP_KERNEL); in vcc_table_allocate()
1444 return (lanai->vccs == NULL) ? -ENOMEM : 0; in vcc_table_allocate()
1446 int bytes = (lanai->num_vci) * sizeof(struct lanai_vcc *); in vcc_table_allocate()
1447 lanai->vccs = vzalloc(bytes); in vcc_table_allocate()
1448 if (unlikely(lanai->vccs == NULL)) in vcc_table_allocate()
1454 static inline void vcc_table_deallocate(const struct lanai_dev *lanai) in vcc_table_deallocate() argument
1457 free_page((unsigned long) lanai->vccs); in vcc_table_deallocate()
1459 vfree(lanai->vccs); in vcc_table_deallocate()
1477 static int lanai_get_sized_buffer(struct lanai_dev *lanai, in lanai_get_sized_buffer() argument
1486 lanai_buf_allocate(buf, size, max_sdu + 32, lanai->pci); in lanai_get_sized_buffer()
1491 "for %s buffer, got only %zu\n", lanai->number, size, in lanai_get_sized_buffer()
1498 static inline int lanai_setup_rx_vci_aal5(struct lanai_dev *lanai, in lanai_setup_rx_vci_aal5() argument
1501 return lanai_get_sized_buffer(lanai, &lvcc->rx.buf, in lanai_setup_rx_vci_aal5()
1506 static int lanai_setup_tx_vci(struct lanai_dev *lanai, struct lanai_vcc *lvcc, in lanai_setup_tx_vci() argument
1519 return lanai_get_sized_buffer(lanai, &lvcc->tx.buf, max_sdu, in lanai_setup_tx_vci()
1523 static inline void host_vcc_bind(struct lanai_dev *lanai, in host_vcc_bind() argument
1530 if (lanai->nbound++ == 0) { in host_vcc_bind()
1532 lanai->conf1 &= ~CONFIG1_POWERDOWN; in host_vcc_bind()
1533 conf1_write(lanai); in host_vcc_bind()
1534 conf2_write(lanai); in host_vcc_bind()
1537 lvcc->vbase = cardvcc_addr(lanai, vci); in host_vcc_bind()
1538 lanai->vccs[lvcc->vci = vci] = lvcc; in host_vcc_bind()
1541 static inline void host_vcc_unbind(struct lanai_dev *lanai, in host_vcc_unbind() argument
1548 lanai->vccs[lvcc->vci] = NULL; in host_vcc_unbind()
1550 if (--lanai->nbound == 0) { in host_vcc_unbind()
1552 lanai->conf1 |= CONFIG1_POWERDOWN; in host_vcc_unbind()
1553 conf1_write(lanai); in host_vcc_unbind()
1560 static void lanai_reset(struct lanai_dev *lanai) in lanai_reset() argument
1563 "implemented\n", lanai->number); in lanai_reset()
1569 reg_write(lanai, INT_ALL, IntAck_Reg); in lanai_reset()
1570 lanai->stats.card_reset++; in lanai_reset()
1578 static int service_buffer_allocate(struct lanai_dev *lanai) in service_buffer_allocate() argument
1580 lanai_buf_allocate(&lanai->service, SERVICE_ENTRIES * 4, 8, in service_buffer_allocate()
1581 lanai->pci); in service_buffer_allocate()
1582 if (unlikely(lanai->service.start == NULL)) in service_buffer_allocate()
1585 lanai->service.start, in service_buffer_allocate()
1586 lanai_buf_size(&lanai->service), in service_buffer_allocate()
1587 lanai_buf_size_cardorder(&lanai->service)); in service_buffer_allocate()
1589 reg_write(lanai, 0, ServWrite_Reg); in service_buffer_allocate()
1591 reg_write(lanai, in service_buffer_allocate()
1592 SSTUFF_SET_SIZE(lanai_buf_size_cardorder(&lanai->service)) | in service_buffer_allocate()
1593 SSTUFF_SET_ADDR(lanai->service.dmaaddr), in service_buffer_allocate()
1598 static inline void service_buffer_deallocate(struct lanai_dev *lanai) in service_buffer_deallocate() argument
1600 lanai_buf_deallocate(&lanai->service, lanai->pci); in service_buffer_deallocate()
1616 static int handle_service(struct lanai_dev *lanai, u32 s) in handle_service() argument
1621 lvcc = lanai->vccs[vci]; in handle_service()
1625 "vcc %d\n", lanai->number, (unsigned int) s, vci); in handle_service()
1627 lanai->stats.service_notx++; in handle_service()
1629 lanai->stats.service_norx++; in handle_service()
1636 "vcc %d\n", lanai->number, (unsigned int) s, vci); in handle_service()
1637 lanai->stats.service_notx++; in handle_service()
1640 __set_bit(vci, lanai->transmit_ready); in handle_service()
1648 "vcc %d\n", lanai->number, (unsigned int) s, vci); in handle_service()
1649 lanai->stats.service_norx++; in handle_service()
1655 "vcc %d\n", lanai->number, (unsigned int) s, vci); in handle_service()
1656 lanai->stats.service_rxnotaal5++; in handle_service()
1676 lanai->stats.ovfl_trash += (bytes / 48); in handle_service()
1684 "PDU on VCI %d!\n", lanai->number, vci); in handle_service()
1685 lanai_reset(lanai); in handle_service()
1698 static void iter_transmit(struct lanai_dev *lanai, vci_t vci) in iter_transmit() argument
1700 struct lanai_vcc *lvcc = lanai->vccs[vci]; in iter_transmit()
1702 lvcc->tx.unqueue(lanai, lvcc, lvcc->tx.endptr); in iter_transmit()
1709 static void run_service(struct lanai_dev *lanai) in run_service() argument
1712 u32 wreg = reg_read(lanai, ServWrite_Reg); in run_service()
1713 const u32 *end = lanai->service.start + wreg; in run_service()
1714 while (lanai->service.ptr != end) { in run_service()
1715 ntx += handle_service(lanai, in run_service()
1716 le32_to_cpup(lanai->service.ptr++)); in run_service()
1717 if (lanai->service.ptr >= lanai->service.end) in run_service()
1718 lanai->service.ptr = lanai->service.start; in run_service()
1720 reg_write(lanai, wreg, ServRead_Reg); in run_service()
1723 vci_bitfield_iterate(lanai, lanai->transmit_ready, in run_service()
1725 bitmap_zero(lanai->transmit_ready, NUM_VCI); in run_service()
1732 static void get_statistics(struct lanai_dev *lanai) in get_statistics() argument
1734 u32 statreg = reg_read(lanai, Statistics_Reg); in get_statistics()
1735 lanai->stats.atm_ovfl += STATS_GET_FIFO_OVFL(statreg); in get_statistics()
1736 lanai->stats.hec_err += STATS_GET_HEC_ERR(statreg); in get_statistics()
1737 lanai->stats.vci_trash += STATS_GET_BAD_VCI(statreg); in get_statistics()
1738 lanai->stats.ovfl_trash += STATS_GET_BUF_OVFL(statreg); in get_statistics()
1745 static void iter_dequeue(struct lanai_dev *lanai, vci_t vci) in iter_dequeue() argument
1747 struct lanai_vcc *lvcc = lanai->vccs[vci]; in iter_dequeue()
1751 __clear_bit(vci, lanai->backlog_vccs); in iter_dequeue()
1755 lvcc->tx.unqueue(lanai, lvcc, endptr); in iter_dequeue()
1761 struct lanai_dev *lanai = from_timer(lanai, t, timer); in lanai_timed_poll() local
1765 if (lanai->conf1 & CONFIG1_POWERDOWN) in lanai_timed_poll()
1770 if (spin_trylock(&lanai->servicelock)) { in lanai_timed_poll()
1771 run_service(lanai); in lanai_timed_poll()
1772 spin_unlock(&lanai->servicelock); in lanai_timed_poll()
1777 vci_bitfield_iterate(lanai, lanai->backlog_vccs, iter_dequeue); in lanai_timed_poll()
1781 get_statistics(lanai); in lanai_timed_poll()
1783 mod_timer(&lanai->timer, jiffies + LANAI_POLL_PERIOD); in lanai_timed_poll()
1786 static inline void lanai_timed_poll_start(struct lanai_dev *lanai) in lanai_timed_poll_start() argument
1788 timer_setup(&lanai->timer, lanai_timed_poll, 0); in lanai_timed_poll_start()
1789 lanai->timer.expires = jiffies + LANAI_POLL_PERIOD; in lanai_timed_poll_start()
1790 add_timer(&lanai->timer); in lanai_timed_poll_start()
1793 static inline void lanai_timed_poll_stop(struct lanai_dev *lanai) in lanai_timed_poll_stop() argument
1795 del_timer_sync(&lanai->timer); in lanai_timed_poll_stop()
1800 static inline void lanai_int_1(struct lanai_dev *lanai, u32 reason) in lanai_int_1() argument
1805 spin_lock(&lanai->servicelock); in lanai_int_1()
1806 run_service(lanai); in lanai_int_1()
1807 spin_unlock(&lanai->servicelock); in lanai_int_1()
1811 vcc_rx_aal0(lanai); in lanai_int_1()
1818 get_statistics(lanai); in lanai_int_1()
1822 lanai_check_status(lanai); in lanai_int_1()
1827 lanai->number, (unsigned int) (reason & INT_DMASHUT), in lanai_int_1()
1828 (unsigned int) reg_read(lanai, DMA_Addr_Reg)); in lanai_int_1()
1830 lanai_reset(lanai); in lanai_int_1()
1835 lanai->number); in lanai_int_1()
1836 conf1_write(lanai); in lanai_int_1()
1837 lanai->stats.dma_reenable++; in lanai_int_1()
1838 pcistatus_check(lanai, 0); in lanai_int_1()
1843 lanai->number); in lanai_int_1()
1844 pcistatus_check(lanai, 0); in lanai_int_1()
1848 "segmentation shutdown, reason=0x%08X\n", lanai->number, in lanai_int_1()
1850 lanai_reset(lanai); in lanai_int_1()
1856 lanai->number, in lanai_int_1()
1858 lanai_reset(lanai); in lanai_int_1()
1870 reg_write(lanai, ack, IntAck_Reg); in lanai_int_1()
1875 struct lanai_dev *lanai = devid; in lanai_int() local
1884 if (unlikely(lanai->conf1 & CONFIG1_POWERDOWN)) in lanai_int()
1888 reason = intr_pending(lanai); in lanai_int()
1895 lanai_int_1(lanai, reason); in lanai_int()
1896 reason = intr_pending(lanai); in lanai_int()
1930 static int lanai_pci_start(struct lanai_dev *lanai) in lanai_pci_start() argument
1932 struct pci_dev *pci = lanai->pci; in lanai_pci_start()
1937 "PCI device", lanai->number); in lanai_pci_start()
1943 "(itf %d): No suitable DMA available.\n", lanai->number); in lanai_pci_start()
1953 "PCI_LATENCY_TIMER: %d\n", lanai->number, result); in lanai_pci_start()
1956 pcistatus_check(lanai, 1); in lanai_pci_start()
1957 pcistatus_check(lanai, 0); in lanai_pci_start()
1969 static inline int vci0_is_ok(struct lanai_dev *lanai, in vci0_is_ok() argument
1975 if (lanai->naal0 != 0) in vci0_is_ok()
1977 lanai->conf2 |= CONFIG2_VCI0_NORMAL; in vci0_is_ok()
1978 conf2_write_if_powerup(lanai); in vci0_is_ok()
1986 static int vci_is_ok(struct lanai_dev *lanai, vci_t vci, in vci_is_ok() argument
1990 const struct lanai_vcc *lvcc = lanai->vccs[vci]; in vci_is_ok()
1991 if (vci == 0 && !vci0_is_ok(lanai, qos)) in vci_is_ok()
2001 lanai->cbrvcc != NULL && lanai->cbrvcc != atmvcc) in vci_is_ok()
2004 if (qos->aal == ATM_AAL0 && lanai->naal0 == 0 && in vci_is_ok()
2006 const struct lanai_vcc *vci0 = lanai->vccs[0]; in vci_is_ok()
2009 lanai->conf2 &= ~CONFIG2_VCI0_NORMAL; in vci_is_ok()
2010 conf2_write_if_powerup(lanai); in vci_is_ok()
2015 static int lanai_normalize_ci(struct lanai_dev *lanai, in lanai_normalize_ci() argument
2029 for (*vcip = ATM_NOT_RSV_VCI; *vcip < lanai->num_vci; in lanai_normalize_ci()
2031 if (vci_is_ok(lanai, *vcip, atmvcc)) in lanai_normalize_ci()
2035 if (*vcip >= lanai->num_vci || *vcip < 0 || in lanai_normalize_ci()
2036 !vci_is_ok(lanai, *vcip, atmvcc)) in lanai_normalize_ci()
2089 static inline void lanai_cbr_setup(struct lanai_dev *lanai) in lanai_cbr_setup() argument
2091 reg_write(lanai, pcr_to_cbricg(&lanai->cbrvcc->qos), CBR_ICG_Reg); in lanai_cbr_setup()
2092 reg_write(lanai, lanai->cbrvcc->vci, CBR_PTR_Reg); in lanai_cbr_setup()
2093 lanai->conf2 |= CONFIG2_CBR_ENABLE; in lanai_cbr_setup()
2094 conf2_write(lanai); in lanai_cbr_setup()
2097 static inline void lanai_cbr_shutdown(struct lanai_dev *lanai) in lanai_cbr_shutdown() argument
2099 lanai->conf2 &= ~CONFIG2_CBR_ENABLE; in lanai_cbr_shutdown()
2100 conf2_write(lanai); in lanai_cbr_shutdown()
2108 struct lanai_dev *lanai = (struct lanai_dev *) atmdev->dev_data; in lanai_dev_open() local
2114 lanai->number = atmdev->number; in lanai_dev_open()
2115 lanai->num_vci = NUM_VCI; in lanai_dev_open()
2116 bitmap_zero(lanai->backlog_vccs, NUM_VCI); in lanai_dev_open()
2117 bitmap_zero(lanai->transmit_ready, NUM_VCI); in lanai_dev_open()
2118 lanai->naal0 = 0; in lanai_dev_open()
2120 lanai->nbound = 0; in lanai_dev_open()
2122 lanai->cbrvcc = NULL; in lanai_dev_open()
2123 memset(&lanai->stats, 0, sizeof lanai->stats); in lanai_dev_open()
2124 spin_lock_init(&lanai->endtxlock); in lanai_dev_open()
2125 spin_lock_init(&lanai->servicelock); in lanai_dev_open()
2128 while (1 << atmdev->ci_range.vci_bits < lanai->num_vci) in lanai_dev_open()
2133 if ((result = lanai_pci_start(lanai)) != 0) in lanai_dev_open()
2135 raw_base = lanai->pci->resource[0].start; in lanai_dev_open()
2136 lanai->base = (bus_addr_t) ioremap(raw_base, LANAI_MAPPING_SIZE); in lanai_dev_open()
2137 if (lanai->base == NULL) { in lanai_dev_open()
2143 reset_board(lanai); in lanai_dev_open()
2144 lanai->conf1 = reg_read(lanai, Config1_Reg); in lanai_dev_open()
2145 lanai->conf1 &= ~(CONFIG1_GPOUT1 | CONFIG1_POWERDOWN | in lanai_dev_open()
2147 lanai->conf1 |= CONFIG1_SET_LEDMODE(LEDMODE_NOT_SOOL); in lanai_dev_open()
2148 reg_write(lanai, lanai->conf1 | CONFIG1_GPOUT1, Config1_Reg); in lanai_dev_open()
2150 conf1_write(lanai); in lanai_dev_open()
2162 reg_read(lanai, Reset_Reg), &lanai->board_rev); in lanai_dev_open()
2167 if ((result = eeprom_read(lanai)) != 0) in lanai_dev_open()
2169 if ((result = eeprom_validate(lanai)) != 0) in lanai_dev_open()
2173 reg_write(lanai, lanai->conf1 | CONFIG1_GPOUT1, Config1_Reg); in lanai_dev_open()
2175 conf1_write(lanai); in lanai_dev_open()
2177 lanai->conf1 |= (CONFIG1_GPOUT2 | CONFIG1_GPOUT3 | CONFIG1_DMA_ENABLE); in lanai_dev_open()
2178 conf1_write(lanai); in lanai_dev_open()
2181 if ((result = sram_test_and_clear(lanai)) != 0) in lanai_dev_open()
2185 lanai->conf1 |= CONFIG1_DMA_ENABLE; in lanai_dev_open()
2186 conf1_write(lanai); in lanai_dev_open()
2187 if ((result = service_buffer_allocate(lanai)) != 0) in lanai_dev_open()
2189 if ((result = vcc_table_allocate(lanai)) != 0) in lanai_dev_open()
2191 lanai->conf2 = (lanai->num_vci >= 512 ? CONFIG2_HOWMANY : 0) | in lanai_dev_open()
2193 conf2_write(lanai); in lanai_dev_open()
2194 reg_write(lanai, TX_FIFO_DEPTH, TxDepth_Reg); in lanai_dev_open()
2195 reg_write(lanai, 0, CBR_ICG_Reg); /* CBR defaults to no limit */ in lanai_dev_open()
2196 if ((result = request_irq(lanai->pci->irq, lanai_int, IRQF_SHARED, in lanai_dev_open()
2197 DEV_LABEL, lanai)) != 0) { in lanai_dev_open()
2202 intr_enable(lanai, INT_ALL & ~(INT_PING | INT_WAKE)); in lanai_dev_open()
2204 lanai->conf1 = (lanai->conf1 & ~CONFIG1_MASK_LOOPMODE) | in lanai_dev_open()
2207 conf1_write(lanai); in lanai_dev_open()
2208 lanai->status = reg_read(lanai, Status_Reg); in lanai_dev_open()
2211 lanai->conf1 |= CONFIG1_POWERDOWN; in lanai_dev_open()
2212 conf1_write(lanai); in lanai_dev_open()
2214 memcpy(atmdev->esi, eeprom_mac(lanai), ESI_LEN); in lanai_dev_open()
2215 lanai_timed_poll_start(lanai); in lanai_dev_open()
2217 "(%pMF)\n", lanai->number, (int) lanai->pci->revision, in lanai_dev_open()
2218 lanai->base, lanai->pci->irq, atmdev->esi); in lanai_dev_open()
2220 "board_rev=%d\n", lanai->number, in lanai_dev_open()
2221 lanai->type==lanai2 ? "2" : "HB", (unsigned int) lanai->serialno, in lanai_dev_open()
2222 (unsigned int) lanai->serialno, lanai->board_rev); in lanai_dev_open()
2226 vcc_table_deallocate(lanai); in lanai_dev_open()
2228 service_buffer_deallocate(lanai); in lanai_dev_open()
2230 reset_board(lanai); in lanai_dev_open()
2232 lanai->conf1 = reg_read(lanai, Config1_Reg) | CONFIG1_POWERDOWN; in lanai_dev_open()
2233 conf1_write(lanai); in lanai_dev_open()
2235 iounmap(lanai->base); in lanai_dev_open()
2236 lanai->base = NULL; in lanai_dev_open()
2238 pci_disable_device(lanai->pci); in lanai_dev_open()
2248 struct lanai_dev *lanai = (struct lanai_dev *) atmdev->dev_data; in lanai_dev_close() local
2249 if (lanai->base==NULL) in lanai_dev_close()
2252 lanai->number); in lanai_dev_close()
2253 lanai_timed_poll_stop(lanai); in lanai_dev_close()
2255 lanai->conf1 = reg_read(lanai, Config1_Reg) & ~CONFIG1_POWERDOWN; in lanai_dev_close()
2256 conf1_write(lanai); in lanai_dev_close()
2258 intr_disable(lanai, INT_ALL); in lanai_dev_close()
2259 free_irq(lanai->pci->irq, lanai); in lanai_dev_close()
2260 reset_board(lanai); in lanai_dev_close()
2262 lanai->conf1 |= CONFIG1_POWERDOWN; in lanai_dev_close()
2263 conf1_write(lanai); in lanai_dev_close()
2265 pci_disable_device(lanai->pci); in lanai_dev_close()
2266 vcc_table_deallocate(lanai); in lanai_dev_close()
2267 service_buffer_deallocate(lanai); in lanai_dev_close()
2268 iounmap(lanai->base); in lanai_dev_close()
2269 kfree(lanai); in lanai_dev_close()
2276 struct lanai_dev *lanai = (struct lanai_dev *) atmvcc->dev->dev_data; in lanai_close() local
2284 if (--lanai->naal0 <= 0) in lanai_close()
2285 aal0_buffer_free(lanai); in lanai_close()
2287 lanai_buf_deallocate(&lvcc->rx.buf, lanai->pci); in lanai_close()
2291 if (atmvcc == lanai->cbrvcc) { in lanai_close()
2293 lanai_cbr_shutdown(lanai); in lanai_close()
2294 lanai->cbrvcc = NULL; in lanai_close()
2296 lanai_shutdown_tx_vci(lanai, lvcc); in lanai_close()
2297 lanai_buf_deallocate(&lvcc->tx.buf, lanai->pci); in lanai_close()
2301 host_vcc_unbind(lanai, lvcc); in lanai_close()
2311 struct lanai_dev *lanai; in lanai_open() local
2320 lanai = (struct lanai_dev *) atmvcc->dev->dev_data; in lanai_open()
2321 result = lanai_normalize_ci(lanai, atmvcc, &vpi, &vci); in lanai_open()
2327 DPRINTK(DEV_LABEL "(itf %d): open %d.%d\n", lanai->number, in lanai_open()
2329 lvcc = lanai->vccs[vci]; in lanai_open()
2341 if (lanai->naal0 == 0) in lanai_open()
2342 result = aal0_buffer_allocate(lanai); in lanai_open()
2345 lanai, lvcc, &atmvcc->qos); in lanai_open()
2355 lanai->naal0++; in lanai_open()
2360 result = lanai_setup_tx_vci(lanai, lvcc, &atmvcc->qos); in lanai_open()
2365 APRINTK(lanai->cbrvcc == NULL, in lanai_open()
2367 lanai->cbrvcc = atmvcc; in lanai_open()
2370 host_vcc_bind(lanai, lvcc, vci); in lanai_open()
2380 if (lanai->cbrvcc == atmvcc) in lanai_open()
2381 lanai_cbr_setup(lanai); in lanai_open()
2394 struct lanai_dev *lanai = (struct lanai_dev *) atmvcc->dev->dev_data; in lanai_send() local
2404 if (unlikely(lanai == NULL)) { in lanai_send()
2413 vcc_tx_aal5(lanai, lvcc, skb); in lanai_send()
2422 vcc_tx_aal0(lanai, lvcc, skb); in lanai_send()
2444 struct lanai_dev *lanai = (struct lanai_dev *) atmdev->dev_data; in lanai_proc_read() local
2450 atmdev->number, lanai->type==lanai2 ? "2" : "HB", in lanai_proc_read()
2451 (unsigned int) lanai->serialno, in lanai_proc_read()
2452 (unsigned int) lanai->magicno, lanai->num_vci); in lanai_proc_read()
2455 lanai->board_rev, (int) lanai->pci->revision); in lanai_proc_read()
2458 &lanai->eeprom[EEPROM_MAC]); in lanai_proc_read()
2461 "GPIN=%d\n", (lanai->status & STATUS_SOOL) ? 1 : 0, in lanai_proc_read()
2462 (lanai->status & STATUS_LOCD) ? 1 : 0, in lanai_proc_read()
2463 (lanai->status & STATUS_LED) ? 1 : 0, in lanai_proc_read()
2464 (lanai->status & STATUS_GPIN) ? 1 : 0); in lanai_proc_read()
2467 "aal0_rx=%zu\n", lanai_buf_size(&lanai->service), in lanai_proc_read()
2468 lanai->naal0 ? lanai_buf_size(&lanai->aal0buf) : 0); in lanai_proc_read()
2470 get_statistics(lanai); in lanai_proc_read()
2473 lanai->stats.ovfl_trash, lanai->stats.vci_trash, in lanai_proc_read()
2474 lanai->stats.hec_err, lanai->stats.atm_ovfl); in lanai_proc_read()
2479 lanai->stats.pcierr_parity_detect, in lanai_proc_read()
2480 lanai->stats.pcierr_serr_set, in lanai_proc_read()
2481 lanai->stats.pcierr_m_target_abort); in lanai_proc_read()
2484 "master_parity=%u\n", lanai->stats.pcierr_s_target_abort, in lanai_proc_read()
2485 lanai->stats.pcierr_master_parity); in lanai_proc_read()
2488 "no_rx=%u, bad_rx_aal=%u\n", lanai->stats.service_norx, in lanai_proc_read()
2489 lanai->stats.service_notx, in lanai_proc_read()
2490 lanai->stats.service_rxnotaal5); in lanai_proc_read()
2493 lanai->stats.dma_reenable, lanai->stats.card_reset); in lanai_proc_read()
2501 if ((lvcc = lanai->vccs[left]) != NULL) in lanai_proc_read()
2526 lvcc->tx.atmvcc == lanai->cbrvcc ? 'C' : 'U', in lanai_proc_read()
2554 struct lanai_dev *lanai; in lanai_init_one() local
2558 lanai = kzalloc(sizeof(*lanai), GFP_KERNEL); in lanai_init_one()
2559 if (lanai == NULL) { in lanai_init_one()
2569 kfree(lanai); in lanai_init_one()
2573 atmdev->dev_data = lanai; in lanai_init_one()
2574 lanai->pci = pci; in lanai_init_one()
2575 lanai->type = (enum lanai_type) ident->device; in lanai_init_one()
2581 kfree(lanai); in lanai_init_one()