Lines Matching +full:rx +full:- +full:equalizer

1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * Actually sync driver for X.21, V.35 and V.24 on FarSync T-series cards
6 * Copyright (C) 2001-2004 FarSite Communications Ltd.
35 MODULE_DESCRIPTION("FarSync T-Series WAN driver. FarSite Communications Ltd.");
71 #define ARPHRD_MYTYPE ARPHRD_HDLC /* Cisco-HDLC (keepalives etc) */
94 * file. Unfortunately various name clashes and the non-portability of the
163 #define cnv_bcnt(len) (-(len))
169 #define RX_ERR 0x40 /* Rx: error (OR of next 4 bits) */
170 #define RX_FRAM 0x20 /* Rx: framing error */
171 #define RX_OFLO 0x10 /* Rx: overflow error */
172 #define RX_CRC 0x08 /* Rx: CRC error */
173 #define RX_HBUF 0x04 /* Rx: buffer error */
174 #define RX_STP 0x02 /* Rx: start of packet */
175 #define RX_ENP 0x01 /* Rx: end of packet */
234 u8 equalizer; member
346 u16 cardMode; /* Bit-mask to enable features:
382 /* Note that we will be using DMA Channel 0 for copying rx data
425 struct net_device *dev; /* Device struct - must be first */
431 int rxpos; /* Next Rx buffer to use */
479 #define dev_to_port(D) (dev_to_hdlc(D)->priv)
480 #define port_to_dev(P) ((P)->dev)
490 #define WIN_OFFSET(X) ((long)&(((struct fst_shared *)SMC_BASE)->X))
492 #define FST_RDB(C, E) (readb((C)->mem + WIN_OFFSET(E)))
493 #define FST_RDW(C, E) (readw((C)->mem + WIN_OFFSET(E)))
494 #define FST_RDL(C, E) (readl((C)->mem + WIN_OFFSET(E)))
496 #define FST_WRB(C, E, B) (writeb((B), (C)->mem + WIN_OFFSET(E)))
497 #define FST_WRW(C, E, W) (writew((W), (C)->mem + WIN_OFFSET(E)))
498 #define FST_WRL(C, E, L) (writel((L), (C)->mem + WIN_OFFSET(E)))
507 * is set in the debug mask. Note: this uses a non-ANSI extension in GCC to
644 "Calling rx & tx bh for card %d\n", i); in fst_process_int_work_q()
659 * AMD Am186CH processor means that we now have to do it by asserting and de-
669 if (card->family == FST_FAMILY_TXU) { in fst_cpureset()
671 (card->device, PCI_INTERRUPT_LINE, &interrupt_line_register)) { in fst_cpureset()
678 outw(0x440f, card->pci_conf + CNTRL_9054 + 2); in fst_cpureset()
679 outw(0x040f, card->pci_conf + CNTRL_9054 + 2); in fst_cpureset()
683 outw(0x240f, card->pci_conf + CNTRL_9054 + 2); in fst_cpureset()
687 outw(0x040f, card->pci_conf + CNTRL_9054 + 2); in fst_cpureset()
690 (card->device, PCI_INTERRUPT_LINE, interrupt_line_register)) { in fst_cpureset()
696 regval = inl(card->pci_conf + CNTRL_9052); in fst_cpureset()
698 outl(regval | 0x40000000, card->pci_conf + CNTRL_9052); in fst_cpureset()
699 outl(regval & ~0x40000000, card->pci_conf + CNTRL_9052); in fst_cpureset()
708 if (card->family == FST_FAMILY_TXU) { in fst_cpurelease()
711 (void)readb(card->mem); in fst_cpurelease()
716 outw(0x040e, card->pci_conf + CNTRL_9054 + 2); in fst_cpurelease()
717 outw(0x040f, card->pci_conf + CNTRL_9054 + 2); in fst_cpurelease()
719 (void)readb(card->ctlmem); in fst_cpurelease()
728 if (card->family == FST_FAMILY_TXU) { in fst_clear_intr()
729 (void)readb(card->ctlmem); in fst_clear_intr()
733 outw(0x0543, card->pci_conf + INTCSR_9052); in fst_clear_intr()
742 if (card->family == FST_FAMILY_TXU) in fst_enable_intr()
743 outl(0x0f0c0900, card->pci_conf + INTCSR_9054); in fst_enable_intr()
745 outw(0x0543, card->pci_conf + INTCSR_9052); in fst_enable_intr()
753 if (card->family == FST_FAMILY_TXU) in fst_disable_intr()
754 outl(0x00000000, card->pci_conf + INTCSR_9054); in fst_disable_intr()
756 outw(0x0000, card->pci_conf + INTCSR_9052); in fst_disable_intr()
786 if (card->family == FST_FAMILY_TXU) { in fst_init_dma()
787 pci_set_master(card->device); in fst_init_dma()
788 outl(0x00020441, card->pci_conf + DMAMODE0); in fst_init_dma()
789 outl(0x00020441, card->pci_conf + DMAMODE1); in fst_init_dma()
790 outl(0x0, card->pci_conf + DMATHR); in fst_init_dma()
805 FST_WRB(card, txDescrRing[port->index][txpos].bits, in fst_tx_dma_complete()
807 dev->stats.tx_packets++; in fst_tx_dma_complete()
808 dev->stats.tx_bytes += len; in fst_tx_dma_complete()
816 skb->dev = dev; in farsync_type_trans()
818 skb->pkt_type = PACKET_HOST; in farsync_type_trans()
822 /* Rx dma complete interrupt
833 pi = port->index; in fst_rx_dma_complete()
834 skb_put_data(skb, card->rx_dma_handle_host, len); in fst_rx_dma_complete()
840 dev->stats.rx_packets++; in fst_rx_dma_complete()
841 dev->stats.rx_bytes += len; in fst_rx_dma_complete()
845 if (port->mode == FST_RAW) in fst_rx_dma_complete()
846 skb->protocol = farsync_type_trans(skb, dev); in fst_rx_dma_complete()
848 skb->protocol = hdlc_type_trans(skb, dev); in fst_rx_dma_complete()
850 fst_process_rx_status(rx_status, port_to_dev(port)->name); in fst_rx_dma_complete()
852 dev->stats.rx_dropped++; in fst_rx_dma_complete()
864 if (card->dmarx_in_progress) in fst_rx_dma()
867 outl(dma, card->pci_conf + DMAPADR0); /* Copy to here */ in fst_rx_dma()
868 outl(mem, card->pci_conf + DMALADR0); /* from here */ in fst_rx_dma()
869 outl(len, card->pci_conf + DMASIZ0); /* for this length */ in fst_rx_dma()
870 outl(0x00000000c, card->pci_conf + DMADPR0); /* In this direction */ in fst_rx_dma()
874 card->dmarx_in_progress = 1; in fst_rx_dma()
875 outb(0x03, card->pci_conf + DMACSR0); /* Start the transfer */ in fst_rx_dma()
887 if (card->dmatx_in_progress) in fst_tx_dma()
890 outl(dma, card->pci_conf + DMAPADR1); /* Copy from here */ in fst_tx_dma()
891 outl(mem, card->pci_conf + DMALADR1); /* to here */ in fst_tx_dma()
892 outl(len, card->pci_conf + DMASIZ1); /* for this length */ in fst_tx_dma()
893 outl(0x000000004, card->pci_conf + DMADPR1); /* In this direction */ in fst_tx_dma()
897 card->dmatx_in_progress = 1; in fst_tx_dma()
898 outb(0x03, card->pci_conf + DMACSR1); /* Start the transfer */ in fst_tx_dma()
913 card = port->card; in fst_issue_cmd()
914 spin_lock_irqsave(&card->card_lock, flags); in fst_issue_cmd()
915 mbval = FST_RDW(card, portMailbox[port->index][0]); in fst_issue_cmd()
920 spin_unlock_irqrestore(&card->card_lock, flags); in fst_issue_cmd()
922 spin_lock_irqsave(&card->card_lock, flags); in fst_issue_cmd()
929 mbval = FST_RDW(card, portMailbox[port->index][0]); in fst_issue_cmd()
937 FST_WRW(card, portMailbox[port->index][0], cmd); in fst_issue_cmd()
940 port->txpos = 0; in fst_issue_cmd()
941 port->txipos = 0; in fst_issue_cmd()
942 port->start = 0; in fst_issue_cmd()
945 spin_unlock_irqrestore(&card->card_lock, flags); in fst_issue_cmd()
953 outputs |= FST_RDL(port->card, v24OpSts[port->index]); in fst_op_raise()
954 FST_WRL(port->card, v24OpSts[port->index], outputs); in fst_op_raise()
956 if (port->run) in fst_op_raise()
963 outputs = ~outputs & FST_RDL(port->card, v24OpSts[port->index]); in fst_op_lower()
964 FST_WRL(port->card, v24OpSts[port->index], outputs); in fst_op_lower()
966 if (port->run) in fst_op_lower()
970 /* Setup port Rx buffers
981 pi = port->index; in fst_rx_config()
982 card = port->card; in fst_rx_config()
983 spin_lock_irqsave(&card->card_lock, flags); in fst_rx_config()
993 port->rxpos = 0; in fst_rx_config()
994 spin_unlock_irqrestore(&card->card_lock, flags); in fst_rx_config()
1008 pi = port->index; in fst_tx_config()
1009 card = port->card; in fst_tx_config()
1010 spin_lock_irqsave(&card->card_lock, flags); in fst_tx_config()
1019 port->txpos = 0; in fst_tx_config()
1020 port->txipos = 0; in fst_tx_config()
1021 port->start = 0; in fst_tx_config()
1022 spin_unlock_irqrestore(&card->card_lock, flags); in fst_tx_config()
1057 dbg(DBG_INTR, "De-assert LOS Alarm\n"); in fst_intr_te1_alarm()
1061 dbg(DBG_INTR, "De-assert RRA Alarm\n"); in fst_intr_te1_alarm()
1066 dbg(DBG_INTR, "De-assert AIS Alarm\n"); in fst_intr_te1_alarm()
1076 signals = FST_RDL(card, v24DebouncedSts[port->index]); in fst_intr_ctlchg()
1078 if (signals & ((port->hwif == X21 || port->hwif == X21D) in fst_intr_ctlchg()
1092 /* Log Rx Errors
1102 dev->stats.rx_errors++; in fst_log_rx_error()
1104 dev->stats.rx_fifo_errors++; in fst_log_rx_error()
1105 dbg(DBG_ASS, "Rx fifo error on card %d port %d buffer %d\n", in fst_log_rx_error()
1106 card->card_no, port->index, rxp); in fst_log_rx_error()
1109 dev->stats.rx_crc_errors++; in fst_log_rx_error()
1110 dbg(DBG_ASS, "Rx crc error on card %d port %d\n", in fst_log_rx_error()
1111 card->card_no, port->index); in fst_log_rx_error()
1114 dev->stats.rx_frame_errors++; in fst_log_rx_error()
1115 dbg(DBG_ASS, "Rx frame error on card %d port %d\n", in fst_log_rx_error()
1116 card->card_no, port->index); in fst_log_rx_error()
1119 dev->stats.rx_length_errors++; in fst_log_rx_error()
1120 dbg(DBG_ASS, "Rx length error (%d) on card %d port %d\n", in fst_log_rx_error()
1121 len, card->card_no, port->index); in fst_log_rx_error()
1125 /* Rx Error Recovery
1134 pi = port->index; in fst_recover_rx_error()
1158 port->rxpos = rxp; in fst_recover_rx_error()
1161 /* Rx complete interrupt
1175 pi = port->index; in fst_intr_rx()
1176 rxp = port->rxpos; in fst_intr_rx()
1183 if (card->dmarx_in_progress) in fst_intr_rx()
1189 len -= 2; in fst_intr_rx()
1195 card->card_no, port->index); in fst_intr_rx()
1200 port->rxpos = rxp; in fst_intr_rx()
1209 if (dmabits != (RX_STP | RX_ENP) || len > LEN_RX_BUFFER - 2) { in fst_intr_rx()
1220 dev->stats.rx_dropped++; in fst_intr_rx()
1226 port->rxpos = rxp; in fst_intr_rx()
1235 if (len < FST_MIN_DMA_LEN || card->family == FST_FAMILY_TXP) { in fst_intr_rx()
1237 card->mem + BUF_OFFSET(rxBuffer[pi][rxp][0]), in fst_intr_rx()
1244 dev->stats.rx_packets++; in fst_intr_rx()
1245 dev->stats.rx_bytes += len; in fst_intr_rx()
1249 if (port->mode == FST_RAW) in fst_intr_rx()
1250 skb->protocol = farsync_type_trans(skb, dev); in fst_intr_rx()
1252 skb->protocol = hdlc_type_trans(skb, dev); in fst_intr_rx()
1254 fst_process_rx_status(rx_status, port_to_dev(port)->name); in fst_intr_rx()
1256 dev->stats.rx_dropped++; in fst_intr_rx()
1258 card->dma_skb_rx = skb; in fst_intr_rx()
1259 card->dma_port_rx = port; in fst_intr_rx()
1260 card->dma_len_rx = len; in fst_intr_rx()
1261 card->dma_rxpos = rxp; in fst_intr_rx()
1262 fst_rx_dma(card, card->rx_dma_handle_card, in fst_intr_rx()
1265 if (rxp != port->rxpos) { in fst_intr_rx()
1267 dbg(DBG_ASS, "rxp = %d rxpos = %d\n", rxp, port->rxpos); in fst_intr_rx()
1270 port->rxpos = rxp; in fst_intr_rx()
1292 for (pi = 0, port = card->ports; pi < card->nports; pi++, port++) { in do_bottom_half_tx()
1293 if (!port->run) in do_bottom_half_tx()
1297 while (!(FST_RDB(card, txDescrRing[pi][port->txpos].bits) & in do_bottom_half_tx()
1299 !(card->dmatx_in_progress)) { in do_bottom_half_tx()
1300 /* There doesn't seem to be a txdone event per-se in do_bottom_half_tx()
1304 spin_lock_irqsave(&card->card_lock, flags); in do_bottom_half_tx()
1305 txq_length = port->txqe - port->txqs; in do_bottom_half_tx()
1312 spin_unlock_irqrestore(&card->card_lock, flags); in do_bottom_half_tx()
1316 spin_lock_irqsave(&card->card_lock, flags); in do_bottom_half_tx()
1317 skb = port->txq[port->txqs]; in do_bottom_half_tx()
1318 port->txqs++; in do_bottom_half_tx()
1319 if (port->txqs == FST_TXQ_DEPTH) in do_bottom_half_tx()
1320 port->txqs = 0; in do_bottom_half_tx()
1322 spin_unlock_irqrestore(&card->card_lock, flags); in do_bottom_half_tx()
1326 FST_WRW(card, txDescrRing[pi][port->txpos].bcnt, in do_bottom_half_tx()
1327 cnv_bcnt(skb->len)); in do_bottom_half_tx()
1328 if (skb->len < FST_MIN_DMA_LEN || in do_bottom_half_tx()
1329 card->family == FST_FAMILY_TXP) { in do_bottom_half_tx()
1331 memcpy_toio(card->mem + in do_bottom_half_tx()
1333 [port-> in do_bottom_half_tx()
1335 skb->data, skb->len); in do_bottom_half_tx()
1337 txDescrRing[pi][port->txpos]. in do_bottom_half_tx()
1340 dev->stats.tx_packets++; in do_bottom_half_tx()
1341 dev->stats.tx_bytes += skb->len; in do_bottom_half_tx()
1345 memcpy(card->tx_dma_handle_host, in do_bottom_half_tx()
1346 skb->data, skb->len); in do_bottom_half_tx()
1347 card->dma_port_tx = port; in do_bottom_half_tx()
1348 card->dma_len_tx = skb->len; in do_bottom_half_tx()
1349 card->dma_txpos = port->txpos; in do_bottom_half_tx()
1351 card->tx_dma_handle_card, in do_bottom_half_tx()
1353 [port->txpos][0]), in do_bottom_half_tx()
1354 skb->len); in do_bottom_half_tx()
1356 if (++port->txpos >= NUM_TX_BUFFER) in do_bottom_half_tx()
1357 port->txpos = 0; in do_bottom_half_tx()
1360 if (port->start) { in do_bottom_half_tx()
1364 port->start = 0; in do_bottom_half_tx()
1384 /* Check for rx completions on all ports on this card */ in do_bottom_half_rx()
1386 for (pi = 0, port = card->ports; pi < card->nports; pi++, port++) { in do_bottom_half_rx()
1387 if (!port->run) in do_bottom_half_rx()
1390 while (!(FST_RDB(card, rxDescrRing[pi][port->rxpos].bits) in do_bottom_half_rx()
1391 & DMA_OWN) && !(card->dmarx_in_progress)) { in do_bottom_half_rx()
1396 fst_q_work_item(&fst_work_intq, card->card_no); in do_bottom_half_rx()
1425 dbg(DBG_INTR, "intr: %d %p\n", card->irq, card); in fst_intr()
1426 if (card->state != FST_RUNNING) { in fst_intr()
1428 card->card_no, card->state); in fst_intr()
1430 /* It is possible to really be running, i.e. we have re-loaded in fst_intr()
1449 if (card->family == FST_FAMILY_TXU) { in fst_intr()
1452 dma_intcsr = inl(card->pci_conf + INTCSR_9054); in fst_intr()
1454 /* DMA Channel 0 (Rx transfer complete) in fst_intr()
1456 dbg(DBG_RX, "DMA Rx xfer complete\n"); in fst_intr()
1457 outb(0x8, card->pci_conf + DMACSR0); in fst_intr()
1458 fst_rx_dma_complete(card, card->dma_port_rx, in fst_intr()
1459 card->dma_len_rx, card->dma_skb_rx, in fst_intr()
1460 card->dma_rxpos); in fst_intr()
1461 card->dmarx_in_progress = 0; in fst_intr()
1468 outb(0x8, card->pci_conf + DMACSR1); in fst_intr()
1469 fst_tx_dma_complete(card, card->dma_port_tx, in fst_intr()
1470 card->dma_len_tx, card->dma_txpos); in fst_intr()
1471 card->dmatx_in_progress = 0; in fst_intr()
1481 card->card_no, int_retry_count); in fst_intr()
1489 fst_q_work_item(&fst_work_intq, card->card_no); in fst_intr()
1497 port = &card->ports[event & 0x03]; in fst_intr()
1504 if (port->run) in fst_intr()
1512 if (port->run) in fst_intr()
1520 dbg(DBG_TX, "Abort complete port %d\n", port->index); in fst_intr()
1530 dbg(DBG_TX, "Tx underflow port %d\n", port->index); in fst_intr()
1531 port_to_dev(port)->stats.tx_errors++; in fst_intr()
1532 port_to_dev(port)->stats.tx_fifo_errors++; in fst_intr()
1534 card->card_no, port->index); in fst_intr()
1543 card->state = FST_IFAILED; in fst_intr()
1571 card->state = FST_BADVERSION; in check_started_ok()
1576 card->state = FST_BADVERSION; in check_started_ok()
1582 card->state = FST_RUNNING; in check_started_ok()
1585 card->state = FST_HALTED; in check_started_ok()
1589 card->state = FST_HALTED; in check_started_ok()
1597 if (FST_RDL(card, numberOfPorts) != card->nports) { in check_started_ok()
1599 card->card_no, in check_started_ok()
1600 FST_RDL(card, numberOfPorts), card->nports); in check_started_ok()
1616 if (info->valid & FSTVAL_PROTO) { in set_conf_from_info()
1617 if (info->proto == FST_RAW) in set_conf_from_info()
1618 port->mode = FST_RAW; in set_conf_from_info()
1620 port->mode = FST_GEN_HDLC; in set_conf_from_info()
1623 if (info->valid & FSTVAL_CABLE) in set_conf_from_info()
1624 err = -EINVAL; in set_conf_from_info()
1626 if (info->valid & FSTVAL_SPEED) in set_conf_from_info()
1627 err = -EINVAL; in set_conf_from_info()
1629 if (info->valid & FSTVAL_PHASE) in set_conf_from_info()
1630 FST_WRB(card, portConfig[port->index].invertClock, in set_conf_from_info()
1631 info->invertClock); in set_conf_from_info()
1632 if (info->valid & FSTVAL_MODE) in set_conf_from_info()
1633 FST_WRW(card, cardMode, info->cardMode); in set_conf_from_info()
1634 if (info->valid & FSTVAL_TE1) { in set_conf_from_info()
1635 FST_WRL(card, suConfig.dataRate, info->lineSpeed); in set_conf_from_info()
1636 FST_WRB(card, suConfig.clocking, info->clockSource); in set_conf_from_info()
1638 if (info->framing == E1) in set_conf_from_info()
1640 if (info->framing == T1) in set_conf_from_info()
1642 if (info->framing == J1) in set_conf_from_info()
1645 FST_WRB(card, suConfig.structure, info->structure); in set_conf_from_info()
1646 FST_WRB(card, suConfig.interface, info->interface); in set_conf_from_info()
1647 FST_WRB(card, suConfig.coding, info->coding); in set_conf_from_info()
1648 FST_WRB(card, suConfig.lineBuildOut, info->lineBuildOut); in set_conf_from_info()
1649 FST_WRB(card, suConfig.equalizer, info->equalizer); in set_conf_from_info()
1650 FST_WRB(card, suConfig.transparentMode, info->transparentMode); in set_conf_from_info()
1651 FST_WRB(card, suConfig.loopMode, info->loopMode); in set_conf_from_info()
1652 FST_WRB(card, suConfig.range, info->range); in set_conf_from_info()
1653 FST_WRB(card, suConfig.txBufferMode, info->txBufferMode); in set_conf_from_info()
1654 FST_WRB(card, suConfig.rxBufferMode, info->rxBufferMode); in set_conf_from_info()
1655 FST_WRB(card, suConfig.startingSlot, info->startingSlot); in set_conf_from_info()
1656 FST_WRB(card, suConfig.losThreshold, info->losThreshold); in set_conf_from_info()
1657 if (info->idleCode) in set_conf_from_info()
1661 FST_WRB(card, suConfig.idleCode, info->idleCode); in set_conf_from_info()
1663 if (info->valid & FSTVAL_TE1) { in set_conf_from_info()
1665 printk("Line Speed = %d\n", info->lineSpeed); in set_conf_from_info()
1666 printk("Start slot = %d\n", info->startingSlot); in set_conf_from_info()
1667 printk("Clock source = %d\n", info->clockSource); in set_conf_from_info()
1669 printk("Structure = %d\n", info->structure); in set_conf_from_info()
1670 printk("interface = %d\n", info->interface); in set_conf_from_info()
1671 printk("Coding = %d\n", info->coding); in set_conf_from_info()
1672 printk("Line build out = %d\n", info->lineBuildOut); in set_conf_from_info()
1673 printk("Equaliser = %d\n", info->equalizer); in set_conf_from_info()
1675 info->transparentMode); in set_conf_from_info()
1676 printk("Loop mode = %d\n", info->loopMode); in set_conf_from_info()
1677 printk("Range = %d\n", info->range); in set_conf_from_info()
1678 printk("Tx Buffer mode = %d\n", info->txBufferMode); in set_conf_from_info()
1679 printk("Rx Buffer mode = %d\n", info->rxBufferMode); in set_conf_from_info()
1680 printk("LOS Threshold = %d\n", info->losThreshold); in set_conf_from_info()
1681 printk("Idle Code = %d\n", info->idleCode); in set_conf_from_info()
1686 if (info->valid & FSTVAL_DEBUG) in set_conf_from_info()
1687 fst_debug_mask = info->debug; in set_conf_from_info()
1701 i = port->index; in gather_conf_info()
1702 info->kernelVersion = LINUX_VERSION_CODE; in gather_conf_info()
1703 info->nports = card->nports; in gather_conf_info()
1704 info->type = card->type; in gather_conf_info()
1705 info->state = card->state; in gather_conf_info()
1706 info->proto = FST_GEN_HDLC; in gather_conf_info()
1707 info->index = i; in gather_conf_info()
1709 info->debug = fst_debug_mask; in gather_conf_info()
1715 info->valid = ((card->state == FST_RUNNING) ? FSTVAL_ALL : FSTVAL_CARD) in gather_conf_info()
1721 info->lineInterface = FST_RDW(card, portConfig[i].lineInterface); in gather_conf_info()
1722 info->internalClock = FST_RDB(card, portConfig[i].internalClock); in gather_conf_info()
1723 info->lineSpeed = FST_RDL(card, portConfig[i].lineSpeed); in gather_conf_info()
1724 info->invertClock = FST_RDB(card, portConfig[i].invertClock); in gather_conf_info()
1725 info->v24IpSts = FST_RDL(card, v24IpSts[i]); in gather_conf_info()
1726 info->v24OpSts = FST_RDL(card, v24OpSts[i]); in gather_conf_info()
1727 info->clockStatus = FST_RDW(card, clockStatus[i]); in gather_conf_info()
1728 info->cableStatus = FST_RDW(card, cableStatus); in gather_conf_info()
1729 info->cardMode = FST_RDW(card, cardMode); in gather_conf_info()
1730 info->smcFirmwareVersion = FST_RDL(card, smcFirmwareVersion); in gather_conf_info()
1736 if (card->family == FST_FAMILY_TXU) { in gather_conf_info()
1737 if (port->index == 0) { in gather_conf_info()
1740 info->cableStatus = info->cableStatus & 1; in gather_conf_info()
1744 info->cableStatus = info->cableStatus >> 1; in gather_conf_info()
1745 info->cableStatus = info->cableStatus & 1; in gather_conf_info()
1750 if (card->type == FST_TYPE_TE1) { in gather_conf_info()
1751 info->lineSpeed = FST_RDL(card, suConfig.dataRate); in gather_conf_info()
1752 info->clockSource = FST_RDB(card, suConfig.clocking); in gather_conf_info()
1753 info->framing = FST_RDB(card, suConfig.framing); in gather_conf_info()
1754 info->structure = FST_RDB(card, suConfig.structure); in gather_conf_info()
1755 info->interface = FST_RDB(card, suConfig.interface); in gather_conf_info()
1756 info->coding = FST_RDB(card, suConfig.coding); in gather_conf_info()
1757 info->lineBuildOut = FST_RDB(card, suConfig.lineBuildOut); in gather_conf_info()
1758 info->equalizer = FST_RDB(card, suConfig.equalizer); in gather_conf_info()
1759 info->loopMode = FST_RDB(card, suConfig.loopMode); in gather_conf_info()
1760 info->range = FST_RDB(card, suConfig.range); in gather_conf_info()
1761 info->txBufferMode = FST_RDB(card, suConfig.txBufferMode); in gather_conf_info()
1762 info->rxBufferMode = FST_RDB(card, suConfig.rxBufferMode); in gather_conf_info()
1763 info->startingSlot = FST_RDB(card, suConfig.startingSlot); in gather_conf_info()
1764 info->losThreshold = FST_RDB(card, suConfig.losThreshold); in gather_conf_info()
1766 info->idleCode = FST_RDB(card, suConfig.idleCode); in gather_conf_info()
1768 info->idleCode = 0; in gather_conf_info()
1769 info->receiveBufferDelay = in gather_conf_info()
1771 info->framingErrorCount = in gather_conf_info()
1773 info->codeViolationCount = in gather_conf_info()
1775 info->crcErrorCount = FST_RDL(card, suStatus.crcErrorCount); in gather_conf_info()
1776 info->lineAttenuation = FST_RDL(card, suStatus.lineAttenuation); in gather_conf_info()
1777 info->lossOfSignal = FST_RDB(card, suStatus.lossOfSignal); in gather_conf_info()
1778 info->receiveRemoteAlarm = in gather_conf_info()
1780 info->alarmIndicationSignal = in gather_conf_info()
1792 if (ifs->size != sizeof(sync)) in fst_set_iface()
1793 return -ENOMEM; in fst_set_iface()
1795 if (copy_from_user(&sync, ifs->ifs_ifsu.sync, sizeof(sync))) in fst_set_iface()
1796 return -EFAULT; in fst_set_iface()
1799 return -EINVAL; in fst_set_iface()
1801 i = port->index; in fst_set_iface()
1803 switch (ifs->type) { in fst_set_iface()
1806 port->hwif = V35; in fst_set_iface()
1811 port->hwif = V24; in fst_set_iface()
1816 port->hwif = X21; in fst_set_iface()
1821 port->hwif = X21D; in fst_set_iface()
1826 port->hwif = T1; in fst_set_iface()
1831 port->hwif = E1; in fst_set_iface()
1838 return -EINVAL; in fst_set_iface()
1851 return -EINVAL; in fst_set_iface()
1868 switch (port->hwif) { in fst_get_iface()
1870 ifs->type = IF_IFACE_E1; in fst_get_iface()
1873 ifs->type = IF_IFACE_T1; in fst_get_iface()
1876 ifs->type = IF_IFACE_V35; in fst_get_iface()
1879 ifs->type = IF_IFACE_V24; in fst_get_iface()
1882 ifs->type = IF_IFACE_X21D; in fst_get_iface()
1886 ifs->type = IF_IFACE_X21; in fst_get_iface()
1889 if (!ifs->size) in fst_get_iface()
1892 if (ifs->size < sizeof(sync)) in fst_get_iface()
1893 return -ENOMEM; in fst_get_iface()
1895 i = port->index; in fst_get_iface()
1903 if (copy_to_user(ifs->ifs_ifsu.sync, &sync, sizeof(sync))) in fst_get_iface()
1904 return -EFAULT; in fst_get_iface()
1906 ifs->size = sizeof(sync); in fst_get_iface()
1923 card = port->card; in fst_siocdevprivate()
1926 return -EPERM; in fst_siocdevprivate()
1931 card->state = FST_RESET; in fst_siocdevprivate()
1936 card->state = FST_STARTING; in fst_siocdevprivate()
1945 return -EINVAL; in fst_siocdevprivate()
1948 return -EFAULT; in fst_siocdevprivate()
1955 return -ENXIO; in fst_siocdevprivate()
1964 memcpy_toio(card->mem + wrthdr.offset, buf, wrthdr.size); in fst_siocdevprivate()
1970 if (card->state == FST_RESET) in fst_siocdevprivate()
1971 card->state = FST_DOWNLOAD; in fst_siocdevprivate()
1980 if (card->state == FST_STARTING) { in fst_siocdevprivate()
1984 if (card->state == FST_RUNNING) { in fst_siocdevprivate()
1985 spin_lock_irqsave(&card->card_lock, flags); in fst_siocdevprivate()
1988 spin_unlock_irqrestore(&card->card_lock, flags); in fst_siocdevprivate()
1993 return -EINVAL; in fst_siocdevprivate()
1998 return -EFAULT; in fst_siocdevprivate()
2007 if (card->state != FST_RUNNING) { in fst_siocdevprivate()
2008 pr_err("Attempt to configure card %d in non-running state (%d)\n", in fst_siocdevprivate()
2009 card->card_no, card->state); in fst_siocdevprivate()
2010 return -EIO; in fst_siocdevprivate()
2013 return -EFAULT; in fst_siocdevprivate()
2017 return -EINVAL; in fst_siocdevprivate()
2027 dbg(DBG_IOCTL, "SIOCDEVPRIVATE, %x\n", ifs->type); in fst_ioctl()
2030 card = port->card; in fst_ioctl()
2033 return -EPERM; in fst_ioctl()
2035 switch (ifs->type) { in fst_ioctl()
2049 port->mode = FST_RAW; in fst_ioctl()
2053 if (port->mode == FST_RAW) { in fst_ioctl()
2054 ifs->type = IF_PROTO_RAW; in fst_ioctl()
2060 port->mode = FST_GEN_HDLC; in fst_ioctl()
2062 ifs->type); in fst_ioctl()
2075 if (port->card->state == FST_RUNNING) { in fst_openport()
2076 if (port->run) { in fst_openport()
2080 port->run = 0; in fst_openport()
2088 port->run = 1; in fst_openport()
2090 signals = FST_RDL(port->card, v24DebouncedSts[port->index]); in fst_openport()
2091 if (signals & ((port->hwif == X21 || port->hwif == X21D) in fst_openport()
2097 port->txqe = 0; in fst_openport()
2098 port->txqs = 0; in fst_openport()
2105 if (port->card->state == FST_RUNNING) { in fst_closeport()
2106 if (port->run) { in fst_closeport()
2107 port->run = 0; in fst_closeport()
2125 return -EBUSY; in fst_open()
2127 if (port->mode != FST_RAW) { in fst_open()
2149 card = port->card; in fst_close()
2151 tx_dma_done = inb(card->pci_conf + DMACSR1); in fst_close()
2152 rx_dma_done = inb(card->pci_conf + DMACSR0); in fst_close()
2155 card->dmatx_in_progress, tx_dma_done, card->dmarx_in_progress, in fst_close()
2160 if (port->mode != FST_RAW) in fst_close()
2173 return -EINVAL; in fst_attach()
2184 card = port->card; in fst_tx_timeout()
2185 dev->stats.tx_errors++; in fst_tx_timeout()
2186 dev->stats.tx_aborted_errors++; in fst_tx_timeout()
2188 card->card_no, port->index); in fst_tx_timeout()
2193 port->start = 0; in fst_tx_timeout()
2205 card = port->card; in fst_start_xmit()
2206 dbg(DBG_TX, "fst_start_xmit: length = %d\n", skb->len); in fst_start_xmit()
2211 dev->stats.tx_errors++; in fst_start_xmit()
2212 dev->stats.tx_carrier_errors++; in fst_start_xmit()
2215 card->card_no, port->index); in fst_start_xmit()
2220 if (skb->len > LEN_TX_BUFFER) { in fst_start_xmit()
2221 dbg(DBG_ASS, "Packet too large %d vs %d\n", skb->len, in fst_start_xmit()
2224 dev->stats.tx_errors++; in fst_start_xmit()
2232 spin_lock_irqsave(&card->card_lock, flags); in fst_start_xmit()
2233 txq_length = port->txqe - port->txqs; in fst_start_xmit()
2240 spin_unlock_irqrestore(&card->card_lock, flags); in fst_start_xmit()
2246 port->start = 1; /* I'm using this to signal stop sent up */ in fst_start_xmit()
2249 if (txq_length == FST_TXQ_DEPTH - 1) { in fst_start_xmit()
2253 dev->stats.tx_errors++; in fst_start_xmit()
2255 card->card_no, port->index); in fst_start_xmit()
2261 spin_lock_irqsave(&card->card_lock, flags); in fst_start_xmit()
2262 port->txq[port->txqe] = skb; in fst_start_xmit()
2263 port->txqe++; in fst_start_xmit()
2264 if (port->txqe == FST_TXQ_DEPTH) in fst_start_xmit()
2265 port->txqe = 0; in fst_start_xmit()
2266 spin_unlock_irqrestore(&card->card_lock, flags); in fst_start_xmit()
2269 fst_q_work_item(&fst_work_txq, card->card_no); in fst_start_xmit()
2301 for (i = 0; i < card->nports; i++) { in fst_init_card()
2302 err = register_hdlc_device(card->ports[i].dev); in fst_init_card()
2305 i, -err); in fst_init_card()
2306 while (i--) in fst_init_card()
2307 unregister_hdlc_device(card->ports[i].dev); in fst_init_card()
2312 pr_info("%s-%s: %s IRQ%d, %d ports\n", in fst_init_card()
2313 port_to_dev(&card->ports[0])->name, in fst_init_card()
2314 port_to_dev(&card->ports[card->nports - 1])->name, in fst_init_card()
2315 type_strings[card->type], card->irq, card->nports); in fst_init_card()
2341 " (c) 2001-2004 FarSite Communications Ltd.\n")); in fst_add_one()
2353 if (pdev->devfn >> 3 == fst_excluded_list[i]) { in fst_add_one()
2355 (pdev->devfn) >> 3); in fst_add_one()
2356 return -EBUSY; in fst_add_one()
2364 return -ENOMEM; in fst_add_one()
2369 pr_err("Failed to enable card. Err %d\n", -err); in fst_add_one()
2375 pr_err("Failed to allocate regions. Err %d\n", -err); in fst_add_one()
2380 card->pci_conf = pci_resource_start(pdev, 1); in fst_add_one()
2381 card->phys_mem = pci_resource_start(pdev, 2); in fst_add_one()
2382 card->phys_ctlmem = pci_resource_start(pdev, 3); in fst_add_one()
2383 card->mem = ioremap(card->phys_mem, FST_MEMSIZE); in fst_add_one()
2384 if (!card->mem) { in fst_add_one()
2386 err = -ENODEV; in fst_add_one()
2389 card->ctlmem = ioremap(card->phys_ctlmem, 0x10); in fst_add_one()
2390 if (!card->ctlmem) { in fst_add_one()
2392 err = -ENODEV; in fst_add_one()
2395 dbg(DBG_PCI, "kernel mem %p, ctlmem %p\n", card->mem, card->ctlmem); in fst_add_one()
2398 if (request_irq(pdev->irq, fst_intr, IRQF_SHARED, FST_DEV_NAME, card)) { in fst_add_one()
2399 pr_err("Unable to register interrupt %d\n", card->irq); in fst_add_one()
2400 err = -ENODEV; in fst_add_one()
2405 card->irq = pdev->irq; in fst_add_one()
2406 card->type = ent->driver_data; in fst_add_one()
2407 card->family = ((ent->driver_data == FST_TYPE_T2P) || in fst_add_one()
2408 (ent->driver_data == FST_TYPE_T4P)) in fst_add_one()
2410 if (ent->driver_data == FST_TYPE_T1U || in fst_add_one()
2411 ent->driver_data == FST_TYPE_TE1) in fst_add_one()
2412 card->nports = 1; in fst_add_one()
2414 card->nports = ((ent->driver_data == FST_TYPE_T2P) || in fst_add_one()
2415 (ent->driver_data == FST_TYPE_T2U)) ? 2 : 4; in fst_add_one()
2417 card->state = FST_UNINIT; in fst_add_one()
2418 spin_lock_init(&card->card_lock); in fst_add_one()
2420 for (i = 0; i < card->nports; i++) { in fst_add_one()
2421 struct net_device *dev = alloc_hdlcdev(&card->ports[i]); in fst_add_one()
2425 while (i--) in fst_add_one()
2426 free_netdev(card->ports[i].dev); in fst_add_one()
2428 err = -ENOMEM; in fst_add_one()
2431 card->ports[i].dev = dev; in fst_add_one()
2432 card->ports[i].card = card; in fst_add_one()
2433 card->ports[i].index = i; in fst_add_one()
2434 card->ports[i].run = 0; in fst_add_one()
2443 dev->mem_start = card->phys_mem in fst_add_one()
2445 dev->mem_end = card->phys_mem in fst_add_one()
2446 + BUF_OFFSET(txBuffer[i][NUM_TX_BUFFER - 1][LEN_RX_BUFFER - 1]); in fst_add_one()
2447 dev->base_addr = card->pci_conf; in fst_add_one()
2448 dev->irq = card->irq; in fst_add_one()
2450 dev->netdev_ops = &fst_ops; in fst_add_one()
2451 dev->tx_queue_len = FST_TX_QUEUE_LEN; in fst_add_one()
2452 dev->watchdog_timeo = FST_TX_TIMEOUT; in fst_add_one()
2453 hdlc->attach = fst_attach; in fst_add_one()
2454 hdlc->xmit = fst_start_xmit; in fst_add_one()
2457 card->device = pdev; in fst_add_one()
2459 dbg(DBG_PCI, "type %d nports %d irq %d\n", card->type, in fst_add_one()
2460 card->nports, card->irq); in fst_add_one()
2462 card->pci_conf, card->phys_mem, card->phys_ctlmem); in fst_add_one()
2466 card->state = FST_RESET; in fst_add_one()
2477 err = -ENOMEM; in fst_add_one()
2481 card->card_no = no_of_cards_added++; /* Record instance and bump it */ in fst_add_one()
2485 if (card->family == FST_FAMILY_TXU) { in fst_add_one()
2488 card->rx_dma_handle_host = in fst_add_one()
2489 dma_alloc_coherent(&card->device->dev, FST_MAX_MTU, in fst_add_one()
2490 &card->rx_dma_handle_card, GFP_KERNEL); in fst_add_one()
2491 if (!card->rx_dma_handle_host) { in fst_add_one()
2492 pr_err("Could not allocate rx dma buffer\n"); in fst_add_one()
2493 err = -ENOMEM; in fst_add_one()
2496 card->tx_dma_handle_host = in fst_add_one()
2497 dma_alloc_coherent(&card->device->dev, FST_MAX_MTU, in fst_add_one()
2498 &card->tx_dma_handle_card, GFP_KERNEL); in fst_add_one()
2499 if (!card->tx_dma_handle_host) { in fst_add_one()
2501 err = -ENOMEM; in fst_add_one()
2508 dma_free_coherent(&card->device->dev, FST_MAX_MTU, in fst_add_one()
2509 card->rx_dma_handle_host, card->rx_dma_handle_card); in fst_add_one()
2512 for (i = 0 ; i < card->nports ; i++) in fst_add_one()
2513 unregister_hdlc_device(card->ports[i].dev); in fst_add_one()
2515 fst_card_array[card->card_no] = NULL; in fst_add_one()
2517 for (i = 0 ; i < card->nports ; i++) in fst_add_one()
2518 free_netdev(card->ports[i].dev); in fst_add_one()
2520 free_irq(card->irq, card); in fst_add_one()
2522 iounmap(card->ctlmem); in fst_add_one()
2524 iounmap(card->mem); in fst_add_one()
2544 for (i = 0; i < card->nports; i++) { in fst_remove_one()
2545 struct net_device *dev = port_to_dev(&card->ports[i]); in fst_remove_one()
2552 free_irq(card->irq, card); in fst_remove_one()
2554 iounmap(card->ctlmem); in fst_remove_one()
2555 iounmap(card->mem); in fst_remove_one()
2557 if (card->family == FST_FAMILY_TXU) { in fst_remove_one()
2560 dma_free_coherent(&card->device->dev, FST_MAX_MTU, in fst_remove_one()
2561 card->rx_dma_handle_host, in fst_remove_one()
2562 card->rx_dma_handle_card); in fst_remove_one()
2563 dma_free_coherent(&card->device->dev, FST_MAX_MTU, in fst_remove_one()
2564 card->tx_dma_handle_host, in fst_remove_one()
2565 card->tx_dma_handle_card); in fst_remove_one()
2567 fst_card_array[card->card_no] = NULL; in fst_remove_one()