Lines Matching +full:wake +full:- +full:on +full:- +full:motion

2  * Copyright (c) 2011 - 2017 Intel Corporation.  All rights reserved.
17 * - Redistributions of source code must retain the above
21 * - Redistributions in binary form must reproduce the above
59 * This file contains almost all the chip-specific register information and
60 * access functions for the QLogic QLogic_IB 7220 PCI-Express chip, with the
64 /* Below uses machine-generated qib_chipnum_regs.h file */
67 /* Use defines to tie machine-generated names to lower-case names */
132 #define CREG_IDX(regname) ((QIB_7220_##regname##_OFFS - \
201 /* wait for TS1, then go on */
215 * on opteron (the northbridge always generates 2 separate HT 32 bit reads),
221 * qib_read_ureg32 - read 32-bit virtualized per-context register
227 * Returns -1 on errors (not distinguishable from valid contents at
233 if (!dd->kregbase || !(dd->flags & QIB_PRESENT)) in qib_read_ureg32()
236 if (dd->userbase) in qib_read_ureg32()
238 ((char __iomem *)dd->userbase + in qib_read_ureg32()
239 dd->ureg_align * ctxt)); in qib_read_ureg32()
242 (dd->uregbase + in qib_read_ureg32()
243 (char __iomem *)dd->kregbase + in qib_read_ureg32()
244 dd->ureg_align * ctxt)); in qib_read_ureg32()
248 * qib_write_ureg - write 32-bit virtualized per-context register
261 if (dd->userbase) in qib_write_ureg()
263 ((char __iomem *) dd->userbase + in qib_write_ureg()
264 dd->ureg_align * ctxt); in qib_write_ureg()
267 (dd->uregbase + in qib_write_ureg()
268 (char __iomem *) dd->kregbase + in qib_write_ureg()
269 dd->ureg_align * ctxt); in qib_write_ureg()
271 if (dd->kregbase && (dd->flags & QIB_PRESENT)) in qib_write_ureg()
276 * qib_write_kreg_ctxt - write a device's per-ctxt 64-bit kernel register
292 if (dd->cspec->cregbase && (dd->flags & QIB_PRESENT)) in write_7220_creg()
293 writeq(value, &dd->cspec->cregbase[regno]); in write_7220_creg()
298 if (!dd->cspec->cregbase || !(dd->flags & QIB_PRESENT)) in read_7220_creg()
300 return readq(&dd->cspec->cregbase[regno]); in read_7220_creg()
305 if (!dd->cspec->cregbase || !(dd->flags & QIB_PRESENT)) in read_7220_creg32()
307 return readl(&dd->cspec->cregbase[regno]); in read_7220_creg32()
311 #define QLOGIC_IB_R_EMULATORREV_MASK ((1ULL << 22) - 1)
318 #define QLOGIC_IB_I_RCVURG_MASK ((1ULL << 17) - 1)
320 #define QLOGIC_IB_I_RCVAVAIL_MASK ((1ULL << 17) - 1)
471 #define IBA7220_LEDBLINK_ON_SHIFT 32 /* 4ns period on after packet */
472 #define IBA7220_LEDBLINK_OFF_SHIFT 0 /* 4ns period off before next on */
631 /* chip-specific hardware errors */
703 /* These are all rcv-related errors which we want to count for stats */
712 /* These are all send-related errors which we want to count for stats */
748 * PIO buffer, and may need to cancel that buffer, so it can be re-used.
754 struct qib_devdata *dd = ppd->dd; in qib_disarm_7220_senderrbufs()
767 dd->piobcnt2k + dd->piobcnt4k); in qib_disarm_7220_senderrbufs()
772 qib_devinfo(dd->pcidev, "Recovering from TXE PIO parity error\n"); in qib_7220_txe_recover()
773 qib_disarm_7220_senderrbufs(dd->pport); in qib_7220_txe_recover()
781 struct qib_devdata *dd = ppd->dd; in qib_7220_sdma_sendctrl()
800 spin_lock(&dd->sendctrl_lock); in qib_7220_sdma_sendctrl()
802 dd->sendctrl |= set_sendctrl; in qib_7220_sdma_sendctrl()
803 dd->sendctrl &= ~clr_sendctrl; in qib_7220_sdma_sendctrl()
805 qib_write_kreg(dd, kr_sendctrl, dd->sendctrl); in qib_7220_sdma_sendctrl()
808 spin_unlock(&dd->sendctrl_lock); in qib_7220_sdma_sendctrl()
848 bidx += scnprintf(buf + bidx, blen - bidx, in qib_decode_7220_sdma_errs()
862 ppd->dd->upd_pio_shadow = 1; /* update our idea of what's busy */ in qib_7220_sdma_hw_clean_up()
872 qib_write_kreg(ppd->dd, kr_senddmalengen, ppd->sdma_descq_cnt); in qib_sdma_7220_setlengen()
873 qib_write_kreg(ppd->dd, kr_senddmalengen, in qib_sdma_7220_setlengen()
874 ppd->sdma_descq_cnt | in qib_sdma_7220_setlengen()
882 ppd->sdma_head_dma[0] = 0; in qib_7220_sdma_hw_start_up()
900 struct qib_devdata *dd = ppd->dd; in sdma_7220_errors()
905 msg = dd->cspec->sdmamsgbuf; in sdma_7220_errors()
907 sizeof(dd->cspec->sdmamsgbuf)); in sdma_7220_errors()
908 spin_lock_irqsave(&ppd->sdma_lock, flags); in sdma_7220_errors()
917 qib_dev_err(ppd->dd, in sdma_7220_errors()
919 ppd->dd->unit, ppd->port, sbuf[2], sbuf[1], in sdma_7220_errors()
924 qib_dev_err(dd, "IB%u:%u SDmaUnexpData\n", ppd->dd->unit, in sdma_7220_errors()
925 ppd->port); in sdma_7220_errors()
927 switch (ppd->sdma_state.current_state) { in sdma_7220_errors()
961 spin_unlock_irqrestore(&ppd->sdma_lock, flags); in sdma_7220_errors()
966 * print * it or not depending on "normal packet errors" vs everything
1038 qib_decode_7220_sdma_errs(dd->pport, err, buf, blen); in qib_decode_7220_err()
1049 struct qib_pportdata *ppd = &cpspec->pportdata; in reenable_7220_chase()
1051 ppd->cpspec->chase_timer.expires = 0; in reenable_7220_chase()
1065 * get stuck if we are unlucky on timing on both sides of in handle_7220_chase()
1067 * then re-enable. in handle_7220_chase()
1075 if (ppd->cpspec->chase_end && in handle_7220_chase()
1076 time_after(tnow, ppd->cpspec->chase_end)) { in handle_7220_chase()
1077 ppd->cpspec->chase_end = 0; in handle_7220_chase()
1081 ppd->cpspec->chase_timer.expires = jiffies + in handle_7220_chase()
1083 add_timer(&ppd->cpspec->chase_timer); in handle_7220_chase()
1084 } else if (!ppd->cpspec->chase_end) in handle_7220_chase()
1085 ppd->cpspec->chase_end = tnow + QIB_CHASE_TIME; in handle_7220_chase()
1089 ppd->cpspec->chase_end = 0; in handle_7220_chase()
1099 struct qib_pportdata *ppd = dd->pport; in handle_7220_errors()
1103 errs &= dd->cspec->errormask; in handle_7220_errors()
1104 msg = dd->cspec->emsgbuf; in handle_7220_errors()
1108 qib_7220_handle_hwerrors(dd, msg, sizeof(dd->cspec->emsgbuf)); in handle_7220_errors()
1121 !(ppd->lflags & QIBL_LINKACTIVE)) { in handle_7220_errors()
1132 !(ppd->lflags & QIBL_LINKACTIVE)) { in handle_7220_errors()
1158 qib_decode_7220_err(dd, msg, sizeof(dd->cspec->emsgbuf), errs & ~mask); in handle_7220_errors()
1171 if (!(ppd->lflags & QIBL_IB_AUTONEG_INPROG)) in handle_7220_errors()
1175 ppd->link_width_active = in handle_7220_errors()
1178 ppd->link_speed_active = in handle_7220_errors()
1196 "Got reset, requires re-init (unload and reload driver)\n"); in handle_7220_errors()
1197 dd->flags &= ~QIB_INITTED; /* needs re-init */ in handle_7220_errors()
1199 *dd->devstatusp |= QIB_STATUS_HWERROR; in handle_7220_errors()
1200 *dd->pport->statusp &= ~QIB_STATUS_IB_CONF; in handle_7220_errors()
1204 qib_dev_porterr(dd, ppd->port, "%s error\n", msg); in handle_7220_errors()
1206 if (ppd->state_wanted & ppd->lflags) in handle_7220_errors()
1207 wake_up_interruptible(&ppd->state_wait); in handle_7220_errors()
1210 * If there were hdrq or egrfull errors, wake up any processes in handle_7220_errors()
1213 * to support it, it's better to just wake everybody up if we in handle_7220_errors()
1231 if (dd->flags & QIB_BADINTR) in qib_7220_set_intr_state()
1234 /* force re-interrupt of any pending interrupts. */ in qib_7220_set_intr_state()
1245 * Forcibly update the in-memory pioavail register copies after cleanup
1252 * This is in chip-specific code because of all of the register accesses,
1253 * even though the details are similar on most chips.
1263 qib_cancel_sends(dd->pport); in qib_7220_clear_freeze()
1266 qib_write_kreg(dd, kr_control, dd->control); in qib_7220_clear_freeze()
1269 /* force in-memory update now we are out of freeze */ in qib_7220_clear_freeze()
1275 * and cancelling sends. Re-enable error interrupts before possible in qib_7220_clear_freeze()
1276 * force of re-interrupt on pending interrupts. in qib_7220_clear_freeze()
1280 qib_write_kreg(dd, kr_errmask, dd->cspec->errormask); in qib_7220_clear_freeze()
1285 * qib_7220_handle_hwerrors - display hardware errors.
1323 hwerrs &= dd->cspec->hwerrmask; in qib_7220_handle_hwerrors()
1327 qib_devinfo(dd->pcidev, in qib_7220_handle_hwerrors()
1340 if ((ctrl & QLOGIC_IB_C_FREEZEMODE) && !dd->diag_client) { in qib_7220_handle_hwerrors()
1364 /* ignore from now on, so disable until driver reloaded */ in qib_7220_handle_hwerrors()
1365 dd->cspec->hwerrmask &= ~HWE_MASK(PowerOnBISTFailed); in qib_7220_handle_hwerrors()
1366 qib_write_kreg(dd, kr_hwerrmask, dd->cspec->hwerrmask); in qib_7220_handle_hwerrors()
1372 bitsmsg = dd->cspec->bitsmsgbuf; in qib_7220_handle_hwerrors()
1378 snprintf(bitsmsg, sizeof(dd->cspec->bitsmsgbuf), in qib_7220_handle_hwerrors()
1388 snprintf(bitsmsg, sizeof(dd->cspec->bitsmsgbuf), in qib_7220_handle_hwerrors()
1392 /* ignore from now on, so disable until driver reloaded */ in qib_7220_handle_hwerrors()
1393 dd->cspec->hwerrmask &= ~(hwerrs & _QIB_PLL_FAIL); in qib_7220_handle_hwerrors()
1394 qib_write_kreg(dd, kr_hwerrmask, dd->cspec->hwerrmask); in qib_7220_handle_hwerrors()
1402 dd->cspec->hwerrmask &= ~QLOGIC_IB_HWE_SERDESPLLFAILED; in qib_7220_handle_hwerrors()
1403 qib_write_kreg(dd, kr_hwerrmask, dd->cspec->hwerrmask); in qib_7220_handle_hwerrors()
1408 if (isfatal && !dd->diag_client) { in qib_7220_handle_hwerrors()
1411 dd->serial); in qib_7220_handle_hwerrors()
1416 if (dd->freezemsg) in qib_7220_handle_hwerrors()
1417 snprintf(dd->freezemsg, dd->freezelen, in qib_7220_handle_hwerrors()
1425 * qib_7220_init_hwerrors - enable hardware errors
1445 qib_devinfo(dd->pcidev, "MemBIST is disabled.\n"); in qib_7220_init_hwerrors()
1450 dd->cspec->hwerrmask = val; in qib_7220_init_hwerrors()
1453 qib_write_kreg(dd, kr_hwerrmask, dd->cspec->hwerrmask); in qib_7220_init_hwerrors()
1459 dd->cspec->errormask = qib_read_kreg64(dd, kr_errmask); in qib_7220_init_hwerrors()
1466 * on chips that are count-based, rather than trigger-based. There is no
1468 * Only chip-specific because it's all register accesses
1474 dd->cspec->errormask |= ERR_MASK(SendPioArmLaunchErr); in qib_set_7220_armlaunch()
1476 dd->cspec->errormask &= ~ERR_MASK(SendPioArmLaunchErr); in qib_set_7220_armlaunch()
1477 qib_write_kreg(dd, kr_errmask, dd->cspec->errormask); in qib_set_7220_armlaunch()
1481 * Formerly took parameter <which> in pre-shifted,
1482 * pre-merged form with LinkCmd and LinkInitCmd
1489 struct qib_devdata *dd = ppd->dd; in qib_set_ib_7220_lstate()
1494 * If we are told to disable, note that so link-recovery in qib_set_ib_7220_lstate()
1497 spin_lock_irqsave(&ppd->lflags_lock, flags); in qib_set_ib_7220_lstate()
1498 ppd->lflags |= QIBL_IB_LINK_DISABLED; in qib_set_ib_7220_lstate()
1499 spin_unlock_irqrestore(&ppd->lflags_lock, flags); in qib_set_ib_7220_lstate()
1504 * link-recovery code attempt to bring us back up. in qib_set_ib_7220_lstate()
1506 spin_lock_irqsave(&ppd->lflags_lock, flags); in qib_set_ib_7220_lstate()
1507 ppd->lflags &= ~QIBL_IB_LINK_DISABLED; in qib_set_ib_7220_lstate()
1508 spin_unlock_irqrestore(&ppd->lflags_lock, flags); in qib_set_ib_7220_lstate()
1514 qib_write_kreg(dd, kr_ibcctrl, ppd->cpspec->ibcctrl | mod_wd); in qib_set_ib_7220_lstate()
1515 /* write to chip to prevent back-to-back writes of ibc reg */ in qib_set_ib_7220_lstate()
1522 * The portion of IBA7220-specific bringup_serdes() that actually deals with
1527 * qib_7220_bringup_serdes - bring up the serdes
1528 * @ppd: physical port on the qlogic_ib device
1532 struct qib_devdata *dd = ppd->dd; in qib_7220_bringup_serdes()
1537 dd->control &= ~QLOGIC_IB_C_LINKENABLE; in qib_7220_bringup_serdes()
1541 ppd->cpspec->ibdeltainprog = 1; in qib_7220_bringup_serdes()
1542 ppd->cpspec->ibsymsnap = read_7220_creg32(dd, cr_ibsymbolerr); in qib_7220_bringup_serdes()
1543 ppd->cpspec->iblnkerrsnap = in qib_7220_bringup_serdes()
1565 ibc |= ((u64)(ppd->ibmaxlen >> 2) + 1) << SYM_LSB(IBCCtrl, MaxPktLen); in qib_7220_bringup_serdes()
1566 ppd->cpspec->ibcctrl = ibc; /* without linkcmd or linkinitcmd! */ in qib_7220_bringup_serdes()
1569 val = ppd->cpspec->ibcctrl | (QLOGIC_IB_IBCC_LINKINITCMD_DISABLE << in qib_7220_bringup_serdes()
1573 if (!ppd->cpspec->ibcddrctrl) { in qib_7220_bringup_serdes()
1574 /* not on re-init after reset */ in qib_7220_bringup_serdes()
1575 ppd->cpspec->ibcddrctrl = qib_read_kreg64(dd, kr_ibcddrctrl); in qib_7220_bringup_serdes()
1577 if (ppd->link_speed_enabled == (QIB_IB_SDR | QIB_IB_DDR)) in qib_7220_bringup_serdes()
1578 ppd->cpspec->ibcddrctrl |= in qib_7220_bringup_serdes()
1582 ppd->cpspec->ibcddrctrl |= in qib_7220_bringup_serdes()
1583 ppd->link_speed_enabled == QIB_IB_DDR ? in qib_7220_bringup_serdes()
1585 if ((ppd->link_width_enabled & (IB_WIDTH_1X | IB_WIDTH_4X)) == in qib_7220_bringup_serdes()
1587 ppd->cpspec->ibcddrctrl |= IBA7220_IBC_WIDTH_AUTONEG; in qib_7220_bringup_serdes()
1589 ppd->cpspec->ibcddrctrl |= in qib_7220_bringup_serdes()
1590 ppd->link_width_enabled == IB_WIDTH_4X ? in qib_7220_bringup_serdes()
1594 /* always enable these on driver reload, not sticky */ in qib_7220_bringup_serdes()
1595 ppd->cpspec->ibcddrctrl |= in qib_7220_bringup_serdes()
1597 ppd->cpspec->ibcddrctrl |= in qib_7220_bringup_serdes()
1601 ppd->cpspec->ibcddrctrl |= IBA7220_IBC_LANE_REV_SUPPORTED; in qib_7220_bringup_serdes()
1603 /* write to chip to prevent back-to-back writes of ibc reg */ in qib_7220_bringup_serdes()
1606 qib_write_kreg(dd, kr_ibcddrctrl, ppd->cpspec->ibcddrctrl); in qib_7220_bringup_serdes()
1627 if (!ppd->guid) in qib_7220_bringup_serdes()
1628 ppd->guid = dd->base_guid; in qib_7220_bringup_serdes()
1629 guid = be64_to_cpu(ppd->guid); in qib_7220_bringup_serdes()
1633 dd->control |= QLOGIC_IB_C_LINKENABLE; in qib_7220_bringup_serdes()
1634 qib_write_kreg(dd, kr_control, dd->control); in qib_7220_bringup_serdes()
1636 /* write to chip to prevent back-to-back writes of ibc reg */ in qib_7220_bringup_serdes()
1642 * qib_7220_quiet_serdes - set serdes to txidle
1649 struct qib_devdata *dd = ppd->dd; in qib_7220_quiet_serdes()
1653 dd->control &= ~QLOGIC_IB_C_LINKENABLE; in qib_7220_quiet_serdes()
1655 dd->control | QLOGIC_IB_C_FREEZEMODE); in qib_7220_quiet_serdes()
1657 ppd->cpspec->chase_end = 0; in qib_7220_quiet_serdes()
1658 if (ppd->cpspec->chase_timer.function) /* if initted */ in qib_7220_quiet_serdes()
1659 del_timer_sync(&ppd->cpspec->chase_timer); in qib_7220_quiet_serdes()
1661 if (ppd->cpspec->ibsymdelta || ppd->cpspec->iblnkerrdelta || in qib_7220_quiet_serdes()
1662 ppd->cpspec->ibdeltainprog) { in qib_7220_quiet_serdes()
1670 if (ppd->cpspec->ibsymdelta || ppd->cpspec->ibdeltainprog) { in qib_7220_quiet_serdes()
1672 if (ppd->cpspec->ibdeltainprog) in qib_7220_quiet_serdes()
1673 val -= val - ppd->cpspec->ibsymsnap; in qib_7220_quiet_serdes()
1674 val -= ppd->cpspec->ibsymdelta; in qib_7220_quiet_serdes()
1677 if (ppd->cpspec->iblnkerrdelta || ppd->cpspec->ibdeltainprog) { in qib_7220_quiet_serdes()
1679 if (ppd->cpspec->ibdeltainprog) in qib_7220_quiet_serdes()
1680 val -= val - ppd->cpspec->iblnkerrsnap; in qib_7220_quiet_serdes()
1681 val -= ppd->cpspec->iblnkerrdelta; in qib_7220_quiet_serdes()
1690 spin_lock_irqsave(&ppd->lflags_lock, flags); in qib_7220_quiet_serdes()
1691 ppd->lflags &= ~QIBL_IB_AUTONEG_INPROG; in qib_7220_quiet_serdes()
1692 spin_unlock_irqrestore(&ppd->lflags_lock, flags); in qib_7220_quiet_serdes()
1693 wake_up(&ppd->cpspec->autoneg_wait); in qib_7220_quiet_serdes()
1694 cancel_delayed_work_sync(&ppd->cpspec->autoneg_work); in qib_7220_quiet_serdes()
1696 shutdown_7220_relock_poll(ppd->dd); in qib_7220_quiet_serdes()
1697 val = qib_read_kreg64(ppd->dd, kr_xgxs_cfg); in qib_7220_quiet_serdes()
1699 qib_write_kreg(ppd->dd, kr_xgxs_cfg, val); in qib_7220_quiet_serdes()
1703 * qib_setup_7220_setextled - set the state of the two external LEDs
1705 * @on: whether the link is up or not
1707 * The exact combo of LEDs if on is true is determined by looking
1720 * require waking up every 10-20 msecs and checking the counters
1721 * on the chip, and then turning the LED off if appropriate. That's
1725 static void qib_setup_7220_setextled(struct qib_pportdata *ppd, u32 on) in qib_setup_7220_setextled() argument
1727 struct qib_devdata *dd = ppd->dd; in qib_setup_7220_setextled()
1735 if (dd->diag_client) in qib_setup_7220_setextled()
1738 if (ppd->led_override) { in qib_setup_7220_setextled()
1739 ltst = (ppd->led_override & QIB_LED_PHYS) ? in qib_setup_7220_setextled()
1741 lst = (ppd->led_override & QIB_LED_LOG) ? in qib_setup_7220_setextled()
1743 } else if (on) { in qib_setup_7220_setextled()
1752 spin_lock_irqsave(&dd->cspec->gpio_lock, flags); in qib_setup_7220_setextled()
1753 extctl = dd->cspec->extctrl & ~(SYM_MASK(EXTCtrl, LEDPriPortGreenOn) | in qib_setup_7220_setextled()
1759 * This is 1/16 sec (66.6ms) on, in qib_setup_7220_setextled()
1767 dd->cspec->extctrl = extctl; in qib_setup_7220_setextled()
1769 spin_unlock_irqrestore(&dd->cspec->gpio_lock, flags); in qib_setup_7220_setextled()
1771 if (ledblink) /* blink the LED on packet receive */ in qib_setup_7220_setextled()
1776 * qib_setup_7220_cleanup - clean up any per-chip chip-specific stuff
1785 kfree(dd->cspec->cntrs); in qib_setup_7220_cleanup()
1786 kfree(dd->cspec->portcntrs); in qib_setup_7220_cleanup()
1791 * SDmaDisabled is handled on the error path.
1797 spin_lock_irqsave(&ppd->sdma_lock, flags); in sdma_7220_intr()
1799 switch (ppd->sdma_state.current_state) { in sdma_7220_intr()
1825 spin_unlock_irqrestore(&ppd->sdma_lock, flags); in sdma_7220_intr()
1832 spin_lock_irqsave(&dd->sendctrl_lock, flags); in qib_wantpiobuf_7220_intr()
1834 if (!(dd->sendctrl & SYM_MASK(SendCtrl, SendBufAvailUpd))) in qib_wantpiobuf_7220_intr()
1837 * blip the availupd off, next write will be on, so in qib_wantpiobuf_7220_intr()
1841 qib_write_kreg(dd, kr_sendctrl, dd->sendctrl & in qib_wantpiobuf_7220_intr()
1844 dd->sendctrl |= SYM_MASK(SendCtrl, SendIntBufAvail); in qib_wantpiobuf_7220_intr()
1846 dd->sendctrl &= ~SYM_MASK(SendCtrl, SendIntBufAvail); in qib_wantpiobuf_7220_intr()
1847 qib_write_kreg(dd, kr_sendctrl, dd->sendctrl); in qib_wantpiobuf_7220_intr()
1850 spin_unlock_irqrestore(&dd->sendctrl_lock, flags); in qib_wantpiobuf_7220_intr()
1877 * have a bad side-effect on some diagnostic that wanted in unlikely_7220_intr()
1878 * to poll for a status-change, but the various shadows in unlikely_7220_intr()
1899 dd->cspec->gpio_mask &= ~gpio_irq; in unlikely_7220_intr()
1900 qib_write_kreg(dd, kr_gpio_mask, dd->cspec->gpio_mask); in unlikely_7220_intr()
1910 qib_devinfo(dd->pcidev, in unlikely_7220_intr()
1927 if ((dd->flags & (QIB_PRESENT | QIB_BADINTR)) != QIB_PRESENT) { in qib_7220intr()
1944 if (unlikely(istat == -1)) { in qib_7220intr()
1951 this_cpu_inc(*dd->int_counter); in qib_7220intr()
1959 * the queue, and will re-interrupt if necessary. The processor in qib_7220intr()
1975 for (i = 0; i < dd->first_user_ctxt; i++) { in qib_7220intr()
1978 qib_kreceive(dd->rcd[i], NULL, NULL); in qib_7220intr()
1992 sdma_7220_intr(dd->pport, istat); in qib_7220intr()
1994 if ((istat & QLOGIC_IB_I_SPIOBUFAVAIL) && (dd->flags & QIB_INITTED)) in qib_7220intr()
2003 * Set up our chip-specific interrupt handler.
2014 ret = pci_request_irq(dd->pcidev, 0, qib_7220intr, NULL, dd, in qib_setup_7220_interrupt()
2018 dd->pcidev->msi_enabled ? "MSI" : "INTx", in qib_setup_7220_interrupt()
2019 pci_irq_vector(dd->pcidev, 0), ret); in qib_setup_7220_interrupt()
2023 * qib_7220_boardname - fill in the board name
2026 * info is based on the board revision register
2032 boardid = SYM_FIELD(dd->revision, Revision, in qib_7220_boardname()
2037 dd->boardname = "InfiniPath_QLE7240"; in qib_7220_boardname()
2040 dd->boardname = "InfiniPath_QLE7280"; in qib_7220_boardname()
2044 dd->boardname = "Unknown_InfiniPath_7220"; in qib_7220_boardname()
2048 if (dd->majrev != 5 || !dd->minrev || dd->minrev > 2) in qib_7220_boardname()
2051 dd->majrev, dd->minrev); in qib_7220_boardname()
2053 snprintf(dd->boardversion, sizeof(dd->boardversion), in qib_7220_boardname()
2055 QIB_CHIP_VERS_MAJ, QIB_CHIP_VERS_MIN, dd->boardname, in qib_7220_boardname()
2056 (unsigned int)SYM_FIELD(dd->revision, Revision_R, Arch), in qib_7220_boardname()
2057 dd->majrev, dd->minrev, in qib_7220_boardname()
2058 (unsigned int)SYM_FIELD(dd->revision, Revision_R, SW)); in qib_7220_boardname()
2077 qib_dev_err(dd, "Resetting InfiniPath unit %u\n", dd->unit); in qib_setup_7220_reset()
2079 /* no interrupts till re-initted */ in qib_setup_7220_reset()
2082 dd->pport->cpspec->ibdeltainprog = 0; in qib_setup_7220_reset()
2083 dd->pport->cpspec->ibsymdelta = 0; in qib_setup_7220_reset()
2084 dd->pport->cpspec->iblnkerrdelta = 0; in qib_setup_7220_reset()
2091 dd->flags &= ~(QIB_INITTED | QIB_PRESENT); in qib_setup_7220_reset()
2093 dd->z_int_counter = qib_int_counter(dd); in qib_setup_7220_reset()
2094 val = dd->control | QLOGIC_IB_C_RESET; in qib_setup_7220_reset()
2095 writeq(val, &dd->kregbase[kr_control]); in qib_setup_7220_reset()
2100 * Allow MBIST, etc. to complete; longer on each retry. in qib_setup_7220_reset()
2112 val = readq(&dd->kregbase[kr_revision]); in qib_setup_7220_reset()
2113 if (val == dd->revision) { in qib_setup_7220_reset()
2114 dd->flags |= QIB_PRESENT; /* it's back */ in qib_setup_7220_reset()
2123 if (qib_pcie_params(dd, dd->lbus_width, NULL)) in qib_setup_7220_reset()
2133 /* do setup similar to speed or link-width changes */ in qib_setup_7220_reset()
2134 if (dd->pport->cpspec->ibcddrctrl & IBA7220_IBC_IBTA_1_2_MASK) in qib_setup_7220_reset()
2135 dd->cspec->presets_needed = 1; in qib_setup_7220_reset()
2136 spin_lock_irqsave(&dd->pport->lflags_lock, flags); in qib_setup_7220_reset()
2137 dd->pport->lflags |= QIBL_IB_FORCE_NOTIFY; in qib_setup_7220_reset()
2138 dd->pport->lflags &= ~QIBL_IB_AUTONEG_FAILED; in qib_setup_7220_reset()
2139 spin_unlock_irqrestore(&dd->pport->lflags_lock, flags); in qib_setup_7220_reset()
2146 * qib_7220_put_tid - write a TID to the chip
2155 if (pa != dd->tidinvalid) { in qib_7220_put_tid()
2172 chippa |= dd->tidtemplate; in qib_7220_put_tid()
2181 * qib_7220_clear_tids - clear all TID entries for a ctxt, expected and eager
2186 * Used from qib_close(). On this chip, TIDs are only 32 bits,
2187 * not 64, but they are still on 64 bit boundaries, so tidbase
2198 if (!dd->kregbase || !rcd) in qib_7220_clear_tids()
2201 ctxt = rcd->ctxt; in qib_7220_clear_tids()
2203 tidinv = dd->tidinvalid; in qib_7220_clear_tids()
2205 ((char __iomem *)(dd->kregbase) + in qib_7220_clear_tids()
2206 dd->rcvtidbase + in qib_7220_clear_tids()
2207 ctxt * dd->rcvtidcnt * sizeof(*tidbase)); in qib_7220_clear_tids()
2209 for (i = 0; i < dd->rcvtidcnt; i++) in qib_7220_clear_tids()
2214 ((char __iomem *)(dd->kregbase) + in qib_7220_clear_tids()
2215 dd->rcvegrbase + in qib_7220_clear_tids()
2216 rcd->rcvegr_tid_base * sizeof(*tidbase)); in qib_7220_clear_tids()
2218 for (i = 0; i < rcd->rcvegrcnt; i++) in qib_7220_clear_tids()
2224 * qib_7220_tidtemplate - setup constants for TID updates
2231 if (dd->rcvegrbufsize == 2048) in qib_7220_tidtemplate()
2232 dd->tidtemplate = IBA7220_TID_SZ_2K; in qib_7220_tidtemplate()
2233 else if (dd->rcvegrbufsize == 4096) in qib_7220_tidtemplate()
2234 dd->tidtemplate = IBA7220_TID_SZ_4K; in qib_7220_tidtemplate()
2235 dd->tidinvalid = 0; in qib_7220_tidtemplate()
2239 * qib_7220_get_base_info - set chip-specific flags for user code
2243 * We set the PCIE flag because the lower bandwidth on PCIe vs
2249 kinfo->spi_runtime_flags |= QIB_RUNTIME_PCIE | in qib_7220_get_base_info()
2252 if (rcd->dd->flags & QIB_USE_SPCL_TRIG) in qib_7220_get_base_info()
2253 kinfo->spi_runtime_flags |= QIB_RUNTIME_SPECIAL_TRIGGER; in qib_7220_get_base_info()
2264 (rhf_addr - dd->rhf_offset + offset); in qib_7220_get_msgheader()
2273 dd->cspec->numctxts = nchipctxts; in qib_7220_config_ctxts()
2275 dd->qpn_mask = 0x3e; in qib_7220_config_ctxts()
2276 dd->first_user_ctxt = qib_n_krcv_queues * dd->num_pports; in qib_7220_config_ctxts()
2277 if (dd->first_user_ctxt > nchipctxts) in qib_7220_config_ctxts()
2278 dd->first_user_ctxt = nchipctxts; in qib_7220_config_ctxts()
2280 dd->first_user_ctxt = dd->num_pports; in qib_7220_config_ctxts()
2281 dd->n_krcv_queues = dd->first_user_ctxt; in qib_7220_config_ctxts()
2284 int nctxts = dd->first_user_ctxt + num_online_cpus(); in qib_7220_config_ctxts()
2287 dd->ctxtcnt = 5; in qib_7220_config_ctxts()
2289 dd->ctxtcnt = 9; in qib_7220_config_ctxts()
2291 dd->ctxtcnt = nchipctxts; in qib_7220_config_ctxts()
2293 dd->ctxtcnt = qib_cfgctxts; in qib_7220_config_ctxts()
2294 if (!dd->ctxtcnt) /* none of the above, set to max */ in qib_7220_config_ctxts()
2295 dd->ctxtcnt = nchipctxts; in qib_7220_config_ctxts()
2300 * Lock to be paranoid about later motion, etc. in qib_7220_config_ctxts()
2302 spin_lock_irqsave(&dd->cspec->rcvmod_lock, flags); in qib_7220_config_ctxts()
2303 if (dd->ctxtcnt > 9) in qib_7220_config_ctxts()
2304 dd->rcvctrl |= 2ULL << IBA7220_R_CTXTCFG_SHIFT; in qib_7220_config_ctxts()
2305 else if (dd->ctxtcnt > 5) in qib_7220_config_ctxts()
2306 dd->rcvctrl |= 1ULL << IBA7220_R_CTXTCFG_SHIFT; in qib_7220_config_ctxts()
2308 if (dd->qpn_mask) in qib_7220_config_ctxts()
2309 dd->rcvctrl |= 1ULL << QIB_7220_RcvCtrl_RcvQPMapEnable_LSB; in qib_7220_config_ctxts()
2310 qib_write_kreg(dd, kr_rcvctrl, dd->rcvctrl); in qib_7220_config_ctxts()
2311 spin_unlock_irqrestore(&dd->cspec->rcvmod_lock, flags); in qib_7220_config_ctxts()
2313 /* kr_rcvegrcnt changes based on the number of contexts enabled */ in qib_7220_config_ctxts()
2314 dd->cspec->rcvegrcnt = qib_read_kreg32(dd, kr_rcvegrcnt); in qib_7220_config_ctxts()
2315 dd->rcvhdrcnt = max(dd->cspec->rcvegrcnt, IBA7220_KRCVEGRCNT); in qib_7220_config_ctxts()
2321 u64 maskr; /* right-justified mask */ in qib_7220_get_ib_cfg()
2324 case QIB_IB_CFG_LWID_ENB: /* Get allowed Link-width */ in qib_7220_get_ib_cfg()
2325 ret = ppd->link_width_enabled; in qib_7220_get_ib_cfg()
2328 case QIB_IB_CFG_LWID: /* Get currently active Link-width */ in qib_7220_get_ib_cfg()
2329 ret = ppd->link_width_active; in qib_7220_get_ib_cfg()
2333 ret = ppd->link_speed_enabled; in qib_7220_get_ib_cfg()
2337 ret = ppd->link_speed_active; in qib_7220_get_ib_cfg()
2340 case QIB_IB_CFG_RXPOL_ENB: /* Get Auto-RX-polarity enable */ in qib_7220_get_ib_cfg()
2345 case QIB_IB_CFG_LREV_ENB: /* Get Auto-Lane-reversal enable */ in qib_7220_get_ib_cfg()
2351 ret = qib_read_kreg64(ppd->dd, kr_ibcddrstatus) in qib_7220_get_ib_cfg()
2356 ret = ppd->vls_operational; in qib_7220_get_ib_cfg()
2368 ret = SYM_FIELD(ppd->cpspec->ibcctrl, IBCCtrl, in qib_7220_get_ib_cfg()
2373 ret = SYM_FIELD(ppd->cpspec->ibcctrl, IBCCtrl, in qib_7220_get_ib_cfg()
2379 ret = (ppd->cpspec->ibcctrl & in qib_7220_get_ib_cfg()
2394 ret = (ppd->link_speed_active == QIB_IB_DDR); in qib_7220_get_ib_cfg()
2398 ret = -EINVAL; in qib_7220_get_ib_cfg()
2401 ret = (int)((ppd->cpspec->ibcddrctrl >> lsb) & maskr); in qib_7220_get_ib_cfg()
2408 struct qib_devdata *dd = ppd->dd; in qib_7220_set_ib_cfg()
2409 u64 maskr; /* right-justified mask */ in qib_7220_set_ib_cfg()
2425 case QIB_IB_CFG_LWID_ENB: /* set allowed Link-width */ in qib_7220_set_ib_cfg()
2429 * on next link change. in qib_7220_set_ib_cfg()
2431 ppd->link_width_enabled = val; in qib_7220_set_ib_cfg()
2432 if (!(ppd->lflags & QIBL_LINKDOWN)) in qib_7220_set_ib_cfg()
2440 * on the next ibstatuschange down interrupt, even in qib_7220_set_ib_cfg()
2441 * if it's not an down->up transition. in qib_7220_set_ib_cfg()
2443 val--; /* convert from IB to chip */ in qib_7220_set_ib_cfg()
2455 * takes effect on next link change. Since setting is being in qib_7220_set_ib_cfg()
2459 ppd->link_speed_enabled = val; in qib_7220_set_ib_cfg()
2460 if ((ppd->cpspec->ibcddrctrl & IBA7220_IBC_IBTA_1_2_MASK) && in qib_7220_set_ib_cfg()
2461 !(val & (val - 1))) in qib_7220_set_ib_cfg()
2462 dd->cspec->presets_needed = 1; in qib_7220_set_ib_cfg()
2463 if (!(ppd->lflags & QIBL_LINKDOWN)) in qib_7220_set_ib_cfg()
2471 * on the next ibstatuschange down interrupt, even in qib_7220_set_ib_cfg()
2472 * if it's not an down->up transition. in qib_7220_set_ib_cfg()
2477 spin_lock_irqsave(&ppd->lflags_lock, flags); in qib_7220_set_ib_cfg()
2478 ppd->lflags &= ~QIBL_IB_AUTONEG_FAILED; in qib_7220_set_ib_cfg()
2479 spin_unlock_irqrestore(&ppd->lflags_lock, flags); in qib_7220_set_ib_cfg()
2490 case QIB_IB_CFG_RXPOL_ENB: /* set Auto-RX-polarity enable */ in qib_7220_set_ib_cfg()
2495 case QIB_IB_CFG_LREV_ENB: /* set Auto-Lane-reversal enable */ in qib_7220_set_ib_cfg()
2501 maskr = SYM_FIELD(ppd->cpspec->ibcctrl, IBCCtrl, in qib_7220_set_ib_cfg()
2504 ppd->cpspec->ibcctrl &= in qib_7220_set_ib_cfg()
2506 ppd->cpspec->ibcctrl |= (u64) val << in qib_7220_set_ib_cfg()
2508 qib_write_kreg(dd, kr_ibcctrl, ppd->cpspec->ibcctrl); in qib_7220_set_ib_cfg()
2514 maskr = SYM_FIELD(ppd->cpspec->ibcctrl, IBCCtrl, in qib_7220_set_ib_cfg()
2517 ppd->cpspec->ibcctrl &= in qib_7220_set_ib_cfg()
2519 ppd->cpspec->ibcctrl |= (u64) val << in qib_7220_set_ib_cfg()
2521 qib_write_kreg(dd, kr_ibcctrl, ppd->cpspec->ibcctrl); in qib_7220_set_ib_cfg()
2527 maskr = (u64) ppd->pkeys[0] | ((u64) ppd->pkeys[1] << 16) | in qib_7220_set_ib_cfg()
2528 ((u64) ppd->pkeys[2] << 32) | in qib_7220_set_ib_cfg()
2529 ((u64) ppd->pkeys[3] << 48); in qib_7220_set_ib_cfg()
2536 ppd->cpspec->ibcctrl &= in qib_7220_set_ib_cfg()
2539 ppd->cpspec->ibcctrl |= in qib_7220_set_ib_cfg()
2541 qib_write_kreg(dd, kr_ibcctrl, ppd->cpspec->ibcctrl); in qib_7220_set_ib_cfg()
2551 * on changes. in qib_7220_set_ib_cfg()
2553 val = (ppd->ibmaxlen >> 2) + 1; in qib_7220_set_ib_cfg()
2554 ppd->cpspec->ibcctrl &= ~SYM_MASK(IBCCtrl, MaxPktLen); in qib_7220_set_ib_cfg()
2555 ppd->cpspec->ibcctrl |= (u64)val << SYM_LSB(IBCCtrl, MaxPktLen); in qib_7220_set_ib_cfg()
2556 qib_write_kreg(dd, kr_ibcctrl, ppd->cpspec->ibcctrl); in qib_7220_set_ib_cfg()
2564 if (!ppd->cpspec->ibdeltainprog && in qib_7220_set_ib_cfg()
2566 ppd->cpspec->ibdeltainprog = 1; in qib_7220_set_ib_cfg()
2567 ppd->cpspec->ibsymsnap = in qib_7220_set_ib_cfg()
2569 ppd->cpspec->iblnkerrsnap = in qib_7220_set_ib_cfg()
2583 ret = -EINVAL; in qib_7220_set_ib_cfg()
2602 ppd->cpspec->chase_end = 0; in qib_7220_set_ib_cfg()
2607 if (ppd->cpspec->chase_timer.expires) { in qib_7220_set_ib_cfg()
2608 del_timer_sync(&ppd->cpspec->chase_timer); in qib_7220_set_ib_cfg()
2609 ppd->cpspec->chase_timer.expires = 0; in qib_7220_set_ib_cfg()
2614 ret = -EINVAL; in qib_7220_set_ib_cfg()
2623 tmp = (ppd->cpspec->ibcddrctrl >> lsb) & maskr; in qib_7220_set_ib_cfg()
2624 /* If the width active on the chip does not match the in qib_7220_set_ib_cfg()
2630 if (ppd->link_width_enabled-1 != tmp) { in qib_7220_set_ib_cfg()
2631 ppd->cpspec->ibcddrctrl &= ~(maskr << lsb); in qib_7220_set_ib_cfg()
2632 ppd->cpspec->ibcddrctrl |= in qib_7220_set_ib_cfg()
2633 (((u64)(ppd->link_width_enabled-1) & maskr) << in qib_7220_set_ib_cfg()
2636 ppd->cpspec->ibcddrctrl); in qib_7220_set_ib_cfg()
2638 spin_lock_irqsave(&ppd->lflags_lock, flags); in qib_7220_set_ib_cfg()
2639 ppd->lflags |= QIBL_IB_FORCE_NOTIFY; in qib_7220_set_ib_cfg()
2640 spin_unlock_irqrestore(&ppd->lflags_lock, flags); in qib_7220_set_ib_cfg()
2646 ret = -EINVAL; in qib_7220_set_ib_cfg()
2654 ret = -EINVAL; in qib_7220_set_ib_cfg()
2657 ppd->cpspec->ibcddrctrl &= ~(maskr << lsb); in qib_7220_set_ib_cfg()
2658 ppd->cpspec->ibcddrctrl |= (((u64) val & maskr) << lsb); in qib_7220_set_ib_cfg()
2659 qib_write_kreg(dd, kr_ibcddrctrl, ppd->cpspec->ibcddrctrl); in qib_7220_set_ib_cfg()
2662 spin_lock_irqsave(&ppd->lflags_lock, flags); in qib_7220_set_ib_cfg()
2663 ppd->lflags |= QIBL_IB_FORCE_NOTIFY; in qib_7220_set_ib_cfg()
2664 spin_unlock_irqrestore(&ppd->lflags_lock, flags); in qib_7220_set_ib_cfg()
2676 ppd->cpspec->ibcctrl |= SYM_MASK(IBCCtrl, Loopback); in qib_7220_set_loopback()
2678 qib_devinfo(ppd->dd->pcidev, "Enabling IB%u:%u IBC loopback\n", in qib_7220_set_loopback()
2679 ppd->dd->unit, ppd->port); in qib_7220_set_loopback()
2681 ppd->cpspec->ibcctrl &= ~SYM_MASK(IBCCtrl, Loopback); in qib_7220_set_loopback()
2684 qib_devinfo(ppd->dd->pcidev, in qib_7220_set_loopback()
2686 ppd->dd->unit, ppd->port); in qib_7220_set_loopback()
2688 ret = -EINVAL; in qib_7220_set_loopback()
2690 qib_write_kreg(ppd->dd, kr_ibcctrl, ppd->cpspec->ibcctrl); in qib_7220_set_loopback()
2691 ddr = ppd->cpspec->ibcddrctrl & ~(IBA7220_IBC_HRTBT_MASK in qib_7220_set_loopback()
2693 ppd->cpspec->ibcddrctrl = ddr | val; in qib_7220_set_loopback()
2694 qib_write_kreg(ppd->dd, kr_ibcddrctrl, in qib_7220_set_loopback()
2695 ppd->cpspec->ibcddrctrl); in qib_7220_set_loopback()
2696 qib_write_kreg(ppd->dd, kr_scratch, 0); in qib_7220_set_loopback()
2705 qib_write_ureg(rcd->dd, ur_rcvegrindexhead, egrhd, rcd->ctxt); in qib_update_7220_usrhead()
2706 qib_write_ureg(rcd->dd, ur_rcvhdrhead, hd, rcd->ctxt); in qib_update_7220_usrhead()
2713 head = qib_read_ureg32(rcd->dd, ur_rcvhdrhead, rcd->ctxt); in qib_7220_hdrqempty()
2714 if (rcd->rcvhdrtail_kvaddr) in qib_7220_hdrqempty()
2717 tail = qib_read_ureg32(rcd->dd, ur_rcvhdrtail, rcd->ctxt); in qib_7220_hdrqempty()
2722 * Modify the RCVCTRL register in chip-specific way. This
2724 * location is chip-specifc, but the needed operations are
2725 * generic. <op> is a bit-mask because we often want to
2731 struct qib_devdata *dd = ppd->dd; in rcvctrl_7220_mod()
2735 spin_lock_irqsave(&dd->cspec->rcvmod_lock, flags); in rcvctrl_7220_mod()
2737 dd->rcvctrl |= (1ULL << IBA7220_R_TAILUPD_SHIFT); in rcvctrl_7220_mod()
2739 dd->rcvctrl &= ~(1ULL << IBA7220_R_TAILUPD_SHIFT); in rcvctrl_7220_mod()
2741 dd->rcvctrl &= ~(1ULL << IBA7220_R_PKEY_DIS_SHIFT); in rcvctrl_7220_mod()
2743 dd->rcvctrl |= (1ULL << IBA7220_R_PKEY_DIS_SHIFT); in rcvctrl_7220_mod()
2745 mask = (1ULL << dd->ctxtcnt) - 1; in rcvctrl_7220_mod()
2750 dd->rcvctrl |= (mask << SYM_LSB(RcvCtrl, PortEnable)); in rcvctrl_7220_mod()
2751 if (!(dd->flags & QIB_NODMA_RTAIL)) in rcvctrl_7220_mod()
2752 dd->rcvctrl |= 1ULL << IBA7220_R_TAILUPD_SHIFT; in rcvctrl_7220_mod()
2755 dd->rcd[ctxt]->rcvhdrqtailaddr_phys); in rcvctrl_7220_mod()
2757 dd->rcd[ctxt]->rcvhdrq_phys); in rcvctrl_7220_mod()
2758 dd->rcd[ctxt]->seq_cnt = 1; in rcvctrl_7220_mod()
2761 dd->rcvctrl &= ~(mask << SYM_LSB(RcvCtrl, PortEnable)); in rcvctrl_7220_mod()
2763 dd->rcvctrl |= (mask << IBA7220_R_INTRAVAIL_SHIFT); in rcvctrl_7220_mod()
2765 dd->rcvctrl &= ~(mask << IBA7220_R_INTRAVAIL_SHIFT); in rcvctrl_7220_mod()
2766 qib_write_kreg(dd, kr_rcvctrl, dd->rcvctrl); in rcvctrl_7220_mod()
2767 if ((op & QIB_RCVCTRL_INTRAVAIL_ENB) && dd->rhdrhead_intr_off) { in rcvctrl_7220_mod()
2770 dd->rhdrhead_intr_off; in rcvctrl_7220_mod()
2784 dd->rcd[ctxt]->head = val; in rcvctrl_7220_mod()
2785 /* If kctxt, interrupt on next receive. */ in rcvctrl_7220_mod()
2786 if (ctxt < dd->first_user_ctxt) in rcvctrl_7220_mod()
2787 val |= dd->rhdrhead_intr_off; in rcvctrl_7220_mod()
2797 for (i = 0; i < dd->cfgctxts; i++) { in rcvctrl_7220_mod()
2804 spin_unlock_irqrestore(&dd->cspec->rcvmod_lock, flags); in rcvctrl_7220_mod()
2808 * Modify the SENDCTRL register in chip-specific way. This
2812 * Chip requires no back-back sendctrl writes, so write
2817 struct qib_devdata *dd = ppd->dd; in sendctrl_7220_mod()
2821 spin_lock_irqsave(&dd->sendctrl_lock, flags); in sendctrl_7220_mod()
2825 dd->sendctrl = 0; in sendctrl_7220_mod()
2827 dd->sendctrl &= ~SYM_MASK(SendCtrl, SPioEnable); in sendctrl_7220_mod()
2829 dd->sendctrl |= SYM_MASK(SendCtrl, SPioEnable); in sendctrl_7220_mod()
2830 if (dd->flags & QIB_USE_SPCL_TRIG) in sendctrl_7220_mod()
2831 dd->sendctrl |= SYM_MASK(SendCtrl, in sendctrl_7220_mod()
2835 dd->sendctrl &= ~SYM_MASK(SendCtrl, SendBufAvailUpd); in sendctrl_7220_mod()
2837 dd->sendctrl |= SYM_MASK(SendCtrl, SendBufAvailUpd); in sendctrl_7220_mod()
2842 tmp_dd_sendctrl = dd->sendctrl; in sendctrl_7220_mod()
2847 last = dd->piobcnt2k + dd->piobcnt4k; in sendctrl_7220_mod()
2859 tmp_dd_sendctrl = dd->sendctrl; in sendctrl_7220_mod()
2868 (dd->sendctrl & SYM_MASK(SendCtrl, SendBufAvailUpd))) in sendctrl_7220_mod()
2875 qib_write_kreg(dd, kr_sendctrl, dd->sendctrl); in sendctrl_7220_mod()
2879 spin_unlock_irqrestore(&dd->sendctrl_lock, flags); in sendctrl_7220_mod()
2886 * to occur, so in-memory copy is in sync with in sendctrl_7220_mod()
2898 * qib_portcntr_7220 - read a per-port counter
2905 struct qib_devdata *dd = ppd->dd; in qib_portcntr_7220()
2946 qib_devinfo(ppd->dd->pcidev, in qib_portcntr_7220()
2956 for (i = 0; i < dd->first_user_ctxt; i++) in qib_portcntr_7220()
2964 * avoid two independent reads when on opteron in qib_portcntr_7220()
2972 if (dd->pport->cpspec->ibdeltainprog) in qib_portcntr_7220()
2973 ret -= ret - ppd->cpspec->ibsymsnap; in qib_portcntr_7220()
2974 ret -= dd->pport->cpspec->ibsymdelta; in qib_portcntr_7220()
2976 if (dd->pport->cpspec->ibdeltainprog) in qib_portcntr_7220()
2977 ret -= ret - ppd->cpspec->iblnkerrsnap; in qib_portcntr_7220()
2978 ret -= dd->pport->cpspec->iblnkerrdelta; in qib_portcntr_7220()
2985 * Device counter names (not port-specific), one line per stat,
2990 * Non-error counters are first.
2991 * Start of "error" counters is indicated by a leading "E " on the first
3045 * same as cntr7220names and cntr7220indices, but for port-specific counters.
3057 "TxDmaDesc\n" /* 7220 and 7322-only */
3058 "E RxDlidFltr\n" /* 7220 and 7322-only */
3081 "RxLclPhyErr\n" /* 7220 and 7322-only */
3082 "RxVL15Drop\n" /* 7220 and 7322-only */
3083 "RxVlErr\n" /* 7220 and 7322-only */
3084 "XcessBufOvfl\n" /* 7220 and 7322-only */
3132 for (i = 0, s = (char *)cntr7220names; s && j <= dd->cfgctxts; in init_7220_cntrnames()
3141 dd->cspec->ncntrs = i; in init_7220_cntrnames()
3144 dd->cspec->cntrnamelen = sizeof(cntr7220names) - 1; in init_7220_cntrnames()
3146 dd->cspec->cntrnamelen = 1 + s - cntr7220names; in init_7220_cntrnames()
3147 dd->cspec->cntrs = kmalloc_array(dd->cspec->ncntrs, sizeof(u64), in init_7220_cntrnames()
3152 dd->cspec->nportcntrs = i - 1; in init_7220_cntrnames()
3153 dd->cspec->portcntrnamelen = sizeof(portcntr7220names) - 1; in init_7220_cntrnames()
3154 dd->cspec->portcntrs = kmalloc_array(dd->cspec->nportcntrs, in init_7220_cntrnames()
3164 if (!dd->cspec->cntrs) { in qib_read_7220cntrs()
3171 ret = dd->cspec->cntrnamelen; in qib_read_7220cntrs()
3175 u64 *cntr = dd->cspec->cntrs; in qib_read_7220cntrs()
3178 ret = dd->cspec->ncntrs * sizeof(u64); in qib_read_7220cntrs()
3186 for (i = 0; i < dd->cspec->ncntrs; i++) in qib_read_7220cntrs()
3198 if (!dd->cspec->portcntrs) { in qib_read_7220portcntrs()
3204 ret = dd->cspec->portcntrnamelen; in qib_read_7220portcntrs()
3208 u64 *cntr = dd->cspec->portcntrs; in qib_read_7220portcntrs()
3209 struct qib_pportdata *ppd = &dd->pport[port]; in qib_read_7220portcntrs()
3212 ret = dd->cspec->nportcntrs * sizeof(u64); in qib_read_7220portcntrs()
3219 for (i = 0; i < dd->cspec->nportcntrs; i++) { in qib_read_7220portcntrs()
3234 * qib_get_7220_faststats - get word counters from chip before they overflow
3237 * This needs more work; in particular, decision on whether we really
3244 struct qib_pportdata *ppd = dd->pport; in qib_get_7220_faststats()
3252 if (!(dd->flags & QIB_INITTED) || dd->diag_client) in qib_get_7220_faststats()
3253 /* but re-arm the timer, for diags case; won't hurt other */ in qib_get_7220_faststats()
3257 * We now try to maintain an activity timer, based on traffic in qib_get_7220_faststats()
3258 * exceeding a threshold, so we need to check the word-counts in qib_get_7220_faststats()
3259 * even if they are 64-bit. in qib_get_7220_faststats()
3263 spin_lock_irqsave(&dd->eep_st_lock, flags); in qib_get_7220_faststats()
3264 traffic_wds -= dd->traffic_wds; in qib_get_7220_faststats()
3265 dd->traffic_wds += traffic_wds; in qib_get_7220_faststats()
3266 spin_unlock_irqrestore(&dd->eep_st_lock, flags); in qib_get_7220_faststats()
3268 mod_timer(&dd->stats_timer, jiffies + HZ * ACTIVITY_TIMER); in qib_get_7220_faststats()
3276 if (!dd->msi_lo) in qib_7220_intr_fallback()
3279 qib_devinfo(dd->pcidev, in qib_7220_intr_fallback()
3283 dd->msi_lo = 0; in qib_7220_intr_fallback()
3284 if (pci_alloc_irq_vectors(dd->pcidev, 1, 1, PCI_IRQ_INTX) < 0) in qib_7220_intr_fallback()
3299 struct qib_devdata *dd = ppd->dd; in qib_7220_xgxs_reset()
3305 dd->control & ~QLOGIC_IB_C_LINKENABLE); in qib_7220_xgxs_reset()
3309 qib_write_kreg(dd, kr_control, dd->control); in qib_7220_xgxs_reset()
3322 * We don't need very complicated heuristics on whether the packet had
3330 u32 lbuf = ppd->dd->cspec->lastbuf_for_pio; in get_7220_link_buf()
3338 sendctrl_7220_mod(ppd->dd->pport, QIB_SENDCTRL_AVAIL_BLIP); in get_7220_link_buf()
3339 qib_read_kreg64(ppd->dd, kr_scratch); /* extra chip flush */ in get_7220_link_buf()
3340 buf = qib_getsendbuf_range(ppd->dd, bnum, lbuf, lbuf); in get_7220_link_buf()
3344 spin_lock_irqsave(&ppd->sdma_lock, flags); in get_7220_link_buf()
3345 if (ppd->sdma_state.current_state == qib_sdma_state_s20_idle && in get_7220_link_buf()
3346 ppd->sdma_state.current_state != qib_sdma_state_s00_hw_down) { in get_7220_link_buf()
3353 spin_unlock_irqrestore(&ppd->sdma_lock, flags); in get_7220_link_buf()
3356 qib_read_kreg64(ppd->dd, kr_scratch); /* extra chip flush */ in get_7220_link_buf()
3357 buf = qib_getsendbuf_range(ppd->dd, bnum, lbuf, lbuf); in get_7220_link_buf()
3364 * This code for non-IBTA-compliant IB speed negotiation is only known to
3366 * with recent firmware. It is based on observed heuristics, rather than
3367 * actual knowledge of the non-compliant speed negotiation.
3368 * It has a number of hard-coded fields, since the hope is to rewrite this
3369 * when a spec is available on how the negoation is intended to work.
3378 struct qib_devdata *dd = ppd->dd; in autoneg_7220_sendpkt()
3388 sendctrl_7220_mod(dd->pport, QIB_SENDCTRL_DISARM_BUF(pnum)); in autoneg_7220_sendpkt()
3393 if (dd->flags & QIB_USE_SPCL_TRIG) { in autoneg_7220_sendpkt()
3394 u32 spcl_off = (pnum >= dd->piobcnt2k) ? 2047 : 1023; in autoneg_7220_sendpkt()
3408 struct qib_devdata *dd = ppd->dd; in autoneg_7220_send()
3466 ppd->cpspec->ibcddrctrl &= ~(IBA7220_IBC_SPEED_AUTONEG_MASK | in set_7220_ibspeed_fast()
3470 ppd->cpspec->ibcddrctrl |= IBA7220_IBC_SPEED_AUTONEG_MASK | in set_7220_ibspeed_fast()
3473 ppd->cpspec->ibcddrctrl |= speed == QIB_IB_DDR ? in set_7220_ibspeed_fast()
3476 qib_write_kreg(ppd->dd, kr_ibcddrctrl, ppd->cpspec->ibcddrctrl); in set_7220_ibspeed_fast()
3477 qib_write_kreg(ppd->dd, kr_scratch, 0); in set_7220_ibspeed_fast()
3482 * IB 1.2-compliant device that we think can do DDR.
3484 * 1.2-compliant devices go directly to DDR prior to reaching INIT
3491 * Required for older non-IB1.2 DDR switches. Newer in try_7220_autoneg()
3492 * non-IB-compliant switches don't need it, but so far, in try_7220_autoneg()
3495 qib_write_kreg(ppd->dd, kr_ncmodectrl, 0x3b9dc07); in try_7220_autoneg()
3497 spin_lock_irqsave(&ppd->lflags_lock, flags); in try_7220_autoneg()
3498 ppd->lflags |= QIBL_IB_AUTONEG_INPROG; in try_7220_autoneg()
3499 spin_unlock_irqrestore(&ppd->lflags_lock, flags); in try_7220_autoneg()
3503 toggle_7220_rclkrls(ppd->dd); in try_7220_autoneg()
3505 queue_delayed_work(ib_wq, &ppd->cpspec->autoneg_work, in try_7220_autoneg()
3510 * Handle the empirically determined mechanism for auto-negotiation
3521 autoneg_work.work)->pportdata; in autoneg_7220_work()
3522 dd = ppd->dd; in autoneg_7220_work()
3529 if (SYM_FIELD(ppd->lastibcstat, IBCStatus, LinkTrainingState) in autoneg_7220_work()
3537 if (!(ppd->lflags & QIBL_IB_AUTONEG_INPROG)) in autoneg_7220_work()
3541 if (wait_event_timeout(ppd->cpspec->autoneg_wait, in autoneg_7220_work()
3542 !(ppd->lflags & QIBL_IB_AUTONEG_INPROG), in autoneg_7220_work()
3549 if (wait_event_timeout(ppd->cpspec->autoneg_wait, in autoneg_7220_work()
3550 !(ppd->lflags & QIBL_IB_AUTONEG_INPROG), in autoneg_7220_work()
3561 wait_event_timeout(ppd->cpspec->autoneg_wait, in autoneg_7220_work()
3562 !(ppd->lflags & QIBL_IB_AUTONEG_INPROG), in autoneg_7220_work()
3565 if (ppd->lflags & QIBL_IB_AUTONEG_INPROG) { in autoneg_7220_work()
3566 spin_lock_irqsave(&ppd->lflags_lock, flags); in autoneg_7220_work()
3567 ppd->lflags &= ~QIBL_IB_AUTONEG_INPROG; in autoneg_7220_work()
3568 if (dd->cspec->autoneg_tries == AUTONEG_TRIES) { in autoneg_7220_work()
3569 ppd->lflags |= QIBL_IB_AUTONEG_FAILED; in autoneg_7220_work()
3570 dd->cspec->autoneg_tries = 0; in autoneg_7220_work()
3572 spin_unlock_irqrestore(&ppd->lflags_lock, flags); in autoneg_7220_work()
3573 set_7220_ibspeed_fast(ppd, ppd->link_speed_enabled); in autoneg_7220_work()
3611 struct qib_devdata *dd = ppd->dd; in qib_7220_ib_updown()
3614 spin_lock_irqsave(&ppd->lflags_lock, flags); in qib_7220_ib_updown()
3615 ppd->lflags &= ~QIBL_IB_FORCE_NOTIFY; in qib_7220_ib_updown()
3616 spin_unlock_irqrestore(&ppd->lflags_lock, flags); in qib_7220_ib_updown()
3624 if (!(ppd->lflags & (QIBL_IB_AUTONEG_FAILED | in qib_7220_ib_updown()
3626 set_7220_ibspeed_fast(ppd, ppd->link_speed_enabled); in qib_7220_ib_updown()
3627 if (!(ppd->lflags & QIBL_IB_AUTONEG_INPROG)) { in qib_7220_ib_updown()
3630 spin_lock_irqsave(&ppd->sdma_lock, flags); in qib_7220_ib_updown()
3634 spin_unlock_irqrestore(&ppd->sdma_lock, flags); in qib_7220_ib_updown()
3640 !(ppd->lflags & (QIBL_IB_AUTONEG_FAILED | in qib_7220_ib_updown()
3642 ppd->link_speed_active == QIB_IB_SDR && in qib_7220_ib_updown()
3643 (ppd->link_speed_enabled & (QIB_IB_DDR | QIB_IB_SDR)) == in qib_7220_ib_updown()
3645 dd->cspec->autoneg_tries < AUTONEG_TRIES) { in qib_7220_ib_updown()
3646 /* we are SDR, and DDR auto-negotiation enabled */ in qib_7220_ib_updown()
3647 ++dd->cspec->autoneg_tries; in qib_7220_ib_updown()
3648 if (!ppd->cpspec->ibdeltainprog) { in qib_7220_ib_updown()
3649 ppd->cpspec->ibdeltainprog = 1; in qib_7220_ib_updown()
3650 ppd->cpspec->ibsymsnap = read_7220_creg32(dd, in qib_7220_ib_updown()
3652 ppd->cpspec->iblnkerrsnap = read_7220_creg32(dd, in qib_7220_ib_updown()
3657 } else if ((ppd->lflags & QIBL_IB_AUTONEG_INPROG) && in qib_7220_ib_updown()
3658 ppd->link_speed_active == QIB_IB_SDR) { in qib_7220_ib_updown()
3665 if ((ppd->lflags & QIBL_IB_AUTONEG_INPROG) && in qib_7220_ib_updown()
3666 (ppd->link_speed_active & QIB_IB_DDR)) { in qib_7220_ib_updown()
3667 spin_lock_irqsave(&ppd->lflags_lock, flags); in qib_7220_ib_updown()
3668 ppd->lflags &= ~(QIBL_IB_AUTONEG_INPROG | in qib_7220_ib_updown()
3670 spin_unlock_irqrestore(&ppd->lflags_lock, in qib_7220_ib_updown()
3672 dd->cspec->autoneg_tries = 0; in qib_7220_ib_updown()
3673 /* re-enable SDR, for next link down */ in qib_7220_ib_updown()
3675 ppd->link_speed_enabled); in qib_7220_ib_updown()
3676 wake_up(&ppd->cpspec->autoneg_wait); in qib_7220_ib_updown()
3678 } else if (ppd->lflags & QIBL_IB_AUTONEG_FAILED) { in qib_7220_ib_updown()
3685 spin_lock_irqsave(&ppd->lflags_lock, flags); in qib_7220_ib_updown()
3686 ppd->lflags &= ~QIBL_IB_AUTONEG_FAILED; in qib_7220_ib_updown()
3687 spin_unlock_irqrestore(&ppd->lflags_lock, in qib_7220_ib_updown()
3689 ppd->cpspec->ibcddrctrl |= in qib_7220_ib_updown()
3696 if (!(ppd->lflags & QIBL_IB_AUTONEG_INPROG)) in qib_7220_ib_updown()
3700 ppd->delay_mult = rate_to_delay in qib_7220_ib_updown()
3705 spin_lock_irqsave(&ppd->sdma_lock, flags); in qib_7220_ib_updown()
3711 if (ppd->sdma_state.current_state != in qib_7220_ib_updown()
3715 spin_unlock_irqrestore(&ppd->sdma_lock, flags); in qib_7220_ib_updown()
3720 if (ppd->cpspec->ibdeltainprog) { in qib_7220_ib_updown()
3721 ppd->cpspec->ibdeltainprog = 0; in qib_7220_ib_updown()
3722 ppd->cpspec->ibsymdelta += read_7220_creg32(ppd->dd, in qib_7220_ib_updown()
3723 cr_ibsymbolerr) - ppd->cpspec->ibsymsnap; in qib_7220_ib_updown()
3724 ppd->cpspec->iblnkerrdelta += read_7220_creg32(ppd->dd, in qib_7220_ib_updown()
3725 cr_iblinkerrrecov) - ppd->cpspec->iblnkerrsnap; in qib_7220_ib_updown()
3728 !ppd->cpspec->ibdeltainprog && in qib_7220_ib_updown()
3729 !(ppd->lflags & QIBL_IB_AUTONEG_INPROG)) { in qib_7220_ib_updown()
3730 ppd->cpspec->ibdeltainprog = 1; in qib_7220_ib_updown()
3731 ppd->cpspec->ibsymsnap = read_7220_creg32(ppd->dd, in qib_7220_ib_updown()
3733 ppd->cpspec->iblnkerrsnap = read_7220_creg32(ppd->dd, in qib_7220_ib_updown()
3746 * dir will end up in D48 of extctrl on existing chips).
3758 spin_lock_irqsave(&dd->cspec->gpio_lock, flags); in gpio_7220_mod()
3759 dd->cspec->extctrl &= ~((u64)mask << SYM_LSB(EXTCtrl, GPIOOe)); in gpio_7220_mod()
3760 dd->cspec->extctrl |= ((u64) dir << SYM_LSB(EXTCtrl, GPIOOe)); in gpio_7220_mod()
3761 new_out = (dd->cspec->gpio_out & ~mask) | out; in gpio_7220_mod()
3763 qib_write_kreg(dd, kr_extctrl, dd->cspec->extctrl); in gpio_7220_mod()
3765 dd->cspec->gpio_out = new_out; in gpio_7220_mod()
3766 spin_unlock_irqrestore(&dd->cspec->gpio_lock, flags); in gpio_7220_mod()
3770 * data on a pin whose direction line was set in the same in gpio_7220_mod()
3772 * that allows us to potentially combine a change on one pin with in gpio_7220_mod()
3773 * a read on another, and because the old code did something like in gpio_7220_mod()
3791 dd->uregbase = qib_read_kreg32(dd, kr_userregbase); in get_7220_chip_params()
3793 dd->rcvtidcnt = qib_read_kreg32(dd, kr_rcvtidcnt); in get_7220_chip_params()
3794 dd->rcvtidbase = qib_read_kreg32(dd, kr_rcvtidbase); in get_7220_chip_params()
3795 dd->rcvegrbase = qib_read_kreg32(dd, kr_rcvegrbase); in get_7220_chip_params()
3796 dd->palign = qib_read_kreg32(dd, kr_palign); in get_7220_chip_params()
3797 dd->piobufbase = qib_read_kreg64(dd, kr_sendpiobufbase); in get_7220_chip_params()
3798 dd->pio2k_bufbase = dd->piobufbase & 0xffffffff; in get_7220_chip_params()
3801 dd->piosize2k = val & ~0U; in get_7220_chip_params()
3802 dd->piosize4k = val >> 32; in get_7220_chip_params()
3805 if (mtu == -1) in get_7220_chip_params()
3807 dd->pport->ibmtu = (u32)mtu; in get_7220_chip_params()
3810 dd->piobcnt2k = val & ~0U; in get_7220_chip_params()
3811 dd->piobcnt4k = val >> 32; in get_7220_chip_params()
3813 dd->pio2kbase = (u32 __iomem *) in get_7220_chip_params()
3814 ((char __iomem *) dd->kregbase + dd->pio2k_bufbase); in get_7220_chip_params()
3815 if (dd->piobcnt4k) { in get_7220_chip_params()
3816 dd->pio4kbase = (u32 __iomem *) in get_7220_chip_params()
3817 ((char __iomem *) dd->kregbase + in get_7220_chip_params()
3818 (dd->piobufbase >> 32)); in get_7220_chip_params()
3821 * paranoid; we calculate it once here, rather than on in get_7220_chip_params()
3824 dd->align4k = ALIGN(dd->piosize4k, dd->palign); in get_7220_chip_params()
3827 piobufs = dd->piobcnt4k + dd->piobcnt2k; in get_7220_chip_params()
3829 dd->pioavregs = ALIGN(piobufs, sizeof(u64) * BITS_PER_BYTE / 2) / in get_7220_chip_params()
3841 /* init after possible re-map in init_chip_wc_pat() */ in set_7220_baseaddrs()
3843 dd->cspec->cregbase = (u64 __iomem *) in set_7220_baseaddrs()
3844 ((char __iomem *) dd->kregbase + cregbase); in set_7220_baseaddrs()
3846 dd->egrtidbase = (u64 __iomem *) in set_7220_baseaddrs()
3847 ((char __iomem *) dd->kregbase + dd->rcvegrbase); in set_7220_baseaddrs()
3870 qib_dev_err(dd, "SendCtrl Hook called with offs %X, %s-bit\n", in sendctrl_hook()
3878 spin_lock_irqsave(&dd->sendctrl_lock, flags); in sendctrl_hook()
3883 * reg or shadow. First-cut: read reg, and complain in sendctrl_hook()
3891 qib_dev_err(dd, "Sendctrl -> %X, Shad -> %X\n", in sendctrl_hook()
3892 (u32)local_data, (u32)dd->sendctrl); in sendctrl_hook()
3894 (dd->sendctrl & SENDCTRL_SHADOWED)) in sendctrl_hook()
3896 (u32)local_data, (u32) dd->sendctrl); in sendctrl_hook()
3910 sval = (dd->sendctrl & ~mask); in sendctrl_hook()
3912 dd->sendctrl = sval; in sendctrl_hook()
3914 qib_dev_err(dd, "Sendctrl <- %X, Shad <- %X\n", in sendctrl_hook()
3919 spin_unlock_irqrestore(&dd->sendctrl_lock, flags); in sendctrl_hook()
3930 * write the final few registers that depend on some of the
3939 qib_write_kreg(dd, kr_rcvhdrentsize, dd->rcvhdrentsize); in qib_late_7220_initreg()
3940 qib_write_kreg(dd, kr_rcvhdrsize, dd->rcvhdrsize); in qib_late_7220_initreg()
3941 qib_write_kreg(dd, kr_rcvhdrcnt, dd->rcvhdrcnt); in qib_late_7220_initreg()
3942 qib_write_kreg(dd, kr_sendpioavailaddr, dd->pioavailregs_phys); in qib_late_7220_initreg()
3944 if (val != dd->pioavailregs_phys) { in qib_late_7220_initreg()
3947 (unsigned long) dd->pioavailregs_phys, in qib_late_7220_initreg()
3949 ret = -EINVAL; in qib_late_7220_initreg()
3963 ppd = &cpspec->pportdata; in qib_init_7220_variables()
3964 dd->pport = ppd; in qib_init_7220_variables()
3965 dd->num_pports = 1; in qib_init_7220_variables()
3967 dd->cspec = (struct qib_chip_specific *)(cpspec + dd->num_pports); in qib_init_7220_variables()
3968 dd->cspec->dd = dd; in qib_init_7220_variables()
3969 ppd->cpspec = cpspec; in qib_init_7220_variables()
3971 spin_lock_init(&dd->cspec->sdepb_lock); in qib_init_7220_variables()
3972 spin_lock_init(&dd->cspec->rcvmod_lock); in qib_init_7220_variables()
3973 spin_lock_init(&dd->cspec->gpio_lock); in qib_init_7220_variables()
3976 dd->revision = readq(&dd->kregbase[kr_revision]); in qib_init_7220_variables()
3978 if ((dd->revision & 0xffffffffU) == 0xffffffffU) { in qib_init_7220_variables()
3981 ret = -ENODEV; in qib_init_7220_variables()
3984 dd->flags |= QIB_PRESENT; /* now register routines work */ in qib_init_7220_variables()
3986 dd->majrev = (u8) SYM_FIELD(dd->revision, Revision_R, in qib_init_7220_variables()
3988 dd->minrev = (u8) SYM_FIELD(dd->revision, Revision_R, in qib_init_7220_variables()
3998 dd->gpio_sda_num = _QIB_GPIO_SDA_NUM; in qib_init_7220_variables()
3999 dd->gpio_scl_num = _QIB_GPIO_SCL_NUM; in qib_init_7220_variables()
4000 dd->twsi_eeprom_dev = QIB_TWSI_EEPROM_DEV; in qib_init_7220_variables()
4002 dd->flags |= QIB_HAS_INTX | QIB_HAS_LINK_LATENCY | in qib_init_7220_variables()
4004 dd->flags |= qib_special_trigger ? in qib_init_7220_variables()
4007 init_waitqueue_head(&cpspec->autoneg_wait); in qib_init_7220_variables()
4008 INIT_DELAYED_WORK(&cpspec->autoneg_work, autoneg_7220_work); in qib_init_7220_variables()
4013 ppd->link_width_supported = IB_WIDTH_1X | IB_WIDTH_4X; in qib_init_7220_variables()
4014 ppd->link_speed_supported = QIB_IB_SDR | QIB_IB_DDR; in qib_init_7220_variables()
4016 ppd->link_width_enabled = ppd->link_width_supported; in qib_init_7220_variables()
4017 ppd->link_speed_enabled = ppd->link_speed_supported; in qib_init_7220_variables()
4022 ppd->link_width_active = IB_WIDTH_4X; in qib_init_7220_variables()
4023 ppd->link_speed_active = QIB_IB_SDR; in qib_init_7220_variables()
4024 ppd->delay_mult = rate_to_delay[0][1]; in qib_init_7220_variables()
4025 ppd->vls_supported = IB_VL_VL0; in qib_init_7220_variables()
4026 ppd->vls_operational = ppd->vls_supported; in qib_init_7220_variables()
4031 timer_setup(&ppd->cpspec->chase_timer, reenable_7220_chase, 0); in qib_init_7220_variables()
4035 dd->rcvhdrentsize = QIB_RCVHDR_ENTSIZE; in qib_init_7220_variables()
4036 dd->rcvhdrsize = QIB_DFLT_RCVHDRSIZE; in qib_init_7220_variables()
4037 dd->rhf_offset = in qib_init_7220_variables()
4038 dd->rcvhdrentsize - sizeof(u64) / sizeof(u32); in qib_init_7220_variables()
4042 dd->rcvegrbufsize = ret != -1 ? max(ret, 2048) : QIB_DEFAULT_MTU; in qib_init_7220_variables()
4043 dd->rcvegrbufsize_shift = ilog2(dd->rcvegrbufsize); in qib_init_7220_variables()
4052 dd->rhdrhead_intr_off = 1ULL << 32; in qib_init_7220_variables()
4055 timer_setup(&dd->stats_timer, qib_get_7220_faststats, 0); in qib_init_7220_variables()
4056 dd->stats_timer.expires = jiffies + ACTIVITY_TIMER * HZ; in qib_init_7220_variables()
4064 dd->control |= 1 << 4; in qib_init_7220_variables()
4066 dd->ureg_align = 0x10000; /* 64KB alignment */ in qib_init_7220_variables()
4068 dd->piosize2kmax_dwords = (dd->piosize2k >> 2)-1; in qib_init_7220_variables()
4095 if (dd->flags & QIB_HAS_SEND_DMA) { in qib_init_7220_variables()
4096 dd->cspec->sdmabufcnt = dd->piobcnt4k; in qib_init_7220_variables()
4099 dd->cspec->sdmabufcnt = 0; in qib_init_7220_variables()
4100 sbufs = dd->piobcnt4k; in qib_init_7220_variables()
4103 dd->cspec->lastbuf_for_pio = dd->piobcnt2k + dd->piobcnt4k - in qib_init_7220_variables()
4104 dd->cspec->sdmabufcnt; in qib_init_7220_variables()
4105 dd->lastctxt_piobuf = dd->cspec->lastbuf_for_pio - sbufs; in qib_init_7220_variables()
4106 dd->cspec->lastbuf_for_pio--; /* range is <= , not < */ in qib_init_7220_variables()
4107 dd->last_pio = dd->cspec->lastbuf_for_pio; in qib_init_7220_variables()
4108 dd->pbufsctxt = dd->lastctxt_piobuf / in qib_init_7220_variables()
4109 (dd->cfgctxts - dd->first_user_ctxt); in qib_init_7220_variables()
4117 if ((dd->pbufsctxt - 2) < updthresh) in qib_init_7220_variables()
4118 updthresh = dd->pbufsctxt - 2; in qib_init_7220_variables()
4120 dd->cspec->updthresh_dflt = updthresh; in qib_init_7220_variables()
4121 dd->cspec->updthresh = updthresh; in qib_init_7220_variables()
4124 dd->sendctrl |= (updthresh & SYM_RMASK(SendCtrl, AvailUpdThld)) in qib_init_7220_variables()
4127 dd->psxmitwait_supported = 1; in qib_init_7220_variables()
4128 dd->psxmitwait_check_rate = QIB_7220_PSXMITWAIT_CHECK_RATE; in qib_init_7220_variables()
4137 struct qib_devdata *dd = ppd->dd; in qib_7220_getsendbuf()
4141 !(ppd->lflags & (QIBL_IB_AUTONEG_INPROG | QIBL_LINKACTIVE))) in qib_7220_getsendbuf()
4144 if ((plen + 1) > dd->piosize2kmax_dwords) in qib_7220_getsendbuf()
4145 first = dd->piobcnt2k; in qib_7220_getsendbuf()
4149 last = dd->cspec->lastbuf_for_pio; in qib_7220_getsendbuf()
4159 write_7220_creg(ppd->dd, cr_psinterval, intv); in qib_set_cntr_7220_sample()
4160 write_7220_creg(ppd->dd, cr_psstart, start); in qib_set_cntr_7220_sample()
4172 /* Commit writes to memory and advance the tail on the chip */ in qib_sdma_update_7220_tail()
4174 ppd->sdma_descq_tail = tail; in qib_sdma_update_7220_tail()
4175 qib_write_kreg(ppd->dd, kr_senddmatail, tail); in qib_sdma_update_7220_tail()
4224 ppd->sdma_state.set_state_action = sdma_7220_action_table; in qib_7220_sdma_init_early()
4229 struct qib_devdata *dd = ppd->dd; in init_sdma_7220_regs()
4234 qib_write_kreg(dd, kr_senddmabase, ppd->sdma_descq_phys); in init_sdma_7220_regs()
4238 qib_write_kreg(dd, kr_senddmaheadaddr, ppd->sdma_head_phys); in init_sdma_7220_regs()
4244 n = dd->piobcnt2k + dd->piobcnt4k; in init_sdma_7220_regs()
4245 i = n - dd->cspec->sdmabufcnt; in init_sdma_7220_regs()
4257 ppd->sdma_state.first_sendbuf = i; in init_sdma_7220_regs()
4258 ppd->sdma_state.last_sendbuf = n; in init_sdma_7220_regs()
4266 struct qib_devdata *dd = ppd->dd; in qib_sdma_7220_gethead()
4275 (dd->flags & QIB_HAS_SDMA_TIMEOUT); in qib_sdma_7220_gethead()
4278 (u16)le64_to_cpu(*ppd->sdma_head_dma) : in qib_sdma_7220_gethead()
4281 swhead = ppd->sdma_descq_head; in qib_sdma_7220_gethead()
4282 swtail = ppd->sdma_descq_tail; in qib_sdma_7220_gethead()
4283 cnt = ppd->sdma_descq_cnt; in qib_sdma_7220_gethead()
4312 u64 hwstatus = qib_read_kreg64(ppd->dd, kr_senddmastatus); in qib_sdma_7220_busy()
4324 * based on the length of the previous packet, use the last delay computed
4331 u8 snd_mult = ppd->delay_mult; in qib_7220_setpbc_control()
4333 u32 ret = ppd->cpspec->last_delay_mult; in qib_7220_setpbc_control()
4335 ppd->cpspec->last_delay_mult = (rcv_mult > snd_mult) ? in qib_7220_setpbc_control()
4336 (plen * (rcv_mult - snd_mult) + 1) >> 1 : 0; in qib_7220_setpbc_control()
4350 if (!rcd->ctxt) { in qib_7220_init_ctxt()
4351 rcd->rcvegrcnt = IBA7220_KRCVEGRCNT; in qib_7220_init_ctxt()
4352 rcd->rcvegr_tid_base = 0; in qib_7220_init_ctxt()
4354 rcd->rcvegrcnt = rcd->dd->cspec->rcvegrcnt; in qib_7220_init_ctxt()
4355 rcd->rcvegr_tid_base = IBA7220_KRCVEGRCNT + in qib_7220_init_ctxt()
4356 (rcd->ctxt - 1) * rcd->rcvegrcnt; in qib_7220_init_ctxt()
4369 spin_lock_irqsave(&dd->uctxt_lock, flags); in qib_7220_txchk_change()
4370 for (i = dd->first_user_ctxt; in qib_7220_txchk_change()
4371 dd->cspec->updthresh != dd->cspec->updthresh_dflt in qib_7220_txchk_change()
4372 && i < dd->cfgctxts; i++) in qib_7220_txchk_change()
4373 if (dd->rcd[i] && dd->rcd[i]->subctxt_cnt && in qib_7220_txchk_change()
4374 ((dd->rcd[i]->piocnt / dd->rcd[i]->subctxt_cnt) - 1) in qib_7220_txchk_change()
4375 < dd->cspec->updthresh_dflt) in qib_7220_txchk_change()
4377 spin_unlock_irqrestore(&dd->uctxt_lock, flags); in qib_7220_txchk_change()
4378 if (i == dd->cfgctxts) { in qib_7220_txchk_change()
4379 spin_lock_irqsave(&dd->sendctrl_lock, flags); in qib_7220_txchk_change()
4380 dd->cspec->updthresh = dd->cspec->updthresh_dflt; in qib_7220_txchk_change()
4381 dd->sendctrl &= ~SYM_MASK(SendCtrl, AvailUpdThld); in qib_7220_txchk_change()
4382 dd->sendctrl |= (dd->cspec->updthresh & in qib_7220_txchk_change()
4385 spin_unlock_irqrestore(&dd->sendctrl_lock, flags); in qib_7220_txchk_change()
4386 sendctrl_7220_mod(dd->pport, QIB_SENDCTRL_AVAIL_BLIP); in qib_7220_txchk_change()
4390 spin_lock_irqsave(&dd->sendctrl_lock, flags); in qib_7220_txchk_change()
4391 if (rcd && rcd->subctxt_cnt && ((rcd->piocnt in qib_7220_txchk_change()
4392 / rcd->subctxt_cnt) - 1) < dd->cspec->updthresh) { in qib_7220_txchk_change()
4393 dd->cspec->updthresh = (rcd->piocnt / in qib_7220_txchk_change()
4394 rcd->subctxt_cnt) - 1; in qib_7220_txchk_change()
4395 dd->sendctrl &= ~SYM_MASK(SendCtrl, AvailUpdThld); in qib_7220_txchk_change()
4396 dd->sendctrl |= (dd->cspec->updthresh & in qib_7220_txchk_change()
4399 spin_unlock_irqrestore(&dd->sendctrl_lock, flags); in qib_7220_txchk_change()
4400 sendctrl_7220_mod(dd->pport, QIB_SENDCTRL_AVAIL_BLIP); in qib_7220_txchk_change()
4402 spin_unlock_irqrestore(&dd->sendctrl_lock, flags); in qib_7220_txchk_change()
4414 * qib_7220_tempsense_rd - read register of temp sensor via TWSI
4426 ret = -EINVAL; in qib_7220_tempsense_rd()
4436 ret = mutex_lock_interruptible(&dd->eep_lock); in qib_7220_tempsense_rd()
4444 mutex_unlock(&dd->eep_lock); in qib_7220_tempsense_rd()
4449 * ret is -ENXIO or -EINVAL from twsi code or this file in qib_7220_tempsense_rd()
4450 * ret is -EINTR from mutex_lock_interruptible. in qib_7220_tempsense_rd()
4470 * qib_init_iba7220_funcs - set up the chip-specific function pointers
4475 * chip-specific function pointers for later use.
4489 dd->f_bringup_serdes = qib_7220_bringup_serdes; in qib_init_iba7220_funcs()
4490 dd->f_cleanup = qib_setup_7220_cleanup; in qib_init_iba7220_funcs()
4491 dd->f_clear_tids = qib_7220_clear_tids; in qib_init_iba7220_funcs()
4492 dd->f_free_irq = qib_free_irq; in qib_init_iba7220_funcs()
4493 dd->f_get_base_info = qib_7220_get_base_info; in qib_init_iba7220_funcs()
4494 dd->f_get_msgheader = qib_7220_get_msgheader; in qib_init_iba7220_funcs()
4495 dd->f_getsendbuf = qib_7220_getsendbuf; in qib_init_iba7220_funcs()
4496 dd->f_gpio_mod = gpio_7220_mod; in qib_init_iba7220_funcs()
4497 dd->f_eeprom_wen = qib_7220_eeprom_wen; in qib_init_iba7220_funcs()
4498 dd->f_hdrqempty = qib_7220_hdrqempty; in qib_init_iba7220_funcs()
4499 dd->f_ib_updown = qib_7220_ib_updown; in qib_init_iba7220_funcs()
4500 dd->f_init_ctxt = qib_7220_init_ctxt; in qib_init_iba7220_funcs()
4501 dd->f_initvl15_bufs = qib_7220_initvl15_bufs; in qib_init_iba7220_funcs()
4502 dd->f_intr_fallback = qib_7220_intr_fallback; in qib_init_iba7220_funcs()
4503 dd->f_late_initreg = qib_late_7220_initreg; in qib_init_iba7220_funcs()
4504 dd->f_setpbc_control = qib_7220_setpbc_control; in qib_init_iba7220_funcs()
4505 dd->f_portcntr = qib_portcntr_7220; in qib_init_iba7220_funcs()
4506 dd->f_put_tid = qib_7220_put_tid; in qib_init_iba7220_funcs()
4507 dd->f_quiet_serdes = qib_7220_quiet_serdes; in qib_init_iba7220_funcs()
4508 dd->f_rcvctrl = rcvctrl_7220_mod; in qib_init_iba7220_funcs()
4509 dd->f_read_cntrs = qib_read_7220cntrs; in qib_init_iba7220_funcs()
4510 dd->f_read_portcntrs = qib_read_7220portcntrs; in qib_init_iba7220_funcs()
4511 dd->f_reset = qib_setup_7220_reset; in qib_init_iba7220_funcs()
4512 dd->f_init_sdma_regs = init_sdma_7220_regs; in qib_init_iba7220_funcs()
4513 dd->f_sdma_busy = qib_sdma_7220_busy; in qib_init_iba7220_funcs()
4514 dd->f_sdma_gethead = qib_sdma_7220_gethead; in qib_init_iba7220_funcs()
4515 dd->f_sdma_sendctrl = qib_7220_sdma_sendctrl; in qib_init_iba7220_funcs()
4516 dd->f_sdma_set_desc_cnt = qib_sdma_set_7220_desc_cnt; in qib_init_iba7220_funcs()
4517 dd->f_sdma_update_tail = qib_sdma_update_7220_tail; in qib_init_iba7220_funcs()
4518 dd->f_sdma_hw_clean_up = qib_7220_sdma_hw_clean_up; in qib_init_iba7220_funcs()
4519 dd->f_sdma_hw_start_up = qib_7220_sdma_hw_start_up; in qib_init_iba7220_funcs()
4520 dd->f_sdma_init_early = qib_7220_sdma_init_early; in qib_init_iba7220_funcs()
4521 dd->f_sendctrl = sendctrl_7220_mod; in qib_init_iba7220_funcs()
4522 dd->f_set_armlaunch = qib_set_7220_armlaunch; in qib_init_iba7220_funcs()
4523 dd->f_set_cntr_sample = qib_set_cntr_7220_sample; in qib_init_iba7220_funcs()
4524 dd->f_iblink_state = qib_7220_iblink_state; in qib_init_iba7220_funcs()
4525 dd->f_ibphys_portstate = qib_7220_phys_portstate; in qib_init_iba7220_funcs()
4526 dd->f_get_ib_cfg = qib_7220_get_ib_cfg; in qib_init_iba7220_funcs()
4527 dd->f_set_ib_cfg = qib_7220_set_ib_cfg; in qib_init_iba7220_funcs()
4528 dd->f_set_ib_loopback = qib_7220_set_loopback; in qib_init_iba7220_funcs()
4529 dd->f_set_intr_state = qib_7220_set_intr_state; in qib_init_iba7220_funcs()
4530 dd->f_setextled = qib_setup_7220_setextled; in qib_init_iba7220_funcs()
4531 dd->f_txchk_change = qib_7220_txchk_change; in qib_init_iba7220_funcs()
4532 dd->f_update_usrhead = qib_update_7220_usrhead; in qib_init_iba7220_funcs()
4533 dd->f_wantpiobuf_intr = qib_wantpiobuf_7220_intr; in qib_init_iba7220_funcs()
4534 dd->f_xgxs_reset = qib_7220_xgxs_reset; in qib_init_iba7220_funcs()
4535 dd->f_writescratch = writescratch; in qib_init_iba7220_funcs()
4536 dd->f_tempsense_rd = qib_7220_tempsense_rd; in qib_init_iba7220_funcs()
4538 dd->f_notify_dca = qib_7220_notify_dca; in qib_init_iba7220_funcs()
4543 * On return, we have the chip mapped, but chip registers in qib_init_iba7220_funcs()
4550 /* initialize chip-specific variables */ in qib_init_iba7220_funcs()
4558 boardid = SYM_FIELD(dd->revision, Revision, in qib_init_iba7220_funcs()