Lines Matching +full:ipmi +full:- +full:bt

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
308 * Each tunable is set to a default value here if it's known at compile-time.
309 * Otherwise it is set to -n as an indication to tweak_tunables() that it should
326 int t4_ntxq = -NTXQ;
332 int t4_nrxq = -NRXQ;
338 static int t4_ntxq_vi = -NTXQ_VI;
343 static int t4_nrxq_vi = -NRXQ_VI;
349 0, "Reserve TX queue 0 of each VI for non-flowid packets");
353 static int t4_nofldtxq = -NOFLDTXQ;
358 static int t4_nofldtxq_vi = -NOFLDTXQ_VI;
365 static int t4_nofldrxq = -NOFLDRXQ;
370 static int t4_nofldrxq_vi = -NOFLDRXQ_VI;
379 #define PKTC_IDX_OFLD (-1)
384 /* 0 means chip/fw default, non-zero number is value in microseconds */
389 /* 0 means chip/fw default, non-zero number is value in microseconds */
394 /* 0 means chip/fw default, non-zero number is # of keepalives before abort */
399 /* 0 means chip/fw default, non-zero number is value in microseconds */
404 /* 0 means chip/fw default, non-zero number is value in microseconds */
409 /* 0 means chip/fw default, non-zero number is # of rexmt before abort */
414 /* -1 means chip/fw default, other values are raw backoff values to use */
416 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
472 static int t4_nnmtxq = -NNMTXQ;
477 static int t4_nnmrxq = -NNMRXQ;
482 static int t4_nnmtxq_vi = -NNMTXQ_VI;
487 static int t4_nnmrxq_vi = -NNMRXQ_VI;
501 #define PKTC_IDX (-1)
519 * Interrupt types allowed (bits 0, 1, 2 = INTx, MSI, MSI-X respectively).
523 0, "Interrupt types allowed (bit 0 = INTx, 1 = MSI, 2 = MSI-X)");
529 #define BUILTIN_CF "built-in"
553 * -1 to run with the firmware default. Same as FEC_AUTO (bit 5)
556 static int t4_fec = -1;
561 t4_fec_bits = "\20\1RS-FEC\2FC-FEC\3NO-FEC\4RSVD1\5RSVD2\6auto\7module";
567 * -1 to set FORCE_FEC iff requested_fec != AUTO. Multiple FEC bits are okay.
574 static int t4_force_fec = -1;
580 * -1 to run with the firmware default.
584 static int t4_autoneg = -1;
589 * Firmware auto-install by driver during attach (0, 1, 2 = prohibited, allowed,
590 * encouraged respectively). '-n' is the same as 'n' except the firmware
595 "Firmware auto-install (0 = prohibited, 1 = allowed, 2 = encouraged)");
614 static int t4_nvmecaps_allowed = -1;
628 static int t4_toecaps_allowed = -1;
632 static int t4_rdmacaps_allowed = -1;
636 static int t4_cryptocaps_allowed = -1;
640 static int t4_iscsicaps_allowed = -1;
663 * -1: driver should figure out a good value.
668 static int pcie_relaxed_ordering = -1;
694 * Set to non-zero to enable the attack filter. A packet that matches any of
767 &t4_tls_short_records, 0, "Use cipher-only mode for short records.");
771 &t4_tls_partial_ghash, 0, "Use partial GHASH for AES-GCM records.");
786 uint16_t intr_type; /* INTx, MSI, or MSI-X */
957 {0x4400, "Chelsio T440-dbg"},
958 {0x4401, "Chelsio T420-CR"},
959 {0x4402, "Chelsio T422-CR"},
960 {0x4403, "Chelsio T440-CR"},
961 {0x4404, "Chelsio T420-BCH"},
962 {0x4405, "Chelsio T440-BCH"},
963 {0x4406, "Chelsio T440-CH"},
964 {0x4407, "Chelsio T420-SO"},
965 {0x4408, "Chelsio T420-CX"},
966 {0x4409, "Chelsio T420-BT"},
967 {0x440a, "Chelsio T404-BT"},
968 {0x440e, "Chelsio T440-LP-CR"},
971 {0x5400, "Chelsio T580-dbg"},
972 {0x5401, "Chelsio T520-CR"}, /* 2 x 10G */
973 {0x5402, "Chelsio T522-CR"}, /* 2 x 10G, 2 X 1G */
974 {0x5403, "Chelsio T540-CR"}, /* 4 x 10G */
975 {0x5407, "Chelsio T520-SO"}, /* 2 x 10G, nomem */
976 {0x5409, "Chelsio T520-BT"}, /* 2 x 10GBaseT */
977 {0x540a, "Chelsio T504-BT"}, /* 4 x 1G */
978 {0x540d, "Chelsio T580-CR"}, /* 2 x 40G */
979 {0x540e, "Chelsio T540-LP-CR"}, /* 4 x 10G */
980 {0x5410, "Chelsio T580-LP-CR"}, /* 2 x 40G */
981 {0x5411, "Chelsio T520-LL-CR"}, /* 2 x 10G */
982 {0x5412, "Chelsio T560-CR"}, /* 1 x 40G, 2 x 10G */
983 {0x5414, "Chelsio T580-LP-SO-CR"}, /* 2 x 40G, nomem */
984 {0x5415, "Chelsio T502-BT"}, /* 2 x 1G */
985 {0x5418, "Chelsio T540-BT"}, /* 4 x 10GBaseT */
986 {0x5419, "Chelsio T540-LP-BT"}, /* 4 x 10GBaseT */
987 {0x541a, "Chelsio T540-SO-BT"}, /* 4 x 10GBaseT, nomem */
988 {0x541b, "Chelsio T540-SO-CR"}, /* 4 x 10G, nomem */
991 {0x5483, "Custom T540-CR"},
992 {0x5484, "Custom T540-BT"},
995 {0x6400, "Chelsio T6-DBG-25"}, /* 2 x 10/25G, debug */
996 {0x6401, "Chelsio T6225-CR"}, /* 2 x 10/25G */
997 {0x6402, "Chelsio T6225-SO-CR"}, /* 2 x 10/25G, nomem */
998 {0x6403, "Chelsio T6425-CR"}, /* 4 x 10/25G */
999 {0x6404, "Chelsio T6425-SO-CR"}, /* 4 x 10/25G, nomem */
1000 {0x6405, "Chelsio T6225-SO-OCP3"}, /* 2 x 10/25G, nomem */
1001 {0x6406, "Chelsio T6225-OCP3"}, /* 2 x 10/25G */
1002 {0x6407, "Chelsio T62100-LP-CR"}, /* 2 x 40/50/100G */
1003 {0x6408, "Chelsio T62100-SO-CR"}, /* 2 x 40/50/100G, nomem */
1004 {0x6409, "Chelsio T6210-BT"}, /* 2 x 10GBASE-T */
1005 {0x640d, "Chelsio T62100-CR"}, /* 2 x 40/50/100G */
1006 {0x6410, "Chelsio T6-DBG-100"}, /* 2 x 40/50/100G, debug */
1007 {0x6411, "Chelsio T6225-LL-CR"}, /* 2 x 10/25G */
1008 {0x6414, "Chelsio T62100-SO-OCP3"}, /* 2 x 40/50/100G, nomem */
1009 {0x6415, "Chelsio T6201-BT"}, /* 2 x 1000BASE-T */
1012 {0x6480, "Custom T6225-CR"},
1013 {0x6481, "Custom T62100-CR"},
1014 {0x6482, "Custom T6225-CR"},
1015 {0x6483, "Custom T62100-CR"},
1016 {0x6484, "Custom T64100-CR"},
1017 {0x6485, "Custom T6240-SO"},
1018 {0x6486, "Custom T6225-SO-CR"},
1019 {0x6487, "Custom T6225-CR"},
1022 {0x7400, "Chelsio T72200-DBG"}, /* 2 x 200G, debug */
1029 {0x7407, "Chelsio T72200-FH"}, /* 2 x 40/100/200G, 2 mem */
1031 {0x7409, "Chelsio S7210-BT"}, /* 2 x 10GBASE-T, nomem */
1032 {0x740a, "Chelsio T7450-RC"}, /* 4 x 10/25/50G, 1 mem, RC */
1033 {0x740b, "Chelsio T72200-RC"}, /* 2 x 40/100/200G, 1 mem, RC */
1034 {0x740c, "Chelsio T72200-FH-RC"}, /* 2 x 40/100/200G, 2 mem, RC */
1035 {0x740d, "Chelsio S72200-OCP3"}, /* 2 x 40/100/200G OCP3 */
1036 {0x740e, "Chelsio S7450-OCP3"}, /* 4 x 1/20/25/50G OCP3 */
1037 {0x740f, "Chelsio S7410-BT-OCP3"}, /* 4 x 10GBASE-T OCP3 */
1038 {0x7410, "Chelsio S7210-BT-A"}, /* 2 x 10GBASE-T */
1216 device_printf(sc->dev, "chip id %d is not supported.\n", id); in t4_init_devnames()
1217 sc->names = NULL; in t4_init_devnames()
1218 } else if (id - CHELSIO_T4 < nitems(devnames)) in t4_init_devnames()
1219 sc->names = &devnames[id - CHELSIO_T4]; in t4_init_devnames()
1221 sc->names = &devnames[nitems(devnames) - 1]; in t4_init_devnames()
1232 parent = device_get_nameunit(sc->dev); in t4_ifnet_unit()
1233 name = sc->names->ifnet_name; in t4_ifnet_unit()
1236 value == pi->port_id) in t4_ifnet_unit()
1239 return (-1); in t4_ifnet_unit()
1257 cur = &sc->cal_info[sc->cal_current]; in t4_calibration()
1258 next_up = (sc->cal_current + 1) % CNT_CAL_INFO; in t4_calibration()
1259 nex = &sc->cal_info[next_up]; in t4_calibration()
1260 if (__predict_false(sc->cal_count == 0)) { in t4_calibration()
1262 cur->hw_cur = hw; in t4_calibration()
1263 cur->sbt_cur = sbt; in t4_calibration()
1264 sc->cal_count++; in t4_calibration()
1268 if (cur->hw_cur == hw) { in t4_calibration()
1270 sc->cal_count = 0; in t4_calibration()
1271 atomic_store_rel_int(&cur->gen, 0); in t4_calibration()
1275 seqc_write_begin(&nex->gen); in t4_calibration()
1276 nex->hw_prev = cur->hw_cur; in t4_calibration()
1277 nex->sbt_prev = cur->sbt_cur; in t4_calibration()
1278 nex->hw_cur = hw; in t4_calibration()
1279 nex->sbt_cur = sbt; in t4_calibration()
1280 seqc_write_end(&nex->gen); in t4_calibration()
1281 sc->cal_current = next_up; in t4_calibration()
1283 callout_reset_sbt_curcpu(&sc->cal_callout, SBT_1S, 0, t4_calibration, in t4_calibration()
1298 sc->cal_info[i].gen = 0; in t4_calibration_start()
1300 sc->cal_current = 0; in t4_calibration_start()
1301 sc->cal_count = 0; in t4_calibration_start()
1302 sc->cal_gen = 0; in t4_calibration_start()
1327 sc->dev = dev; in t4_attach()
1328 sysctl_ctx_init(&sc->ctx); in t4_attach()
1329 TUNABLE_INT_FETCH("hw.cxgbe.dflags", &sc->debug_flags); in t4_attach()
1339 sc->params.pci.mps = 128 << ((v & PCIEM_CTL_MAX_PAYLOAD) >> 5); in t4_attach()
1351 sc->sge_gts_reg = MYPF_REG(A_SGE_PF_GTS); in t4_attach()
1352 sc->sge_kdoorbell_reg = MYPF_REG(A_SGE_PF_KDOORBELL); in t4_attach()
1353 sc->traceq = -1; in t4_attach()
1354 mtx_init(&sc->ifp_lock, sc->ifp_lockname, 0, MTX_DEF); in t4_attach()
1355 snprintf(sc->ifp_lockname, sizeof(sc->ifp_lockname), "%s tracer", in t4_attach()
1358 snprintf(sc->lockname, sizeof(sc->lockname), "%s", in t4_attach()
1360 mtx_init(&sc->sc_lock, sc->lockname, 0, MTX_DEF); in t4_attach()
1363 mtx_init(&sc->sfl_lock, "starving freelists", 0, MTX_DEF); in t4_attach()
1364 TAILQ_INIT(&sc->sfl); in t4_attach()
1365 callout_init_mtx(&sc->sfl_callout, &sc->sfl_lock, 0); in t4_attach()
1367 mtx_init(&sc->reg_lock, "indirect register access", 0, MTX_DEF); in t4_attach()
1369 sc->policy = NULL; in t4_attach()
1370 rw_init(&sc->policy_lock, "connection offload policy"); in t4_attach()
1372 callout_init(&sc->ktls_tick, 1); in t4_attach()
1374 callout_init(&sc->cal_callout, 1); in t4_attach()
1376 refcount_init(&sc->vxlan_refcount, 0); in t4_attach()
1378 TASK_INIT(&sc->reset_task, 0, reset_adapter_task, sc); in t4_attach()
1379 TASK_INIT(&sc->fatal_error_task, 0, fatal_error_task, sc); in t4_attach()
1381 sc->ctrlq_oid = SYSCTL_ADD_NODE(&sc->ctx, in t4_attach()
1382 SYSCTL_CHILDREN(device_get_sysctl_tree(sc->dev)), OID_AUTO, "ctrlq", in t4_attach()
1384 sc->fwq_oid = SYSCTL_ADD_NODE(&sc->ctx, in t4_attach()
1385 SYSCTL_CHILDREN(device_get_sysctl_tree(sc->dev)), OID_AUTO, "fwq", in t4_attach()
1392 memset(sc->chan_map, 0xff, sizeof(sc->chan_map)); in t4_attach()
1393 memset(sc->port_map, 0xff, sizeof(sc->port_map)); in t4_attach()
1397 rc = -t4_prep_adapter(sc, buf); in t4_attach()
1411 sc->pf = chip_id(sc) <= CHELSIO_T5 ? G_SOURCEPF(j) : G_T6_SOURCEPF(j); in t4_attach()
1412 sc->mbox = sc->pf; in t4_attach()
1415 if (sc->names == NULL) { in t4_attach()
1434 rc = make_dev_s(&mda, &sc->cdev, "%s", device_get_nameunit(dev)); in t4_attach()
1457 MPASS(sc->flags & FW_OK); in t4_attach()
1463 if (sc->flags & MASTER_PF) { in t4_attach()
1490 * First pass over all the ports - allocate VIs and initialize some in t4_attach()
1497 sc->port[i] = pi; in t4_attach()
1500 pi->adapter = sc; in t4_attach()
1501 pi->port_id = i; in t4_attach()
1504 * pi->nvi's final value is known. in t4_attach()
1506 pi->vi = malloc(sizeof(struct vi_info) * t4_num_vis, M_CXGBE, in t4_attach()
1513 rc = -t4_port_init(sc, sc->mbox, sc->pf, 0, i); in t4_attach()
1517 free(pi->vi, M_CXGBE); in t4_attach()
1519 sc->port[i] = NULL; in t4_attach()
1523 if (is_bt(pi->port_type)) in t4_attach()
1524 setbit(&sc->bt_map, pi->hw_port); in t4_attach()
1526 MPASS(!isset(&sc->bt_map, pi->hw_port)); in t4_attach()
1528 snprintf(pi->lockname, sizeof(pi->lockname), "%sp%d", in t4_attach()
1530 mtx_init(&pi->pi_lock, pi->lockname, 0, MTX_DEF); in t4_attach()
1531 for (j = 0; j < sc->params.tp.lb_nchan; j++) in t4_attach()
1532 sc->chan_map[pi->tx_chan + j] = i; in t4_attach()
1533 sc->port_map[pi->hw_port] = i; in t4_attach()
1542 pi->fcs_reg = -1; in t4_attach()
1544 pi->fcs_reg = A_MPS_PORT_STAT_RX_PORT_CRC_ERROR_L; in t4_attach()
1545 pi->fcs_base = 0; in t4_attach()
1548 ifmedia_init(&pi->media, IFM_IMASK, cxgbe_media_change, in t4_attach()
1556 pi->flags |= FIXED_IFMEDIA; in t4_attach()
1559 pi->dev = device_add_child(dev, sc->names->ifnet_name, in t4_attach()
1561 if (pi->dev == NULL) { in t4_attach()
1567 pi->vi[0].dev = pi->dev; in t4_attach()
1568 device_set_softc(pi->dev, pi); in t4_attach()
1574 nports = sc->params.nports; in t4_attach()
1580 sc->intr_type = iaq.intr_type; in t4_attach()
1581 sc->intr_count = iaq.nirq; in t4_attach()
1583 s = &sc->sge; in t4_attach()
1584 s->nctrlq = max(sc->params.nports, sc->params.ncores); in t4_attach()
1585 s->nrxq = nports * iaq.nrxq; in t4_attach()
1586 s->ntxq = nports * iaq.ntxq; in t4_attach()
1588 s->nrxq += nports * (num_vis - 1) * iaq.nrxq_vi; in t4_attach()
1589 s->ntxq += nports * (num_vis - 1) * iaq.ntxq_vi; in t4_attach()
1591 s->neq = s->ntxq + s->nrxq; /* the free list in an rxq is an eq */ in t4_attach()
1592 s->neq += nports; /* ctrl queues: 1 per port */ in t4_attach()
1593 s->niq = s->nrxq + 1; /* 1 extra for firmware event queue */ in t4_attach()
1596 s->nofldtxq = nports * iaq.nofldtxq; in t4_attach()
1598 s->nofldtxq += nports * (num_vis - 1) * iaq.nofldtxq_vi; in t4_attach()
1599 s->neq += s->nofldtxq; in t4_attach()
1601 s->ofld_txq = malloc(s->nofldtxq * sizeof(struct sge_ofld_txq), in t4_attach()
1607 s->nofldrxq = nports * iaq.nofldrxq; in t4_attach()
1609 s->nofldrxq += nports * (num_vis - 1) * iaq.nofldrxq_vi; in t4_attach()
1610 s->neq += s->nofldrxq; /* free list */ in t4_attach()
1611 s->niq += s->nofldrxq; in t4_attach()
1613 s->ofld_rxq = malloc(s->nofldrxq * sizeof(struct sge_ofld_rxq), in t4_attach()
1618 s->nnmrxq = 0; in t4_attach()
1619 s->nnmtxq = 0; in t4_attach()
1621 s->nnmrxq += nports * iaq.nnmrxq; in t4_attach()
1622 s->nnmtxq += nports * iaq.nnmtxq; in t4_attach()
1625 s->nnmrxq += nports * (num_vis - 1) * iaq.nnmrxq_vi; in t4_attach()
1626 s->nnmtxq += nports * (num_vis - 1) * iaq.nnmtxq_vi; in t4_attach()
1628 s->neq += s->nnmtxq + s->nnmrxq; in t4_attach()
1629 s->niq += s->nnmrxq; in t4_attach()
1631 s->nm_rxq = malloc(s->nnmrxq * sizeof(struct sge_nm_rxq), in t4_attach()
1633 s->nm_txq = malloc(s->nnmtxq * sizeof(struct sge_nm_txq), in t4_attach()
1636 MPASS(s->niq <= s->iqmap_sz); in t4_attach()
1637 MPASS(s->neq <= s->eqmap_sz); in t4_attach()
1639 s->ctrlq = malloc(s->nctrlq * sizeof(struct sge_wrq), M_CXGBE, in t4_attach()
1641 s->rxq = malloc(s->nrxq * sizeof(struct sge_rxq), M_CXGBE, in t4_attach()
1643 s->txq = malloc(s->ntxq * sizeof(struct sge_txq), M_CXGBE, in t4_attach()
1645 s->iqmap = malloc(s->iqmap_sz * sizeof(struct sge_iq *), M_CXGBE, in t4_attach()
1647 s->eqmap = malloc(s->eqmap_sz * sizeof(struct sge_eq *), M_CXGBE, in t4_attach()
1650 sc->irq = malloc(sc->intr_count * sizeof(struct irq), M_CXGBE, in t4_attach()
1663 if (sc->vres.key.size != 0) in t4_attach()
1664 sc->key_map = vmem_create("T4TLS key map", sc->vres.key.start, in t4_attach()
1665 sc->vres.key.size, 32, 0, M_FIRSTFIT | M_WAITOK); in t4_attach()
1683 struct port_info *pi = sc->port[i]; in t4_attach()
1689 pi->nvi = num_vis; in t4_attach()
1691 vi->pi = pi; in t4_attach()
1692 vi->adapter = sc; in t4_attach()
1693 vi->first_intr = -1; in t4_attach()
1694 vi->qsize_rxq = t4_qsize_rxq; in t4_attach()
1695 vi->qsize_txq = t4_qsize_txq; in t4_attach()
1697 vi->first_rxq = rqidx; in t4_attach()
1698 vi->first_txq = tqidx; in t4_attach()
1699 vi->tmr_idx = t4_tmr_idx; in t4_attach()
1700 vi->pktc_idx = t4_pktc_idx; in t4_attach()
1701 vi->nrxq = j == 0 ? iaq.nrxq : iaq.nrxq_vi; in t4_attach()
1702 vi->ntxq = j == 0 ? iaq.ntxq : iaq.ntxq_vi; in t4_attach()
1704 rqidx += vi->nrxq; in t4_attach()
1705 tqidx += vi->ntxq; in t4_attach()
1707 if (j == 0 && vi->ntxq > 1) in t4_attach()
1708 vi->rsrv_noflowq = t4_rsrv_noflowq ? 1 : 0; in t4_attach()
1710 vi->rsrv_noflowq = 0; in t4_attach()
1713 vi->first_ofld_txq = ofld_tqidx; in t4_attach()
1714 vi->nofldtxq = j == 0 ? iaq.nofldtxq : iaq.nofldtxq_vi; in t4_attach()
1715 ofld_tqidx += vi->nofldtxq; in t4_attach()
1718 vi->ofld_tmr_idx = t4_tmr_idx_ofld; in t4_attach()
1719 vi->ofld_pktc_idx = t4_pktc_idx_ofld; in t4_attach()
1720 vi->first_ofld_rxq = ofld_rqidx; in t4_attach()
1721 vi->nofldrxq = j == 0 ? iaq.nofldrxq : iaq.nofldrxq_vi; in t4_attach()
1723 ofld_rqidx += vi->nofldrxq; in t4_attach()
1726 vi->first_nm_rxq = nm_rqidx; in t4_attach()
1727 vi->first_nm_txq = nm_tqidx; in t4_attach()
1729 vi->nnmrxq = iaq.nnmrxq; in t4_attach()
1730 vi->nnmtxq = iaq.nnmtxq; in t4_attach()
1732 vi->nnmrxq = iaq.nnmrxq_vi; in t4_attach()
1733 vi->nnmtxq = iaq.nnmtxq_vi; in t4_attach()
1735 nm_rqidx += vi->nnmrxq; in t4_attach()
1736 nm_tqidx += vi->nnmtxq; in t4_attach()
1751 * Ensure thread-safe mailbox access (in debug builds). in t4_attach()
1757 sc->flags |= CHK_MBOX_ACCESS; in t4_attach()
1764 sc->params.pci.speed, sc->params.pci.width, sc->params.nports, in t4_attach()
1765 sc->intr_count, sc->intr_type == INTR_MSIX ? "MSI-X" : in t4_attach()
1766 (sc->intr_type == INTR_MSI ? "MSI" : "INTx"), in t4_attach()
1767 sc->intr_count > 1 ? "s" : "", sc->sge.neq, sc->sge.niq); in t4_attach()
1774 if (rc != 0 && sc->cdev) { in t4_attach()
1798 pi = sc->port[i]; in t4_child_location()
1799 if (pi != NULL && pi->dev == dev) { in t4_child_location()
1800 sbuf_printf(sb, "port=%d", pi->port_id); in t4_child_location()
1813 if (sc->flags & FW_OK) in t4_ready()
1827 pi = sc->port[port]; in t4_read_port_device()
1828 if (pi == NULL || pi->dev == NULL) in t4_read_port_device()
1830 *child = pi->dev; in t4_read_port_device()
1894 if (sc->cdev) { in t4_detach_common()
1895 destroy_dev(sc->cdev); in t4_detach_common()
1896 sc->cdev = NULL; in t4_detach_common()
1903 sc->flags &= ~CHK_MBOX_ACCESS; in t4_detach_common()
1904 if (sc->flags & FULL_INIT_DONE) { in t4_detach_common()
1905 if (!(sc->flags & IS_VF)) in t4_detach_common()
1918 for (i = 0; i < sc->intr_count; i++) in t4_detach_common()
1919 t4_free_irq(sc, &sc->irq[i]); in t4_detach_common()
1921 if ((sc->flags & (IS_VF | FW_OK)) == FW_OK) in t4_detach_common()
1925 pi = sc->port[i]; in t4_detach_common()
1927 t4_free_vi(sc, sc->mbox, sc->pf, 0, pi->vi[0].viid); in t4_detach_common()
1929 mtx_destroy(&pi->pi_lock); in t4_detach_common()
1930 free(pi->vi, M_CXGBE); in t4_detach_common()
1934 callout_stop(&sc->cal_callout); in t4_detach_common()
1935 callout_drain(&sc->cal_callout); in t4_detach_common()
1937 sysctl_ctx_free(&sc->ctx); in t4_detach_common()
1940 if ((sc->flags & (IS_VF | FW_OK)) == FW_OK) in t4_detach_common()
1941 t4_fw_bye(sc, sc->mbox); in t4_detach_common()
1943 if (sc->intr_type == INTR_MSI || sc->intr_type == INTR_MSIX) in t4_detach_common()
1946 if (sc->regs_res) in t4_detach_common()
1947 bus_release_resource(dev, SYS_RES_MEMORY, sc->regs_rid, in t4_detach_common()
1948 sc->regs_res); in t4_detach_common()
1950 if (sc->udbs_res) in t4_detach_common()
1951 bus_release_resource(dev, SYS_RES_MEMORY, sc->udbs_rid, in t4_detach_common()
1952 sc->udbs_res); in t4_detach_common()
1954 if (sc->msix_res) in t4_detach_common()
1955 bus_release_resource(dev, SYS_RES_MEMORY, sc->msix_rid, in t4_detach_common()
1956 sc->msix_res); in t4_detach_common()
1958 if (sc->l2t) in t4_detach_common()
1960 if (sc->smt) in t4_detach_common()
1961 t4_free_smt(sc->smt); in t4_detach_common()
1966 if (sc->key_map) in t4_detach_common()
1967 vmem_destroy(sc->key_map); in t4_detach_common()
1974 free(sc->sge.ofld_txq, M_CXGBE); in t4_detach_common()
1977 free(sc->sge.ofld_rxq, M_CXGBE); in t4_detach_common()
1980 free(sc->sge.nm_rxq, M_CXGBE); in t4_detach_common()
1981 free(sc->sge.nm_txq, M_CXGBE); in t4_detach_common()
1983 free(sc->irq, M_CXGBE); in t4_detach_common()
1984 free(sc->sge.rxq, M_CXGBE); in t4_detach_common()
1985 free(sc->sge.txq, M_CXGBE); in t4_detach_common()
1986 free(sc->sge.ctrlq, M_CXGBE); in t4_detach_common()
1987 free(sc->sge.iqmap, M_CXGBE); in t4_detach_common()
1988 free(sc->sge.eqmap, M_CXGBE); in t4_detach_common()
1989 free(sc->tids.ftid_tab, M_CXGBE); in t4_detach_common()
1990 free(sc->tids.hpftid_tab, M_CXGBE); in t4_detach_common()
1991 free_hftid_hash(&sc->tids); in t4_detach_common()
1992 free(sc->tids.tid_tab, M_CXGBE); in t4_detach_common()
1995 callout_drain(&sc->ktls_tick); in t4_detach_common()
1996 callout_drain(&sc->sfl_callout); in t4_detach_common()
1997 if (mtx_initialized(&sc->tids.ftid_lock)) { in t4_detach_common()
1998 mtx_destroy(&sc->tids.ftid_lock); in t4_detach_common()
1999 cv_destroy(&sc->tids.ftid_cv); in t4_detach_common()
2001 if (mtx_initialized(&sc->tids.atid_lock)) in t4_detach_common()
2002 mtx_destroy(&sc->tids.atid_lock); in t4_detach_common()
2003 if (mtx_initialized(&sc->ifp_lock)) in t4_detach_common()
2004 mtx_destroy(&sc->ifp_lock); in t4_detach_common()
2006 if (rw_initialized(&sc->policy_lock)) { in t4_detach_common()
2007 rw_destroy(&sc->policy_lock); in t4_detach_common()
2009 if (sc->policy != NULL) in t4_detach_common()
2010 free_offload_policy(sc->policy); in t4_detach_common()
2015 struct memwin *mw = &sc->memwin[i]; in t4_detach_common()
2017 if (rw_initialized(&mw->mw_lock)) in t4_detach_common()
2018 rw_destroy(&mw->mw_lock); in t4_detach_common()
2021 mtx_destroy(&sc->sfl_lock); in t4_detach_common()
2022 mtx_destroy(&sc->reg_lock); in t4_detach_common()
2023 mtx_destroy(&sc->sc_lock); in t4_detach_common()
2036 if (atomic_testandset_int(&sc->error_flags, ilog2(ADAP_STOPPED))) { in stop_adapter()
2038 __func__, curthread, sc->flags, sc->error_flags); in stop_adapter()
2042 sc->flags, sc->error_flags); in stop_adapter()
2045 pi = sc->port[i]; in stop_adapter()
2049 if (pi->up_vis > 0 && pi->link_cfg.link_ok) { in stop_adapter()
2056 pi->link_cfg.link_ok = false; in stop_adapter()
2070 if (!atomic_testandclear_int(&sc->error_flags, ilog2(ADAP_STOPPED))) { in restart_adapter()
2072 __func__, curthread, sc->flags, sc->error_flags); in restart_adapter()
2076 sc->flags, sc->error_flags); in restart_adapter()
2079 MPASS((sc->flags & FW_OK) == 0); in restart_adapter()
2080 MPASS((sc->flags & MASTER_PF) == 0); in restart_adapter()
2081 MPASS(sc->reset_thread == NULL); in restart_adapter()
2088 sc->reset_thread = curthread; in restart_adapter()
2092 sc->reset_thread = NULL; in restart_adapter()
2093 atomic_set_int(&sc->error_flags, ADAP_STOPPED); in restart_adapter()
2096 atomic_clear_int(&sc->error_flags, ADAP_FATAL_ERR); in restart_adapter()
2097 atomic_add_int(&sc->incarnation, 1); in restart_adapter()
2098 atomic_add_int(&sc->num_resets, 1); in restart_adapter()
2109 MPASS(sc->reset_thread == curthread); in set_adapter_hwstatus()
2110 mtx_lock(&sc->reg_lock); in set_adapter_hwstatus()
2111 atomic_clear_int(&sc->error_flags, HW_OFF_LIMITS); in set_adapter_hwstatus()
2112 mtx_unlock(&sc->reg_lock); in set_adapter_hwstatus()
2116 mtx_lock(&sc->reg_lock); in set_adapter_hwstatus()
2117 atomic_set_int(&sc->error_flags, HW_OFF_LIMITS); in set_adapter_hwstatus()
2118 mtx_unlock(&sc->reg_lock); in set_adapter_hwstatus()
2119 sc->flags &= ~(FW_OK | MASTER_PF); in set_adapter_hwstatus()
2120 sc->reset_thread = NULL; in set_adapter_hwstatus()
2158 pi = sc->port[i]; in stop_lld()
2161 pi->vxlan_tcam_entry = false; in stop_lld()
2163 vi->xact_addr_filt = -1; in stop_lld()
2164 mtx_lock(&vi->tick_mtx); in stop_lld()
2165 vi->flags |= VI_SKIP_STATS; in stop_lld()
2166 mtx_unlock(&vi->tick_mtx); in stop_lld()
2167 if (!(vi->flags & VI_INIT_DONE)) in stop_lld()
2170 ifp = vi->ifp; in stop_lld()
2172 mtx_lock(&vi->tick_mtx); in stop_lld()
2173 callout_stop(&vi->tick); in stop_lld()
2174 mtx_unlock(&vi->tick_mtx); in stop_lld()
2175 callout_drain(&vi->tick); in stop_lld()
2183 txq->eq.flags &= ~(EQ_ENABLED | EQ_HW_ALLOCATED); in stop_lld()
2188 TXQ_LOCK(&ofld_txq->wrq); in stop_lld()
2189 ofld_txq->wrq.eq.flags &= ~EQ_HW_ALLOCATED; in stop_lld()
2190 TXQ_UNLOCK(&ofld_txq->wrq); in stop_lld()
2194 rxq->iq.flags &= ~IQ_HW_ALLOCATED; in stop_lld()
2198 ofld_rxq->iq.flags &= ~IQ_HW_ALLOCATED; in stop_lld()
2205 if (sc->flags & FULL_INIT_DONE) { in stop_lld()
2207 wrq = &sc->sge.ctrlq[i]; in stop_lld()
2209 wrq->eq.flags &= ~EQ_HW_ALLOCATED; in stop_lld()
2214 if (pi->flags & HAS_TRACEQ) { in stop_lld()
2215 pi->flags &= ~HAS_TRACEQ; in stop_lld()
2216 sc->traceq = -1; in stop_lld()
2217 sc->tracer_valid = 0; in stop_lld()
2218 sc->tracer_enabled = 0; in stop_lld()
2221 if (sc->flags & FULL_INIT_DONE) { in stop_lld()
2223 sc->sge.fwq.flags &= ~IQ_HW_ALLOCATED; in stop_lld()
2224 quiesce_iq_fl(sc, &sc->sge.fwq, NULL); in stop_lld()
2228 callout_stop(&sc->cal_callout); in stop_lld()
2229 callout_drain(&sc->cal_callout); in stop_lld()
2303 o->flags = sc->flags; in save_caps_and_params()
2305 o->nbmcaps = sc->nbmcaps; in save_caps_and_params()
2306 o->linkcaps = sc->linkcaps; in save_caps_and_params()
2307 o->switchcaps = sc->switchcaps; in save_caps_and_params()
2308 o->nvmecaps = sc->nvmecaps; in save_caps_and_params()
2309 o->niccaps = sc->niccaps; in save_caps_and_params()
2310 o->toecaps = sc->toecaps; in save_caps_and_params()
2311 o->rdmacaps = sc->rdmacaps; in save_caps_and_params()
2312 o->cryptocaps = sc->cryptocaps; in save_caps_and_params()
2313 o->iscsicaps = sc->iscsicaps; in save_caps_and_params()
2314 o->fcoecaps = sc->fcoecaps; in save_caps_and_params()
2316 o->cfcsum = sc->cfcsum; in save_caps_and_params()
2317 MPASS(sizeof(o->cfg_file) == sizeof(sc->cfg_file)); in save_caps_and_params()
2318 memcpy(o->cfg_file, sc->cfg_file, sizeof(o->cfg_file)); in save_caps_and_params()
2320 o->params = sc->params; in save_caps_and_params()
2321 o->vres = sc->vres; in save_caps_and_params()
2322 o->tids = sc->tids; in save_caps_and_params()
2323 o->sge = sc->sge; in save_caps_and_params()
2325 o->rawf_base = sc->rawf_base; in save_caps_and_params()
2326 o->nrawf = sc->nrawf; in save_caps_and_params()
2338 if (o->c##caps != sc->c##caps) { \ in compare_caps_and_params()
2339 CH_ERR(sc, "%scaps 0x%04x -> 0x%04x.\n", #c, o->c##caps, \ in compare_caps_and_params()
2340 sc->c##caps); \ in compare_caps_and_params()
2357 if (o->cfcsum != sc->cfcsum) { in compare_caps_and_params()
2358 CH_ERR(sc, "config file %s (0x%x) -> %s (0x%x)\n", o->cfg_file, in compare_caps_and_params()
2359 o->cfcsum, sc->cfg_file, sc->cfcsum); in compare_caps_and_params()
2364 if (o->p != sc->p) { \ in compare_caps_and_params()
2365 CH_ERR(sc, #name " %d -> %d\n", o->p, sc->p); \ in compare_caps_and_params()
2457 MPASS(sc->flags & FW_OK); in restart_lld()
2459 if (sc->flags & MASTER_PF) { in restart_lld()
2478 pi = sc->port[i]; in restart_lld()
2480 MPASS(pi->vi != NULL); in restart_lld()
2481 MPASS(pi->vi[0].dev == pi->dev); in restart_lld()
2483 rc = -t4_port_init(sc, sc->mbox, sc->pf, 0, i); in restart_lld()
2486 "failed to re-initialize port %d: %d\n", i, rc); in restart_lld()
2489 MPASS(sc->chan_map[pi->tx_chan] == i); in restart_lld()
2501 "failed to re-allocate extra VI: %d\n", rc); in restart_lld()
2514 if (sc->flags & FULL_INIT_DONE) { in restart_lld()
2517 CH_ERR(sc, "failed to re-initialize adapter: %d\n", rc); in restart_lld()
2521 if (sc->vxlan_refcount > 0) in restart_lld()
2525 pi = sc->port[i]; in restart_lld()
2527 mtx_lock(&vi->tick_mtx); in restart_lld()
2528 vi->flags &= ~VI_SKIP_STATS; in restart_lld()
2529 mtx_unlock(&vi->tick_mtx); in restart_lld()
2530 if (!(vi->flags & VI_INIT_DONE)) in restart_lld()
2534 CH_ERR(vi, "failed to re-initialize " in restart_lld()
2538 if (sc->traceq < 0 && IS_MAIN_VI(vi)) { in restart_lld()
2539 sc->traceq = sc->sge.rxq[vi->first_rxq].iq.abs_id; in restart_lld()
2540 t4_set_trace_rss_control(sc, pi->tx_chan, sc->traceq); in restart_lld()
2541 pi->flags |= HAS_TRACEQ; in restart_lld()
2544 ifp = vi->ifp; in restart_lld()
2556 CH_ERR(vi, "failed to re-configure MAC: %d\n", rc); in restart_lld()
2559 rc = -t4_enable_vi(sc, sc->mbox, vi->viid, true, in restart_lld()
2562 CH_ERR(vi, "failed to re-enable VI: %d\n", rc); in restart_lld()
2567 txq->eq.flags |= EQ_ENABLED; in restart_lld()
2570 mtx_lock(&vi->tick_mtx); in restart_lld()
2571 callout_schedule(&vi->tick, hz); in restart_lld()
2572 mtx_unlock(&vi->tick_mtx); in restart_lld()
2575 if (pi->up_vis > 0) { in restart_lld()
2580 if (pi->link_cfg.link_ok) in restart_lld()
2588 pi = sc->port[i]; in restart_lld()
2590 if (!(vi->flags & VI_INIT_DONE)) in restart_lld()
2592 ifp = vi->ifp; in restart_lld()
2597 CH_ERR(vi, "failed to re-configure MCAST MACs: %d\n", rc); in restart_lld()
2662 MPASS(sc->error_flags & HW_OFF_LIMITS); in reset_adapter_with_pl_rst()
2663 bus_space_write_4(sc->bt, sc->bh, A_PL_RST, in reset_adapter_with_pl_rst()
2672 device_t pdev = device_get_parent(sc->dev); in reset_adapter_with_pcie_sbr()
2718 device_t pdev = device_get_parent(sc->dev); in reset_adapter_with_pcie_link_bounce()
2793 const int flags = sc->flags; in reset_adapter_task()
2794 const int eflags = sc->error_flags; in reset_adapter_task()
2802 "flags 0x%08x -> 0x%08x, err_flags 0x%08x -> 0x%08x.\n", in reset_adapter_task()
2803 rc, flags, sc->flags, eflags, sc->error_flags); in reset_adapter_task()
2812 device_set_descf(dev, "port %d", pi->port_id); in cxgbe_probe()
2828 struct sysctl_ctx_list *ctx = &vi->ctx; in cxgbe_vi_attach()
2831 struct adapter *sc = vi->adapter; in cxgbe_vi_attach()
2834 children = SYSCTL_CHILDREN(device_get_sysctl_tree(vi->dev)); in cxgbe_vi_attach()
2835 vi->rxq_oid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, "rxq", in cxgbe_vi_attach()
2837 vi->txq_oid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, "txq", in cxgbe_vi_attach()
2840 vi->nm_rxq_oid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, "nm_rxq", in cxgbe_vi_attach()
2842 vi->nm_txq_oid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, "nm_txq", in cxgbe_vi_attach()
2846 vi->ofld_rxq_oid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, "ofld_rxq", in cxgbe_vi_attach()
2850 vi->ofld_txq_oid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, "ofld_txq", in cxgbe_vi_attach()
2854 vi->xact_addr_filt = -1; in cxgbe_vi_attach()
2855 mtx_init(&vi->tick_mtx, "vi tick", NULL, MTX_DEF); in cxgbe_vi_attach()
2856 callout_init_mtx(&vi->tick, &vi->tick_mtx, 0); in cxgbe_vi_attach()
2857 if (sc->flags & IS_VF || t4_tx_vm_wr != 0) in cxgbe_vi_attach()
2858 vi->flags |= TX_USES_VM_WR; in cxgbe_vi_attach()
2862 vi->ifp = ifp; in cxgbe_vi_attach()
2872 if (vi->pi->nvi > 1 || sc->flags & IS_VF) in cxgbe_vi_attach()
2896 if (vi->nofldrxq != 0) in cxgbe_vi_attach()
2900 if (is_ethoffload(sc) && vi->nofldtxq != 0) { in cxgbe_vi_attach()
2907 if (vi->flags & TX_USES_VM_WR) in cxgbe_vi_attach()
2912 if (is_ethoffload(sc) && vi->nofldtxq != 0) in cxgbe_vi_attach()
2919 if (sc->flags & KERN_TLS_ON || !is_t6(sc)) in cxgbe_vi_attach()
2924 ether_ifattach(ifp, vi->hw_addr); in cxgbe_vi_attach()
2926 if (vi->nnmrxq != 0) in cxgbe_vi_attach()
2930 sbuf_printf(sb, "%d txq, %d rxq (NIC)", vi->ntxq, vi->nrxq); in cxgbe_vi_attach()
2934 sbuf_printf(sb, "; %d txq (TOE)", vi->nofldtxq); in cxgbe_vi_attach()
2937 sbuf_printf(sb, "; %d txq (TOE/ETHOFLD)", vi->nofldtxq); in cxgbe_vi_attach()
2940 sbuf_printf(sb, "; %d txq (ETHOFLD)", vi->nofldtxq); in cxgbe_vi_attach()
2946 sbuf_printf(sb, ", %d rxq (TOE)", vi->nofldrxq); in cxgbe_vi_attach()
2951 vi->nnmtxq, vi->nnmrxq); in cxgbe_vi_attach()
2963 vi->pfil = pfil_head_register(&pa); in cxgbe_vi_attach()
2970 struct adapter *sc = pi->adapter; in cxgbe_attach()
2974 sysctl_ctx_init(&pi->ctx); in cxgbe_attach()
2976 cxgbe_vi_attach(dev, &pi->vi[0]); in cxgbe_attach()
2981 vi->dev = device_add_child(dev, sc->names->vi_ifnet_name, DEVICE_UNIT_ANY); in cxgbe_attach()
2982 if (vi->dev == NULL) { in cxgbe_attach()
2986 device_set_softc(vi->dev, vi); in cxgbe_attach()
2999 if_t ifp = vi->ifp; in cxgbe_vi_detach()
3001 if (vi->pfil != NULL) { in cxgbe_vi_detach()
3002 pfil_head_unregister(vi->pfil); in cxgbe_vi_detach()
3003 vi->pfil = NULL; in cxgbe_vi_detach()
3014 callout_drain(&vi->tick); in cxgbe_vi_detach()
3015 mtx_destroy(&vi->tick_mtx); in cxgbe_vi_detach()
3016 sysctl_ctx_free(&vi->ctx); in cxgbe_vi_detach()
3019 if_free(vi->ifp); in cxgbe_vi_detach()
3020 vi->ifp = NULL; in cxgbe_vi_detach()
3027 struct adapter *sc = pi->adapter; in cxgbe_detach()
3035 sysctl_ctx_free(&pi->ctx); in cxgbe_detach()
3036 begin_vi_detach(sc, &pi->vi[0]); in cxgbe_detach()
3037 if (pi->flags & HAS_TRACEQ) { in cxgbe_detach()
3038 sc->traceq = -1; /* cloner should not create ifnet */ in cxgbe_detach()
3041 cxgbe_vi_detach(&pi->vi[0]); in cxgbe_detach()
3042 ifmedia_removeall(&pi->media); in cxgbe_detach()
3043 end_vi_detach(sc, &pi->vi[0]); in cxgbe_detach()
3052 struct adapter *sc = vi->adapter; in cxgbe_init()
3065 struct port_info *pi = vi->pi; in cxgbe_ioctl()
3066 struct adapter *sc = pi->adapter; in cxgbe_ioctl()
3072 mtu = ifr->ifr_mtu; in cxgbe_ioctl()
3080 if (vi->flags & VI_INIT_DONE) { in cxgbe_ioctl()
3101 flags = vi->if_flags; in cxgbe_ioctl()
3110 vi->if_flags = if_getflags(ifp); in cxgbe_ioctl()
3132 mask = ifr->ifr_reqcap ^ if_getcapenable(ifp); in cxgbe_ioctl()
3142 "tso4 disabled due to -txcsum.\n"); in cxgbe_ioctl()
3154 "tso6 disabled due to -txcsum6.\n"); in cxgbe_ioctl()
3194 rxq->iq.flags |= IQ_LRO_ENABLED; in cxgbe_ioctl()
3196 rxq->iq.flags &= ~IQ_LRO_ENABLED; in cxgbe_ioctl()
3219 /* Need to find out how to disable auto-mtu-inflation */ in cxgbe_ioctl()
3236 rxq->iq.flags |= IQ_RX_TIMESTAMP; in cxgbe_ioctl()
3238 rxq->iq.flags &= ~IQ_RX_TIMESTAMP; in cxgbe_ioctl()
3277 rc = ifmedia_ioctl(ifp, ifr, &pi->media, cmd); in cxgbe_ioctl()
3300 rc = -t4_i2c_rd(sc, sc->mbox, pi->port_id, i2c.dev_addr, in cxgbe_ioctl()
3319 struct port_info *pi = vi->pi; in cxgbe_transmit()
3326 MPASS(m->m_nextpkt == NULL); /* not quite ready for this yet */ in cxgbe_transmit()
3328 if (m->m_pkthdr.csum_flags & CSUM_SND_TAG) in cxgbe_transmit()
3329 MPASS(m->m_pkthdr.snd_tag->ifp == ifp); in cxgbe_transmit()
3332 if (__predict_false(pi->link_cfg.link_ok == false)) { in cxgbe_transmit()
3337 rc = parse_pkt(&m, vi->flags & TX_USES_VM_WR); in cxgbe_transmit()
3346 atomic_add_int(&pi->tx_parse_error, 1); /* rare, atomic is ok */ in cxgbe_transmit()
3351 sc = vi->adapter; in cxgbe_transmit()
3352 txq = &sc->sge.txq[vi->first_txq]; in cxgbe_transmit()
3354 txq += ((m->m_pkthdr.flowid % (vi->ntxq - vi->rsrv_noflowq)) + in cxgbe_transmit()
3355 vi->rsrv_noflowq); in cxgbe_transmit()
3358 rc = mp_ring_enqueue(txq->r, items, 1, 256); in cxgbe_transmit()
3373 if (vi->flags & VI_INIT_DONE) { in cxgbe_qflush()
3376 txq->eq.flags |= EQ_QFLUSH; in cxgbe_qflush()
3378 while (!mp_ring_is_idle(txq->r)) { in cxgbe_qflush()
3379 mp_ring_check_drainage(txq->r, 4096); in cxgbe_qflush()
3383 txq->eq.flags &= ~EQ_QFLUSH; in cxgbe_qflush()
3394 struct fw_vi_stats_vf *s = &vi->stats; in vi_get_counter()
3396 mtx_lock(&vi->tick_mtx); in vi_get_counter()
3398 mtx_unlock(&vi->tick_mtx); in vi_get_counter()
3402 return (s->rx_bcast_frames + s->rx_mcast_frames + in vi_get_counter()
3403 s->rx_ucast_frames); in vi_get_counter()
3405 return (s->rx_err_frames); in vi_get_counter()
3407 return (s->tx_bcast_frames + s->tx_mcast_frames + in vi_get_counter()
3408 s->tx_ucast_frames + s->tx_offload_frames); in vi_get_counter()
3410 return (s->tx_drop_frames); in vi_get_counter()
3412 return (s->rx_bcast_bytes + s->rx_mcast_bytes + in vi_get_counter()
3413 s->rx_ucast_bytes); in vi_get_counter()
3415 return (s->tx_bcast_bytes + s->tx_mcast_bytes + in vi_get_counter()
3416 s->tx_ucast_bytes + s->tx_offload_bytes); in vi_get_counter()
3418 return (s->rx_mcast_frames); in vi_get_counter()
3420 return (s->tx_mcast_frames); in vi_get_counter()
3425 if (vi->flags & VI_INIT_DONE) { in vi_get_counter()
3430 drops += counter_u64_fetch(txq->r->dropped); in vi_get_counter()
3446 struct port_info *pi = vi->pi; in cxgbe_get_counter()
3447 struct port_stats *s = &pi->stats; in cxgbe_get_counter()
3449 mtx_lock(&vi->tick_mtx); in cxgbe_get_counter()
3451 mtx_unlock(&vi->tick_mtx); in cxgbe_get_counter()
3455 return (s->rx_frames); in cxgbe_get_counter()
3458 return (s->rx_jabber + s->rx_runt + s->rx_too_long + in cxgbe_get_counter()
3459 s->rx_fcs_err + s->rx_len_err); in cxgbe_get_counter()
3462 return (s->tx_frames); in cxgbe_get_counter()
3465 return (s->tx_error_frames); in cxgbe_get_counter()
3468 return (s->rx_octets); in cxgbe_get_counter()
3471 return (s->tx_octets); in cxgbe_get_counter()
3474 return (s->rx_mcast_frames); in cxgbe_get_counter()
3477 return (s->tx_mcast_frames); in cxgbe_get_counter()
3480 return (s->rx_ovflow0 + s->rx_ovflow1 + s->rx_ovflow2 + in cxgbe_get_counter()
3481 s->rx_ovflow3 + s->rx_trunc0 + s->rx_trunc1 + s->rx_trunc2 + in cxgbe_get_counter()
3482 s->rx_trunc3 + pi->tnl_cong_drops); in cxgbe_get_counter()
3487 drops = s->tx_drop; in cxgbe_get_counter()
3488 if (vi->flags & VI_INIT_DONE) { in cxgbe_get_counter()
3493 drops += counter_u64_fetch(txq->r->dropped); in cxgbe_get_counter()
3512 switch (params->hdr.type) { in cxgbe_snd_tag_alloc()
3523 if (is_t6(vi->pi->adapter)) in cxgbe_snd_tag_alloc()
3545 struct port_info *pi = vi->pi; in cxgbe_media_change()
3546 struct ifmedia *ifm = &pi->media; in cxgbe_media_change()
3547 struct link_config *lc = &pi->link_cfg; in cxgbe_media_change()
3548 struct adapter *sc = pi->adapter; in cxgbe_media_change()
3555 if (IFM_SUBTYPE(ifm->ifm_media) == IFM_AUTO) { in cxgbe_media_change()
3557 if (!(lc->pcaps & FW_PORT_CAP32_ANEG)) { in cxgbe_media_change()
3561 lc->requested_aneg = AUTONEG_ENABLE; in cxgbe_media_change()
3562 lc->requested_speed = 0; in cxgbe_media_change()
3563 lc->requested_fc |= PAUSE_AUTONEG; in cxgbe_media_change()
3565 lc->requested_aneg = AUTONEG_DISABLE; in cxgbe_media_change()
3566 lc->requested_speed = in cxgbe_media_change()
3567 ifmedia_baudrate(ifm->ifm_media) / 1000000; in cxgbe_media_change()
3568 lc->requested_fc = 0; in cxgbe_media_change()
3569 if (IFM_OPTIONS(ifm->ifm_media) & IFM_ETH_RXPAUSE) in cxgbe_media_change()
3570 lc->requested_fc |= PAUSE_RX; in cxgbe_media_change()
3571 if (IFM_OPTIONS(ifm->ifm_media) & IFM_ETH_TXPAUSE) in cxgbe_media_change()
3572 lc->requested_fc |= PAUSE_TX; in cxgbe_media_change()
3574 if (pi->up_vis > 0 && hw_all_ok(sc)) { in cxgbe_media_change()
3595 switch(pi->port_type) { in port_mword()
3656 switch (pi->mod_type) { in port_mword()
3749 struct port_info *pi = vi->pi; in cxgbe_media_status()
3750 struct adapter *sc = pi->adapter; in cxgbe_media_status()
3751 struct link_config *lc = &pi->link_cfg; in cxgbe_media_status()
3757 if (pi->up_vis == 0 && hw_all_ok(sc)) { in cxgbe_media_status()
3770 ifmr->ifm_status = IFM_AVALID; in cxgbe_media_status()
3771 if (lc->link_ok == false) in cxgbe_media_status()
3773 ifmr->ifm_status |= IFM_ACTIVE; in cxgbe_media_status()
3776 ifmr->ifm_active = IFM_ETHER | IFM_FDX; in cxgbe_media_status()
3777 ifmr->ifm_active &= ~(IFM_ETH_TXPAUSE | IFM_ETH_RXPAUSE); in cxgbe_media_status()
3778 if (lc->fc & PAUSE_RX) in cxgbe_media_status()
3779 ifmr->ifm_active |= IFM_ETH_RXPAUSE; in cxgbe_media_status()
3780 if (lc->fc & PAUSE_TX) in cxgbe_media_status()
3781 ifmr->ifm_active |= IFM_ETH_TXPAUSE; in cxgbe_media_status()
3782 ifmr->ifm_active |= port_mword(pi, speed_to_fwcap(lc->speed)); in cxgbe_media_status()
3793 device_set_descf(dev, "port %d vi %td", vi->pi->port_id, in vcxgbe_probe()
3794 vi - vi->pi->vi); in vcxgbe_probe()
3807 index = vi - pi->vi; in alloc_extra_vi()
3811 device_get_nameunit(vi->dev))); in alloc_extra_vi()
3813 rc = t4_alloc_vi_func(sc, sc->mbox, pi->hw_port, sc->pf, 0, 1, in alloc_extra_vi()
3814 vi->hw_addr, &vi->rss_size, &vi->vfvld, &vi->vin, func, 0); in alloc_extra_vi()
3817 "for port %d: %d\n", index, pi->port_id, -rc); in alloc_extra_vi()
3818 return (-rc); in alloc_extra_vi()
3820 vi->viid = rc; in alloc_extra_vi()
3822 if (vi->rss_size == 1) { in alloc_extra_vi()
3829 device_printf(vi->dev, "RSS table not available.\n"); in alloc_extra_vi()
3830 vi->rss_base = 0xffff; in alloc_extra_vi()
3837 V_FW_PARAMS_PARAM_YZ(vi->viid); in alloc_extra_vi()
3838 rc = t4_query_params(sc, sc->mbox, sc->pf, 0, 1, &param, &val); in alloc_extra_vi()
3840 vi->rss_base = 0xffff; in alloc_extra_vi()
3842 MPASS((val >> 16) == vi->rss_size); in alloc_extra_vi()
3843 vi->rss_base = val & 0xffff; in alloc_extra_vi()
3858 pi = vi->pi; in vcxgbe_attach()
3859 sc = pi->adapter; in vcxgbe_attach()
3881 sc = vi->adapter; in vcxgbe_detach()
3885 t4_free_vi(sc, sc->mbox, sc->pf, 0, vi->viid); in vcxgbe_detach()
3899 panic("%s: panic on fatal error", device_get_nameunit(sc->dev)); in delayed_panic()
3908 if (atomic_testandclear_int(&sc->error_flags, ilog2(ADAP_CIM_ERR))) { in fatal_error_task()
3933 const bool verbose = (sc->debug_flags & DF_VERBOSE_SLOWINTR) != 0; in t4_fatal_err()
3936 if (atomic_testandset_int(&sc->error_flags, ilog2(ADAP_FATAL_ERR))) in t4_fatal_err()
3948 atomic_set_int(&sc->error_flags, ADAP_CIM_ERR); in t4_fatal_err()
3952 device_get_nameunit(sc->dev), fw_error); in t4_fatal_err()
3953 taskqueue_enqueue(reset_tq, &sc->fatal_error_task); in t4_fatal_err()
3967 sc->regs_rid = PCIR_BAR(0); in t4_map_bars_0_and_4()
3968 sc->regs_res = bus_alloc_resource_any(sc->dev, SYS_RES_MEMORY, in t4_map_bars_0_and_4()
3969 &sc->regs_rid, RF_ACTIVE); in t4_map_bars_0_and_4()
3970 if (sc->regs_res == NULL) { in t4_map_bars_0_and_4()
3971 device_printf(sc->dev, "cannot map registers.\n"); in t4_map_bars_0_and_4()
3974 sc->bt = rman_get_bustag(sc->regs_res); in t4_map_bars_0_and_4()
3975 sc->bh = rman_get_bushandle(sc->regs_res); in t4_map_bars_0_and_4()
3976 sc->mmio_len = rman_get_size(sc->regs_res); in t4_map_bars_0_and_4()
3977 setbit(&sc->doorbells, DOORBELL_KDB); in t4_map_bars_0_and_4()
3979 sc->msix_rid = PCIR_BAR(4); in t4_map_bars_0_and_4()
3980 sc->msix_res = bus_alloc_resource_any(sc->dev, SYS_RES_MEMORY, in t4_map_bars_0_and_4()
3981 &sc->msix_rid, RF_ACTIVE); in t4_map_bars_0_and_4()
3982 if (sc->msix_res == NULL) { in t4_map_bars_0_and_4()
3983 device_printf(sc->dev, "cannot map MSI-X BAR.\n"); in t4_map_bars_0_and_4()
3998 if (is_t4(sc) && sc->rdmacaps == 0) in t4_map_bar_2()
4001 sc->udbs_rid = PCIR_BAR(2); in t4_map_bar_2()
4002 sc->udbs_res = bus_alloc_resource_any(sc->dev, SYS_RES_MEMORY, in t4_map_bar_2()
4003 &sc->udbs_rid, RF_ACTIVE); in t4_map_bar_2()
4004 if (sc->udbs_res == NULL) { in t4_map_bar_2()
4005 device_printf(sc->dev, "cannot map doorbell BAR.\n"); in t4_map_bar_2()
4008 sc->udbs_base = rman_get_virtual(sc->udbs_res); in t4_map_bar_2()
4011 setbit(&sc->doorbells, DOORBELL_UDB); in t4_map_bar_2()
4025 rc = pmap_change_attr((vm_offset_t)sc->udbs_base, in t4_map_bar_2()
4026 rman_get_size(sc->udbs_res), PAT_WRITE_COMBINING); in t4_map_bar_2()
4028 clrbit(&sc->doorbells, DOORBELL_UDB); in t4_map_bar_2()
4029 setbit(&sc->doorbells, DOORBELL_WCWR); in t4_map_bar_2()
4030 setbit(&sc->doorbells, DOORBELL_UDBWC); in t4_map_bar_2()
4032 device_printf(sc->dev, in t4_map_bar_2()
4043 sc->iwt.wc_en = isset(&sc->doorbells, DOORBELL_UDBWC) ? 1 : 0; in t4_map_bar_2()
4051 if ((sc->doorbells & t4_doorbells_allowed) != 0) { in t4_adj_doorbells()
4052 sc->doorbells &= t4_doorbells_allowed; in t4_adj_doorbells()
4056 sc->doorbells, t4_doorbells_allowed); in t4_adj_doorbells()
4104 for (i = 0, mw = &sc->memwin[0]; i < NUM_MEMWIN; i++, mw_init++, mw++) { in setup_memwin()
4105 if (!rw_initialized(&mw->mw_lock)) { in setup_memwin()
4106 rw_init(&mw->mw_lock, "memory window access"); in setup_memwin()
4107 mw->mw_base = mw_init->base; in setup_memwin()
4108 mw->mw_aperture = mw_init->aperture; in setup_memwin()
4109 mw->mw_curpos = 0; in setup_memwin()
4114 t4_write_reg(sc, reg, (mw->mw_base + bar0) | V_BIR(0) | in setup_memwin()
4115 V_WINDOW(ilog2(mw->mw_aperture) - 10)); in setup_memwin()
4116 rw_wlock(&mw->mw_lock); in setup_memwin()
4117 position_memwin(sc, i, mw->mw_curpos); in setup_memwin()
4118 rw_wunlock(&mw->mw_lock); in setup_memwin()
4128 * address prior to the requested address. mw->mw_curpos always has the actual
4138 mw = &sc->memwin[idx]; in position_memwin()
4139 rw_assert(&mw->mw_lock, RA_WLOCKED); in position_memwin()
4143 mw->mw_curpos = addr & ~0xf; /* start must be 16B aligned */ in position_memwin()
4145 pf = V_PFNUM(sc->pf); in position_memwin()
4146 mw->mw_curpos = addr & ~0x7f; /* start must be 128B aligned */ in position_memwin()
4150 val = (mw->mw_curpos >> X_T7_MEMOFST_SHIFT) | pf; in position_memwin()
4153 val = mw->mw_curpos | pf; in position_memwin()
4172 mw = &sc->memwin[idx]; in rw_via_memwin()
4174 rw_rlock(&mw->mw_lock); in rw_via_memwin()
4175 mw_end = mw->mw_curpos + mw->mw_aperture; in rw_via_memwin()
4176 if (addr >= mw_end || addr < mw->mw_curpos) { in rw_via_memwin()
4178 if (!rw_try_upgrade(&mw->mw_lock)) { in rw_via_memwin()
4179 rw_runlock(&mw->mw_lock); in rw_via_memwin()
4180 rw_wlock(&mw->mw_lock); in rw_via_memwin()
4182 rw_assert(&mw->mw_lock, RA_WLOCKED); in rw_via_memwin()
4184 rw_downgrade(&mw->mw_lock); in rw_via_memwin()
4185 mw_end = mw->mw_curpos + mw->mw_aperture; in rw_via_memwin()
4187 rw_assert(&mw->mw_lock, RA_RLOCKED); in rw_via_memwin()
4190 v = t4_read_reg(sc, mw->mw_base + addr - in rw_via_memwin()
4191 mw->mw_curpos); in rw_via_memwin()
4195 t4_write_reg(sc, mw->mw_base + addr - in rw_via_memwin()
4196 mw->mw_curpos, htole32(v)); in rw_via_memwin()
4199 len -= 4; in rw_via_memwin()
4201 rw_runlock(&mw->mw_lock); in rw_via_memwin()
4216 t = &sc->tids; in t4_init_atid_table()
4217 if (t->natids == 0) in t4_init_atid_table()
4220 MPASS(t->atid_tab == NULL); in t4_init_atid_table()
4222 t->atid_tab = malloc(t->natids * sizeof(*t->atid_tab), M_CXGBE, in t4_init_atid_table()
4224 mtx_init(&t->atid_lock, "atid lock", NULL, MTX_DEF); in t4_init_atid_table()
4225 t->afree = t->atid_tab; in t4_init_atid_table()
4226 t->atids_in_use = 0; in t4_init_atid_table()
4227 t->atid_alloc_stopped = false; in t4_init_atid_table()
4228 for (i = 1; i < t->natids; i++) in t4_init_atid_table()
4229 t->atid_tab[i - 1].next = &t->atid_tab[i]; in t4_init_atid_table()
4230 t->atid_tab[t->natids - 1].next = NULL; in t4_init_atid_table()
4238 t = &sc->tids; in t4_free_atid_table()
4240 KASSERT(t->atids_in_use == 0, in t4_free_atid_table()
4241 ("%s: %d atids still in use.", __func__, t->atids_in_use)); in t4_free_atid_table()
4243 if (mtx_initialized(&t->atid_lock)) in t4_free_atid_table()
4244 mtx_destroy(&t->atid_lock); in t4_free_atid_table()
4245 free(t->atid_tab, M_CXGBE); in t4_free_atid_table()
4246 t->atid_tab = NULL; in t4_free_atid_table()
4252 struct tid_info *t = &sc->tids; in stop_atid_allocator()
4254 if (t->natids == 0) in stop_atid_allocator()
4256 mtx_lock(&t->atid_lock); in stop_atid_allocator()
4257 t->atid_alloc_stopped = true; in stop_atid_allocator()
4258 mtx_unlock(&t->atid_lock); in stop_atid_allocator()
4264 struct tid_info *t = &sc->tids; in restart_atid_allocator()
4266 if (t->natids == 0) in restart_atid_allocator()
4268 mtx_lock(&t->atid_lock); in restart_atid_allocator()
4269 KASSERT(t->atids_in_use == 0, in restart_atid_allocator()
4270 ("%s: %d atids still in use.", __func__, t->atids_in_use)); in restart_atid_allocator()
4271 t->atid_alloc_stopped = false; in restart_atid_allocator()
4272 mtx_unlock(&t->atid_lock); in restart_atid_allocator()
4278 struct tid_info *t = &sc->tids; in alloc_atid()
4279 int atid = -1; in alloc_atid()
4281 mtx_lock(&t->atid_lock); in alloc_atid()
4282 if (t->afree && !t->atid_alloc_stopped) { in alloc_atid()
4283 union aopen_entry *p = t->afree; in alloc_atid()
4285 atid = p - t->atid_tab; in alloc_atid()
4287 t->afree = p->next; in alloc_atid()
4288 p->data = ctx; in alloc_atid()
4289 t->atids_in_use++; in alloc_atid()
4291 mtx_unlock(&t->atid_lock); in alloc_atid()
4298 struct tid_info *t = &sc->tids; in lookup_atid()
4300 return (t->atid_tab[atid].data); in lookup_atid()
4306 struct tid_info *t = &sc->tids; in free_atid()
4307 union aopen_entry *p = &t->atid_tab[atid]; in free_atid()
4309 mtx_lock(&t->atid_lock); in free_atid()
4310 p->next = t->afree; in free_atid()
4311 t->afree = p; in free_atid()
4312 t->atids_in_use--; in free_atid()
4313 mtx_unlock(&t->atid_lock); in free_atid()
4344 return ((const struct t4_range *)a)->start - in t4_range_cmp()
4345 ((const struct t4_range *)b)->start; in t4_range_cmp()
4371 r->size = G_EDRAM0_SIZE(addr_len) << 20; in validate_mem_range()
4372 if (r->size > 0) { in validate_mem_range()
4373 r->start = G_EDRAM0_BASE(addr_len) << 20; in validate_mem_range()
4374 if (addr >= r->start && in validate_mem_range()
4375 addr + len <= r->start + r->size) in validate_mem_range()
4383 r->size = G_EDRAM1_SIZE(addr_len) << 20; in validate_mem_range()
4384 if (r->size > 0) { in validate_mem_range()
4385 r->start = G_EDRAM1_BASE(addr_len) << 20; in validate_mem_range()
4386 if (addr >= r->start && in validate_mem_range()
4387 addr + len <= r->start + r->size) in validate_mem_range()
4395 r->size = G_EXT_MEM_SIZE(addr_len) << 20; in validate_mem_range()
4396 if (r->size > 0) { in validate_mem_range()
4397 r->start = G_EXT_MEM_BASE(addr_len) << 20; in validate_mem_range()
4398 if (addr >= r->start && in validate_mem_range()
4399 addr + len <= r->start + r->size) in validate_mem_range()
4407 r->size = G_EXT_MEM1_SIZE(addr_len) << 20; in validate_mem_range()
4408 if (r->size > 0) { in validate_mem_range()
4409 r->start = G_EXT_MEM1_BASE(addr_len) << 20; in validate_mem_range()
4410 if (addr >= r->start && in validate_mem_range()
4411 addr + len <= r->start + r->size) in validate_mem_range()
4423 /* Start from index 0 and examine the next n - 1 entries. */ in validate_mem_range()
4425 for (remaining = n - 1; remaining > 0; remaining--, r++) { in validate_mem_range()
4427 MPASS(r->size > 0); /* r is a valid entry. */ in validate_mem_range()
4429 MPASS(next->size > 0); /* and so is the next one. */ in validate_mem_range()
4431 while (r->start + r->size >= next->start) { in validate_mem_range()
4433 r->size = max(r->start + r->size, in validate_mem_range()
4434 next->start + next->size) - r->start; in validate_mem_range()
4435 n--; /* One fewer entry in total. */ in validate_mem_range()
4436 if (--remaining == 0) in validate_mem_range()
4446 MPASS(next->size > 0); /* must be valid */ in validate_mem_range()
4450 * This so that the foo->size assertion in the in validate_mem_range()
4456 bzero(&mem_ranges[n], (nitems(mem_ranges) - n) * in validate_mem_range()
4466 if (addr >= r->start && in validate_mem_range()
4467 addr + len <= r->start + r->size) in validate_mem_range()
4545 struct devlog_params *dparams = &sc->params.devlog; in fixup_devlog_params()
4548 rc = validate_mt_off_len(sc, dparams->memtype, dparams->start, in fixup_devlog_params()
4549 dparams->size, &dparams->addr); in fixup_devlog_params()
4558 iaq->nirq = T4_EXTRA_INTR; in update_nirq()
4559 iaq->nirq += nports * max(iaq->nrxq, iaq->nnmrxq); in update_nirq()
4560 iaq->nirq += nports * iaq->nofldrxq; in update_nirq()
4561 iaq->nirq += nports * (iaq->num_vis - 1) * in update_nirq()
4562 max(iaq->nrxq_vi, iaq->nnmrxq_vi); in update_nirq()
4563 iaq->nirq += nports * (iaq->num_vis - 1) * iaq->nofldrxq_vi; in update_nirq()
4574 const int nports = sc->params.nports; in calculate_iaq()
4580 iaq->intr_type = itype; in calculate_iaq()
4581 iaq->num_vis = t4_num_vis; in calculate_iaq()
4582 iaq->ntxq = t4_ntxq; in calculate_iaq()
4583 iaq->ntxq_vi = t4_ntxq_vi; in calculate_iaq()
4584 iaq->nrxq = t4_nrxq; in calculate_iaq()
4585 iaq->nrxq_vi = t4_nrxq_vi; in calculate_iaq()
4588 if (sc->params.tid_qid_sel_mask == 0) { in calculate_iaq()
4589 iaq->nofldtxq = t4_nofldtxq; in calculate_iaq()
4590 iaq->nofldtxq_vi = t4_nofldtxq_vi; in calculate_iaq()
4592 iaq->nofldtxq = roundup(t4_nofldtxq, sc->params.ncores); in calculate_iaq()
4593 iaq->nofldtxq_vi = roundup(t4_nofldtxq_vi, in calculate_iaq()
4594 sc->params.ncores); in calculate_iaq()
4595 if (iaq->nofldtxq != t4_nofldtxq) in calculate_iaq()
4596 device_printf(sc->dev, in calculate_iaq()
4597 "nofldtxq updated (%d -> %d) for correct" in calculate_iaq()
4599 t4_nofldtxq, iaq->nofldtxq, in calculate_iaq()
4600 sc->params.ncores); in calculate_iaq()
4601 if (iaq->num_vis > 1 && in calculate_iaq()
4602 iaq->nofldtxq_vi != t4_nofldtxq_vi) in calculate_iaq()
4603 device_printf(sc->dev, in calculate_iaq()
4604 "nofldtxq_vi updated (%d -> %d) for correct" in calculate_iaq()
4606 t4_nofldtxq_vi, iaq->nofldtxq_vi, in calculate_iaq()
4607 sc->params.ncores); in calculate_iaq()
4613 iaq->nofldrxq = t4_nofldrxq; in calculate_iaq()
4614 iaq->nofldrxq_vi = t4_nofldrxq_vi; in calculate_iaq()
4619 iaq->nnmtxq = t4_nnmtxq; in calculate_iaq()
4620 iaq->nnmrxq = t4_nnmrxq; in calculate_iaq()
4623 iaq->nnmtxq_vi = t4_nnmtxq_vi; in calculate_iaq()
4624 iaq->nnmrxq_vi = t4_nnmrxq_vi; in calculate_iaq()
4629 if (iaq->nirq <= navail && in calculate_iaq()
4630 (itype != INTR_MSI || powerof2(iaq->nirq))) { in calculate_iaq()
4632 * This is the normal case -- there are enough interrupts for in calculate_iaq()
4642 while (iaq->num_vis > 1) { in calculate_iaq()
4643 iaq->num_vis--; in calculate_iaq()
4645 if (iaq->nirq <= navail && in calculate_iaq()
4646 (itype != INTR_MSI || powerof2(iaq->nirq))) { in calculate_iaq()
4647 device_printf(sc->dev, "virtual interfaces per port " in calculate_iaq()
4651 iaq->num_vis, t4_num_vis, iaq->nrxq, iaq->nofldrxq, in calculate_iaq()
4652 iaq->nrxq_vi, iaq->nofldrxq_vi, iaq->nnmrxq_vi, in calculate_iaq()
4653 itype, navail, iaq->nirq); in calculate_iaq()
4661 MPASS(iaq->num_vis == 1); in calculate_iaq()
4662 iaq->ntxq_vi = iaq->nrxq_vi = 0; in calculate_iaq()
4663 iaq->nofldtxq_vi = iaq->nofldrxq_vi = 0; in calculate_iaq()
4664 iaq->nnmtxq_vi = iaq->nnmrxq_vi = 0; in calculate_iaq()
4665 if (iaq->num_vis != t4_num_vis) { in calculate_iaq()
4666 device_printf(sc->dev, "extra virtual interfaces disabled. " in calculate_iaq()
4669 iaq->nrxq, iaq->nofldrxq, iaq->nrxq_vi, iaq->nofldrxq_vi, in calculate_iaq()
4670 iaq->nnmrxq_vi, itype, navail, iaq->nirq); in calculate_iaq()
4679 if (iaq->nrxq > 1) { in calculate_iaq()
4680 iaq->nrxq = rounddown_pow_of_two(iaq->nrxq - 1); in calculate_iaq()
4681 if (iaq->nnmrxq > iaq->nrxq) in calculate_iaq()
4682 iaq->nnmrxq = iaq->nrxq; in calculate_iaq()
4684 if (iaq->nofldrxq > 1) in calculate_iaq()
4685 iaq->nofldrxq >>= 1; in calculate_iaq()
4687 old_nirq = iaq->nirq; in calculate_iaq()
4689 if (iaq->nirq <= navail && in calculate_iaq()
4690 (itype != INTR_MSI || powerof2(iaq->nirq))) { in calculate_iaq()
4691 device_printf(sc->dev, "running with reduced number of " in calculate_iaq()
4694 "itype %d, navail %u, nirq %d.\n", iaq->nrxq, in calculate_iaq()
4695 iaq->nofldrxq, itype, navail, iaq->nirq); in calculate_iaq()
4698 } while (old_nirq != iaq->nirq); in calculate_iaq()
4701 device_printf(sc->dev, "running with minimal number of queues. " in calculate_iaq()
4703 iaq->nirq = 1; in calculate_iaq()
4704 iaq->nrxq = 1; in calculate_iaq()
4705 iaq->ntxq = 1; in calculate_iaq()
4706 if (iaq->nofldrxq > 0) { in calculate_iaq()
4707 iaq->nofldrxq = 1; in calculate_iaq()
4708 iaq->nofldtxq = 1; in calculate_iaq()
4709 if (sc->params.tid_qid_sel_mask == 0) in calculate_iaq()
4710 iaq->nofldtxq = 1; in calculate_iaq()
4712 iaq->nofldtxq = sc->params.ncores; in calculate_iaq()
4714 iaq->nnmtxq = 0; in calculate_iaq()
4715 iaq->nnmrxq = 0; in calculate_iaq()
4717 MPASS(iaq->num_vis > 0); in calculate_iaq()
4718 if (iaq->num_vis > 1) { in calculate_iaq()
4719 MPASS(iaq->nrxq_vi > 0); in calculate_iaq()
4720 MPASS(iaq->ntxq_vi > 0); in calculate_iaq()
4722 MPASS(iaq->nirq > 0); in calculate_iaq()
4723 MPASS(iaq->nrxq > 0); in calculate_iaq()
4724 MPASS(iaq->ntxq > 0); in calculate_iaq()
4726 MPASS(powerof2(iaq->nirq)); in calculate_iaq()
4727 if (sc->params.tid_qid_sel_mask != 0) in calculate_iaq()
4728 MPASS(iaq->nofldtxq % sc->params.ncores == 0); in calculate_iaq()
4742 navail = pci_msix_count(sc->dev); in cfg_itype_and_nqueues()
4744 navail = pci_msi_count(sc->dev); in cfg_itype_and_nqueues()
4752 nalloc = iaq->nirq; in cfg_itype_and_nqueues()
4755 rc = pci_alloc_msix(sc->dev, &nalloc); in cfg_itype_and_nqueues()
4757 rc = pci_alloc_msi(sc->dev, &nalloc); in cfg_itype_and_nqueues()
4760 if (nalloc == iaq->nirq) in cfg_itype_and_nqueues()
4767 device_printf(sc->dev, "fewer vectors than requested, " in cfg_itype_and_nqueues()
4769 itype, iaq->nirq, nalloc); in cfg_itype_and_nqueues()
4770 pci_release_msi(sc->dev); in cfg_itype_and_nqueues()
4775 device_printf(sc->dev, in cfg_itype_and_nqueues()
4777 itype, rc, iaq->nirq, nalloc); in cfg_itype_and_nqueues()
4780 device_printf(sc->dev, in cfg_itype_and_nqueues()
4782 "allowed=%d, msi-x=%d, msi=%d, intx=1", t4_intr_types, in cfg_itype_and_nqueues()
4783 pci_msix_count(sc->dev), pci_msi_count(sc->dev)); in cfg_itype_and_nqueues()
4910 if (hdr1->chip == hdr2->chip && hdr1->fw_ver == hdr2->fw_ver) in fw_compatible()
4917 #define SAME_INTF(x) (hdr1->intfver_##x == hdr2->intfver_##x) in fw_compatible()
4918 if (hdr1->chip == hdr2->chip && SAME_INTF(nic) && SAME_INTF(vnic) && in fw_compatible()
4939 device_printf(sc->dev, in load_fw_module()
4945 *dcfg = firmware_get(fw_info->kld_name); in load_fw_module()
4948 *fw = firmware_get(fw_info->fw_mod_name); in load_fw_module()
4977 const uint32_t c = be32toh(card_fw->fw_ver); in install_kld_firmware()
4985 fw_install = t4_fw_install < 0 ? -t4_fw_install : t4_fw_install; in install_kld_firmware()
4991 device_printf(sc->dev, in install_kld_firmware()
4993 " will use compiled-in firmware version for" in install_kld_firmware()
4997 memcpy(&bundled_fw, fw->data, sizeof(bundled_fw)); in install_kld_firmware()
5006 if ((sc->flags & FW_OK) == 0) { in install_kld_firmware()
5042 device_printf(sc->dev, "firmware on card (%u.%u.%u.%u) is %s, " in install_kld_firmware()
5058 device_printf(sc->dev, in install_kld_firmware()
5065 device_printf(sc->dev, "firmware on card (%u.%u.%u.%u) is %s, " in install_kld_firmware()
5070 rc = sc->flags & FW_OK ? 0 : ENOENT; in install_kld_firmware()
5073 k = be32toh(((const struct fw_hdr *)fw->data)->fw_ver); in install_kld_firmware()
5076 device_printf(sc->dev, in install_kld_firmware()
5083 rc = sc->flags & FW_OK ? 0 : EINVAL; in install_kld_firmware()
5087 device_printf(sc->dev, "firmware on card (%u.%u.%u.%u) is %s, " in install_kld_firmware()
5094 rc = -t4_fw_upgrade(sc, sc->mbox, fw->data, fw->datasize, 0); in install_kld_firmware()
5096 device_printf(sc->dev, "failed to install firmware: %d\n", rc); in install_kld_firmware()
5100 memcpy(card_fw, fw->data, sizeof(*card_fw)); in install_kld_firmware()
5125 device_printf(sc->dev, in contact_firmware()
5130 drv_fw = &fw_info->fw_h; in contact_firmware()
5135 rc = -t4_get_fw_hdr(sc, card_fw); in contact_firmware()
5137 device_printf(sc->dev, in contact_firmware()
5150 rc = t4_fw_hello(sc, sc->mbox, sc->mbox, MASTER_MAY, &state); in contact_firmware()
5152 rc = -rc; in contact_firmware()
5153 device_printf(sc->dev, in contact_firmware()
5163 MPASS(be32toh(card_fw->flags) & FW_HDR_FLAGS_RESET_HALT); in contact_firmware()
5164 sc->flags |= FW_OK; /* The firmware responded to the FW_HELLO. */ in contact_firmware()
5166 if (rc == sc->pf) { in contact_firmware()
5167 sc->flags |= MASTER_PF; in contact_firmware()
5180 device_printf(sc->dev, "couldn't be master(%d), " in contact_firmware()
5190 device_printf(sc->dev, "PF%d is master, device state %d. " in contact_firmware()
5192 snprintf(sc->cfg_file, sizeof(sc->cfg_file), "pf%d", rc); in contact_firmware()
5193 sc->cfcsum = 0; in contact_firmware()
5197 if (rc != 0 && sc->flags & FW_OK) { in contact_firmware()
5198 t4_fw_bye(sc, sc->mbox); in contact_firmware()
5199 sc->flags &= ~FW_OK; in contact_firmware()
5219 if (pci_get_device(sc->dev) == 0x440a) in copy_cfg_file_to_card()
5227 device_printf(sc->dev, in copy_cfg_file_to_card()
5232 cfdata = dcfg->data; in copy_cfg_file_to_card()
5233 cflen = dcfg->datasize & ~3; in copy_cfg_file_to_card()
5239 device_printf(sc->dev, in copy_cfg_file_to_card()
5245 snprintf(s, sizeof(s), "%s_%s", fw_info->kld_name, cfg_file); in copy_cfg_file_to_card()
5249 device_printf(sc->dev, in copy_cfg_file_to_card()
5255 cfdata = rcfg->data; in copy_cfg_file_to_card()
5256 cflen = rcfg->datasize & ~3; in copy_cfg_file_to_card()
5260 device_printf(sc->dev, in copy_cfg_file_to_card()
5269 device_printf(sc->dev, in copy_cfg_file_to_card()
5318 rc = -t4_fw_reset(sc, sc->mbox, F_PIORSTMODE | F_PIORST); in apply_cfg_and_initialize()
5320 device_printf(sc->dev, "firmware reset failed: %d.\n", rc); in apply_cfg_and_initialize()
5343 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, &param, &val); in apply_cfg_and_initialize()
5346 device_printf(sc->dev, in apply_cfg_and_initialize()
5359 device_printf(sc->dev, in apply_cfg_and_initialize()
5364 rc = -t4_wr_mbox(sc, sc->mbox, &caps, sizeof(caps), &caps); in apply_cfg_and_initialize()
5366 device_printf(sc->dev, "failed to pre-process config file: %d " in apply_cfg_and_initialize()
5374 device_printf(sc->dev, in apply_cfg_and_initialize()
5378 sc->cfcsum = cfcsum; in apply_cfg_and_initialize()
5379 snprintf(sc->cfg_file, sizeof(sc->cfg_file), "%s", cfg_file); in apply_cfg_and_initialize()
5386 caps.x##caps &= htobe16(caps_allowed->x##caps); \ in apply_cfg_and_initialize()
5403 * to cope with the situation in non-debug builds by disabling in apply_cfg_and_initialize()
5417 rc = -t4_wr_mbox(sc, sc->mbox, &caps, sizeof(caps), NULL); in apply_cfg_and_initialize()
5419 device_printf(sc->dev, in apply_cfg_and_initialize()
5428 rc = -t4_fw_initialize(sc, sc->mbox); in apply_cfg_and_initialize()
5430 device_printf(sc->dev, "fw_initialize failed: %d.\n", rc); in apply_cfg_and_initialize()
5449 MPASS(sc->flags & MASTER_PF); in partition_resources()
5465 fallback = sc->debug_flags & DF_DISABLE_CFG_RETRY ? false : true; in partition_resources()
5471 device_printf(sc->dev, in partition_resources()
5497 snprintf(sc->fw_version, sizeof(sc->fw_version), "%u.%u.%u.%u", in get_params__pre_init()
5498 G_FW_HDR_FW_VER_MAJOR(sc->params.fw_vers), in get_params__pre_init()
5499 G_FW_HDR_FW_VER_MINOR(sc->params.fw_vers), in get_params__pre_init()
5500 G_FW_HDR_FW_VER_MICRO(sc->params.fw_vers), in get_params__pre_init()
5501 G_FW_HDR_FW_VER_BUILD(sc->params.fw_vers)); in get_params__pre_init()
5503 snprintf(sc->bs_version, sizeof(sc->bs_version), "%u.%u.%u.%u", in get_params__pre_init()
5504 G_FW_HDR_FW_VER_MAJOR(sc->params.bs_vers), in get_params__pre_init()
5505 G_FW_HDR_FW_VER_MINOR(sc->params.bs_vers), in get_params__pre_init()
5506 G_FW_HDR_FW_VER_MICRO(sc->params.bs_vers), in get_params__pre_init()
5507 G_FW_HDR_FW_VER_BUILD(sc->params.bs_vers)); in get_params__pre_init()
5509 snprintf(sc->tp_version, sizeof(sc->tp_version), "%u.%u.%u.%u", in get_params__pre_init()
5510 G_FW_HDR_FW_VER_MAJOR(sc->params.tp_vers), in get_params__pre_init()
5511 G_FW_HDR_FW_VER_MINOR(sc->params.tp_vers), in get_params__pre_init()
5512 G_FW_HDR_FW_VER_MICRO(sc->params.tp_vers), in get_params__pre_init()
5513 G_FW_HDR_FW_VER_BUILD(sc->params.tp_vers)); in get_params__pre_init()
5515 snprintf(sc->er_version, sizeof(sc->er_version), "%u.%u.%u.%u", in get_params__pre_init()
5516 G_FW_HDR_FW_VER_MAJOR(sc->params.er_vers), in get_params__pre_init()
5517 G_FW_HDR_FW_VER_MINOR(sc->params.er_vers), in get_params__pre_init()
5518 G_FW_HDR_FW_VER_MICRO(sc->params.er_vers), in get_params__pre_init()
5519 G_FW_HDR_FW_VER_BUILD(sc->params.er_vers)); in get_params__pre_init()
5523 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 2, param, val); in get_params__pre_init()
5525 device_printf(sc->dev, in get_params__pre_init()
5530 sc->params.portvec = val[0]; in get_params__pre_init()
5531 sc->params.nports = bitcount32(val[0]); in get_params__pre_init()
5532 sc->params.vpd.cclk = val[1]; in get_params__pre_init()
5535 rc = -t4_init_devlog_ncores_params(sc, 1); in get_params__pre_init()
5539 device_printf(sc->dev, in get_params__pre_init()
5559 rc = -t4_set_params(sc, sc->mbox, sc->pf, 0, 1, &param, &val); in set_params__pre_init()
5562 sc->params.fw_vers < FW_VERSION32(1, 20, 1, 0)) { in set_params__pre_init()
5566 device_printf(sc->dev, in set_params__pre_init()
5572 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, &param, &val); in set_params__pre_init()
5574 rc = -t4_set_params(sc, sc->mbox, sc->pf, 0, 1, &param, in set_params__pre_init()
5577 device_printf(sc->dev, in set_params__pre_init()
5586 rc = -t4_set_params(sc, sc->mbox, sc->pf, 0, 1, &param, &val); in set_params__pre_init()
5588 sc->params.viid_smt_extn_support = true; in set_params__pre_init()
5590 sc->params.viid_smt_extn_support = false; in set_params__pre_init()
5615 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 7, param, val); in get_params__post_init()
5617 device_printf(sc->dev, in get_params__post_init()
5622 sc->sge.iq_start = val[0]; in get_params__post_init()
5623 sc->sge.eq_start = val[1]; in get_params__post_init()
5625 sc->tids.ftid_base = val[2]; in get_params__post_init()
5626 sc->tids.ftid_end = val[3]; in get_params__post_init()
5627 sc->tids.nftids = val[3] - val[2] + 1; in get_params__post_init()
5629 sc->vres.l2t.start = val[4]; in get_params__post_init()
5630 sc->vres.l2t.size = val[5] - val[4] + 1; in get_params__post_init()
5632 if (sc->vres.l2t.size > 0) in get_params__post_init()
5634 sc->params.core_vdd = val[6]; in get_params__post_init()
5638 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 2, param, val); in get_params__post_init()
5640 device_printf(sc->dev, in get_params__post_init()
5644 MPASS((int)val[0] >= sc->sge.iq_start); in get_params__post_init()
5645 sc->sge.iqmap_sz = val[0] - sc->sge.iq_start + 1; in get_params__post_init()
5646 MPASS((int)val[1] >= sc->sge.eq_start); in get_params__post_init()
5647 sc->sge.eqmap_sz = val[1] - sc->sge.eq_start + 1; in get_params__post_init()
5651 sc->tids.tid_base = t4_read_reg(sc, in get_params__post_init()
5656 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 2, param, val); in get_params__post_init()
5658 device_printf(sc->dev, in get_params__post_init()
5663 sc->tids.hpftid_base = val[0]; in get_params__post_init()
5664 sc->tids.hpftid_end = val[1]; in get_params__post_init()
5665 sc->tids.nhpftids = val[1] - val[0] + 1; in get_params__post_init()
5671 MPASS(sc->tids.hpftid_base == 0); in get_params__post_init()
5672 MPASS(sc->tids.tid_base == sc->tids.nhpftids); in get_params__post_init()
5677 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 2, param, val); in get_params__post_init()
5679 device_printf(sc->dev, in get_params__post_init()
5684 sc->rawf_base = val[0]; in get_params__post_init()
5685 sc->nrawf = val[1] - val[0] + 1; in get_params__post_init()
5689 if (sc->params.ncores > 1) { in get_params__post_init()
5693 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, param, val); in get_params__post_init()
5694 sc->params.tid_qid_sel_mask = rc == 0 ? val[0] : 0; in get_params__post_init()
5708 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, param, val); in get_params__post_init()
5710 sc->params.mps_bg_map = val[0]; in get_params__post_init()
5712 sc->params.mps_bg_map = UINT32_MAX; /* Not a legal value. */ in get_params__post_init()
5716 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, param, val); in get_params__post_init()
5718 sc->params.tp_ch_map = val[0]; in get_params__post_init()
5720 sc->params.tp_ch_map = UINT32_MAX; /* Not a legal value. */ in get_params__post_init()
5724 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, param, val); in get_params__post_init()
5726 sc->params.tx_tp_ch_map = val[0]; in get_params__post_init()
5728 sc->params.tx_tp_ch_map = UINT32_MAX; /* Not a legal value. */ in get_params__post_init()
5735 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, param, val); in get_params__post_init()
5737 sc->params.filter2_wr_support = val[0] != 0; in get_params__post_init()
5739 sc->params.filter2_wr_support = 0; in get_params__post_init()
5746 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, param, val); in get_params__post_init()
5748 sc->params.ulptx_memwrite_dsgl = val[0] != 0; in get_params__post_init()
5750 sc->params.ulptx_memwrite_dsgl = false; in get_params__post_init()
5754 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, param, val); in get_params__post_init()
5756 sc->params.fr_nsmr_tpte_wr_support = val[0] != 0; in get_params__post_init()
5758 sc->params.fr_nsmr_tpte_wr_support = false; in get_params__post_init()
5762 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, param, val); in get_params__post_init()
5764 sc->params.dev_512sgl_mr = val[0] != 0; in get_params__post_init()
5766 sc->params.dev_512sgl_mr = false; in get_params__post_init()
5769 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, param, val); in get_params__post_init()
5771 sc->params.max_pkts_per_eth_tx_pkts_wr = val[0]; in get_params__post_init()
5773 sc->params.max_pkts_per_eth_tx_pkts_wr = 15; in get_params__post_init()
5776 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, param, val); in get_params__post_init()
5779 sc->params.nsched_cls = val[0]; in get_params__post_init()
5781 sc->params.nsched_cls = sc->chip_params->nsched_cls; in get_params__post_init()
5788 rc = -t4_wr_mbox(sc, sc->mbox, &caps, sizeof(caps), &caps); in get_params__post_init()
5790 device_printf(sc->dev, in get_params__post_init()
5796 sc->x = htobe16(caps.x); \ in get_params__post_init()
5809 if (sc->niccaps & FW_CAPS_CONFIG_NIC_HASHFILTER) { in get_params__post_init()
5811 MPASS(sc->toecaps == 0); in get_params__post_init()
5812 sc->toecaps = 0; in get_params__post_init()
5815 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, param, val); in get_params__post_init()
5817 device_printf(sc->dev, in get_params__post_init()
5821 sc->tids.ntids = val[0]; in get_params__post_init()
5822 if (sc->params.fw_vers < FW_VERSION32(1, 20, 5, 0)) { in get_params__post_init()
5823 MPASS(sc->tids.ntids >= sc->tids.nhpftids); in get_params__post_init()
5824 sc->tids.ntids -= sc->tids.nhpftids; in get_params__post_init()
5826 sc->tids.natids = min(sc->tids.ntids / 2, MAX_ATIDS); in get_params__post_init()
5827 sc->params.hash_filter = 1; in get_params__post_init()
5829 if (sc->niccaps & FW_CAPS_CONFIG_NIC_ETHOFLD) { in get_params__post_init()
5833 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 3, param, val); in get_params__post_init()
5835 device_printf(sc->dev, in get_params__post_init()
5840 sc->tids.etid_base = val[0]; in get_params__post_init()
5841 sc->tids.etid_end = val[1]; in get_params__post_init()
5842 sc->tids.netids = val[1] - val[0] + 1; in get_params__post_init()
5843 sc->params.eo_wr_cred = val[2]; in get_params__post_init()
5844 sc->params.ethoffload = 1; in get_params__post_init()
5847 if (sc->toecaps) { in get_params__post_init()
5848 /* query offload-related parameters */ in get_params__post_init()
5855 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 6, param, val); in get_params__post_init()
5857 device_printf(sc->dev, in get_params__post_init()
5861 sc->tids.ntids = val[0]; in get_params__post_init()
5862 if (sc->params.fw_vers < FW_VERSION32(1, 20, 5, 0)) { in get_params__post_init()
5863 MPASS(sc->tids.ntids >= sc->tids.nhpftids); in get_params__post_init()
5864 sc->tids.ntids -= sc->tids.nhpftids; in get_params__post_init()
5866 sc->tids.natids = min(sc->tids.ntids / 2, MAX_ATIDS); in get_params__post_init()
5868 sc->tids.stid_base = val[1]; in get_params__post_init()
5869 sc->tids.nstids = val[2] - val[1] + 1; in get_params__post_init()
5871 sc->vres.ddp.start = val[3]; in get_params__post_init()
5872 sc->vres.ddp.size = val[4] - val[3] + 1; in get_params__post_init()
5873 sc->params.ofldq_wr_cred = val[5]; in get_params__post_init()
5874 sc->params.offload = 1; in get_params__post_init()
5877 * The firmware attempts memfree TOE configuration for -SO cards in get_params__post_init()
5884 sc->iscsicaps = 0; in get_params__post_init()
5885 sc->nvmecaps = 0; in get_params__post_init()
5886 sc->rdmacaps = 0; in get_params__post_init()
5888 if (sc->nvmecaps || sc->rdmacaps) { in get_params__post_init()
5893 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 4, param, val); in get_params__post_init()
5895 device_printf(sc->dev, in get_params__post_init()
5899 sc->vres.stag.start = val[0]; in get_params__post_init()
5900 sc->vres.stag.size = val[1] - val[0] + 1; in get_params__post_init()
5901 sc->vres.pbl.start = val[2]; in get_params__post_init()
5902 sc->vres.pbl.size = val[3] - val[2] + 1; in get_params__post_init()
5904 if (sc->rdmacaps) { in get_params__post_init()
5911 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 6, param, val); in get_params__post_init()
5913 device_printf(sc->dev, in get_params__post_init()
5917 sc->vres.rq.start = val[0]; in get_params__post_init()
5918 sc->vres.rq.size = val[1] - val[0] + 1; in get_params__post_init()
5919 sc->vres.qp.start = val[2]; in get_params__post_init()
5920 sc->vres.qp.size = val[3] - val[2] + 1; in get_params__post_init()
5921 sc->vres.cq.start = val[4]; in get_params__post_init()
5922 sc->vres.cq.size = val[5] - val[4] + 1; in get_params__post_init()
5930 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 6, param, val); in get_params__post_init()
5932 device_printf(sc->dev, in get_params__post_init()
5936 sc->vres.ocq.start = val[0]; in get_params__post_init()
5937 sc->vres.ocq.size = val[1] - val[0] + 1; in get_params__post_init()
5938 sc->vres.srq.start = val[2]; in get_params__post_init()
5939 sc->vres.srq.size = val[3] - val[2] + 1; in get_params__post_init()
5940 sc->params.max_ordird_qp = val[4]; in get_params__post_init()
5941 sc->params.max_ird_adapter = val[5]; in get_params__post_init()
5943 if (sc->iscsicaps) { in get_params__post_init()
5946 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 2, param, val); in get_params__post_init()
5948 device_printf(sc->dev, in get_params__post_init()
5952 sc->vres.iscsi.start = val[0]; in get_params__post_init()
5953 sc->vres.iscsi.size = val[1] - val[0] + 1; in get_params__post_init()
5955 if (sc->cryptocaps & FW_CAPS_CONFIG_TLSKEYS) { in get_params__post_init()
5958 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 2, param, val); in get_params__post_init()
5960 device_printf(sc->dev, in get_params__post_init()
5964 sc->vres.key.start = val[0]; in get_params__post_init()
5965 sc->vres.key.size = val[1] - val[0] + 1; in get_params__post_init()
5974 t4_read_mtu_tbl(sc, sc->params.mtus, NULL); in get_params__post_init()
5975 t4_load_mtus(sc, sc->params.mtus, sc->params.a_wnd, sc->params.b_wnd); in get_params__post_init()
5996 callout_schedule_sbt(&sc->ktls_tick, SBT_1MS, 0, C_HARDCLOCK); in ktls_tick()
6008 rc = -t4_set_params(sc, sc->mbox, sc->pf, 0, 1, &param, &param); in t6_config_kern_tls()
6016 sc->flags |= KERN_TLS_ON; in t6_config_kern_tls()
6017 callout_reset_sbt(&sc->ktls_tick, SBT_1MS, 0, ktls_tick, sc, in t6_config_kern_tls()
6020 sc->flags &= ~KERN_TLS_ON; in t6_config_kern_tls()
6021 callout_stop(&sc->ktls_tick); in t6_config_kern_tls()
6039 (void)t4_set_params(sc, sc->mbox, sc->pf, 0, 1, &param, &val); in set_params__post_init()
6044 if (t4_set_params(sc, sc->mbox, sc->pf, 0, 1, &param, &val) == 0) in set_params__post_init()
6045 sc->params.port_caps32 = 1; in set_params__post_init()
6048 val = 1 << (G_MASKSIZE(t4_read_reg(sc, A_TP_RSS_CONFIG_TNL)) - 1); in set_params__post_init()
6050 V_MASKFILTER(val - 1)); in set_params__post_init()
6126 if (t4_toe_rexmt_backoff[i] != -1) { in set_params__post_init()
6145 sc->tlst.inline_keys = t4_tls_inline_keys; in set_params__post_init()
6147 sc->tlst.combo_wrs = t4_tls_combo_wrs; in set_params__post_init()
6150 sc->tlst.short_records = t4_tls_short_records; in set_params__post_init()
6151 sc->tlst.partial_ghash = t4_tls_partial_ghash; in set_params__post_init()
6164 struct adapter_params *p = &sc->params; in t4_set_desc()
6166 device_set_descf(sc->dev, "Chelsio %s", p->vpd.id); in t4_set_desc()
6195 ifm = &pi->media; in set_current_media()
6196 if (ifm->ifm_cur != NULL && in set_current_media()
6197 IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_NONE) in set_current_media()
6200 lc = &pi->link_cfg; in set_current_media()
6201 if (lc->requested_aneg != AUTONEG_DISABLE && in set_current_media()
6202 lc->pcaps & FW_PORT_CAP32_ANEG) { in set_current_media()
6207 if (lc->requested_fc & PAUSE_TX) in set_current_media()
6209 if (lc->requested_fc & PAUSE_RX) in set_current_media()
6211 if (lc->requested_speed == 0) in set_current_media()
6212 speed = port_top_speed(pi) * 1000; /* Gbps -> Mbps */ in set_current_media()
6214 speed = lc->requested_speed; in set_current_media()
6226 return (pi->port_type == FW_PORT_TYPE_BT_SGMII || in fixed_ifmedia()
6227 pi->port_type == FW_PORT_TYPE_BT_XFI || in fixed_ifmedia()
6228 pi->port_type == FW_PORT_TYPE_BT_XAUI || in fixed_ifmedia()
6229 pi->port_type == FW_PORT_TYPE_KX4 || in fixed_ifmedia()
6230 pi->port_type == FW_PORT_TYPE_KX || in fixed_ifmedia()
6231 pi->port_type == FW_PORT_TYPE_KR || in fixed_ifmedia()
6232 pi->port_type == FW_PORT_TYPE_BP_AP || in fixed_ifmedia()
6233 pi->port_type == FW_PORT_TYPE_BP4_AP || in fixed_ifmedia()
6234 pi->port_type == FW_PORT_TYPE_BP40_BA || in fixed_ifmedia()
6235 pi->port_type == FW_PORT_TYPE_KR4_100G || in fixed_ifmedia()
6236 pi->port_type == FW_PORT_TYPE_KR_SFP28 || in fixed_ifmedia()
6237 pi->port_type == FW_PORT_TYPE_KR_XLAUI); in fixed_ifmedia()
6250 if (pi->flags & FIXED_IFMEDIA) in build_medialist()
6256 ifm = &pi->media; in build_medialist()
6258 lc = &pi->link_cfg; in build_medialist()
6259 ss = G_FW_PORT_CAP32_SPEED(lc->pcaps); /* Supported Speeds */ in build_medialist()
6263 MPASS(LIST_EMPTY(&ifm->ifm_list)); in build_medialist()
6285 if (lc->pcaps & FW_PORT_CAP32_ANEG) in build_medialist()
6297 struct link_config *lc = &pi->link_cfg; in init_link_config()
6301 lc->requested_caps = 0; in init_link_config()
6302 lc->requested_speed = 0; in init_link_config()
6305 lc->requested_aneg = AUTONEG_DISABLE; in init_link_config()
6307 lc->requested_aneg = AUTONEG_ENABLE; in init_link_config()
6309 lc->requested_aneg = AUTONEG_AUTO; in init_link_config()
6311 lc->requested_fc = t4_pause_settings & (PAUSE_TX | PAUSE_RX | in init_link_config()
6315 lc->requested_fec = FEC_AUTO; in init_link_config()
6317 lc->requested_fec = FEC_NONE; in init_link_config()
6319 /* -1 is handled by the FEC_AUTO block above and not here. */ in init_link_config()
6320 lc->requested_fec = t4_fec & in init_link_config()
6322 if (lc->requested_fec == 0) in init_link_config()
6323 lc->requested_fec = FEC_AUTO; in init_link_config()
6326 lc->force_fec = -1; in init_link_config()
6328 lc->force_fec = 1; in init_link_config()
6330 lc->force_fec = 0; in init_link_config()
6341 struct link_config *lc = &pi->link_cfg; in fixup_link_config()
6347 if (lc->requested_speed != 0) { in fixup_link_config()
6348 fwspeed = speed_to_fwcap(lc->requested_speed); in fixup_link_config()
6349 if ((fwspeed & lc->pcaps) == 0) { in fixup_link_config()
6351 lc->requested_speed = 0; in fixup_link_config()
6356 MPASS(lc->requested_aneg == AUTONEG_ENABLE || in fixup_link_config()
6357 lc->requested_aneg == AUTONEG_DISABLE || in fixup_link_config()
6358 lc->requested_aneg == AUTONEG_AUTO); in fixup_link_config()
6359 if (lc->requested_aneg == AUTONEG_ENABLE && in fixup_link_config()
6360 !(lc->pcaps & FW_PORT_CAP32_ANEG)) { in fixup_link_config()
6362 lc->requested_aneg = AUTONEG_AUTO; in fixup_link_config()
6366 MPASS((lc->requested_fc & ~(PAUSE_TX | PAUSE_RX | PAUSE_AUTONEG)) == 0); in fixup_link_config()
6367 if (lc->requested_fc & PAUSE_TX && in fixup_link_config()
6368 !(lc->pcaps & FW_PORT_CAP32_FC_TX)) { in fixup_link_config()
6370 lc->requested_fc &= ~PAUSE_TX; in fixup_link_config()
6372 if (lc->requested_fc & PAUSE_RX && in fixup_link_config()
6373 !(lc->pcaps & FW_PORT_CAP32_FC_RX)) { in fixup_link_config()
6375 lc->requested_fc &= ~PAUSE_RX; in fixup_link_config()
6377 if (!(lc->requested_fc & PAUSE_AUTONEG) && in fixup_link_config()
6378 !(lc->pcaps & FW_PORT_CAP32_FORCE_PAUSE)) { in fixup_link_config()
6380 lc->requested_fc |= PAUSE_AUTONEG; in fixup_link_config()
6384 if ((lc->requested_fec & FEC_RS && in fixup_link_config()
6385 !(lc->pcaps & FW_PORT_CAP32_FEC_RS)) || in fixup_link_config()
6386 (lc->requested_fec & FEC_BASER_RS && in fixup_link_config()
6387 !(lc->pcaps & FW_PORT_CAP32_FEC_BASER_RS))) { in fixup_link_config()
6389 lc->requested_fec = FEC_AUTO; in fixup_link_config()
6402 struct adapter *sc = pi->adapter; in apply_link_config()
6403 struct link_config *lc = &pi->link_cfg; in apply_link_config()
6410 if (lc->requested_aneg == AUTONEG_ENABLE) in apply_link_config()
6411 MPASS(lc->pcaps & FW_PORT_CAP32_ANEG); in apply_link_config()
6412 if (!(lc->requested_fc & PAUSE_AUTONEG)) in apply_link_config()
6413 MPASS(lc->pcaps & FW_PORT_CAP32_FORCE_PAUSE); in apply_link_config()
6414 if (lc->requested_fc & PAUSE_TX) in apply_link_config()
6415 MPASS(lc->pcaps & FW_PORT_CAP32_FC_TX); in apply_link_config()
6416 if (lc->requested_fc & PAUSE_RX) in apply_link_config()
6417 MPASS(lc->pcaps & FW_PORT_CAP32_FC_RX); in apply_link_config()
6418 if (lc->requested_fec & FEC_RS) in apply_link_config()
6419 MPASS(lc->pcaps & FW_PORT_CAP32_FEC_RS); in apply_link_config()
6420 if (lc->requested_fec & FEC_BASER_RS) in apply_link_config()
6421 MPASS(lc->pcaps & FW_PORT_CAP32_FEC_BASER_RS); in apply_link_config()
6423 if (!(sc->flags & IS_VF)) { in apply_link_config()
6424 rc = -t4_link_l1cfg(sc, sc->mbox, pi->hw_port, lc); in apply_link_config()
6426 device_printf(pi->dev, "l1cfg failed: %d\n", rc); in apply_link_config()
6432 * An L1_CFG will almost always result in a link-change event if the in apply_link_config()
6440 if (lc->link_ok && !(lc->requested_fc & PAUSE_AUTONEG)) in apply_link_config()
6441 lc->fc = lc->requested_fc & (PAUSE_TX | PAUSE_RX); in apply_link_config()
6460 struct vi_info *vi = if_getsoftc(ctx->ifp); in add_maddr()
6461 struct port_info *pi = vi->pi; in add_maddr()
6462 struct adapter *sc = pi->adapter; in add_maddr()
6464 if (ctx->rc < 0) in add_maddr()
6467 ctx->mcaddr[ctx->i] = LLADDR(sdl); in add_maddr()
6468 MPASS(ETHER_IS_MULTICAST(ctx->mcaddr[ctx->i])); in add_maddr()
6469 ctx->i++; in add_maddr()
6471 if (ctx->i == FW_MAC_EXACT_CHUNK) { in add_maddr()
6472 ctx->rc = t4_alloc_mac_filt(sc, sc->mbox, vi->viid, ctx->del, in add_maddr()
6473 ctx->i, ctx->mcaddr, NULL, &ctx->hash, 0); in add_maddr()
6474 if (ctx->rc < 0) { in add_maddr()
6477 for (j = 0; j < ctx->i; j++) { in add_maddr()
6478 if_printf(ctx->ifp, in add_maddr()
6482 ctx->mcaddr[j][0], ctx->mcaddr[j][1], in add_maddr()
6483 ctx->mcaddr[j][2], ctx->mcaddr[j][3], in add_maddr()
6484 ctx->mcaddr[j][4], ctx->mcaddr[j][5], in add_maddr()
6485 -ctx->rc); in add_maddr()
6489 ctx->del = 0; in add_maddr()
6490 ctx->i = 0; in add_maddr()
6505 struct port_info *pi = vi->pi; in update_mac_settings()
6506 struct adapter *sc = pi->adapter; in update_mac_settings()
6507 int mtu = -1, promisc = -1, allmulti = -1, vlanex = -1; in update_mac_settings()
6526 rc = -t4_set_rxmode(sc, sc->mbox, vi->viid, mtu, promisc, in update_mac_settings()
6539 rc = t4_change_mac(sc, sc->mbox, vi->viid, vi->xact_addr_filt, in update_mac_settings()
6540 ucaddr, true, &vi->smt_idx); in update_mac_settings()
6542 rc = -rc; in update_mac_settings()
6546 vi->xact_addr_filt = rc; in update_mac_settings()
6571 rc = -ctx.rc; in update_mac_settings()
6575 rc = t4_alloc_mac_filt(sc, sc->mbox, vi->viid, in update_mac_settings()
6579 rc = -rc; in update_mac_settings()
6596 rc = -t4_set_addr_hash(sc, sc->mbox, vi->viid, 0, ctx.hash, 0); in update_mac_settings()
6602 pi->vxlan_tcam_entry = false; in update_mac_settings()
6606 if (IS_MAIN_VI(vi) && sc->vxlan_refcount > 0 && in update_mac_settings()
6607 pi->vxlan_tcam_entry == false) { in update_mac_settings()
6608 rc = t4_alloc_raw_mac_filt(sc, vi->viid, match_all_mac, in update_mac_settings()
6609 match_all_mac, sc->rawf_base + pi->port_id, 1, pi->port_id, in update_mac_settings()
6612 rc = -rc; in update_mac_settings()
6616 MPASS(rc == sc->rawf_base + pi->port_id); in update_mac_settings()
6618 pi->vxlan_tcam_entry = true; in update_mac_settings()
6657 if (mtx_sleep(&sc->flags, &sc->sc_lock, in begin_synchronized_op()
6667 sc->last_op = wmesg; in begin_synchronized_op()
6668 sc->last_op_thr = curthread; in begin_synchronized_op()
6669 sc->last_op_flags = flags; in begin_synchronized_op()
6689 wakeup(&sc->flags); in begin_vi_detach()
6691 mtx_sleep(&sc->flags, &sc->sc_lock, 0, "t4detach", 0); in begin_vi_detach()
6694 sc->last_op = "t4detach"; in begin_vi_detach()
6695 sc->last_op_thr = curthread; in begin_vi_detach()
6696 sc->last_op_flags = 0; in begin_vi_detach()
6708 wakeup(&sc->flags); in end_vi_detach()
6726 wakeup(&sc->flags); in end_synchronized_op()
6733 struct port_info *pi = vi->pi; in cxgbe_init_synchronized()
6734 struct adapter *sc = pi->adapter; in cxgbe_init_synchronized()
6735 if_t ifp = vi->ifp; in cxgbe_init_synchronized()
6744 if (!(sc->flags & FULL_INIT_DONE) && ((rc = adapter_init(sc)) != 0)) in cxgbe_init_synchronized()
6747 if (!(vi->flags & VI_INIT_DONE) && ((rc = vi_init(vi)) != 0)) in cxgbe_init_synchronized()
6755 if (pi->up_vis == 0) { in cxgbe_init_synchronized()
6762 rc = -t4_enable_vi(sc, sc->mbox, vi->viid, true, true); in cxgbe_init_synchronized()
6776 txq->eq.flags |= EQ_ENABLED; in cxgbe_init_synchronized()
6783 if (sc->traceq < 0 && IS_MAIN_VI(vi)) { in cxgbe_init_synchronized()
6784 sc->traceq = sc->sge.rxq[vi->first_rxq].iq.abs_id; in cxgbe_init_synchronized()
6785 t4_set_trace_rss_control(sc, pi->tx_chan, sc->traceq); in cxgbe_init_synchronized()
6786 pi->flags |= HAS_TRACEQ; in cxgbe_init_synchronized()
6790 pi->up_vis++; in cxgbe_init_synchronized()
6792 if (pi->link_cfg.link_ok) in cxgbe_init_synchronized()
6796 mtx_lock(&vi->tick_mtx); in cxgbe_init_synchronized()
6797 if (vi->pi->nvi > 1 || sc->flags & IS_VF) in cxgbe_init_synchronized()
6798 callout_reset(&vi->tick, hz, vi_tick, vi); in cxgbe_init_synchronized()
6800 callout_reset(&vi->tick, hz, cxgbe_tick, vi); in cxgbe_init_synchronized()
6801 mtx_unlock(&vi->tick_mtx); in cxgbe_init_synchronized()
6815 struct port_info *pi = vi->pi; in cxgbe_uninit_synchronized()
6816 struct adapter *sc = pi->adapter; in cxgbe_uninit_synchronized()
6817 if_t ifp = vi->ifp; in cxgbe_uninit_synchronized()
6823 if (!(vi->flags & VI_INIT_DONE)) { in cxgbe_uninit_synchronized()
6827 "vi->flags 0x%016lx, if_flags 0x%08x, " in cxgbe_uninit_synchronized()
6828 "if_drv_flags 0x%08x\n", vi->flags, if_getflags(ifp), in cxgbe_uninit_synchronized()
6841 rc = -t4_enable_vi(sc, sc->mbox, vi->viid, false, false); in cxgbe_uninit_synchronized()
6849 txq->eq.flags &= ~EQ_ENABLED; in cxgbe_uninit_synchronized()
6853 mtx_lock(&vi->tick_mtx); in cxgbe_uninit_synchronized()
6854 callout_stop(&vi->tick); in cxgbe_uninit_synchronized()
6855 mtx_unlock(&vi->tick_mtx); in cxgbe_uninit_synchronized()
6863 pi->up_vis--; in cxgbe_uninit_synchronized()
6864 if (pi->up_vis > 0) { in cxgbe_uninit_synchronized()
6869 pi->link_cfg.link_ok = false; in cxgbe_uninit_synchronized()
6870 pi->link_cfg.speed = 0; in cxgbe_uninit_synchronized()
6871 pi->link_cfg.link_down_rc = 255; in cxgbe_uninit_synchronized()
6880 * will walk the entire sc->irq list and clean up whatever is valid.
6890 struct sge *sge = &sc->sge; in t4_setup_intr_handlers()
6905 irq = &sc->irq[0]; in t4_setup_intr_handlers()
6906 rid = sc->intr_type == INTR_INTX ? 0 : 1; in t4_setup_intr_handlers()
6911 if (sc->flags & IS_VF) in t4_setup_intr_handlers()
6912 KASSERT(sc->intr_count >= T4VF_EXTRA_INTR + sc->params.nports, in t4_setup_intr_handlers()
6915 KASSERT(sc->intr_count >= T4_EXTRA_INTR + sc->params.nports, in t4_setup_intr_handlers()
6919 if (!(sc->flags & IS_VF)) { in t4_setup_intr_handlers()
6928 rc = t4_alloc_irq(sc, irq, rid, t4_intr_evt, &sge->fwq, "evt"); in t4_setup_intr_handlers()
6935 pi = sc->port[p]; in t4_setup_intr_handlers()
6937 vi->first_intr = rid - 1; in t4_setup_intr_handlers()
6939 if (vi->nnmrxq > 0) { in t4_setup_intr_handlers()
6940 int n = max(vi->nrxq, vi->nnmrxq); in t4_setup_intr_handlers()
6942 rxq = &sge->rxq[vi->first_rxq]; in t4_setup_intr_handlers()
6944 nm_rxq = &sge->nm_rxq[vi->first_nm_rxq]; in t4_setup_intr_handlers()
6949 if (q < vi->nrxq) in t4_setup_intr_handlers()
6950 irq->rxq = rxq++; in t4_setup_intr_handlers()
6952 if (q < vi->nnmrxq) in t4_setup_intr_handlers()
6953 irq->nm_rxq = nm_rxq++; in t4_setup_intr_handlers()
6955 if (irq->nm_rxq != NULL && in t4_setup_intr_handlers()
6956 irq->rxq == NULL) { in t4_setup_intr_handlers()
6959 t4_nm_intr, irq->nm_rxq, s); in t4_setup_intr_handlers()
6961 if (irq->nm_rxq != NULL && in t4_setup_intr_handlers()
6962 irq->rxq != NULL) { in t4_setup_intr_handlers()
6968 if (irq->rxq != NULL && in t4_setup_intr_handlers()
6969 irq->nm_rxq == NULL) { in t4_setup_intr_handlers()
6972 t4_intr, irq->rxq, s); in t4_setup_intr_handlers()
6977 if (q < vi->nrxq) { in t4_setup_intr_handlers()
6978 bus_bind_intr(sc->dev, irq->res, in t4_setup_intr_handlers()
6984 vi->nintr++; in t4_setup_intr_handlers()
6995 bus_bind_intr(sc->dev, irq->res, in t4_setup_intr_handlers()
7000 vi->nintr++; in t4_setup_intr_handlers()
7012 vi->nintr++; in t4_setup_intr_handlers()
7017 MPASS(irq == &sc->irq[sc->intr_count]); in t4_setup_intr_handlers()
7034 rss_key[i] = htobe32(raw_rss_key[nitems(rss_key) - 1 - i]); in write_global_rss_key()
7036 t4_write_rss_key(sc, &rss_key[0], -1, 1); in write_global_rss_key()
7057 MPASS(sc->params.nports <= nitems(sc->tq)); in adapter_full_init()
7058 for (i = 0; i < sc->params.nports; i++) { in adapter_full_init()
7059 if (sc->tq[i] != NULL) in adapter_full_init()
7061 sc->tq[i] = taskqueue_create("t4 taskq", M_NOWAIT, in adapter_full_init()
7062 taskqueue_thread_enqueue, &sc->tq[i]); in adapter_full_init()
7063 if (sc->tq[i] == NULL) { in adapter_full_init()
7067 taskqueue_start_threads(&sc->tq[i], 1, PI_NET, "%s tq%d", in adapter_full_init()
7068 device_get_nameunit(sc->dev), i); in adapter_full_init()
7071 if (!(sc->flags & IS_VF)) { in adapter_full_init()
7085 KASSERT((sc->flags & FULL_INIT_DONE) == 0, in adapter_init()
7092 sc->flags |= FULL_INIT_DONE; in adapter_init()
7107 for (i = 0; i < nitems(sc->tq); i++) { in adapter_full_uninit()
7108 if (sc->tq[i] == NULL) in adapter_full_uninit()
7110 taskqueue_free(sc->tq[i]); in adapter_full_uninit()
7111 sc->tq[i] = NULL; in adapter_full_uninit()
7114 sc->flags &= ~FULL_INIT_DONE; in adapter_full_uninit()
7159 * enabling any 4-tuple hash is nonsense configuration. in hashen_to_hashconfig()
7188 struct adapter *sc = vi->adapter; in vi_full_init()
7209 if (vi->nrxq > vi->rss_size) { in vi_full_init()
7211 "some queues will never receive traffic.\n", vi->nrxq, in vi_full_init()
7212 vi->rss_size); in vi_full_init()
7213 } else if (vi->rss_size % vi->nrxq) { in vi_full_init()
7215 "expect uneven traffic distribution.\n", vi->nrxq, in vi_full_init()
7216 vi->rss_size); in vi_full_init()
7219 if (vi->nrxq != nbuckets) { in vi_full_init()
7221 "performance will be impacted.\n", vi->nrxq, nbuckets); in vi_full_init()
7224 if (vi->rss == NULL) in vi_full_init()
7225 vi->rss = malloc(vi->rss_size * sizeof (*vi->rss), M_CXGBE, in vi_full_init()
7227 for (i = 0; i < vi->rss_size;) { in vi_full_init()
7230 j %= vi->nrxq; in vi_full_init()
7231 rxq = &sc->sge.rxq[vi->first_rxq + j]; in vi_full_init()
7232 vi->rss[i++] = rxq->iq.abs_id; in vi_full_init()
7235 vi->rss[i++] = rxq->iq.abs_id; in vi_full_init()
7236 if (i == vi->rss_size) in vi_full_init()
7242 rc = -t4_config_rss_range(sc, sc->mbox, vi->viid, 0, vi->rss_size, in vi_full_init()
7243 vi->rss, vi->rss_size); in vi_full_init()
7250 vi->hashen = hashconfig_to_hashen(hashconfig); in vi_full_init()
7257 extra = hashen_to_hashconfig(vi->hashen) ^ hashconfig; in vi_full_init()
7274 CH_ALERT(vi, "IPv4 2-tuple hashing forced on.\n"); in vi_full_init()
7276 CH_ALERT(vi, "TCP/IPv4 4-tuple hashing forced on.\n"); in vi_full_init()
7278 CH_ALERT(vi, "IPv6 2-tuple hashing forced on.\n"); in vi_full_init()
7280 CH_ALERT(vi, "TCP/IPv6 4-tuple hashing forced on.\n"); in vi_full_init()
7282 CH_ALERT(vi, "UDP/IPv4 4-tuple hashing forced on.\n"); in vi_full_init()
7284 CH_ALERT(vi, "UDP/IPv6 4-tuple hashing forced on.\n"); in vi_full_init()
7286 vi->hashen = F_FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN | in vi_full_init()
7291 rc = -t4_config_vi_rss(sc, sc->mbox, vi->viid, vi->hashen, vi->rss[0], in vi_full_init()
7306 ASSERT_SYNCHRONIZED_OP(vi->adapter); in vi_init()
7307 KASSERT((vi->flags & VI_INIT_DONE) == 0, in vi_init()
7314 vi->flags |= VI_INIT_DONE; in vi_init()
7326 if (vi->flags & VI_INIT_DONE) { in vi_full_uninit()
7328 free(vi->rss, M_CXGBE); in vi_full_uninit()
7329 free(vi->nm_rss, M_CXGBE); in vi_full_uninit()
7333 vi->flags &= ~VI_INIT_DONE; in vi_full_uninit()
7339 struct sge_eq *eq = &txq->eq; in quiesce_txq()
7340 struct sge_qstat *spg = (void *)&eq->desc[eq->sidx]; in quiesce_txq()
7342 MPASS(eq->flags & EQ_SW_ALLOCATED); in quiesce_txq()
7343 MPASS(!(eq->flags & EQ_ENABLED)); in quiesce_txq()
7346 while (!mp_ring_is_idle(txq->r)) { in quiesce_txq()
7347 mp_ring_check_drainage(txq->r, 4096); in quiesce_txq()
7350 MPASS(txq->txp.npkt == 0); in quiesce_txq()
7352 if (eq->flags & EQ_HW_ALLOCATED) { in quiesce_txq()
7358 while (spg->cidx != htobe16(eq->pidx)) in quiesce_txq()
7360 while (eq->cidx != eq->pidx) in quiesce_txq()
7368 while (eq->cidx != eq->pidx) { in quiesce_txq()
7372 txsd = &txq->sdesc[eq->cidx]; in quiesce_txq()
7373 for (m = txsd->m; m != NULL; m = nextpkt) { in quiesce_txq()
7374 nextpkt = m->m_nextpkt; in quiesce_txq()
7375 m->m_nextpkt = NULL; in quiesce_txq()
7378 IDXINCR(eq->cidx, txsd->desc_used, eq->sidx); in quiesce_txq()
7380 spg->pidx = spg->cidx = htobe16(eq->cidx); in quiesce_txq()
7391 while ((wr = STAILQ_FIRST(&wrq->wr_list)) != NULL) { in quiesce_wrq()
7392 STAILQ_REMOVE_HEAD(&wrq->wr_list, link); in quiesce_wrq()
7394 wrq->nwr_pending--; in quiesce_wrq()
7395 wrq->ndesc_needed -= howmany(wr->wr_len, EQ_ESIZE); in quiesce_wrq()
7399 MPASS(wrq->nwr_pending == 0); in quiesce_wrq()
7400 MPASS(wrq->ndesc_needed == 0); in quiesce_wrq()
7401 wrq->nwr_pending = 0; in quiesce_wrq()
7402 wrq->ndesc_needed = 0; in quiesce_wrq()
7410 while (!atomic_cmpset_int(&iq->state, IQS_IDLE, IQS_DISABLED)) in quiesce_iq_fl()
7414 MPASS(iq->flags & IQ_HAS_FL); in quiesce_iq_fl()
7416 mtx_lock(&sc->sfl_lock); in quiesce_iq_fl()
7418 fl->flags |= FL_DOOMED; in quiesce_iq_fl()
7420 callout_stop(&sc->sfl_callout); in quiesce_iq_fl()
7421 mtx_unlock(&sc->sfl_lock); in quiesce_iq_fl()
7423 KASSERT((fl->flags & FL_STARVING) == 0, in quiesce_iq_fl()
7427 if (!(iq->flags & IQ_HW_ALLOCATED)) in quiesce_iq_fl()
7441 struct adapter *sc = vi->adapter; in quiesce_vi()
7451 if (!(vi->flags & VI_INIT_DONE)) in quiesce_vi()
7460 quiesce_wrq(&ofld_txq->wrq); in quiesce_vi()
7465 quiesce_iq_fl(sc, &rxq->iq, &rxq->fl); in quiesce_vi()
7470 quiesce_iq_fl(sc, &ofld_rxq->iq, &ofld_rxq->fl); in quiesce_vi()
7481 irq->rid = rid; in t4_alloc_irq()
7482 irq->res = bus_alloc_resource_any(sc->dev, SYS_RES_IRQ, &irq->rid, in t4_alloc_irq()
7484 if (irq->res == NULL) { in t4_alloc_irq()
7485 device_printf(sc->dev, in t4_alloc_irq()
7490 rc = bus_setup_intr(sc->dev, irq->res, INTR_MPSAFE | INTR_TYPE_NET, in t4_alloc_irq()
7491 NULL, handler, arg, &irq->tag); in t4_alloc_irq()
7493 device_printf(sc->dev, in t4_alloc_irq()
7497 bus_describe_intr(sc->dev, irq->res, irq->tag, "%s", name); in t4_alloc_irq()
7505 if (irq->tag) in t4_free_irq()
7506 bus_teardown_intr(sc->dev, irq->res, irq->tag); in t4_free_irq()
7507 if (irq->res) in t4_free_irq()
7508 bus_release_resource(sc->dev, SYS_RES_IRQ, irq->rid, irq->res); in t4_free_irq()
7519 regs->version = chip_id(sc) | chip_rev(sc) << 10; in get_regs()
7520 t4_get_regs(sc, buf, regs->len); in get_regs()
7547 if (sc->flags & IS_VF) { in read_vf_stat()
7551 mtx_assert(&sc->reg_lock, MA_OWNED); in read_vf_stat()
7567 if (!(sc->flags & IS_VF)) in t4_get_vi_stats()
7568 mtx_lock(&sc->reg_lock); in t4_get_vi_stats()
7569 stats->tx_bcast_bytes = GET_STAT(TX_VF_BCAST_BYTES); in t4_get_vi_stats()
7570 stats->tx_bcast_frames = GET_STAT(TX_VF_BCAST_FRAMES); in t4_get_vi_stats()
7571 stats->tx_mcast_bytes = GET_STAT(TX_VF_MCAST_BYTES); in t4_get_vi_stats()
7572 stats->tx_mcast_frames = GET_STAT(TX_VF_MCAST_FRAMES); in t4_get_vi_stats()
7573 stats->tx_ucast_bytes = GET_STAT(TX_VF_UCAST_BYTES); in t4_get_vi_stats()
7574 stats->tx_ucast_frames = GET_STAT(TX_VF_UCAST_FRAMES); in t4_get_vi_stats()
7575 stats->tx_drop_frames = GET_STAT(TX_VF_DROP_FRAMES); in t4_get_vi_stats()
7576 stats->tx_offload_bytes = GET_STAT(TX_VF_OFFLOAD_BYTES); in t4_get_vi_stats()
7577 stats->tx_offload_frames = GET_STAT(TX_VF_OFFLOAD_FRAMES); in t4_get_vi_stats()
7578 stats->rx_bcast_bytes = GET_STAT(RX_VF_BCAST_BYTES); in t4_get_vi_stats()
7579 stats->rx_bcast_frames = GET_STAT(RX_VF_BCAST_FRAMES); in t4_get_vi_stats()
7580 stats->rx_mcast_bytes = GET_STAT(RX_VF_MCAST_BYTES); in t4_get_vi_stats()
7581 stats->rx_mcast_frames = GET_STAT(RX_VF_MCAST_FRAMES); in t4_get_vi_stats()
7582 stats->rx_ucast_bytes = GET_STAT(RX_VF_UCAST_BYTES); in t4_get_vi_stats()
7583 stats->rx_ucast_frames = GET_STAT(RX_VF_UCAST_FRAMES); in t4_get_vi_stats()
7584 stats->rx_err_frames = GET_STAT(RX_VF_ERR_FRAMES); in t4_get_vi_stats()
7585 if (!(sc->flags & IS_VF)) in t4_get_vi_stats()
7586 mtx_unlock(&sc->reg_lock); in t4_get_vi_stats()
7609 mtx_assert(&vi->tick_mtx, MA_OWNED); in vi_refresh_stats()
7611 if (vi->flags & VI_SKIP_STATS) in vi_refresh_stats()
7616 if (timevalcmp(&tv, &vi->last_refreshed, <)) in vi_refresh_stats()
7619 t4_get_vi_stats(vi->adapter, vi->vin, &vi->stats); in vi_refresh_stats()
7620 getmicrotime(&vi->last_refreshed); in vi_refresh_stats()
7632 mtx_assert(&vi->tick_mtx, MA_OWNED); in cxgbe_refresh_stats()
7634 if (vi->flags & VI_SKIP_STATS) in cxgbe_refresh_stats()
7639 if (timevalcmp(&tv, &vi->last_refreshed, <)) in cxgbe_refresh_stats()
7642 pi = vi->pi; in cxgbe_refresh_stats()
7643 sc = vi->adapter; in cxgbe_refresh_stats()
7645 t4_get_port_stats(sc, pi->hw_port, &pi->stats); in cxgbe_refresh_stats()
7646 chan_map = pi->rx_e_chan_map; in cxgbe_refresh_stats()
7648 i = ffs(chan_map) - 1; in cxgbe_refresh_stats()
7649 mtx_lock(&sc->reg_lock); in cxgbe_refresh_stats()
7652 mtx_unlock(&sc->reg_lock); in cxgbe_refresh_stats()
7656 pi->tnl_cong_drops = tnl_cong_drops; in cxgbe_refresh_stats()
7657 getmicrotime(&vi->last_refreshed); in cxgbe_refresh_stats()
7666 mtx_assert(&vi->tick_mtx, MA_OWNED); in cxgbe_tick()
7669 callout_schedule(&vi->tick, hz); in cxgbe_tick()
7677 mtx_assert(&vi->tick_mtx, MA_OWNED); in vi_tick()
7680 callout_schedule(&vi->tick, hz); in vi_tick()
7727 sc->params.ncores, "# of active CIM cores"); in cim_sysctls()
7729 for (i = 0; i < sc->params.ncores; i++) { in cim_sysctls()
7785 MPASS(qcount <= sc->chip_params->cim_num_ibq); in cim_sysctls()
7816 MPASS(qcount <= sc->chip_params->cim_num_obq); in cim_sysctls()
7831 "\20\001IPMI\002NCSI", /* 0: NBM */
7853 struct sysctl_ctx_list *ctx = &sc->ctx; in t4_sysctls()
7861 oid = device_get_sysctl_tree(sc->dev); in t4_sysctls()
7864 sc->sc_do_rxcopy = 1; in t4_sysctls()
7866 &sc->sc_do_rxcopy, 1, "Do RX copy of small frames"); in t4_sysctls()
7869 sc->params.nports, "# of ports"); in t4_sysctls()
7873 (uintptr_t)&sc->doorbells, sysctl_bitfield_8b, "A", in t4_sysctls()
7877 sc->params.vpd.cclk, "core clock frequency (in KHz)"); in t4_sysctls()
7881 sc->params.sge.timer_val, sizeof(sc->params.sge.timer_val), in t4_sysctls()
7886 sc->params.sge.counter_val, sizeof(sc->params.sge.counter_val), in t4_sysctls()
7891 sc->lro_timeout = 100; in t4_sysctls()
7893 &sc->lro_timeout, 0, "lro inactive-flush timeout (in us)"); in t4_sysctls()
7896 &sc->debug_flags, 0, "flags to enable runtime debugging"); in t4_sysctls()
7899 CTLFLAG_RD, sc->tp_version, 0, "TP microcode version"); in t4_sysctls()
7902 CTLFLAG_RD, sc->fw_version, 0, "firmware version"); in t4_sysctls()
7904 if (sc->flags & IS_VF) in t4_sysctls()
7911 CTLFLAG_RD, sc->params.vpd.sn, 0, "serial number"); in t4_sysctls()
7914 CTLFLAG_RD, sc->params.vpd.pn, 0, "part number"); in t4_sysctls()
7917 CTLFLAG_RD, sc->params.vpd.ec, 0, "engineering change"); in t4_sysctls()
7920 CTLFLAG_RD, sc->params.vpd.md, 0, "manufacturing diags version"); in t4_sysctls()
7923 CTLFLAG_RD, sc->params.vpd.na, 0, "network address"); in t4_sysctls()
7926 sc->er_version, 0, "expansion ROM version"); in t4_sysctls()
7929 sc->bs_version, 0, "bootstrap firmware version"); in t4_sysctls()
7932 NULL, sc->params.scfg_vers, "serial config version"); in t4_sysctls()
7935 NULL, sc->params.vpd_vers, "VPD version"); in t4_sysctls()
7938 CTLFLAG_RD, sc->cfg_file, 0, "configuration file"); in t4_sysctls()
7941 sc->cfcsum, "config file checksum"); in t4_sysctls()
7946 (uintptr_t)&sc->name, sysctl_bitfield_16b, "A", \ in t4_sysctls()
7962 NULL, sc->tids.nftids, "number of filters"); in t4_sysctls()
7984 &sc->swintr, 0, "software triggered interrupts"); in t4_sysctls()
8010 sysctl_ddp_stats, "A", "non-TCP DDP statistics"); in t4_sysctls()
8017 CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, -1, in t4_sysctls()
8116 CTLFLAG_RW, &sc->tlst.inline_keys, 0, "Always pass TLS " in t4_sysctls()
8122 CTLFLAG_RW, &sc->tlst.combo_wrs, 0, "Attempt to " in t4_sysctls()
8127 CTLFLAG_RW, &sc->tlst.short_records, 0, in t4_sysctls()
8128 "Use cipher-only mode for short records."); in t4_sysctls()
8130 CTLFLAG_RW, &sc->tlst.partial_ghash, 0, in t4_sysctls()
8131 "Use partial GHASH for AES-GCM records."); in t4_sysctls()
8148 sc->tt.cong_algorithm = -1; in t4_sysctls()
8150 CTLFLAG_RW, &sc->tt.cong_algorithm, 0, "congestion control " in t4_sysctls()
8151 "(-1 = default, 0 = reno, 1 = tahoe, 2 = newreno, " in t4_sysctls()
8154 sc->tt.sndbuf = -1; in t4_sysctls()
8156 &sc->tt.sndbuf, 0, "hardware send buffer"); in t4_sysctls()
8158 sc->tt.ddp = 0; in t4_sysctls()
8160 CTLFLAG_RW | CTLFLAG_SKIP, &sc->tt.ddp, 0, ""); in t4_sysctls()
8162 &sc->tt.ddp, 0, "Enable zero-copy aio_read(2)"); in t4_sysctls()
8164 sc->tt.rx_coalesce = -1; in t4_sysctls()
8166 CTLFLAG_RW, &sc->tt.rx_coalesce, 0, "receive coalescing"); in t4_sysctls()
8168 sc->tt.tls = 1; in t4_sysctls()
8173 sc->tt.tx_align = -1; in t4_sysctls()
8175 CTLFLAG_RW, &sc->tt.tx_align, 0, "chop and align payload"); in t4_sysctls()
8177 sc->tt.tx_zcopy = 0; in t4_sysctls()
8179 CTLFLAG_RW, &sc->tt.tx_zcopy, 0, in t4_sysctls()
8180 "Enable zero-copy aio_write(2)"); in t4_sysctls()
8182 sc->tt.cop_managed_offloading = !!t4_cop_managed_offloading; in t4_sysctls()
8185 &sc->tt.cop_managed_offloading, 0, in t4_sysctls()
8188 sc->tt.autorcvbuf_inc = 16 * 1024; in t4_sysctls()
8190 CTLFLAG_RW, &sc->tt.autorcvbuf_inc, 0, in t4_sysctls()
8193 sc->tt.update_hc_on_pmtu_change = 1; in t4_sysctls()
8196 &sc->tt.update_hc_on_pmtu_change, 0, in t4_sysctls()
8199 sc->tt.iso = 1; in t4_sysctls()
8201 &sc->tt.iso, 0, "Enable iSCSI segmentation offload"); in t4_sysctls()
8291 struct sysctl_ctx_list *ctx = &vi->ctx; in vi_sysctls()
8298 oid = device_get_sysctl_tree(vi->dev); in vi_sysctls()
8302 vi->viid, "VI identifer"); in vi_sysctls()
8304 &vi->nrxq, 0, "# of rx queues"); in vi_sysctls()
8306 &vi->ntxq, 0, "# of tx queues"); in vi_sysctls()
8308 &vi->first_rxq, 0, "index of first rx queue"); in vi_sysctls()
8310 &vi->first_txq, 0, "index of first tx queue"); in vi_sysctls()
8312 vi->rss_base, "start of RSS indirection table"); in vi_sysctls()
8314 vi->rss_size, "size of RSS indirection table"); in vi_sysctls()
8320 "Reserve queue 0 for non-flowid packets"); in vi_sysctls()
8323 if (vi->adapter->flags & IS_VF) { in vi_sysctls()
8324 MPASS(vi->flags & TX_USES_VM_WR); in vi_sysctls()
8334 if (vi->nofldrxq != 0) { in vi_sysctls()
8336 &vi->nofldrxq, 0, in vi_sysctls()
8339 CTLFLAG_RD, &vi->first_ofld_rxq, 0, in vi_sysctls()
8352 if (vi->nofldtxq != 0) { in vi_sysctls()
8354 &vi->nofldtxq, 0, in vi_sysctls()
8357 CTLFLAG_RD, &vi->first_ofld_txq, 0, in vi_sysctls()
8362 if (vi->nnmrxq != 0) { in vi_sysctls()
8364 &vi->nnmrxq, 0, "# of netmap rx queues"); in vi_sysctls()
8366 &vi->nnmtxq, 0, "# of netmap tx queues"); in vi_sysctls()
8368 CTLFLAG_RD, &vi->first_nm_rxq, 0, in vi_sysctls()
8371 CTLFLAG_RD, &vi->first_nm_txq, 0, in vi_sysctls()
8394 struct sysctl_ctx_list *ctx = &pi->ctx; in cxgbe_sysctls()
8397 struct adapter *sc = pi->adapter; in cxgbe_sysctls()
8405 oid = device_get_sysctl_tree(pi->dev); in cxgbe_sysctls()
8411 if (pi->port_type == FW_PORT_TYPE_BT_XAUI) { in cxgbe_sysctls()
8437 "autonegotiation (-1 = not supported)"); in cxgbe_sysctls()
8443 &pi->link_cfg.requested_caps, 0, "L1 config requested by driver"); in cxgbe_sysctls()
8445 &pi->link_cfg.pcaps, 0, "port capabilities"); in cxgbe_sysctls()
8447 &pi->link_cfg.acaps, 0, "advertised capabilities"); in cxgbe_sysctls()
8449 &pi->link_cfg.lpacaps, 0, "link partner advertised capabilities"); in cxgbe_sysctls()
8454 pi->mps_bg_map, "MPS buffer group map"); in cxgbe_sysctls()
8456 NULL, pi->rx_e_chan_map, "TP rx e-channel map"); in cxgbe_sysctls()
8458 pi->tx_chan, "TP tx c-channel"); in cxgbe_sysctls()
8460 pi->rx_chan, "TP rx c-channel"); in cxgbe_sysctls()
8462 if (sc->flags & IS_VF) in cxgbe_sysctls()
8473 CTLFLAG_RW, &pi->sched_params->pktsize, 0, in cxgbe_sysctls()
8474 "pktsize for per-flow cl-rl (0 means up to the driver )"); in cxgbe_sysctls()
8476 CTLFLAG_RW, &pi->sched_params->burstsize, 0, in cxgbe_sysctls()
8477 "burstsize for per-flow cl-rl (0 means up to the driver)"); in cxgbe_sysctls()
8478 for (i = 0; i < sc->params.nsched_cls; i++) { in cxgbe_sysctls()
8479 struct tx_cl_rl_params *tc = &pi->sched_params->cl_rl[i]; in cxgbe_sysctls()
8486 CTLFLAG_RD, &tc->state, 0, "current state"); in cxgbe_sysctls()
8489 (uintptr_t)&tc->flags, sysctl_bitfield_8b, "A", "flags"); in cxgbe_sysctls()
8491 CTLFLAG_RD, &tc->refcount, 0, "references to this class"); in cxgbe_sysctls()
8494 (pi->port_id << 16) | i, sysctl_tc_params, "A", in cxgbe_sysctls()
8505 &pi->tx_parse_error, 0, in cxgbe_sysctls()
8509 if (sc->params.tp.lb_mode) { \ in cxgbe_sysctls()
8517 t4_port_reg(sc, pi->tx_chan, A_MPS_PORT_STAT_##stat##_L), \ in cxgbe_sysctls()
8556 CTLFLAG_RD, &pi->stats.rx_fcs_err, in cxgbe_sysctls()
8589 if (pi->mps_bg_map & 1) { in cxgbe_sysctls()
8591 "# drops due to buffer-group 0 overflows"); in cxgbe_sysctls()
8593 "# of buffer-group 0 truncated packets"); in cxgbe_sysctls()
8595 if (pi->mps_bg_map & 2) { in cxgbe_sysctls()
8597 "# drops due to buffer-group 1 overflows"); in cxgbe_sysctls()
8599 "# of buffer-group 1 truncated packets"); in cxgbe_sysctls()
8601 if (pi->mps_bg_map & 4) { in cxgbe_sysctls()
8603 "# drops due to buffer-group 2 overflows"); in cxgbe_sysctls()
8605 "# of buffer-group 2 truncated packets"); in cxgbe_sysctls()
8607 if (pi->mps_bg_map & 8) { in cxgbe_sysctls()
8609 "# drops due to buffer-group 3 overflows"); in cxgbe_sysctls()
8611 "# of buffer-group 3 truncated packets"); in cxgbe_sysctls()
8623 for (i = arg1; arg2; arg2 -= sizeof(int), i++) { in sysctl_int_array()
8673 struct adapter *sc = pi->adapter; in sysctl_btphy()
8677 rc = begin_synchronized_op(sc, &pi->vi[0], SLEEP_OK | INTR_OK, "t4btt"); in sysctl_btphy()
8684 rc = -t4_mdio_rd(sc, sc->mbox, pi->mdio_addr, 0x1e, in sysctl_btphy()
8703 val = vi->rsrv_noflowq; in sysctl_noflowq()
8705 if (rc != 0 || req->newptr == NULL) in sysctl_noflowq()
8708 if ((val >= 1) && (vi->ntxq > 1)) in sysctl_noflowq()
8709 vi->rsrv_noflowq = 1; in sysctl_noflowq()
8711 vi->rsrv_noflowq = 0; in sysctl_noflowq()
8720 struct adapter *sc = vi->adapter; in sysctl_tx_vm_wr()
8723 MPASS(!(sc->flags & IS_VF)); in sysctl_tx_vm_wr()
8725 val = vi->flags & TX_USES_VM_WR ? 1 : 0; in sysctl_tx_vm_wr()
8727 if (rc != 0 || req->newptr == NULL) in sysctl_tx_vm_wr()
8739 else if (if_getdrvflags(vi->ifp) & IFF_DRV_RUNNING) { in sysctl_tx_vm_wr()
8747 struct port_info *pi = vi->pi; in sysctl_tx_vm_wr()
8750 uint8_t npkt = sc->params.max_pkts_per_eth_tx_pkts_wr; in sysctl_tx_vm_wr()
8753 vi->flags |= TX_USES_VM_WR; in sysctl_tx_vm_wr()
8754 if_sethwtsomaxsegcount(vi->ifp, TX_SGL_SEGS_VM_TSO); in sysctl_tx_vm_wr()
8756 V_TXPKT_INTF(pi->hw_port)); in sysctl_tx_vm_wr()
8757 if (!(sc->flags & IS_VF)) in sysctl_tx_vm_wr()
8758 npkt--; in sysctl_tx_vm_wr()
8760 vi->flags &= ~TX_USES_VM_WR; in sysctl_tx_vm_wr()
8761 if_sethwtsomaxsegcount(vi->ifp, TX_SGL_SEGS_TSO); in sysctl_tx_vm_wr()
8763 V_TXPKT_INTF(pi->hw_port) | V_TXPKT_PF(sc->pf) | in sysctl_tx_vm_wr()
8764 V_TXPKT_VF(vi->vin) | V_TXPKT_VF_VLD(vi->vfvld)); in sysctl_tx_vm_wr()
8767 txq->cpl_ctrl0 = ctrl0; in sysctl_tx_vm_wr()
8768 txq->txp.max_npkt = npkt; in sysctl_tx_vm_wr()
8779 struct adapter *sc = vi->adapter; in sysctl_holdoff_tmr_idx()
8784 idx = vi->tmr_idx; in sysctl_holdoff_tmr_idx()
8787 if (rc != 0 || req->newptr == NULL) in sysctl_holdoff_tmr_idx()
8798 v = V_QINTR_TIMER_IDX(idx) | V_QINTR_CNT_EN(vi->pktc_idx != -1); in sysctl_holdoff_tmr_idx()
8801 atomic_store_rel_8(&rxq->iq.intr_params, v); in sysctl_holdoff_tmr_idx()
8803 rxq->iq.intr_params = v; in sysctl_holdoff_tmr_idx()
8806 vi->tmr_idx = idx; in sysctl_holdoff_tmr_idx()
8816 struct adapter *sc = vi->adapter; in sysctl_holdoff_pktc_idx()
8819 idx = vi->pktc_idx; in sysctl_holdoff_pktc_idx()
8822 if (rc != 0 || req->newptr == NULL) in sysctl_holdoff_pktc_idx()
8825 if (idx < -1 || idx >= SGE_NCOUNTERS) in sysctl_holdoff_pktc_idx()
8833 if (vi->flags & VI_INIT_DONE) in sysctl_holdoff_pktc_idx()
8836 vi->pktc_idx = idx; in sysctl_holdoff_pktc_idx()
8846 struct adapter *sc = vi->adapter; in sysctl_qsize_rxq()
8849 qsize = vi->qsize_rxq; in sysctl_qsize_rxq()
8852 if (rc != 0 || req->newptr == NULL) in sysctl_qsize_rxq()
8863 if (vi->flags & VI_INIT_DONE) in sysctl_qsize_rxq()
8866 vi->qsize_rxq = qsize; in sysctl_qsize_rxq()
8876 struct adapter *sc = vi->adapter; in sysctl_qsize_txq()
8879 qsize = vi->qsize_txq; in sysctl_qsize_txq()
8882 if (rc != 0 || req->newptr == NULL) in sysctl_qsize_txq()
8893 if (vi->flags & VI_INIT_DONE) in sysctl_qsize_txq()
8896 vi->qsize_txq = qsize; in sysctl_qsize_txq()
8906 struct adapter *sc = pi->adapter; in sysctl_pause_settings()
8907 struct link_config *lc = &pi->link_cfg; in sysctl_pause_settings()
8910 if (req->newptr == NULL) { in sysctl_pause_settings()
8918 if (lc->link_ok) { in sysctl_pause_settings()
8919 sbuf_printf(sb, "%b", (lc->fc & (PAUSE_TX | PAUSE_RX)) | in sysctl_pause_settings()
8920 (lc->requested_fc & PAUSE_AUTONEG), bits); in sysctl_pause_settings()
8922 sbuf_printf(sb, "%b", lc->requested_fc & (PAUSE_TX | in sysctl_pause_settings()
8931 s[0] = '0' + (lc->requested_fc & (PAUSE_TX | PAUSE_RX | in sysctl_pause_settings()
8943 n = s[0] - '0'; in sysctl_pause_settings()
8947 rc = begin_synchronized_op(sc, &pi->vi[0], SLEEP_OK | INTR_OK, in sysctl_pause_settings()
8953 lc->requested_fc = n; in sysctl_pause_settings()
8955 if (pi->up_vis > 0) in sysctl_pause_settings()
8970 struct link_config *lc = &pi->link_cfg; in sysctl_link_fec()
8977 if (lc->link_ok) in sysctl_link_fec()
8978 sbuf_printf(sb, "%b", lc->fec, t4_fec_bits); in sysctl_link_fec()
8991 struct adapter *sc = pi->adapter; in sysctl_requested_fec()
8992 struct link_config *lc = &pi->link_cfg; in sysctl_requested_fec()
8996 if (req->newptr == NULL) { in sysctl_requested_fec()
9003 sbuf_printf(sb, "%b", lc->requested_fec, t4_fec_bits); in sysctl_requested_fec()
9011 lc->requested_fec == FEC_AUTO ? -1 : in sysctl_requested_fec()
9012 lc->requested_fec & (M_FW_PORT_CAP32_FEC | FEC_MODULE)); in sysctl_requested_fec()
9024 rc = begin_synchronized_op(sc, &pi->vi[0], SLEEP_OK | INTR_OK, in sysctl_requested_fec()
9029 old = lc->requested_fec; in sysctl_requested_fec()
9031 lc->requested_fec = FEC_AUTO; in sysctl_requested_fec()
9033 lc->requested_fec = FEC_NONE; in sysctl_requested_fec()
9035 if ((lc->pcaps | in sysctl_requested_fec()
9037 lc->pcaps) { in sysctl_requested_fec()
9041 lc->requested_fec = n & (M_FW_PORT_CAP32_FEC | in sysctl_requested_fec()
9046 if (pi->up_vis > 0) { in sysctl_requested_fec()
9049 lc->requested_fec = old; in sysctl_requested_fec()
9067 struct adapter *sc = pi->adapter; in sysctl_module_fec()
9068 struct link_config *lc = &pi->link_cfg; in sysctl_module_fec()
9086 if (pi->up_vis == 0) { in sysctl_module_fec()
9096 fec = lc->fec_hint; in sysctl_module_fec()
9097 if (pi->mod_type == FW_PORT_MOD_TYPE_NONE || in sysctl_module_fec()
9098 !fec_supported(lc->pcaps)) { in sysctl_module_fec()
9119 struct adapter *sc = pi->adapter; in sysctl_autoneg()
9120 struct link_config *lc = &pi->link_cfg; in sysctl_autoneg()
9123 if (lc->pcaps & FW_PORT_CAP32_ANEG) in sysctl_autoneg()
9124 val = lc->requested_aneg == AUTONEG_DISABLE ? 0 : 1; in sysctl_autoneg()
9126 val = -1; in sysctl_autoneg()
9128 if (rc != 0 || req->newptr == NULL) in sysctl_autoneg()
9137 rc = begin_synchronized_op(sc, &pi->vi[0], SLEEP_OK | INTR_OK, in sysctl_autoneg()
9142 if (val == AUTONEG_ENABLE && !(lc->pcaps & FW_PORT_CAP32_ANEG)) { in sysctl_autoneg()
9146 lc->requested_aneg = val; in sysctl_autoneg()
9149 if (pi->up_vis > 0) in sysctl_autoneg()
9163 struct adapter *sc = pi->adapter; in sysctl_force_fec()
9164 struct link_config *lc = &pi->link_cfg; in sysctl_force_fec()
9167 val = lc->force_fec; in sysctl_force_fec()
9168 MPASS(val >= -1 && val <= 1); in sysctl_force_fec()
9170 if (rc != 0 || req->newptr == NULL) in sysctl_force_fec()
9172 if (!(lc->pcaps & FW_PORT_CAP32_FORCE_FEC)) in sysctl_force_fec()
9174 if (val < -1 || val > 1) in sysctl_force_fec()
9177 rc = begin_synchronized_op(sc, &pi->vi[0], SLEEP_OK | INTR_OK, "t4ff"); in sysctl_force_fec()
9181 lc->force_fec = val; in sysctl_force_fec()
9184 if (pi->up_vis > 0) in sysctl_force_fec()
9199 mtx_lock(&sc->reg_lock); in sysctl_handle_t4_reg64()
9206 mtx_unlock(&sc->reg_lock); in sysctl_handle_t4_reg64()
9216 struct adapter *sc = pi->adapter; in sysctl_handle_t4_portstat64()
9220 mtx_lock(&sc->reg_lock); in sysctl_handle_t4_portstat64()
9225 for (i = 0; i < sc->params.tp.lb_nchan; i++) { in sysctl_handle_t4_portstat64()
9227 t4_port_reg(sc, pi->tx_chan + i, reg)); in sysctl_handle_t4_portstat64()
9231 mtx_unlock(&sc->reg_lock); in sysctl_handle_t4_portstat64()
9253 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, &param, &val); in sysctl_temperature()
9259 /* unknown is returned as 0 but we display -1 in that case */ in sysctl_temperature()
9260 t = val == 0 ? -1 : val; in sysctl_temperature()
9273 if (sc->params.core_vdd == 0) { in sysctl_vdd()
9284 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, in sysctl_vdd()
9290 sc->params.core_vdd = val; in sysctl_vdd()
9293 return (sysctl_handle_int(oidp, &sc->params.core_vdd, 0, req)); in sysctl_vdd()
9303 v = sc->sensor_resets; in sysctl_reset_sensor()
9305 if (rc != 0 || req->newptr == NULL || v <= 0) in sysctl_reset_sensor()
9308 if (sc->params.fw_vers < FW_VERSION32(1, 24, 7, 0) || in sysctl_reset_sensor()
9322 rc = -t4_set_params(sc, sc->mbox, sc->pf, 0, 1, &param, &val); in sysctl_reset_sensor()
9326 sc->sensor_resets++; in sysctl_reset_sensor()
9339 KASSERT(coreid < sc->params.ncores, in sysctl_loadavg()
9351 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, &param, &val); in sysctl_loadavg()
9391 mtx_lock(&sc->reg_lock); in sysctl_cctrl()
9396 mtx_unlock(&sc->reg_lock); in sysctl_cctrl()
9407 sc->params.a_wnd[i], dec_fac[sc->params.b_wnd[i]]); in sysctl_cctrl()
9427 KASSERT(qid >= 0 && qid < sc->chip_params->cim_num_ibq, in sysctl_cim_ibq()
9429 KASSERT(coreid >= 0 && coreid < sc->params.ncores, in sysctl_cim_ibq()
9434 mtx_lock(&sc->reg_lock); in sysctl_cim_ibq()
9436 rc = -ENXIO; in sysctl_cim_ibq()
9439 mtx_unlock(&sc->reg_lock); in sysctl_cim_ibq()
9441 rc = -rc; in sysctl_cim_ibq()
9472 KASSERT(qid >= 0 && qid < sc->chip_params->cim_num_obq, in sysctl_cim_obq()
9474 KASSERT(coreid >= 0 && coreid < sc->params.ncores, in sysctl_cim_obq()
9479 mtx_lock(&sc->reg_lock); in sysctl_cim_obq()
9481 rc = -ENXIO; in sysctl_cim_obq()
9484 mtx_unlock(&sc->reg_lock); in sysctl_cim_obq()
9486 rc = -rc; in sysctl_cim_obq()
9519 for (p = buf; p <= &buf[sc->params.cim_la_size - 8]; p += 8) { in sbuf_cim_la4()
9549 for (p = buf; p <= &buf[sc->params.cim_la_size - 10]; p += 10) { in sbuf_cim_la6()
9579 buf = malloc(sc->params.cim_la_size * sizeof(uint32_t), M_CXGBE, in sbuf_cim_la()
9584 mtx_lock(&sc->reg_lock); in sbuf_cim_la()
9588 rc = -t4_cim_read_core(sc, 1, coreid, A_UP_UP_DBG_LA_CFG, 1, in sbuf_cim_la()
9591 rc = -t4_cim_read_la_core(sc, coreid, buf, NULL); in sbuf_cim_la()
9593 mtx_unlock(&sc->reg_lock); in sbuf_cim_la()
9627 device_get_nameunit(sc->dev), in dump_cim_regs()
9634 device_get_nameunit(sc->dev), in dump_cim_regs()
9650 device_get_nameunit(sc->dev)); in dump_cimla()
9658 device_get_nameunit(sc->dev), sbuf_data(&sb)); in dump_cimla()
9667 atomic_set_int(&sc->error_flags, ADAP_CIM_ERR); in t4_os_cim_err()
9687 mtx_lock(&sc->reg_lock); in sysctl_cim_ma_la()
9692 mtx_unlock(&sc->reg_lock); in sysctl_cim_ma_la()
9735 mtx_lock(&sc->reg_lock); in sysctl_cim_pif_la()
9740 mtx_unlock(&sc->reg_lock); in sysctl_cim_pif_la()
9778 "TP0", "TP1", "ULP", "SGE0", "SGE1", "NC-SI", /* ibq's */ in sysctl_cim_qcfg()
9779 "ULP0", "ULP1", "ULP2", "ULP3", "SGE", "NC-SI", /* obq's */ in sysctl_cim_qcfg()
9780 "SGE0-RX", "SGE1-RX" /* additional obq's (T5 onwards) */ in sysctl_cim_qcfg()
9785 cim_num_obq = sc->chip_params->cim_num_obq; in sysctl_cim_qcfg()
9795 mtx_lock(&sc->reg_lock); in sysctl_cim_qcfg()
9799 rc = -t4_cim_read(sc, ibq_rdaddr, 4 * nq, stat); in sysctl_cim_qcfg()
9801 rc = -t4_cim_read(sc, obq_rdaddr, 2 * cim_num_obq, in sysctl_cim_qcfg()
9807 mtx_unlock(&sc->reg_lock); in sysctl_cim_qcfg()
9826 wr[0] - base[i], G_QUESOPCNT(p[3]), G_QUEEOPCNT(p[3]), in sysctl_cim_qcfg()
9849 "TP0", "TP1", "TP2", "TP3", "ULP", "SGE0", "SGE1", "NC-SI", in sysctl_cim_qcfg_t7()
9853 "ULP0", "ULP1", "ULP2", "ULP3", "SGE", "NC-SI", "SGE0-RX", in sysctl_cim_qcfg_t7()
9862 "ULP0", "ULP1", "ULP2", "ULP3", "SGE", "RSVD", "SGE0-RX", in sysctl_cim_qcfg_t7()
9869 mtx_lock(&sc->reg_lock); in sysctl_cim_qcfg_t7()
9873 rc = -t4_cim_read_core(sc, 1, coreid, in sysctl_cim_qcfg_t7()
9878 rc = -t4_cim_read_core(sc, 1, coreid, in sysctl_cim_qcfg_t7()
9886 rc = -t4_cim_read_core(sc, 1, coreid, addr, 1, in sysctl_cim_qcfg_t7()
9894 mtx_unlock(&sc->reg_lock); in sysctl_cim_qcfg_t7()
9921 coreid == 0 ? qname_obq_t7[i - CIM_NUM_IBQ_T7] : in sysctl_cim_qcfg_t7()
9922 qname_obq_sec_t7[i - CIM_NUM_IBQ_T7], in sysctl_cim_qcfg_t7()
9946 mtx_lock(&sc->reg_lock); in sysctl_cpl_stats()
9951 mtx_unlock(&sc->reg_lock); in sysctl_cpl_stats()
9955 if (sc->chip_params->nchan > 2) { in sysctl_cpl_stats()
9989 mtx_lock(&sc->reg_lock); in sysctl_ddp_stats()
9994 mtx_unlock(&sc->reg_lock); in sysctl_ddp_stats()
10019 mtx_lock(&sc->reg_lock); in sysctl_tid_stats()
10024 mtx_unlock(&sc->reg_lock); in sysctl_tid_stats()
10078 struct devlog_params *dparams = &sc->params.devlog; in sbuf_devlog()
10083 KASSERT(coreid >= 0 && coreid < sc->params.ncores, in sbuf_devlog()
10086 if (dparams->addr == 0) in sbuf_devlog()
10089 size = dparams->size / sc->params.ncores; in sbuf_devlog()
10090 addr = dparams->addr + coreid * size; in sbuf_devlog()
10097 mtx_lock(&sc->reg_lock); in sbuf_devlog()
10102 mtx_unlock(&sc->reg_lock); in sbuf_devlog()
10110 if (e->timestamp == 0) in sbuf_devlog()
10113 e->timestamp = be64toh(e->timestamp); in sbuf_devlog()
10114 e->seqno = be32toh(e->seqno); in sbuf_devlog()
10116 e->params[j] = be32toh(e->params[j]); in sbuf_devlog()
10118 if (e->timestamp < ftstamp) { in sbuf_devlog()
10119 ftstamp = e->timestamp; in sbuf_devlog()
10133 if (e->timestamp == 0) in sbuf_devlog()
10137 e->seqno, e->timestamp, in sbuf_devlog()
10138 (e->level < nitems(devlog_level_strings) ? in sbuf_devlog()
10139 devlog_level_strings[e->level] : "UNKNOWN"), in sbuf_devlog()
10140 (e->facility < nitems(devlog_facility_strings) ? in sbuf_devlog()
10141 devlog_facility_strings[e->facility] : "UNKNOWN")); in sbuf_devlog()
10142 sbuf_printf(sb, e->fmt, e->params[0], e->params[1], in sbuf_devlog()
10143 e->params[2], e->params[3], e->params[4], in sbuf_devlog()
10144 e->params[5], e->params[6], e->params[7]); in sbuf_devlog()
10164 if (coreid == -1) { in sysctl_devlog()
10165 /* -1 means all cores */ in sysctl_devlog()
10166 for (i = rc = 0; i < sc->params.ncores && rc == 0; i++) { in sysctl_devlog()
10167 if (sc->params.ncores > 0) in sysctl_devlog()
10172 KASSERT(coreid >= 0 && coreid < sc->params.ncores, in sysctl_devlog()
10190 device_get_nameunit(sc->dev)); in dump_devlog()
10193 for (i = rc = 0; i < sc->params.ncores && rc == 0; i++) { in dump_devlog()
10194 if (sc->params.ncores > 0) in dump_devlog()
10201 device_get_nameunit(sc->dev), sbuf_data(&sb)); in dump_devlog()
10213 int i, nchan = sc->chip_params->nchan; in sysctl_fcoe_stats()
10216 mtx_lock(&sc->reg_lock); in sysctl_fcoe_stats()
10223 mtx_unlock(&sc->reg_lock); in sysctl_fcoe_stats()
10272 mtx_lock(&sc->reg_lock); in sysctl_hw_sched()
10274 mtx_unlock(&sc->reg_lock); in sysctl_hw_sched()
10282 mtx_unlock(&sc->reg_lock); in sysctl_hw_sched()
10289 sbuf_printf(sb, "\n %u %-5s %u ", i, in sysctl_hw_sched()
10337 for (i = 0; i < sc->chip_params->nchan; i += 2) { in sysctl_lb_stats()
10338 mtx_lock(&sc->reg_lock); in sysctl_lb_stats()
10345 mtx_unlock(&sc->reg_lock); in sysctl_lb_stats()
10355 sbuf_printf(sb, "\n%-17s %20ju %20ju", stat_name[j], in sysctl_lb_stats()
10371 struct link_config *lc = &pi->link_cfg; in sysctl_linkdnrc()
10378 if (lc->link_ok || lc->link_down_rc == 255) in sysctl_linkdnrc()
10381 sbuf_printf(sb, "%s", t4_link_down_rc_str(lc->link_down_rc)); in sysctl_linkdnrc()
10398 const uint64_t v1 = ((const struct mem_desc *)a)->base; in mem_desc_cmp()
10399 const uint64_t v2 = ((const struct mem_desc *)b)->base; in mem_desc_cmp()
10402 return (-1); in mem_desc_cmp()
10417 size = to - from + 1; in mem_region_show()
10422 sbuf_printf(sb, "%-18s 0x%012jx-0x%012jx [%ju]\n", name, in mem_region_show()
10425 sbuf_printf(sb, "%-18s 0x%08jx-0x%08jx [%ju]\n", name, in mem_region_show()
10448 "ULPTX state:", "RoCE RRQ region:", "On-chip queues:", in sysctl_meminfo()
10467 mtx_lock(&sc->reg_lock); in sysctl_meminfo()
10572 (md++)->base = t4_read_reg(sc, A_SGE_DBQ_CTXT_BADDR); in sysctl_meminfo()
10573 (md++)->base = t4_read_reg(sc, A_SGE_IMSG_CTXT_BADDR); in sysctl_meminfo()
10574 (md++)->base = t4_read_reg(sc, A_SGE_FLM_CACHE_BADDR); in sysctl_meminfo()
10575 (md++)->base = t4_read_reg(sc, A_TP_CMM_TCB_BASE); in sysctl_meminfo()
10576 (md++)->base = t4_read_reg(sc, A_TP_CMM_MM_BASE); in sysctl_meminfo()
10577 (md++)->base = t4_read_reg(sc, A_TP_CMM_TIMER_BASE); in sysctl_meminfo()
10578 (md++)->base = t4_read_reg(sc, A_TP_CMM_MM_RX_FLST_BASE); in sysctl_meminfo()
10579 (md++)->base = t4_read_reg(sc, A_TP_CMM_MM_TX_FLST_BASE); in sysctl_meminfo()
10580 (md++)->base = t4_read_reg(sc, A_TP_CMM_MM_PS_FLST_BASE); in sysctl_meminfo()
10583 md->base = t4_read_reg(sc, A_TP_PMM_TX_BASE); in sysctl_meminfo()
10584 md->limit = md->base - 1 + in sysctl_meminfo()
10589 md->base = t4_read_reg(sc, A_TP_PMM_RX_BASE); in sysctl_meminfo()
10590 md->limit = md->base - 1 + in sysctl_meminfo()
10597 md->base = t4_read_reg(sc, A_LE_DB_HASH_TID_BASE); in sysctl_meminfo()
10599 md->base = t4_read_reg(sc, A_LE_DB_HASH_TBL_BASE_ADDR); in sysctl_meminfo()
10600 md->limit = 0; in sysctl_meminfo()
10602 md->base = 0; in sysctl_meminfo()
10603 md->idx = nitems(region); /* hide it */ in sysctl_meminfo()
10609 md->base = (uint64_t)t4_read_reg(sc, A_ULP_ ## reg ## _LLIMIT) << shift; \ in sysctl_meminfo()
10610 md->limit = (uint64_t)t4_read_reg(sc, A_ULP_ ## reg ## _ULIMIT) << shift; \ in sysctl_meminfo()
10611 md->limit += (1 << shift) - 1; \ in sysctl_meminfo()
10616 md->base = 0; \ in sysctl_meminfo()
10617 md->idx = nitems(region); \ in sysctl_meminfo()
10654 md->base = 0; in sysctl_meminfo()
10656 md->idx = nitems(region); in sysctl_meminfo()
10669 md->base = t4_read_reg(sc, A_SGE_DBVFIFO_BADDR); in sysctl_meminfo()
10670 md->limit = md->base + size - 1; in sysctl_meminfo()
10672 md->idx = nitems(region); in sysctl_meminfo()
10676 md->base = t4_read_reg(sc, A_ULP_RX_CTX_BASE); in sysctl_meminfo()
10677 md->limit = 0; in sysctl_meminfo()
10679 md->base = t4_read_reg(sc, A_ULP_TX_ERR_TABLE_BASE); in sysctl_meminfo()
10680 md->limit = 0; in sysctl_meminfo()
10685 md->base = lo; in sysctl_meminfo()
10687 md->base = 0; in sysctl_meminfo()
10688 md->idx = nitems(region); in sysctl_meminfo()
10692 md->base = sc->vres.ocq.start; in sysctl_meminfo()
10693 if (sc->vres.ocq.size) in sysctl_meminfo()
10694 md->limit = md->base + sc->vres.ocq.size - 1; in sysctl_meminfo()
10696 md->idx = nitems(region); /* hide it */ in sysctl_meminfo()
10699 /* add any address-space holes, there can be up to 3 */ in sysctl_meminfo()
10700 for (n = 0; n < i - 1; n++) in sysctl_meminfo()
10702 (md++)->base = avail[n].limit; in sysctl_meminfo()
10704 (md++)->base = avail[n].limit; in sysctl_meminfo()
10706 n = md - mem; in sysctl_meminfo()
10712 avail[lo].limit - 1); in sysctl_meminfo()
10719 mem[i].limit = i < n - 1 ? mem[i + 1].base - 1 : ~0; in sysctl_meminfo()
10725 hi = t4_read_reg(sc, A_CIM_SDRAM_ADDR_SIZE) + lo - 1; in sysctl_meminfo()
10726 if (hi != lo - 1) { in sysctl_meminfo()
10732 hi = t4_read_reg(sc, A_CIM_EXTMEM2_ADDR_SIZE) + lo - 1; in sysctl_meminfo()
10733 if (hi != lo - 1) in sysctl_meminfo()
10759 sbuf_printf(sb, "%u p-structs (%u free)\n", in sysctl_meminfo()
10779 for (i = 0; i < sc->chip_params->nchan; i++) { in sysctl_meminfo()
10797 mtx_unlock(&sc->reg_lock); in sysctl_meminfo()
10829 for (i = 0; i < sc->chip_params->mps_tcam_size; i++) { in sysctl_mps_tcam()
10834 mtx_lock(&sc->reg_lock); in sysctl_mps_tcam()
10841 mtx_unlock(&sc->reg_lock); in sysctl_mps_tcam()
10847 mtx_lock(&sc->reg_lock); in sysctl_mps_tcam()
10854 mtx_unlock(&sc->reg_lock); in sysctl_mps_tcam()
10862 (cls_lo & F_VF_VALID) ? G_VF(cls_lo) : -1); in sysctl_mps_tcam()
10884 rc = -t4_wr_mbox(sc, sc->mbox, &ldst_cmd, in sysctl_mps_tcam()
10932 for (i = 0; i < sc->chip_params->mps_tcam_size; i++) { in sysctl_mps_tcam_t6()
10943 ctl |= V_CTLTCAMINDEX(i - 256) | V_CTLTCAMSEL(1); in sysctl_mps_tcam_t6()
10944 mtx_lock(&sc->reg_lock); in sysctl_mps_tcam_t6()
10954 mtx_unlock(&sc->reg_lock); in sysctl_mps_tcam_t6()
10974 mtx_lock(&sc->reg_lock); in sysctl_mps_tcam_t6()
10984 mtx_unlock(&sc->reg_lock); in sysctl_mps_tcam_t6()
10999 mtx_lock(&sc->reg_lock); in sysctl_mps_tcam_t6()
11006 mtx_unlock(&sc->reg_lock); in sysctl_mps_tcam_t6()
11012 "%012jx %06x %06x - - %3c" in sysctl_mps_tcam_t6()
11018 cls_lo & F_T6_VF_VALID ? G_T6_VF(cls_lo) : -1); in sysctl_mps_tcam_t6()
11021 "%012jx - - ", i, addr[0], addr[1], in sysctl_mps_tcam_t6()
11028 sbuf_printf(sb, " - N "); in sysctl_mps_tcam_t6()
11030 sbuf_printf(sb, "- %3c %4x %3c %#x%4u%4d", in sysctl_mps_tcam_t6()
11034 cls_lo & F_T6_VF_VALID ? G_T6_VF(cls_lo) : -1); in sysctl_mps_tcam_t6()
11058 rc = -t4_wr_mbox(sc, sc->mbox, &ldst_cmd, in sysctl_mps_tcam_t6()
11112 for (i = 0; i < sc->chip_params->mps_tcam_size; i++) { in sysctl_mps_tcam_t7()
11125 ctl |= V_CTLTCAMINDEX(i - 256) | V_T7_CTLTCAMSEL(1); in sysctl_mps_tcam_t7()
11133 ctl |= V_CTLTCAMINDEX(i - 512) | V_T7_CTLTCAMSEL(1); in sysctl_mps_tcam_t7()
11135 ctl |= V_CTLTCAMINDEX(i - 1024) | V_T7_CTLTCAMSEL(2); in sysctl_mps_tcam_t7()
11138 mtx_lock(&sc->reg_lock); in sysctl_mps_tcam_t7()
11148 mtx_unlock(&sc->reg_lock); in sysctl_mps_tcam_t7()
11168 mtx_lock(&sc->reg_lock); in sysctl_mps_tcam_t7()
11178 mtx_unlock(&sc->reg_lock); in sysctl_mps_tcam_t7()
11193 mtx_lock(&sc->reg_lock); in sysctl_mps_tcam_t7()
11207 mtx_unlock(&sc->reg_lock); in sysctl_mps_tcam_t7()
11213 "%012jx %06x %06x - - %3c" in sysctl_mps_tcam_t7()
11219 cls_lo & F_T6_VF_VALID ? G_T6_VF(cls_lo) : -1); in sysctl_mps_tcam_t7()
11222 "%012jx - - ", i, addr[0], addr[1], in sysctl_mps_tcam_t7()
11229 sbuf_printf(sb, " - N "); in sysctl_mps_tcam_t7()
11231 sbuf_printf(sb, "- %3c %4x %3c %#x%4u%4d", in sysctl_mps_tcam_t7()
11235 cls_lo & F_T6_VF_VALID ? G_T6_VF(cls_lo) : -1); in sysctl_mps_tcam_t7()
11258 rc = -t4_wr_mbox(sc, sc->mbox, &ldst_cmd, in sysctl_mps_tcam_t7()
11302 mtx_lock(&sc->reg_lock); in sysctl_path_mtus()
11307 mtx_unlock(&sc->reg_lock); in sysctl_path_mtus()
11345 mtx_lock(&sc->reg_lock); in sysctl_pm_stats()
11354 mtx_unlock(&sc->reg_lock); in sysctl_pm_stats()
11364 sbuf_printf(sb, "\n%-13s %10u %20ju", tx_stats[i], tx_cnt[i], in sysctl_pm_stats()
11370 sbuf_printf(sb, "\n%-13s %10u %20ju", rx_stats[i], rx_cnt[i], in sysctl_pm_stats()
11377 sbuf_printf(sb, "\n%-13s %10u %20ju", tx_stats[i], tx_cnt[i], in sysctl_pm_stats()
11379 sbuf_printf(sb, "\n%-13s %10u %20ju", rx_stats[i], rx_cnt[i], in sysctl_pm_stats()
11387 sbuf_printf(sb, "\n%-13s %10u %20ju", tx_stats[i], tx_cnt[i], in sysctl_pm_stats()
11389 sbuf_printf(sb, "\n%-13s %10u %20ju", rx_stats[i], rx_cnt[i], in sysctl_pm_stats()
11396 sbuf_printf(sb, "%-40s %u\n", "ReqWrite", stats[i++]); in sysctl_pm_stats()
11397 sbuf_printf(sb, "%-40s %u\n", "ReqReadInv", stats[i++]); in sysctl_pm_stats()
11398 sbuf_printf(sb, "%-40s %u\n", "ReqReadNoInv", stats[i++]); in sysctl_pm_stats()
11399 sbuf_printf(sb, "%-40s %u\n", "Write Split Request", in sysctl_pm_stats()
11401 sbuf_printf(sb, "%-40s %u\n", in sysctl_pm_stats()
11403 sbuf_printf(sb, "%-40s %u\n", in sysctl_pm_stats()
11406 sbuf_printf(sb, "%-40s %u\n", "Write Hit", stats[i++]); in sysctl_pm_stats()
11407 sbuf_printf(sb, "%-40s %u\n", "Normal Read Hit", in sysctl_pm_stats()
11409 sbuf_printf(sb, "%-40s %u\n", "Feedback Read Hit", in sysctl_pm_stats()
11411 sbuf_printf(sb, "%-40s %u\n", "Normal Read Hit Full Avail", in sysctl_pm_stats()
11413 sbuf_printf(sb, "%-40s %u\n", "Normal Read Hit Full UnAvail", in sysctl_pm_stats()
11415 sbuf_printf(sb, "%-40s %u\n", in sysctl_pm_stats()
11418 sbuf_printf(sb, "%-40s %u\n", "FB Read Hit Full Avail", in sysctl_pm_stats()
11420 sbuf_printf(sb, "%-40s %u\n", "FB Read Hit Full UnAvail", in sysctl_pm_stats()
11422 sbuf_printf(sb, "%-40s %u\n", "FB Read Hit Partial Avail", in sysctl_pm_stats()
11424 sbuf_printf(sb, "%-40s %u\n", "Normal Read Full Free", in sysctl_pm_stats()
11426 sbuf_printf(sb, "%-40s %u\n", in sysctl_pm_stats()
11427 "Normal Read Part-avail Mul-Regions", in sysctl_pm_stats()
11429 sbuf_printf(sb, "%-40s %u\n", in sysctl_pm_stats()
11430 "FB Read Part-avail Mul-Regions", in sysctl_pm_stats()
11432 sbuf_printf(sb, "%-40s %u\n", "Write Miss FL Used", in sysctl_pm_stats()
11434 sbuf_printf(sb, "%-40s %u\n", "Write Miss LRU Used", in sysctl_pm_stats()
11436 sbuf_printf(sb, "%-40s %u\n", in sysctl_pm_stats()
11437 "Write Miss LRU-Multiple Evict", stats[i++]); in sysctl_pm_stats()
11438 sbuf_printf(sb, "%-40s %u\n", in sysctl_pm_stats()
11440 sbuf_printf(sb, "%-40s %u\n", in sysctl_pm_stats()
11442 sbuf_printf(sb, "%-40s %u\n", "Write Overflow Eviction", in sysctl_pm_stats()
11444 sbuf_printf(sb, "%-40s %u", "Read Overflow Eviction", in sysctl_pm_stats()
11463 mtx_lock(&sc->reg_lock); in sysctl_rdma_stats()
11468 mtx_unlock(&sc->reg_lock); in sysctl_rdma_stats()
11494 mtx_lock(&sc->reg_lock); in sysctl_tcp_stats()
11499 mtx_unlock(&sc->reg_lock); in sysctl_tcp_stats()
11531 struct tid_info *t = &sc->tids; in sysctl_tids()
11538 if (t->natids) { in sysctl_tids()
11539 sbuf_printf(sb, "ATID range: 0-%u, in use: %u\n", t->natids - 1, in sysctl_tids()
11540 t->atids_in_use); in sysctl_tids()
11543 if (t->nhpftids) { in sysctl_tids()
11544 sbuf_printf(sb, "HPFTID range: %u-%u, in use: %u\n", in sysctl_tids()
11545 t->hpftid_base, t->hpftid_end, t->hpftids_in_use); in sysctl_tids()
11548 if (t->ntids) { in sysctl_tids()
11551 mtx_lock(&sc->reg_lock); in sysctl_tids()
11564 mtx_unlock(&sc->reg_lock); in sysctl_tids()
11571 sbuf_printf(sb, "%u-%u, ", t->tid_base, x - 1); in sysctl_tids()
11572 sbuf_printf(sb, "%u-%u", y, t->ntids - 1); in sysctl_tids()
11574 sbuf_printf(sb, "%u-%u", t->tid_base, t->tid_base + in sysctl_tids()
11575 t->ntids - 1); in sysctl_tids()
11578 atomic_load_acq_int(&t->tids_in_use)); in sysctl_tids()
11581 if (t->nstids) { in sysctl_tids()
11582 sbuf_printf(sb, "STID range: %u-%u, in use: %u\n", t->stid_base, in sysctl_tids()
11583 t->stid_base + t->nstids - 1, t->stids_in_use); in sysctl_tids()
11586 if (t->nftids) { in sysctl_tids()
11587 sbuf_printf(sb, "FTID range: %u-%u, in use: %u\n", t->ftid_base, in sysctl_tids()
11588 t->ftid_end, t->ftids_in_use); in sysctl_tids()
11591 if (t->netids) { in sysctl_tids()
11592 sbuf_printf(sb, "ETID range: %u-%u, in use: %u\n", t->etid_base, in sysctl_tids()
11593 t->etid_base + t->netids - 1, t->etids_in_use); in sysctl_tids()
11596 mtx_lock(&sc->reg_lock); in sysctl_tids()
11603 mtx_unlock(&sc->reg_lock); in sysctl_tids()
11626 mtx_lock(&sc->reg_lock); in sysctl_tp_err_stats()
11631 mtx_unlock(&sc->reg_lock); in sysctl_tp_err_stats()
11639 if (sc->chip_params->nchan > 2) { in sysctl_tp_err_stats()
11704 mtx_lock(&sc->reg_lock); in sysctl_tnl_stats()
11709 mtx_unlock(&sc->reg_lock); in sysctl_tnl_stats()
11717 if (sc->chip_params->nchan > 2) { in sysctl_tnl_stats()
11744 struct tp_params *tpp = &sc->params.tp; in sysctl_tp_la_mask()
11748 mask = tpp->la_mask >> 16; in sysctl_tp_la_mask()
11750 if (rc != 0 || req->newptr == NULL) in sysctl_tp_la_mask()
11754 mtx_lock(&sc->reg_lock); in sysctl_tp_la_mask()
11758 tpp->la_mask = mask << 16; in sysctl_tp_la_mask()
11760 tpp->la_mask); in sysctl_tp_la_mask()
11762 mtx_unlock(&sc->reg_lock); in sysctl_tp_la_mask()
11779 while (f->name) { in field_desc_show()
11780 uint64_t mask = (1ULL << f->width) - 1; in field_desc_show()
11781 int len = snprintf(buf, sizeof(buf), "%s: %ju", f->name, in field_desc_show()
11782 ((uintmax_t)v >> f->start) & mask); in field_desc_show()
11942 if (idx < (TPLA_SIZE / 2 - 1) || p[1] != ~0ULL) in tp_la_show2()
11953 if (idx < (TPLA_SIZE / 2 - 1) || p[1] != ~0ULL) in tp_la_show3()
11974 mtx_lock(&sc->reg_lock); in sysctl_tp_la()
11993 mtx_unlock(&sc->reg_lock); in sysctl_tp_la()
12016 mtx_lock(&sc->reg_lock); in sysctl_tx_rate()
12021 mtx_unlock(&sc->reg_lock); in sysctl_tx_rate()
12029 if (sc->chip_params->nchan > 2) { in sysctl_tx_rate()
12066 mtx_lock(&sc->reg_lock); in sysctl_ulprx_la()
12071 mtx_unlock(&sc->reg_lock); in sysctl_ulprx_la()
12100 mtx_lock(&sc->reg_lock); in sysctl_wcwr_stats()
12108 mtx_unlock(&sc->reg_lock); in sysctl_wcwr_stats()
12145 rc = bus_get_cpus(sc->dev, op, sizeof(cpuset), &cpuset); in sysctl_cpus()
12168 val = atomic_load_int(&sc->num_resets); in sysctl_reset()
12170 if (rc != 0 || req->newptr == NULL) in sysctl_reset()
12175 atomic_store_int(&sc->num_resets, 0); in sysctl_reset()
12185 taskqueue_enqueue(reset_tq, &sc->reset_task); in sysctl_reset()
12197 v = sc->tt.tls; in sysctl_tls()
12199 if (rc != 0 || req->newptr == NULL) in sysctl_tls()
12202 if (v != 0 && !(sc->cryptocaps & FW_CAPS_CONFIG_TLSKEYS)) in sysctl_tls()
12211 sc->tt.tls = !!v; in sysctl_tls()
12213 for_each_vi(sc->port[i], j, vi) { in sysctl_tls()
12214 if (vi->flags & VI_INIT_DONE) in sysctl_tls()
12215 t4_update_fl_bufsize(vi->ifp); in sysctl_tls()
12245 u_int cclk_ps = 1000000000 / sc->params.vpd.cclk; in sysctl_tp_tick()
12247 mtx_lock(&sc->reg_lock); in sysctl_tp_tick()
12249 res = (u_int)-1; in sysctl_tp_tick()
12252 mtx_unlock(&sc->reg_lock); in sysctl_tp_tick()
12253 if (res == (u_int)-1) in sysctl_tp_tick()
12284 u_int cclk_ps = 1000000000 / sc->params.vpd.cclk; in sysctl_tp_dack_timer()
12286 mtx_lock(&sc->reg_lock); in sysctl_tp_dack_timer()
12295 mtx_unlock(&sc->reg_lock); in sysctl_tp_dack_timer()
12311 u_int cclk_ps = 1000000000 / sc->params.vpd.cclk; in sysctl_tp_timer()
12318 mtx_lock(&sc->reg_lock); in sysctl_tp_timer()
12330 mtx_unlock(&sc->reg_lock); in sysctl_tp_timer()
12350 mtx_lock(&sc->reg_lock); in sysctl_tp_shift_cnt()
12357 mtx_unlock(&sc->reg_lock); in sysctl_tp_shift_cnt()
12375 mtx_lock(&sc->reg_lock); in sysctl_tp_backoff()
12382 mtx_unlock(&sc->reg_lock); in sysctl_tp_backoff()
12393 struct adapter *sc = vi->adapter; in sysctl_holdoff_tmr_idx_ofld()
12398 idx = vi->ofld_tmr_idx; in sysctl_holdoff_tmr_idx_ofld()
12401 if (rc != 0 || req->newptr == NULL) in sysctl_holdoff_tmr_idx_ofld()
12412 v = V_QINTR_TIMER_IDX(idx) | V_QINTR_CNT_EN(vi->ofld_pktc_idx != -1); in sysctl_holdoff_tmr_idx_ofld()
12415 atomic_store_rel_8(&ofld_rxq->iq.intr_params, v); in sysctl_holdoff_tmr_idx_ofld()
12417 ofld_rxq->iq.intr_params = v; in sysctl_holdoff_tmr_idx_ofld()
12420 vi->ofld_tmr_idx = idx; in sysctl_holdoff_tmr_idx_ofld()
12430 struct adapter *sc = vi->adapter; in sysctl_holdoff_pktc_idx_ofld()
12433 idx = vi->ofld_pktc_idx; in sysctl_holdoff_pktc_idx_ofld()
12436 if (rc != 0 || req->newptr == NULL) in sysctl_holdoff_pktc_idx_ofld()
12439 if (idx < -1 || idx >= SGE_NCOUNTERS) in sysctl_holdoff_pktc_idx_ofld()
12447 if (vi->flags & VI_INIT_DONE) in sysctl_holdoff_pktc_idx_ofld()
12450 vi->ofld_pktc_idx = idx; in sysctl_holdoff_pktc_idx_ofld()
12463 if (len < sc->chip_params->sge_ctxt_size) in get_sge_context()
12480 if (sc->flags & FW_OK) { in get_sge_context()
12481 rc = -t4_sge_ctxt_rd(sc, sc->mbox, cid, mem_id, data); in get_sge_context()
12490 rc = -t4_sge_ctxt_rd_bd(sc, cid, mem_id, data); in get_sge_context()
12517 if (sc->flags & FULL_INIT_DONE && in load_fw()
12518 (sc->debug_flags & DF_LOAD_FW_ANYTIME) == 0) { in load_fw()
12523 fw_data = malloc(fw->len, M_CXGBE, M_WAITOK); in load_fw()
12525 rc = copyin(fw->data, fw_data, fw->len); in load_fw()
12527 rc = -t4_load_fw(sc, fw_data, fw->len); in load_fw()
12550 if (cfg->len == 0) { in load_cfg()
12552 rc = -t4_load_cfg(sc, NULL, 0); in load_cfg()
12556 cfg_data = malloc(cfg->len, M_CXGBE, M_WAITOK); in load_cfg()
12558 rc = copyin(cfg->data, cfg_data, cfg->len); in load_cfg()
12560 rc = -t4_load_cfg(sc, cfg_data, cfg->len); in load_cfg()
12575 if (br->len > 1024 * 1024) in load_boot()
12578 if (br->pf_offset == 0) { in load_boot()
12580 if (br->pfidx_addr > 7) in load_boot()
12582 offset = G_OFFSET(t4_read_reg(sc, PF_REG(br->pfidx_addr, in load_boot()
12584 } else if (br->pf_offset == 1) { in load_boot()
12586 offset = G_OFFSET(br->pfidx_addr); in load_boot()
12600 if (br->len == 0) { in load_boot()
12602 rc = -t4_load_boot(sc, NULL, offset, 0); in load_boot()
12606 br_data = malloc(br->len, M_CXGBE, M_WAITOK); in load_boot()
12608 rc = copyin(br->data, br_data, br->len); in load_boot()
12610 rc = -t4_load_boot(sc, br_data, offset, br->len); in load_boot()
12633 if (bc->len == 0) { in load_bootcfg()
12635 rc = -t4_load_bootcfg(sc, NULL, 0); in load_bootcfg()
12639 bc_data = malloc(bc->len, M_CXGBE, M_WAITOK); in load_bootcfg()
12641 rc = copyin(bc->data, bc_data, bc->len); in load_bootcfg()
12643 rc = -t4_load_bootcfg(sc, bc_data, bc->len); in load_bootcfg()
12659 buf = malloc(dump->len, M_CXGBE, M_NOWAIT | M_ZERO); in cudbg_dump()
12670 cudbg->adap = sc; in cudbg_dump()
12671 cudbg->print = (cudbg_print_cb)printf; in cudbg_dump()
12674 device_printf(sc->dev, "%s: wr_flash %u, len %u, data %p.\n", in cudbg_dump()
12675 __func__, dump->wr_flash, dump->len, dump->data); in cudbg_dump()
12678 if (dump->wr_flash) in cudbg_dump()
12679 cudbg->use_flash = 1; in cudbg_dump()
12680 MPASS(sizeof(cudbg->dbg_bitmap) == sizeof(dump->bitmap)); in cudbg_dump()
12681 memcpy(cudbg->dbg_bitmap, dump->bitmap, sizeof(cudbg->dbg_bitmap)); in cudbg_dump()
12683 rc = cudbg_collect(handle, buf, &dump->len); in cudbg_dump()
12687 rc = copyout(buf, dump->data, dump->len); in cudbg_dump()
12703 r = &op->rule[0]; in free_offload_policy()
12704 for (i = 0; i < op->nrules; i++, r++) { in free_offload_policy()
12705 free(r->bpf_prog.bf_insns, M_CXGBE); in free_offload_policy()
12707 free(op->rule, M_CXGBE); in free_offload_policy()
12724 if (uop->nrules == 0) { in set_offload_policy()
12728 } else if (uop->nrules > 256) { /* arbitrary */ in set_offload_policy()
12734 op->nrules = uop->nrules; in set_offload_policy()
12735 len = op->nrules * sizeof(struct offload_rule); in set_offload_policy()
12736 op->rule = malloc(len, M_CXGBE, M_ZERO | M_WAITOK); in set_offload_policy()
12737 rc = copyin(uop->rule, op->rule, len); in set_offload_policy()
12739 free(op->rule, M_CXGBE); in set_offload_policy()
12744 r = &op->rule[0]; in set_offload_policy()
12745 for (i = 0; i < op->nrules; i++, r++) { in set_offload_policy()
12748 if (r->open_type != OPEN_TYPE_LISTEN && in set_offload_policy()
12749 r->open_type != OPEN_TYPE_ACTIVE && in set_offload_policy()
12750 r->open_type != OPEN_TYPE_PASSIVE && in set_offload_policy()
12751 r->open_type != OPEN_TYPE_DONTCARE) { in set_offload_policy()
12758 op->nrules = i; in set_offload_policy()
12764 s = &r->settings; in set_offload_policy()
12765 if ((s->offload != 0 && s->offload != 1) || in set_offload_policy()
12766 s->cong_algo < -1 || s->cong_algo > CONG_ALG_HIGHSPEED || in set_offload_policy()
12767 s->sched_class < -1 || in set_offload_policy()
12768 s->sched_class >= sc->params.nsched_cls) { in set_offload_policy()
12773 bf = &r->bpf_prog; in set_offload_policy()
12774 u = bf->bf_insns; /* userspace ptr */ in set_offload_policy()
12775 bf->bf_insns = NULL; in set_offload_policy()
12776 if (bf->bf_len == 0) { in set_offload_policy()
12780 len = bf->bf_len * sizeof(*bf->bf_insns); in set_offload_policy()
12781 bf->bf_insns = malloc(len, M_CXGBE, M_ZERO | M_WAITOK); in set_offload_policy()
12782 rc = copyin(u, bf->bf_insns, len); in set_offload_policy()
12786 if (!bpf_validate(bf->bf_insns, bf->bf_len)) { in set_offload_policy()
12792 rw_wlock(&sc->policy_lock); in set_offload_policy()
12793 old = sc->policy; in set_offload_policy()
12794 sc->policy = op; in set_offload_policy()
12795 rw_wunlock(&sc->policy_lock); in set_offload_policy()
12810 mtx_lock(&sc->reg_lock); in read_card_mem()
12814 rc = validate_mem_range(sc, mr->addr, mr->len); in read_card_mem()
12815 mtx_unlock(&sc->reg_lock); in read_card_mem()
12819 buf = malloc(min(mr->len, MAX_READ_BUF_SIZE), M_CXGBE, M_WAITOK); in read_card_mem()
12820 addr = mr->addr; in read_card_mem()
12821 remaining = mr->len; in read_card_mem()
12822 dst = (void *)mr->data; in read_card_mem()
12826 mtx_lock(&sc->reg_lock); in read_card_mem()
12831 mtx_unlock(&sc->reg_lock); in read_card_mem()
12840 remaining -= n; in read_card_mem()
12854 if (i2cd->len == 0 || i2cd->port_id >= sc->params.nports) in read_i2c()
12857 if (i2cd->len > sizeof(i2cd->data)) in read_i2c()
12866 rc = -t4_i2c_rd(sc, sc->mbox, i2cd->port_id, i2cd->dev_addr, in read_i2c()
12867 i2cd->offset, i2cd->len, &i2cd->data[0]); in read_i2c()
12889 if (port_id >= sc->params.nports) in clear_stats()
12891 pi = sc->port[port_id]; in clear_stats()
12895 mtx_lock(&sc->reg_lock); in clear_stats()
12898 t4_clr_port_stats(sc, pi->hw_port); in clear_stats()
12900 if (pi->fcs_reg != -1) in clear_stats()
12901 pi->fcs_base = t4_read_reg64(sc, in clear_stats()
12902 t4_port_reg(sc, pi->tx_chan, pi->fcs_reg)); in clear_stats()
12904 pi->stats.rx_fcs_err = 0; in clear_stats()
12907 if (vi->flags & VI_INIT_DONE) in clear_stats()
12908 t4_clr_vi_stats(sc, vi->vin); in clear_stats()
12910 chan_map = pi->rx_e_chan_map; in clear_stats()
12913 i = ffs(chan_map) - 1; in clear_stats()
12919 mtx_unlock(&sc->reg_lock); in clear_stats()
12920 pi->tx_parse_error = 0; in clear_stats()
12921 pi->tnl_cong_drops = 0; in clear_stats()
12928 if (vi->flags & VI_INIT_DONE) { in clear_stats()
12932 rxq->lro.lro_queued = 0; in clear_stats()
12933 rxq->lro.lro_flushed = 0; in clear_stats()
12935 rxq->rxcsum = 0; in clear_stats()
12936 rxq->vlan_extraction = 0; in clear_stats()
12937 rxq->vxlan_rxcsum = 0; in clear_stats()
12939 rxq->fl.cl_allocated = 0; in clear_stats()
12940 rxq->fl.cl_recycled = 0; in clear_stats()
12941 rxq->fl.cl_fast_recycled = 0; in clear_stats()
12945 txq->txcsum = 0; in clear_stats()
12946 txq->tso_wrs = 0; in clear_stats()
12947 txq->vlan_insertion = 0; in clear_stats()
12948 txq->imm_wrs = 0; in clear_stats()
12949 txq->sgl_wrs = 0; in clear_stats()
12950 txq->txpkt_wrs = 0; in clear_stats()
12951 txq->txpkts0_wrs = 0; in clear_stats()
12952 txq->txpkts1_wrs = 0; in clear_stats()
12953 txq->txpkts0_pkts = 0; in clear_stats()
12954 txq->txpkts1_pkts = 0; in clear_stats()
12955 txq->txpkts_flush = 0; in clear_stats()
12956 txq->raw_wrs = 0; in clear_stats()
12957 txq->vxlan_tso_wrs = 0; in clear_stats()
12958 txq->vxlan_txcsum = 0; in clear_stats()
12959 txq->kern_tls_records = 0; in clear_stats()
12960 txq->kern_tls_short = 0; in clear_stats()
12961 txq->kern_tls_partial = 0; in clear_stats()
12962 txq->kern_tls_full = 0; in clear_stats()
12963 txq->kern_tls_octets = 0; in clear_stats()
12964 txq->kern_tls_waste = 0; in clear_stats()
12965 txq->kern_tls_header = 0; in clear_stats()
12966 txq->kern_tls_fin_short = 0; in clear_stats()
12967 txq->kern_tls_cbc = 0; in clear_stats()
12968 txq->kern_tls_gcm = 0; in clear_stats()
12970 txq->kern_tls_options = 0; in clear_stats()
12971 txq->kern_tls_fin = 0; in clear_stats()
12973 txq->kern_tls_ghash_received = 0; in clear_stats()
12974 txq->kern_tls_ghash_requested = 0; in clear_stats()
12975 txq->kern_tls_lso = 0; in clear_stats()
12976 txq->kern_tls_partial_ghash = 0; in clear_stats()
12977 txq->kern_tls_splitmode = 0; in clear_stats()
12978 txq->kern_tls_trailer = 0; in clear_stats()
12980 mp_ring_reset_stats(txq->r); in clear_stats()
12985 ofld_txq->wrq.tx_wrs_direct = 0; in clear_stats()
12986 ofld_txq->wrq.tx_wrs_copied = 0; in clear_stats()
12987 counter_u64_zero(ofld_txq->tx_iscsi_pdus); in clear_stats()
12988 counter_u64_zero(ofld_txq->tx_iscsi_octets); in clear_stats()
12989 counter_u64_zero(ofld_txq->tx_iscsi_iso_wrs); in clear_stats()
12990 counter_u64_zero(ofld_txq->tx_nvme_pdus); in clear_stats()
12991 counter_u64_zero(ofld_txq->tx_nvme_octets); in clear_stats()
12992 counter_u64_zero(ofld_txq->tx_nvme_iso_wrs); in clear_stats()
12993 counter_u64_zero(ofld_txq->tx_aio_jobs); in clear_stats()
12994 counter_u64_zero(ofld_txq->tx_aio_octets); in clear_stats()
12995 counter_u64_zero(ofld_txq->tx_toe_tls_records); in clear_stats()
12996 counter_u64_zero(ofld_txq->tx_toe_tls_octets); in clear_stats()
13001 ofld_rxq->fl.cl_allocated = 0; in clear_stats()
13002 ofld_rxq->fl.cl_recycled = 0; in clear_stats()
13003 ofld_rxq->fl.cl_fast_recycled = 0; in clear_stats()
13005 ofld_rxq->rx_iscsi_ddp_setup_ok); in clear_stats()
13007 ofld_rxq->rx_iscsi_ddp_setup_error); in clear_stats()
13008 ofld_rxq->rx_iscsi_ddp_pdus = 0; in clear_stats()
13009 ofld_rxq->rx_iscsi_ddp_octets = 0; in clear_stats()
13010 ofld_rxq->rx_iscsi_fl_pdus = 0; in clear_stats()
13011 ofld_rxq->rx_iscsi_fl_octets = 0; in clear_stats()
13013 ofld_rxq->rx_nvme_ddp_setup_ok); in clear_stats()
13015 ofld_rxq->rx_nvme_ddp_setup_no_stag); in clear_stats()
13017 ofld_rxq->rx_nvme_ddp_setup_error); in clear_stats()
13018 counter_u64_zero(ofld_rxq->rx_nvme_ddp_pdus); in clear_stats()
13019 counter_u64_zero(ofld_rxq->rx_nvme_ddp_octets); in clear_stats()
13020 counter_u64_zero(ofld_rxq->rx_nvme_fl_pdus); in clear_stats()
13021 counter_u64_zero(ofld_rxq->rx_nvme_fl_octets); in clear_stats()
13023 ofld_rxq->rx_nvme_invalid_headers); in clear_stats()
13025 ofld_rxq->rx_nvme_header_digest_errors); in clear_stats()
13027 ofld_rxq->rx_nvme_data_digest_errors); in clear_stats()
13028 ofld_rxq->rx_aio_ddp_jobs = 0; in clear_stats()
13029 ofld_rxq->rx_aio_ddp_octets = 0; in clear_stats()
13030 ofld_rxq->rx_toe_tls_records = 0; in clear_stats()
13031 ofld_rxq->rx_toe_tls_octets = 0; in clear_stats()
13032 ofld_rxq->rx_toe_ddp_octets = 0; in clear_stats()
13033 counter_u64_zero(ofld_rxq->ddp_buffer_alloc); in clear_stats()
13034 counter_u64_zero(ofld_rxq->ddp_buffer_reuse); in clear_stats()
13035 counter_u64_zero(ofld_rxq->ddp_buffer_free); in clear_stats()
13040 wrq = &sc->sge.ctrlq[pi->port_id]; in clear_stats()
13041 wrq->tx_wrs_direct = 0; in clear_stats()
13042 wrq->tx_wrs_copied = 0; in clear_stats()
13056 bcopy(&ca->addr[0], &in6.s6_addr[0], sizeof(in6.s6_addr)); in hold_clip_addr()
13072 bcopy(&ca->addr[0], &in6.s6_addr[0], sizeof(in6.s6_addr)); in release_clip_addr()
13084 return (pci_find_cap(sc->dev, cap, &i) == 0 ? i : 0); in t4_os_find_pci_capability()
13090 struct adapter *sc = pi->adapter; in t4_os_portmod_changed()
13098 KASSERT((pi->flags & FIXED_IFMEDIA) == 0, in t4_os_portmod_changed()
13099 ("%s: port_type %u", __func__, pi->port_type)); in t4_os_portmod_changed()
13101 vi = &pi->vi[0]; in t4_os_portmod_changed()
13105 if (pi->mod_type != FW_PORT_MOD_TYPE_NONE) { in t4_os_portmod_changed()
13113 ifp = vi->ifp; in t4_os_portmod_changed()
13114 if (pi->mod_type == FW_PORT_MOD_TYPE_NONE) in t4_os_portmod_changed()
13116 else if (pi->mod_type == FW_PORT_MOD_TYPE_UNKNOWN) in t4_os_portmod_changed()
13118 else if (pi->mod_type == FW_PORT_MOD_TYPE_NOTSUPPORTED) in t4_os_portmod_changed()
13120 else if (pi->mod_type > 0 && pi->mod_type < nitems(mod_str)) { in t4_os_portmod_changed()
13122 port_top_speed(pi), mod_str[pi->mod_type]); in t4_os_portmod_changed()
13125 pi->mod_type); in t4_os_portmod_changed()
13134 struct link_config *lc = &pi->link_cfg; in t4_os_link_changed()
13135 struct adapter *sc = pi->adapter; in t4_os_link_changed()
13141 if (lc->link_ok) { in t4_os_link_changed()
13142 if (lc->speed > 25000 || in t4_os_link_changed()
13143 (lc->speed == 25000 && lc->fec == FEC_RS)) in t4_os_link_changed()
13144 pi->fcs_reg = A_MAC_PORT_AFRAMECHECKSEQUENCEERRORS; in t4_os_link_changed()
13146 pi->fcs_reg = A_MAC_PORT_MTIP_1G10G_RX_CRCERRORS; in t4_os_link_changed()
13147 pi->fcs_base = t4_read_reg64(sc, in t4_os_link_changed()
13148 t4_port_reg(sc, pi->tx_chan, pi->fcs_reg)); in t4_os_link_changed()
13149 pi->stats.rx_fcs_err = 0; in t4_os_link_changed()
13151 pi->fcs_reg = -1; in t4_os_link_changed()
13154 MPASS(pi->fcs_reg != -1); in t4_os_link_changed()
13155 MPASS(pi->fcs_base == 0); in t4_os_link_changed()
13159 ifp = vi->ifp; in t4_os_link_changed()
13163 if (lc->link_ok) { in t4_os_link_changed()
13164 if_setbaudrate(ifp, IF_Mbps(lc->speed)); in t4_os_link_changed()
13181 * in - the only guarantee is that sc->sc_lock is a valid lock. in t4_iterate()
13193 struct adapter *sc = dev->si_drv1; in t4_ioctl()
13203 if ((edata->addr & 0x3) != 0 || edata->addr >= sc->mmio_len) in t4_ioctl()
13206 mtx_lock(&sc->reg_lock); in t4_ioctl()
13209 else if (edata->size == 4) in t4_ioctl()
13210 edata->val = t4_read_reg(sc, edata->addr); in t4_ioctl()
13211 else if (edata->size == 8) in t4_ioctl()
13212 edata->val = t4_read_reg64(sc, edata->addr); in t4_ioctl()
13215 mtx_unlock(&sc->reg_lock); in t4_ioctl()
13222 if ((edata->addr & 0x3) != 0 || edata->addr >= sc->mmio_len) in t4_ioctl()
13225 mtx_lock(&sc->reg_lock); in t4_ioctl()
13228 else if (edata->size == 4) { in t4_ioctl()
13229 if (edata->val & 0xffffffff00000000) in t4_ioctl()
13231 t4_write_reg(sc, edata->addr, (uint32_t) edata->val); in t4_ioctl()
13232 } else if (edata->size == 8) in t4_ioctl()
13233 t4_write_reg64(sc, edata->addr, edata->val); in t4_ioctl()
13236 mtx_unlock(&sc->reg_lock); in t4_ioctl()
13245 if (regs->len < reglen) { in t4_ioctl()
13246 regs->len = reglen; /* hint to the caller */ in t4_ioctl()
13250 regs->len = reglen; in t4_ioctl()
13252 mtx_lock(&sc->reg_lock); in t4_ioctl()
13257 mtx_unlock(&sc->reg_lock); in t4_ioctl()
13259 rc = copyout(buf, regs->data, reglen); in t4_ioctl()
13284 rc = get_sge_context(sc, ctxt->mem_id, ctxt->cid, in t4_ioctl()
13285 sizeof(ctxt->data), &ctxt->data[0]); in t4_ioctl()
13336 rc = get_sge_context(sc, ctxt->mem_id, ctxt->cid, in t4_ioctl()
13337 sizeof(ctxt->data), &ctxt->data[0]); in t4_ioctl()
13352 struct port_info *pi = vi->pi; in toe_capability()
13353 struct adapter *sc = pi->adapter; in toe_capability()
13364 if (sc->flags & KERN_TLS_ON && is_t6(sc)) { in toe_capability()
13375 p = sc->port[i]; in toe_capability()
13377 if (if_getcapenable(v->ifp) & IFCAP_TXTLS) { in toe_capability()
13380 device_get_nameunit(v->dev)); in toe_capability()
13396 if ((if_getcapenable(vi->ifp) & IFCAP_TOE) != 0) { in toe_capability()
13406 if (!(vi->flags & VI_INIT_DONE) && ((rc = vi_init(vi)) != 0)) in toe_capability()
13408 if (!(pi->vi[0].flags & VI_INIT_DONE) && in toe_capability()
13409 ((rc = vi_init(&pi->vi[0])) != 0)) in toe_capability()
13412 if (isset(&sc->offload_map, pi->port_id)) { in toe_capability()
13414 MPASS(pi->uld_vis > 0); in toe_capability()
13415 pi->uld_vis++; in toe_capability()
13428 KASSERT(sc->tom_softc != NULL, in toe_capability()
13445 if (pi->uld_vis++ == 0) in toe_capability()
13446 setbit(&sc->offload_map, pi->port_id); in toe_capability()
13448 if ((if_getcapenable(vi->ifp) & IFCAP_TOE) == 0) { in toe_capability()
13452 MPASS(isset(&sc->offload_map, pi->port_id)); in toe_capability()
13453 MPASS(pi->uld_vis > 0); in toe_capability()
13454 if (--pi->uld_vis == 0) in toe_capability()
13455 clrbit(&sc->offload_map, pi->port_id); in toe_capability()
13506 if (!(sc->flags & FULL_INIT_DONE)) { in t4_activate_uld()
13516 rc = t4_uld_list[id]->uld_activate(sc); in t4_activate_uld()
13518 setbit(&sc->active_ulds, id); in t4_activate_uld()
13539 rc = t4_uld_list[id]->uld_deactivate(sc); in t4_deactivate_uld()
13541 clrbit(&sc->active_ulds, id); in t4_deactivate_uld()
13560 rc = t4_uld_list[i]->uld_deactivate(sc); in deactivate_all_uld()
13563 clrbit(&sc->active_ulds, i); in deactivate_all_uld()
13581 t4_uld_list[i]->uld_stop == NULL) in stop_all_uld()
13583 (void) t4_uld_list[i]->uld_stop(sc); in stop_all_uld()
13599 t4_uld_list[i]->uld_restart == NULL) in restart_all_uld()
13601 (void) t4_uld_list[i]->uld_restart(sc); in restart_all_uld()
13613 return (isset(&sc->active_ulds, id)); in uld_active()
13631 if (sc->flags & KERN_TLS_ON) in ktls_capability()
13633 if (sc->offload_map != 0) { in ktls_capability()
13662 nq = *t < 0 ? -*t : c; in calculate_nqueues()
13705 if (t4_toecaps_allowed == -1) in tweak_tunables()
13708 if (t4_toecaps_allowed == -1) in tweak_tunables()
13713 if (t4_rdmacaps_allowed == -1) { in tweak_tunables()
13718 if (t4_iscsicaps_allowed == -1) { in tweak_tunables()
13724 if (t4_nvmecaps_allowed == -1) in tweak_tunables()
13730 if (t4_pktc_idx_ofld < -1 || t4_pktc_idx_ofld >= SGE_NCOUNTERS) in tweak_tunables()
13733 if (t4_rdmacaps_allowed == -1) in tweak_tunables()
13736 if (t4_iscsicaps_allowed == -1) in tweak_tunables()
13739 if (t4_nvmecaps_allowed == -1) in tweak_tunables()
13753 if (t4_pktc_idx < -1 || t4_pktc_idx >= SGE_NCOUNTERS) in tweak_tunables()
13767 * Number of VIs to create per-port. The first VI is the "main" regular in tweak_tunables()
13801 base = sc->memwin[2].mw_base; in t4_dump_mem()
13807 pf = V_PFNUM(sc->pf); in t4_dump_mem()
13810 off = addr - win_pos; in t4_dump_mem()
13827 len -= sizeof(buf); in t4_dump_mem()
13848 struct devlog_params *dparams = &sc->params.devlog; in t4_dump_devlog()
13853 if (dparams->start == 0) { in t4_dump_devlog()
13858 nentries = dparams->size / sizeof(struct fw_devlog_e); in t4_dump_devlog()
13859 m = fwmtype_to_hwmtype(dparams->memtype); in t4_dump_devlog()
13862 first = -1; in t4_dump_devlog()
13864 rc = -t4_mem_read(sc, m, dparams->start + i * sizeof(e), in t4_dump_devlog()
13879 if (first == -1) in t4_dump_devlog()
13884 rc = -t4_mem_read(sc, m, dparams->start + i * sizeof(e), in t4_dump_devlog()
14040 t4_write_reg(sc, A_MPS_RX_VXLAN_TYPE, V_VXLAN(sc->vxlan_port) | in enable_vxlan_rx()
14043 pi = sc->port[i]; in enable_vxlan_rx()
14044 if (pi->vxlan_tcam_entry == true) in enable_vxlan_rx()
14046 rc = t4_alloc_raw_mac_filt(sc, pi->vi[0].viid, match_all_mac, in enable_vxlan_rx()
14047 match_all_mac, sc->rawf_base + pi->port_id, 1, pi->port_id, in enable_vxlan_rx()
14050 rc = -rc; in enable_vxlan_rx()
14051 CH_ERR(&pi->vi[0], in enable_vxlan_rx()
14054 MPASS(rc == sc->rawf_base + pi->port_id); in enable_vxlan_rx()
14055 pi->vxlan_tcam_entry = true; in enable_vxlan_rx()
14065 if (sc->nrawf == 0 || chip_id(sc) <= CHELSIO_T5) in t4_vxlan_start()
14070 if (sc->vxlan_refcount == 0) { in t4_vxlan_start()
14071 sc->vxlan_port = v->port; in t4_vxlan_start()
14072 sc->vxlan_refcount = 1; in t4_vxlan_start()
14075 } else if (sc->vxlan_port == v->port) { in t4_vxlan_start()
14076 sc->vxlan_refcount++; in t4_vxlan_start()
14080 sc->vxlan_port, v->port); in t4_vxlan_start()
14090 if (sc->nrawf == 0 || chip_id(sc) <= CHELSIO_T5) in t4_vxlan_stop()
14100 if (sc->vxlan_port != v->port) in t4_vxlan_stop()
14102 if (sc->vxlan_refcount == 0) { in t4_vxlan_stop()
14104 "ignoring attempt to stop it again.\n", sc->vxlan_port); in t4_vxlan_stop()
14105 } else if (--sc->vxlan_refcount == 0 && !hw_off_limits(sc)) in t4_vxlan_stop()
14199 if (--loaded == 0) { in mod_event()