Lines Matching +full:pa +full:- +full:stats

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
272 * Each tunable is set to a default value here if it's known at compile-time.
273 * Otherwise it is set to -n as an indication to tweak_tunables() that it should
290 int t4_ntxq = -NTXQ;
296 int t4_nrxq = -NRXQ;
302 static int t4_ntxq_vi = -NTXQ_VI;
307 static int t4_nrxq_vi = -NRXQ_VI;
313 0, "Reserve TX queue 0 of each VI for non-flowid packets");
317 static int t4_nofldtxq = -NOFLDTXQ;
322 static int t4_nofldtxq_vi = -NOFLDTXQ_VI;
329 static int t4_nofldrxq = -NOFLDRXQ;
334 static int t4_nofldrxq_vi = -NOFLDRXQ_VI;
343 #define PKTC_IDX_OFLD (-1)
348 /* 0 means chip/fw default, non-zero number is value in microseconds */
353 /* 0 means chip/fw default, non-zero number is value in microseconds */
358 /* 0 means chip/fw default, non-zero number is # of keepalives before abort */
363 /* 0 means chip/fw default, non-zero number is value in microseconds */
368 /* 0 means chip/fw default, non-zero number is value in microseconds */
373 /* 0 means chip/fw default, non-zero number is # of rexmt before abort */
378 /* -1 means chip/fw default, other values are raw backoff values to use */
380 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
436 static int t4_nnmtxq = -NNMTXQ;
441 static int t4_nnmrxq = -NNMRXQ;
446 static int t4_nnmtxq_vi = -NNMTXQ_VI;
451 static int t4_nnmrxq_vi = -NNMRXQ_VI;
465 #define PKTC_IDX (-1)
483 * Interrupt types allowed (bits 0, 1, 2 = INTx, MSI, MSI-X respectively).
487 0, "Interrupt types allowed (bit 0 = INTx, 1 = MSI, 2 = MSI-X)");
493 #define BUILTIN_CF "built-in"
517 * -1 to run with the firmware default. Same as FEC_AUTO (bit 5)
520 static int t4_fec = -1;
528 * -1 to set FORCE_FEC iff requested_fec != AUTO. Multiple FEC bits are okay.
535 static int t4_force_fec = -1;
541 * -1 to run with the firmware default.
545 static int t4_autoneg = -1;
550 * Firmware auto-install by driver during attach (0, 1, 2 = prohibited, allowed,
551 * encouraged respectively). '-n' is the same as 'n' except the firmware
556 "Firmware auto-install (0 = prohibited, 1 = allowed, 2 = encouraged)");
585 static int t4_toecaps_allowed = -1;
589 static int t4_rdmacaps_allowed = -1;
593 static int t4_cryptocaps_allowed = -1;
597 static int t4_iscsicaps_allowed = -1;
620 * -1: driver should figure out a good value.
625 static int pcie_relaxed_ordering = -1;
647 * Set to non-zero to enable the attack filter. A packet that matches any of
731 uint16_t intr_type; /* INTx, MSI, or MSI-X */
898 {0x4400, "Chelsio T440-dbg"},
899 {0x4401, "Chelsio T420-CR"},
900 {0x4402, "Chelsio T422-CR"},
901 {0x4403, "Chelsio T440-CR"},
902 {0x4404, "Chelsio T420-BCH"},
903 {0x4405, "Chelsio T440-BCH"},
904 {0x4406, "Chelsio T440-CH"},
905 {0x4407, "Chelsio T420-SO"},
906 {0x4408, "Chelsio T420-CX"},
907 {0x4409, "Chelsio T420-BT"},
908 {0x440a, "Chelsio T404-BT"},
909 {0x440e, "Chelsio T440-LP-CR"},
912 {0x5400, "Chelsio T580-dbg"},
913 {0x5401, "Chelsio T520-CR"}, /* 2 x 10G */
914 {0x5402, "Chelsio T522-CR"}, /* 2 x 10G, 2 X 1G */
915 {0x5403, "Chelsio T540-CR"}, /* 4 x 10G */
916 {0x5407, "Chelsio T520-SO"}, /* 2 x 10G, nomem */
917 {0x5409, "Chelsio T520-BT"}, /* 2 x 10GBaseT */
918 {0x540a, "Chelsio T504-BT"}, /* 4 x 1G */
919 {0x540d, "Chelsio T580-CR"}, /* 2 x 40G */
920 {0x540e, "Chelsio T540-LP-CR"}, /* 4 x 10G */
921 {0x5410, "Chelsio T580-LP-CR"}, /* 2 x 40G */
922 {0x5411, "Chelsio T520-LL-CR"}, /* 2 x 10G */
923 {0x5412, "Chelsio T560-CR"}, /* 1 x 40G, 2 x 10G */
924 {0x5414, "Chelsio T580-LP-SO-CR"}, /* 2 x 40G, nomem */
925 {0x5415, "Chelsio T502-BT"}, /* 2 x 1G */
926 {0x5418, "Chelsio T540-BT"}, /* 4 x 10GBaseT */
927 {0x5419, "Chelsio T540-LP-BT"}, /* 4 x 10GBaseT */
928 {0x541a, "Chelsio T540-SO-BT"}, /* 4 x 10GBaseT, nomem */
929 {0x541b, "Chelsio T540-SO-CR"}, /* 4 x 10G, nomem */
932 {0x5483, "Custom T540-CR"},
933 {0x5484, "Custom T540-BT"},
936 {0x6400, "Chelsio T6-DBG-25"}, /* 2 x 10/25G, debug */
937 {0x6401, "Chelsio T6225-CR"}, /* 2 x 10/25G */
938 {0x6402, "Chelsio T6225-SO-CR"}, /* 2 x 10/25G, nomem */
939 {0x6403, "Chelsio T6425-CR"}, /* 4 x 10/25G */
940 {0x6404, "Chelsio T6425-SO-CR"}, /* 4 x 10/25G, nomem */
941 {0x6405, "Chelsio T6225-SO-OCP3"}, /* 2 x 10/25G, nomem */
942 {0x6406, "Chelsio T6225-OCP3"}, /* 2 x 10/25G */
943 {0x6407, "Chelsio T62100-LP-CR"}, /* 2 x 40/50/100G */
944 {0x6408, "Chelsio T62100-SO-CR"}, /* 2 x 40/50/100G, nomem */
945 {0x6409, "Chelsio T6210-BT"}, /* 2 x 10GBASE-T */
946 {0x640d, "Chelsio T62100-CR"}, /* 2 x 40/50/100G */
947 {0x6410, "Chelsio T6-DBG-100"}, /* 2 x 40/50/100G, debug */
948 {0x6411, "Chelsio T6225-LL-CR"}, /* 2 x 10/25G */
949 {0x6414, "Chelsio T62100-SO-OCP3"}, /* 2 x 40/50/100G, nomem */
950 {0x6415, "Chelsio T6201-BT"}, /* 2 x 1000BASE-T */
953 {0x6480, "Custom T6225-CR"},
954 {0x6481, "Custom T62100-CR"},
955 {0x6482, "Custom T6225-CR"},
956 {0x6483, "Custom T62100-CR"},
957 {0x6484, "Custom T64100-CR"},
958 {0x6485, "Custom T6240-SO"},
959 {0x6486, "Custom T6225-SO-CR"},
960 {0x6487, "Custom T6225-CR"},
1101 if (id >= CHELSIO_T4 && id - CHELSIO_T4 < nitems(devnames)) in t4_init_devnames()
1102 sc->names = &devnames[id - CHELSIO_T4]; in t4_init_devnames()
1104 device_printf(sc->dev, "chip id %d is not supported.\n", id); in t4_init_devnames()
1105 sc->names = NULL; in t4_init_devnames()
1117 parent = device_get_nameunit(sc->dev); in t4_ifnet_unit()
1118 name = sc->names->ifnet_name; in t4_ifnet_unit()
1121 value == pi->port_id) in t4_ifnet_unit()
1124 return (-1); in t4_ifnet_unit()
1142 cur = &sc->cal_info[sc->cal_current]; in t4_calibration()
1143 next_up = (sc->cal_current + 1) % CNT_CAL_INFO; in t4_calibration()
1144 nex = &sc->cal_info[next_up]; in t4_calibration()
1145 if (__predict_false(sc->cal_count == 0)) { in t4_calibration()
1147 cur->hw_cur = hw; in t4_calibration()
1148 cur->sbt_cur = sbt; in t4_calibration()
1149 sc->cal_count++; in t4_calibration()
1153 if (cur->hw_cur == hw) { in t4_calibration()
1155 sc->cal_count = 0; in t4_calibration()
1156 atomic_store_rel_int(&cur->gen, 0); in t4_calibration()
1160 seqc_write_begin(&nex->gen); in t4_calibration()
1161 nex->hw_prev = cur->hw_cur; in t4_calibration()
1162 nex->sbt_prev = cur->sbt_cur; in t4_calibration()
1163 nex->hw_cur = hw; in t4_calibration()
1164 nex->sbt_cur = sbt; in t4_calibration()
1165 seqc_write_end(&nex->gen); in t4_calibration()
1166 sc->cal_current = next_up; in t4_calibration()
1168 callout_reset_sbt_curcpu(&sc->cal_callout, SBT_1S, 0, t4_calibration, in t4_calibration()
1183 sc->cal_info[i].gen = 0; in t4_calibration_start()
1185 sc->cal_current = 0; in t4_calibration_start()
1186 sc->cal_count = 0; in t4_calibration_start()
1187 sc->cal_gen = 0; in t4_calibration_start()
1212 sc->dev = dev; in t4_attach()
1213 sysctl_ctx_init(&sc->ctx); in t4_attach()
1214 TUNABLE_INT_FETCH("hw.cxgbe.dflags", &sc->debug_flags); in t4_attach()
1224 sc->params.pci.mps = 128 << ((v & PCIEM_CTL_MAX_PAYLOAD) >> 5); in t4_attach()
1236 sc->sge_gts_reg = MYPF_REG(A_SGE_PF_GTS); in t4_attach()
1237 sc->sge_kdoorbell_reg = MYPF_REG(A_SGE_PF_KDOORBELL); in t4_attach()
1238 sc->traceq = -1; in t4_attach()
1239 mtx_init(&sc->ifp_lock, sc->ifp_lockname, 0, MTX_DEF); in t4_attach()
1240 snprintf(sc->ifp_lockname, sizeof(sc->ifp_lockname), "%s tracer", in t4_attach()
1243 snprintf(sc->lockname, sizeof(sc->lockname), "%s", in t4_attach()
1245 mtx_init(&sc->sc_lock, sc->lockname, 0, MTX_DEF); in t4_attach()
1248 mtx_init(&sc->sfl_lock, "starving freelists", 0, MTX_DEF); in t4_attach()
1249 TAILQ_INIT(&sc->sfl); in t4_attach()
1250 callout_init_mtx(&sc->sfl_callout, &sc->sfl_lock, 0); in t4_attach()
1252 mtx_init(&sc->reg_lock, "indirect register access", 0, MTX_DEF); in t4_attach()
1254 sc->policy = NULL; in t4_attach()
1255 rw_init(&sc->policy_lock, "connection offload policy"); in t4_attach()
1257 callout_init(&sc->ktls_tick, 1); in t4_attach()
1259 callout_init(&sc->cal_callout, 1); in t4_attach()
1261 refcount_init(&sc->vxlan_refcount, 0); in t4_attach()
1263 TASK_INIT(&sc->reset_task, 0, reset_adapter_task, sc); in t4_attach()
1264 TASK_INIT(&sc->fatal_error_task, 0, fatal_error_task, sc); in t4_attach()
1266 sc->ctrlq_oid = SYSCTL_ADD_NODE(&sc->ctx, in t4_attach()
1267 SYSCTL_CHILDREN(device_get_sysctl_tree(sc->dev)), OID_AUTO, "ctrlq", in t4_attach()
1269 sc->fwq_oid = SYSCTL_ADD_NODE(&sc->ctx, in t4_attach()
1270 SYSCTL_CHILDREN(device_get_sysctl_tree(sc->dev)), OID_AUTO, "fwq", in t4_attach()
1277 memset(sc->chan_map, 0xff, sizeof(sc->chan_map)); in t4_attach()
1281 rc = -t4_prep_adapter(sc, buf); in t4_attach()
1295 sc->pf = chip_id(sc) <= CHELSIO_T5 ? G_SOURCEPF(j) : G_T6_SOURCEPF(j); in t4_attach()
1296 sc->mbox = sc->pf; in t4_attach()
1299 if (sc->names == NULL) { in t4_attach()
1318 rc = make_dev_s(&mda, &sc->cdev, "%s", device_get_nameunit(dev)); in t4_attach()
1341 MPASS(sc->flags & FW_OK); in t4_attach()
1347 if (sc->flags & MASTER_PF) { in t4_attach()
1374 * First pass over all the ports - allocate VIs and initialize some in t4_attach()
1381 sc->port[i] = pi; in t4_attach()
1384 pi->adapter = sc; in t4_attach()
1385 pi->port_id = i; in t4_attach()
1388 * pi->nvi's final value is known. in t4_attach()
1390 pi->vi = malloc(sizeof(struct vi_info) * t4_num_vis, M_CXGBE, in t4_attach()
1397 rc = -t4_port_init(sc, sc->mbox, sc->pf, 0, i); in t4_attach()
1401 free(pi->vi, M_CXGBE); in t4_attach()
1403 sc->port[i] = NULL; in t4_attach()
1407 if (is_bt(pi->port_type)) in t4_attach()
1408 setbit(&sc->bt_map, pi->tx_chan); in t4_attach()
1410 MPASS(!isset(&sc->bt_map, pi->tx_chan)); in t4_attach()
1412 snprintf(pi->lockname, sizeof(pi->lockname), "%sp%d", in t4_attach()
1414 mtx_init(&pi->pi_lock, pi->lockname, 0, MTX_DEF); in t4_attach()
1415 sc->chan_map[pi->tx_chan] = i; in t4_attach()
1424 pi->fcs_reg = -1; in t4_attach()
1426 pi->fcs_reg = t4_port_reg(sc, pi->tx_chan, in t4_attach()
1429 pi->fcs_base = 0; in t4_attach()
1432 ifmedia_init(&pi->media, IFM_IMASK, cxgbe_media_change, in t4_attach()
1440 pi->flags |= FIXED_IFMEDIA; in t4_attach()
1443 pi->dev = device_add_child(dev, sc->names->ifnet_name, in t4_attach()
1445 if (pi->dev == NULL) { in t4_attach()
1451 pi->vi[0].dev = pi->dev; in t4_attach()
1452 device_set_softc(pi->dev, pi); in t4_attach()
1458 nports = sc->params.nports; in t4_attach()
1464 sc->intr_type = iaq.intr_type; in t4_attach()
1465 sc->intr_count = iaq.nirq; in t4_attach()
1467 s = &sc->sge; in t4_attach()
1468 s->nrxq = nports * iaq.nrxq; in t4_attach()
1469 s->ntxq = nports * iaq.ntxq; in t4_attach()
1471 s->nrxq += nports * (num_vis - 1) * iaq.nrxq_vi; in t4_attach()
1472 s->ntxq += nports * (num_vis - 1) * iaq.ntxq_vi; in t4_attach()
1474 s->neq = s->ntxq + s->nrxq; /* the free list in an rxq is an eq */ in t4_attach()
1475 s->neq += nports; /* ctrl queues: 1 per port */ in t4_attach()
1476 s->niq = s->nrxq + 1; /* 1 extra for firmware event queue */ in t4_attach()
1479 s->nofldtxq = nports * iaq.nofldtxq; in t4_attach()
1481 s->nofldtxq += nports * (num_vis - 1) * iaq.nofldtxq_vi; in t4_attach()
1482 s->neq += s->nofldtxq; in t4_attach()
1484 s->ofld_txq = malloc(s->nofldtxq * sizeof(struct sge_ofld_txq), in t4_attach()
1490 s->nofldrxq = nports * iaq.nofldrxq; in t4_attach()
1492 s->nofldrxq += nports * (num_vis - 1) * iaq.nofldrxq_vi; in t4_attach()
1493 s->neq += s->nofldrxq; /* free list */ in t4_attach()
1494 s->niq += s->nofldrxq; in t4_attach()
1496 s->ofld_rxq = malloc(s->nofldrxq * sizeof(struct sge_ofld_rxq), in t4_attach()
1501 s->nnmrxq = 0; in t4_attach()
1502 s->nnmtxq = 0; in t4_attach()
1504 s->nnmrxq += nports * iaq.nnmrxq; in t4_attach()
1505 s->nnmtxq += nports * iaq.nnmtxq; in t4_attach()
1508 s->nnmrxq += nports * (num_vis - 1) * iaq.nnmrxq_vi; in t4_attach()
1509 s->nnmtxq += nports * (num_vis - 1) * iaq.nnmtxq_vi; in t4_attach()
1511 s->neq += s->nnmtxq + s->nnmrxq; in t4_attach()
1512 s->niq += s->nnmrxq; in t4_attach()
1514 s->nm_rxq = malloc(s->nnmrxq * sizeof(struct sge_nm_rxq), in t4_attach()
1516 s->nm_txq = malloc(s->nnmtxq * sizeof(struct sge_nm_txq), in t4_attach()
1519 MPASS(s->niq <= s->iqmap_sz); in t4_attach()
1520 MPASS(s->neq <= s->eqmap_sz); in t4_attach()
1522 s->ctrlq = malloc(nports * sizeof(struct sge_wrq), M_CXGBE, in t4_attach()
1524 s->rxq = malloc(s->nrxq * sizeof(struct sge_rxq), M_CXGBE, in t4_attach()
1526 s->txq = malloc(s->ntxq * sizeof(struct sge_txq), M_CXGBE, in t4_attach()
1528 s->iqmap = malloc(s->iqmap_sz * sizeof(struct sge_iq *), M_CXGBE, in t4_attach()
1530 s->eqmap = malloc(s->eqmap_sz * sizeof(struct sge_eq *), M_CXGBE, in t4_attach()
1533 sc->irq = malloc(sc->intr_count * sizeof(struct irq), M_CXGBE, in t4_attach()
1546 if (sc->vres.key.size != 0) in t4_attach()
1547 sc->key_map = vmem_create("T4TLS key map", sc->vres.key.start, in t4_attach()
1548 sc->vres.key.size, 32, 0, M_FIRSTFIT | M_WAITOK); in t4_attach()
1565 struct port_info *pi = sc->port[i]; in t4_attach()
1571 pi->nvi = num_vis; in t4_attach()
1573 vi->pi = pi; in t4_attach()
1574 vi->adapter = sc; in t4_attach()
1575 vi->first_intr = -1; in t4_attach()
1576 vi->qsize_rxq = t4_qsize_rxq; in t4_attach()
1577 vi->qsize_txq = t4_qsize_txq; in t4_attach()
1579 vi->first_rxq = rqidx; in t4_attach()
1580 vi->first_txq = tqidx; in t4_attach()
1581 vi->tmr_idx = t4_tmr_idx; in t4_attach()
1582 vi->pktc_idx = t4_pktc_idx; in t4_attach()
1583 vi->nrxq = j == 0 ? iaq.nrxq : iaq.nrxq_vi; in t4_attach()
1584 vi->ntxq = j == 0 ? iaq.ntxq : iaq.ntxq_vi; in t4_attach()
1586 rqidx += vi->nrxq; in t4_attach()
1587 tqidx += vi->ntxq; in t4_attach()
1589 if (j == 0 && vi->ntxq > 1) in t4_attach()
1590 vi->rsrv_noflowq = t4_rsrv_noflowq ? 1 : 0; in t4_attach()
1592 vi->rsrv_noflowq = 0; in t4_attach()
1595 vi->first_ofld_txq = ofld_tqidx; in t4_attach()
1596 vi->nofldtxq = j == 0 ? iaq.nofldtxq : iaq.nofldtxq_vi; in t4_attach()
1597 ofld_tqidx += vi->nofldtxq; in t4_attach()
1600 vi->ofld_tmr_idx = t4_tmr_idx_ofld; in t4_attach()
1601 vi->ofld_pktc_idx = t4_pktc_idx_ofld; in t4_attach()
1602 vi->first_ofld_rxq = ofld_rqidx; in t4_attach()
1603 vi->nofldrxq = j == 0 ? iaq.nofldrxq : iaq.nofldrxq_vi; in t4_attach()
1605 ofld_rqidx += vi->nofldrxq; in t4_attach()
1608 vi->first_nm_rxq = nm_rqidx; in t4_attach()
1609 vi->first_nm_txq = nm_tqidx; in t4_attach()
1611 vi->nnmrxq = iaq.nnmrxq; in t4_attach()
1612 vi->nnmtxq = iaq.nnmtxq; in t4_attach()
1614 vi->nnmrxq = iaq.nnmrxq_vi; in t4_attach()
1615 vi->nnmtxq = iaq.nnmtxq_vi; in t4_attach()
1617 nm_rqidx += vi->nnmrxq; in t4_attach()
1618 nm_tqidx += vi->nnmtxq; in t4_attach()
1633 * Ensure thread-safe mailbox access (in debug builds). in t4_attach()
1639 sc->flags |= CHK_MBOX_ACCESS; in t4_attach()
1646 sc->params.pci.speed, sc->params.pci.width, sc->params.nports, in t4_attach()
1647 sc->intr_count, sc->intr_type == INTR_MSIX ? "MSI-X" : in t4_attach()
1648 (sc->intr_type == INTR_MSI ? "MSI" : "INTx"), in t4_attach()
1649 sc->intr_count > 1 ? "s" : "", sc->sge.neq, sc->sge.niq); in t4_attach()
1656 if (rc != 0 && sc->cdev) { in t4_attach()
1680 pi = sc->port[i]; in t4_child_location()
1681 if (pi != NULL && pi->dev == dev) { in t4_child_location()
1682 sbuf_printf(sb, "port=%d", pi->port_id); in t4_child_location()
1695 if (sc->flags & FW_OK) in t4_ready()
1709 pi = sc->port[port]; in t4_read_port_device()
1710 if (pi == NULL || pi->dev == NULL) in t4_read_port_device()
1712 *child = pi->dev; in t4_read_port_device()
1776 if (sc->cdev) { in t4_detach_common()
1777 destroy_dev(sc->cdev); in t4_detach_common()
1778 sc->cdev = NULL; in t4_detach_common()
1785 sc->flags &= ~CHK_MBOX_ACCESS; in t4_detach_common()
1786 if (sc->flags & FULL_INIT_DONE) { in t4_detach_common()
1787 if (!(sc->flags & IS_VF)) in t4_detach_common()
1800 for (i = 0; i < sc->intr_count; i++) in t4_detach_common()
1801 t4_free_irq(sc, &sc->irq[i]); in t4_detach_common()
1803 if ((sc->flags & (IS_VF | FW_OK)) == FW_OK) in t4_detach_common()
1807 pi = sc->port[i]; in t4_detach_common()
1809 t4_free_vi(sc, sc->mbox, sc->pf, 0, pi->vi[0].viid); in t4_detach_common()
1811 mtx_destroy(&pi->pi_lock); in t4_detach_common()
1812 free(pi->vi, M_CXGBE); in t4_detach_common()
1816 callout_stop(&sc->cal_callout); in t4_detach_common()
1817 callout_drain(&sc->cal_callout); in t4_detach_common()
1819 sysctl_ctx_free(&sc->ctx); in t4_detach_common()
1822 if ((sc->flags & (IS_VF | FW_OK)) == FW_OK) in t4_detach_common()
1823 t4_fw_bye(sc, sc->mbox); in t4_detach_common()
1825 if (sc->intr_type == INTR_MSI || sc->intr_type == INTR_MSIX) in t4_detach_common()
1828 if (sc->regs_res) in t4_detach_common()
1829 bus_release_resource(dev, SYS_RES_MEMORY, sc->regs_rid, in t4_detach_common()
1830 sc->regs_res); in t4_detach_common()
1832 if (sc->udbs_res) in t4_detach_common()
1833 bus_release_resource(dev, SYS_RES_MEMORY, sc->udbs_rid, in t4_detach_common()
1834 sc->udbs_res); in t4_detach_common()
1836 if (sc->msix_res) in t4_detach_common()
1837 bus_release_resource(dev, SYS_RES_MEMORY, sc->msix_rid, in t4_detach_common()
1838 sc->msix_res); in t4_detach_common()
1840 if (sc->l2t) in t4_detach_common()
1842 if (sc->smt) in t4_detach_common()
1843 t4_free_smt(sc->smt); in t4_detach_common()
1848 if (sc->key_map) in t4_detach_common()
1849 vmem_destroy(sc->key_map); in t4_detach_common()
1855 free(sc->sge.ofld_txq, M_CXGBE); in t4_detach_common()
1858 free(sc->sge.ofld_rxq, M_CXGBE); in t4_detach_common()
1861 free(sc->sge.nm_rxq, M_CXGBE); in t4_detach_common()
1862 free(sc->sge.nm_txq, M_CXGBE); in t4_detach_common()
1864 free(sc->irq, M_CXGBE); in t4_detach_common()
1865 free(sc->sge.rxq, M_CXGBE); in t4_detach_common()
1866 free(sc->sge.txq, M_CXGBE); in t4_detach_common()
1867 free(sc->sge.ctrlq, M_CXGBE); in t4_detach_common()
1868 free(sc->sge.iqmap, M_CXGBE); in t4_detach_common()
1869 free(sc->sge.eqmap, M_CXGBE); in t4_detach_common()
1870 free(sc->tids.ftid_tab, M_CXGBE); in t4_detach_common()
1871 free(sc->tids.hpftid_tab, M_CXGBE); in t4_detach_common()
1872 free_hftid_hash(&sc->tids); in t4_detach_common()
1873 free(sc->tids.tid_tab, M_CXGBE); in t4_detach_common()
1876 callout_drain(&sc->ktls_tick); in t4_detach_common()
1877 callout_drain(&sc->sfl_callout); in t4_detach_common()
1878 if (mtx_initialized(&sc->tids.ftid_lock)) { in t4_detach_common()
1879 mtx_destroy(&sc->tids.ftid_lock); in t4_detach_common()
1880 cv_destroy(&sc->tids.ftid_cv); in t4_detach_common()
1882 if (mtx_initialized(&sc->tids.atid_lock)) in t4_detach_common()
1883 mtx_destroy(&sc->tids.atid_lock); in t4_detach_common()
1884 if (mtx_initialized(&sc->ifp_lock)) in t4_detach_common()
1885 mtx_destroy(&sc->ifp_lock); in t4_detach_common()
1887 if (rw_initialized(&sc->policy_lock)) { in t4_detach_common()
1888 rw_destroy(&sc->policy_lock); in t4_detach_common()
1890 if (sc->policy != NULL) in t4_detach_common()
1891 free_offload_policy(sc->policy); in t4_detach_common()
1896 struct memwin *mw = &sc->memwin[i]; in t4_detach_common()
1898 if (rw_initialized(&mw->mw_lock)) in t4_detach_common()
1899 rw_destroy(&mw->mw_lock); in t4_detach_common()
1902 mtx_destroy(&sc->sfl_lock); in t4_detach_common()
1903 mtx_destroy(&sc->reg_lock); in t4_detach_common()
1904 mtx_destroy(&sc->sc_lock); in t4_detach_common()
1917 if (atomic_testandset_int(&sc->error_flags, ilog2(ADAP_STOPPED))) { in stop_adapter()
1919 __func__, curthread, sc->flags, sc->error_flags); in stop_adapter()
1923 sc->flags, sc->error_flags); in stop_adapter()
1926 pi = sc->port[i]; in stop_adapter()
1928 if (pi->up_vis > 0 && pi->link_cfg.link_ok) { in stop_adapter()
1935 pi->link_cfg.link_ok = false; in stop_adapter()
1949 if (!atomic_testandclear_int(&sc->error_flags, ilog2(ADAP_STOPPED))) { in restart_adapter()
1951 __func__, curthread, sc->flags, sc->error_flags); in restart_adapter()
1955 sc->flags, sc->error_flags); in restart_adapter()
1958 MPASS((sc->flags & FW_OK) == 0); in restart_adapter()
1959 MPASS((sc->flags & MASTER_PF) == 0); in restart_adapter()
1960 MPASS(sc->reset_thread == NULL); in restart_adapter()
1967 sc->reset_thread = curthread; in restart_adapter()
1971 sc->reset_thread = NULL; in restart_adapter()
1972 atomic_set_int(&sc->error_flags, ADAP_STOPPED); in restart_adapter()
1975 atomic_clear_int(&sc->error_flags, ADAP_FATAL_ERR); in restart_adapter()
1976 atomic_add_int(&sc->incarnation, 1); in restart_adapter()
1977 atomic_add_int(&sc->num_resets, 1); in restart_adapter()
1988 MPASS(sc->reset_thread == curthread); in set_adapter_hwstatus()
1989 mtx_lock(&sc->reg_lock); in set_adapter_hwstatus()
1990 atomic_clear_int(&sc->error_flags, HW_OFF_LIMITS); in set_adapter_hwstatus()
1991 mtx_unlock(&sc->reg_lock); in set_adapter_hwstatus()
1995 mtx_lock(&sc->reg_lock); in set_adapter_hwstatus()
1996 atomic_set_int(&sc->error_flags, HW_OFF_LIMITS); in set_adapter_hwstatus()
1997 mtx_unlock(&sc->reg_lock); in set_adapter_hwstatus()
1998 sc->flags &= ~(FW_OK | MASTER_PF); in set_adapter_hwstatus()
1999 sc->reset_thread = NULL; in set_adapter_hwstatus()
2037 pi = sc->port[i]; in stop_lld()
2038 pi->vxlan_tcam_entry = false; in stop_lld()
2040 vi->xact_addr_filt = -1; in stop_lld()
2041 mtx_lock(&vi->tick_mtx); in stop_lld()
2042 vi->flags |= VI_SKIP_STATS; in stop_lld()
2043 mtx_unlock(&vi->tick_mtx); in stop_lld()
2044 if (!(vi->flags & VI_INIT_DONE)) in stop_lld()
2047 ifp = vi->ifp; in stop_lld()
2049 mtx_lock(&vi->tick_mtx); in stop_lld()
2050 callout_stop(&vi->tick); in stop_lld()
2051 mtx_unlock(&vi->tick_mtx); in stop_lld()
2052 callout_drain(&vi->tick); in stop_lld()
2060 txq->eq.flags &= ~(EQ_ENABLED | EQ_HW_ALLOCATED); in stop_lld()
2065 TXQ_LOCK(&ofld_txq->wrq); in stop_lld()
2066 ofld_txq->wrq.eq.flags &= ~EQ_HW_ALLOCATED; in stop_lld()
2067 TXQ_UNLOCK(&ofld_txq->wrq); in stop_lld()
2071 rxq->iq.flags &= ~IQ_HW_ALLOCATED; in stop_lld()
2075 ofld_rxq->iq.flags &= ~IQ_HW_ALLOCATED; in stop_lld()
2082 if (sc->flags & FULL_INIT_DONE) { in stop_lld()
2084 wrq = &sc->sge.ctrlq[i]; in stop_lld()
2086 wrq->eq.flags &= ~EQ_HW_ALLOCATED; in stop_lld()
2091 if (pi->flags & HAS_TRACEQ) { in stop_lld()
2092 pi->flags &= ~HAS_TRACEQ; in stop_lld()
2093 sc->traceq = -1; in stop_lld()
2094 sc->tracer_valid = 0; in stop_lld()
2095 sc->tracer_enabled = 0; in stop_lld()
2098 if (sc->flags & FULL_INIT_DONE) { in stop_lld()
2100 sc->sge.fwq.flags &= ~IQ_HW_ALLOCATED; in stop_lld()
2101 quiesce_iq_fl(sc, &sc->sge.fwq, NULL); in stop_lld()
2105 callout_stop(&sc->cal_callout); in stop_lld()
2106 callout_drain(&sc->cal_callout); in stop_lld()
2179 o->flags = sc->flags; in save_caps_and_params()
2181 o->nbmcaps = sc->nbmcaps; in save_caps_and_params()
2182 o->linkcaps = sc->linkcaps; in save_caps_and_params()
2183 o->switchcaps = sc->switchcaps; in save_caps_and_params()
2184 o->niccaps = sc->niccaps; in save_caps_and_params()
2185 o->toecaps = sc->toecaps; in save_caps_and_params()
2186 o->rdmacaps = sc->rdmacaps; in save_caps_and_params()
2187 o->cryptocaps = sc->cryptocaps; in save_caps_and_params()
2188 o->iscsicaps = sc->iscsicaps; in save_caps_and_params()
2189 o->fcoecaps = sc->fcoecaps; in save_caps_and_params()
2191 o->cfcsum = sc->cfcsum; in save_caps_and_params()
2192 MPASS(sizeof(o->cfg_file) == sizeof(sc->cfg_file)); in save_caps_and_params()
2193 memcpy(o->cfg_file, sc->cfg_file, sizeof(o->cfg_file)); in save_caps_and_params()
2195 o->params = sc->params; in save_caps_and_params()
2196 o->vres = sc->vres; in save_caps_and_params()
2197 o->tids = sc->tids; in save_caps_and_params()
2198 o->sge = sc->sge; in save_caps_and_params()
2200 o->rawf_base = sc->rawf_base; in save_caps_and_params()
2201 o->nrawf = sc->nrawf; in save_caps_and_params()
2213 if (o->c##caps != sc->c##caps) { \ in compare_caps_and_params()
2214 CH_ERR(sc, "%scaps 0x%04x -> 0x%04x.\n", #c, o->c##caps, \ in compare_caps_and_params()
2215 sc->c##caps); \ in compare_caps_and_params()
2231 if (o->cfcsum != sc->cfcsum) { in compare_caps_and_params()
2232 CH_ERR(sc, "config file %s (0x%x) -> %s (0x%x)\n", o->cfg_file, in compare_caps_and_params()
2233 o->cfcsum, sc->cfg_file, sc->cfcsum); in compare_caps_and_params()
2238 if (o->p != sc->p) { \ in compare_caps_and_params()
2239 CH_ERR(sc, #name " %d -> %d\n", o->p, sc->p); \ in compare_caps_and_params()
2331 MPASS(sc->flags & FW_OK); in restart_lld()
2333 if (sc->flags & MASTER_PF) { in restart_lld()
2352 pi = sc->port[i]; in restart_lld()
2354 MPASS(pi->vi != NULL); in restart_lld()
2355 MPASS(pi->vi[0].dev == pi->dev); in restart_lld()
2357 rc = -t4_port_init(sc, sc->mbox, sc->pf, 0, i); in restart_lld()
2360 "failed to re-initialize port %d: %d\n", i, rc); in restart_lld()
2363 MPASS(sc->chan_map[pi->tx_chan] == i); in restart_lld()
2375 "failed to re-allocate extra VI: %d\n", rc); in restart_lld()
2388 if (sc->flags & FULL_INIT_DONE) { in restart_lld()
2391 CH_ERR(sc, "failed to re-initialize adapter: %d\n", rc); in restart_lld()
2395 if (sc->vxlan_refcount > 0) in restart_lld()
2399 pi = sc->port[i]; in restart_lld()
2401 mtx_lock(&vi->tick_mtx); in restart_lld()
2402 vi->flags &= ~VI_SKIP_STATS; in restart_lld()
2403 mtx_unlock(&vi->tick_mtx); in restart_lld()
2404 if (!(vi->flags & VI_INIT_DONE)) in restart_lld()
2408 CH_ERR(vi, "failed to re-initialize " in restart_lld()
2412 if (sc->traceq < 0 && IS_MAIN_VI(vi)) { in restart_lld()
2413 sc->traceq = sc->sge.rxq[vi->first_rxq].iq.abs_id; in restart_lld()
2417 V_RSSCONTROL(pi->tx_chan) | in restart_lld()
2418 V_QUEUENUMBER(sc->traceq)); in restart_lld()
2419 pi->flags |= HAS_TRACEQ; in restart_lld()
2422 ifp = vi->ifp; in restart_lld()
2434 CH_ERR(vi, "failed to re-configure MAC: %d\n", rc); in restart_lld()
2437 rc = -t4_enable_vi(sc, sc->mbox, vi->viid, true, in restart_lld()
2440 CH_ERR(vi, "failed to re-enable VI: %d\n", rc); in restart_lld()
2445 txq->eq.flags |= EQ_ENABLED; in restart_lld()
2448 mtx_lock(&vi->tick_mtx); in restart_lld()
2449 callout_schedule(&vi->tick, hz); in restart_lld()
2450 mtx_unlock(&vi->tick_mtx); in restart_lld()
2453 if (pi->up_vis > 0) { in restart_lld()
2458 if (pi->link_cfg.link_ok) in restart_lld()
2466 pi = sc->port[i]; in restart_lld()
2468 if (!(vi->flags & VI_INIT_DONE)) in restart_lld()
2470 ifp = vi->ifp; in restart_lld()
2475 CH_ERR(vi, "failed to re-configure MCAST MACs: %d\n", rc); in restart_lld()
2542 rc = BUS_RESET_CHILD(device_get_parent(sc->dev), sc->dev, 0); in reset_adapter_with_pci_bus_reset()
2553 MPASS(sc->error_flags & HW_OFF_LIMITS); in reset_adapter_with_pl_rst()
2554 bus_space_write_4(sc->bt, sc->bh, A_PL_RST, in reset_adapter_with_pl_rst()
2576 const int flags = sc->flags; in reset_adapter_task()
2577 const int eflags = sc->error_flags; in reset_adapter_task()
2585 "flags 0x%08x -> 0x%08x, err_flags 0x%08x -> 0x%08x.\n", in reset_adapter_task()
2586 rc, flags, sc->flags, eflags, sc->error_flags); in reset_adapter_task()
2595 device_set_descf(dev, "port %d", pi->port_id); in cxgbe_probe()
2611 struct sysctl_ctx_list *ctx = &vi->ctx; in cxgbe_vi_attach()
2613 struct pfil_head_args pa; in cxgbe_vi_attach() local
2614 struct adapter *sc = vi->adapter; in cxgbe_vi_attach()
2617 children = SYSCTL_CHILDREN(device_get_sysctl_tree(vi->dev)); in cxgbe_vi_attach()
2618 vi->rxq_oid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, "rxq", in cxgbe_vi_attach()
2620 vi->txq_oid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, "txq", in cxgbe_vi_attach()
2623 vi->nm_rxq_oid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, "nm_rxq", in cxgbe_vi_attach()
2625 vi->nm_txq_oid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, "nm_txq", in cxgbe_vi_attach()
2629 vi->ofld_rxq_oid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, "ofld_rxq", in cxgbe_vi_attach()
2633 vi->ofld_txq_oid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, "ofld_txq", in cxgbe_vi_attach()
2637 vi->xact_addr_filt = -1; in cxgbe_vi_attach()
2638 mtx_init(&vi->tick_mtx, "vi tick", NULL, MTX_DEF); in cxgbe_vi_attach()
2639 callout_init_mtx(&vi->tick, &vi->tick_mtx, 0); in cxgbe_vi_attach()
2640 if (sc->flags & IS_VF || t4_tx_vm_wr != 0) in cxgbe_vi_attach()
2641 vi->flags |= TX_USES_VM_WR; in cxgbe_vi_attach()
2645 vi->ifp = ifp; in cxgbe_vi_attach()
2655 if (vi->pi->nvi > 1 || sc->flags & IS_VF) in cxgbe_vi_attach()
2679 if (vi->nofldrxq != 0) in cxgbe_vi_attach()
2683 if (is_ethoffload(sc) && vi->nofldtxq != 0) { in cxgbe_vi_attach()
2690 if (vi->flags & TX_USES_VM_WR) in cxgbe_vi_attach()
2695 if (is_ethoffload(sc) && vi->nofldtxq != 0) in cxgbe_vi_attach()
2702 if (sc->flags & KERN_TLS_ON || !is_t6(sc)) in cxgbe_vi_attach()
2707 ether_ifattach(ifp, vi->hw_addr); in cxgbe_vi_attach()
2709 if (vi->nnmrxq != 0) in cxgbe_vi_attach()
2713 sbuf_printf(sb, "%d txq, %d rxq (NIC)", vi->ntxq, vi->nrxq); in cxgbe_vi_attach()
2717 sbuf_printf(sb, "; %d txq (TOE)", vi->nofldtxq); in cxgbe_vi_attach()
2720 sbuf_printf(sb, "; %d txq (TOE/ETHOFLD)", vi->nofldtxq); in cxgbe_vi_attach()
2723 sbuf_printf(sb, "; %d txq (ETHOFLD)", vi->nofldtxq); in cxgbe_vi_attach()
2729 sbuf_printf(sb, ", %d rxq (TOE)", vi->nofldrxq); in cxgbe_vi_attach()
2734 vi->nnmtxq, vi->nnmrxq); in cxgbe_vi_attach()
2742 pa.pa_version = PFIL_VERSION; in cxgbe_vi_attach()
2743 pa.pa_flags = PFIL_IN; in cxgbe_vi_attach()
2744 pa.pa_type = PFIL_TYPE_ETHERNET; in cxgbe_vi_attach()
2745 pa.pa_headname = if_name(ifp); in cxgbe_vi_attach()
2746 vi->pfil = pfil_head_register(&pa); in cxgbe_vi_attach()
2753 struct adapter *sc = pi->adapter; in cxgbe_attach()
2757 sysctl_ctx_init(&pi->ctx); in cxgbe_attach()
2759 cxgbe_vi_attach(dev, &pi->vi[0]); in cxgbe_attach()
2764 vi->dev = device_add_child(dev, sc->names->vi_ifnet_name, DEVICE_UNIT_ANY); in cxgbe_attach()
2765 if (vi->dev == NULL) { in cxgbe_attach()
2769 device_set_softc(vi->dev, vi); in cxgbe_attach()
2782 if_t ifp = vi->ifp; in cxgbe_vi_detach()
2784 if (vi->pfil != NULL) { in cxgbe_vi_detach()
2785 pfil_head_unregister(vi->pfil); in cxgbe_vi_detach()
2786 vi->pfil = NULL; in cxgbe_vi_detach()
2797 callout_drain(&vi->tick); in cxgbe_vi_detach()
2798 mtx_destroy(&vi->tick_mtx); in cxgbe_vi_detach()
2799 sysctl_ctx_free(&vi->ctx); in cxgbe_vi_detach()
2802 if_free(vi->ifp); in cxgbe_vi_detach()
2803 vi->ifp = NULL; in cxgbe_vi_detach()
2810 struct adapter *sc = pi->adapter; in cxgbe_detach()
2818 sysctl_ctx_free(&pi->ctx); in cxgbe_detach()
2819 begin_vi_detach(sc, &pi->vi[0]); in cxgbe_detach()
2820 if (pi->flags & HAS_TRACEQ) { in cxgbe_detach()
2821 sc->traceq = -1; /* cloner should not create ifnet */ in cxgbe_detach()
2824 cxgbe_vi_detach(&pi->vi[0]); in cxgbe_detach()
2825 ifmedia_removeall(&pi->media); in cxgbe_detach()
2826 end_vi_detach(sc, &pi->vi[0]); in cxgbe_detach()
2835 struct adapter *sc = vi->adapter; in cxgbe_init()
2848 struct port_info *pi = vi->pi; in cxgbe_ioctl()
2849 struct adapter *sc = pi->adapter; in cxgbe_ioctl()
2855 mtu = ifr->ifr_mtu; in cxgbe_ioctl()
2863 if (vi->flags & VI_INIT_DONE) { in cxgbe_ioctl()
2884 flags = vi->if_flags; in cxgbe_ioctl()
2893 vi->if_flags = if_getflags(ifp); in cxgbe_ioctl()
2915 mask = ifr->ifr_reqcap ^ if_getcapenable(ifp); in cxgbe_ioctl()
2925 "tso4 disabled due to -txcsum.\n"); in cxgbe_ioctl()
2937 "tso6 disabled due to -txcsum6.\n"); in cxgbe_ioctl()
2977 rxq->iq.flags |= IQ_LRO_ENABLED; in cxgbe_ioctl()
2979 rxq->iq.flags &= ~IQ_LRO_ENABLED; in cxgbe_ioctl()
3002 /* Need to find out how to disable auto-mtu-inflation */ in cxgbe_ioctl()
3019 rxq->iq.flags |= IQ_RX_TIMESTAMP; in cxgbe_ioctl()
3021 rxq->iq.flags &= ~IQ_RX_TIMESTAMP; in cxgbe_ioctl()
3060 rc = ifmedia_ioctl(ifp, ifr, &pi->media, cmd); in cxgbe_ioctl()
3083 rc = -t4_i2c_rd(sc, sc->mbox, pi->port_id, i2c.dev_addr, in cxgbe_ioctl()
3102 struct port_info *pi = vi->pi; in cxgbe_transmit()
3109 MPASS(m->m_nextpkt == NULL); /* not quite ready for this yet */ in cxgbe_transmit()
3111 if (m->m_pkthdr.csum_flags & CSUM_SND_TAG) in cxgbe_transmit()
3112 MPASS(m->m_pkthdr.snd_tag->ifp == ifp); in cxgbe_transmit()
3115 if (__predict_false(pi->link_cfg.link_ok == false)) { in cxgbe_transmit()
3120 rc = parse_pkt(&m, vi->flags & TX_USES_VM_WR); in cxgbe_transmit()
3129 atomic_add_int(&pi->tx_parse_error, 1); /* rare, atomic is ok */ in cxgbe_transmit()
3134 sc = vi->adapter; in cxgbe_transmit()
3135 txq = &sc->sge.txq[vi->first_txq]; in cxgbe_transmit()
3137 txq += ((m->m_pkthdr.flowid % (vi->ntxq - vi->rsrv_noflowq)) + in cxgbe_transmit()
3138 vi->rsrv_noflowq); in cxgbe_transmit()
3141 rc = mp_ring_enqueue(txq->r, items, 1, 256); in cxgbe_transmit()
3156 if (vi->flags & VI_INIT_DONE) { in cxgbe_qflush()
3159 txq->eq.flags |= EQ_QFLUSH; in cxgbe_qflush()
3161 while (!mp_ring_is_idle(txq->r)) { in cxgbe_qflush()
3162 mp_ring_check_drainage(txq->r, 4096); in cxgbe_qflush()
3166 txq->eq.flags &= ~EQ_QFLUSH; in cxgbe_qflush()
3177 struct fw_vi_stats_vf *s = &vi->stats; in vi_get_counter()
3179 mtx_lock(&vi->tick_mtx); in vi_get_counter()
3181 mtx_unlock(&vi->tick_mtx); in vi_get_counter()
3185 return (s->rx_bcast_frames + s->rx_mcast_frames + in vi_get_counter()
3186 s->rx_ucast_frames); in vi_get_counter()
3188 return (s->rx_err_frames); in vi_get_counter()
3190 return (s->tx_bcast_frames + s->tx_mcast_frames + in vi_get_counter()
3191 s->tx_ucast_frames + s->tx_offload_frames); in vi_get_counter()
3193 return (s->tx_drop_frames); in vi_get_counter()
3195 return (s->rx_bcast_bytes + s->rx_mcast_bytes + in vi_get_counter()
3196 s->rx_ucast_bytes); in vi_get_counter()
3198 return (s->tx_bcast_bytes + s->tx_mcast_bytes + in vi_get_counter()
3199 s->tx_ucast_bytes + s->tx_offload_bytes); in vi_get_counter()
3201 return (s->rx_mcast_frames); in vi_get_counter()
3203 return (s->tx_mcast_frames); in vi_get_counter()
3208 if (vi->flags & VI_INIT_DONE) { in vi_get_counter()
3213 drops += counter_u64_fetch(txq->r->dropped); in vi_get_counter()
3229 struct port_info *pi = vi->pi; in cxgbe_get_counter()
3230 struct port_stats *s = &pi->stats; in cxgbe_get_counter()
3232 mtx_lock(&vi->tick_mtx); in cxgbe_get_counter()
3234 mtx_unlock(&vi->tick_mtx); in cxgbe_get_counter()
3238 return (s->rx_frames); in cxgbe_get_counter()
3241 return (s->rx_jabber + s->rx_runt + s->rx_too_long + in cxgbe_get_counter()
3242 s->rx_fcs_err + s->rx_len_err); in cxgbe_get_counter()
3245 return (s->tx_frames); in cxgbe_get_counter()
3248 return (s->tx_error_frames); in cxgbe_get_counter()
3251 return (s->rx_octets); in cxgbe_get_counter()
3254 return (s->tx_octets); in cxgbe_get_counter()
3257 return (s->rx_mcast_frames); in cxgbe_get_counter()
3260 return (s->tx_mcast_frames); in cxgbe_get_counter()
3263 return (s->rx_ovflow0 + s->rx_ovflow1 + s->rx_ovflow2 + in cxgbe_get_counter()
3264 s->rx_ovflow3 + s->rx_trunc0 + s->rx_trunc1 + s->rx_trunc2 + in cxgbe_get_counter()
3265 s->rx_trunc3 + pi->tnl_cong_drops); in cxgbe_get_counter()
3270 drops = s->tx_drop; in cxgbe_get_counter()
3271 if (vi->flags & VI_INIT_DONE) { in cxgbe_get_counter()
3276 drops += counter_u64_fetch(txq->r->dropped); in cxgbe_get_counter()
3295 switch (params->hdr.type) { in cxgbe_snd_tag_alloc()
3306 if (is_t6(vi->pi->adapter)) in cxgbe_snd_tag_alloc()
3328 struct port_info *pi = vi->pi; in cxgbe_media_change()
3329 struct ifmedia *ifm = &pi->media; in cxgbe_media_change()
3330 struct link_config *lc = &pi->link_cfg; in cxgbe_media_change()
3331 struct adapter *sc = pi->adapter; in cxgbe_media_change()
3338 if (IFM_SUBTYPE(ifm->ifm_media) == IFM_AUTO) { in cxgbe_media_change()
3340 if (!(lc->pcaps & FW_PORT_CAP32_ANEG)) { in cxgbe_media_change()
3344 lc->requested_aneg = AUTONEG_ENABLE; in cxgbe_media_change()
3345 lc->requested_speed = 0; in cxgbe_media_change()
3346 lc->requested_fc |= PAUSE_AUTONEG; in cxgbe_media_change()
3348 lc->requested_aneg = AUTONEG_DISABLE; in cxgbe_media_change()
3349 lc->requested_speed = in cxgbe_media_change()
3350 ifmedia_baudrate(ifm->ifm_media) / 1000000; in cxgbe_media_change()
3351 lc->requested_fc = 0; in cxgbe_media_change()
3352 if (IFM_OPTIONS(ifm->ifm_media) & IFM_ETH_RXPAUSE) in cxgbe_media_change()
3353 lc->requested_fc |= PAUSE_RX; in cxgbe_media_change()
3354 if (IFM_OPTIONS(ifm->ifm_media) & IFM_ETH_TXPAUSE) in cxgbe_media_change()
3355 lc->requested_fc |= PAUSE_TX; in cxgbe_media_change()
3357 if (pi->up_vis > 0 && !hw_off_limits(sc)) { in cxgbe_media_change()
3378 switch(pi->port_type) { in port_mword()
3437 switch (pi->mod_type) { in port_mword()
3517 struct port_info *pi = vi->pi; in cxgbe_media_status()
3518 struct adapter *sc = pi->adapter; in cxgbe_media_status()
3519 struct link_config *lc = &pi->link_cfg; in cxgbe_media_status()
3525 if (pi->up_vis == 0 && !hw_off_limits(sc)) { in cxgbe_media_status()
3538 ifmr->ifm_status = IFM_AVALID; in cxgbe_media_status()
3539 if (lc->link_ok == false) in cxgbe_media_status()
3541 ifmr->ifm_status |= IFM_ACTIVE; in cxgbe_media_status()
3544 ifmr->ifm_active = IFM_ETHER | IFM_FDX; in cxgbe_media_status()
3545 ifmr->ifm_active &= ~(IFM_ETH_TXPAUSE | IFM_ETH_RXPAUSE); in cxgbe_media_status()
3546 if (lc->fc & PAUSE_RX) in cxgbe_media_status()
3547 ifmr->ifm_active |= IFM_ETH_RXPAUSE; in cxgbe_media_status()
3548 if (lc->fc & PAUSE_TX) in cxgbe_media_status()
3549 ifmr->ifm_active |= IFM_ETH_TXPAUSE; in cxgbe_media_status()
3550 ifmr->ifm_active |= port_mword(pi, speed_to_fwcap(lc->speed)); in cxgbe_media_status()
3561 device_set_descf(dev, "port %d vi %td", vi->pi->port_id, in vcxgbe_probe()
3562 vi - vi->pi->vi); in vcxgbe_probe()
3575 index = vi - pi->vi; in alloc_extra_vi()
3579 device_get_nameunit(vi->dev))); in alloc_extra_vi()
3581 rc = t4_alloc_vi_func(sc, sc->mbox, pi->tx_chan, sc->pf, 0, 1, in alloc_extra_vi()
3582 vi->hw_addr, &vi->rss_size, &vi->vfvld, &vi->vin, func, 0); in alloc_extra_vi()
3585 "for port %d: %d\n", index, pi->port_id, -rc); in alloc_extra_vi()
3586 return (-rc); in alloc_extra_vi()
3588 vi->viid = rc; in alloc_extra_vi()
3590 if (vi->rss_size == 1) { in alloc_extra_vi()
3597 device_printf(vi->dev, "RSS table not available.\n"); in alloc_extra_vi()
3598 vi->rss_base = 0xffff; in alloc_extra_vi()
3605 V_FW_PARAMS_PARAM_YZ(vi->viid); in alloc_extra_vi()
3606 rc = t4_query_params(sc, sc->mbox, sc->pf, 0, 1, &param, &val); in alloc_extra_vi()
3608 vi->rss_base = 0xffff; in alloc_extra_vi()
3610 MPASS((val >> 16) == vi->rss_size); in alloc_extra_vi()
3611 vi->rss_base = val & 0xffff; in alloc_extra_vi()
3626 pi = vi->pi; in vcxgbe_attach()
3627 sc = pi->adapter; in vcxgbe_attach()
3649 sc = vi->adapter; in vcxgbe_detach()
3653 t4_free_vi(sc, sc->mbox, sc->pf, 0, vi->viid); in vcxgbe_detach()
3667 panic("%s: panic on fatal error", device_get_nameunit(sc->dev)); in delayed_panic()
3676 if (atomic_testandclear_int(&sc->error_flags, ilog2(ADAP_CIM_ERR))) { in fatal_error_task()
3701 const bool verbose = (sc->debug_flags & DF_VERBOSE_SLOWINTR) != 0; in t4_fatal_err()
3704 if (atomic_testandset_int(&sc->error_flags, ilog2(ADAP_FATAL_ERR))) in t4_fatal_err()
3716 atomic_set_int(&sc->error_flags, ADAP_CIM_ERR); in t4_fatal_err()
3720 device_get_nameunit(sc->dev), fw_error); in t4_fatal_err()
3721 taskqueue_enqueue(reset_tq, &sc->fatal_error_task); in t4_fatal_err()
3735 sc->regs_rid = PCIR_BAR(0); in t4_map_bars_0_and_4()
3736 sc->regs_res = bus_alloc_resource_any(sc->dev, SYS_RES_MEMORY, in t4_map_bars_0_and_4()
3737 &sc->regs_rid, RF_ACTIVE); in t4_map_bars_0_and_4()
3738 if (sc->regs_res == NULL) { in t4_map_bars_0_and_4()
3739 device_printf(sc->dev, "cannot map registers.\n"); in t4_map_bars_0_and_4()
3742 sc->bt = rman_get_bustag(sc->regs_res); in t4_map_bars_0_and_4()
3743 sc->bh = rman_get_bushandle(sc->regs_res); in t4_map_bars_0_and_4()
3744 sc->mmio_len = rman_get_size(sc->regs_res); in t4_map_bars_0_and_4()
3745 setbit(&sc->doorbells, DOORBELL_KDB); in t4_map_bars_0_and_4()
3747 sc->msix_rid = PCIR_BAR(4); in t4_map_bars_0_and_4()
3748 sc->msix_res = bus_alloc_resource_any(sc->dev, SYS_RES_MEMORY, in t4_map_bars_0_and_4()
3749 &sc->msix_rid, RF_ACTIVE); in t4_map_bars_0_and_4()
3750 if (sc->msix_res == NULL) { in t4_map_bars_0_and_4()
3751 device_printf(sc->dev, "cannot map MSI-X BAR.\n"); in t4_map_bars_0_and_4()
3766 if (is_t4(sc) && sc->rdmacaps == 0) in t4_map_bar_2()
3769 sc->udbs_rid = PCIR_BAR(2); in t4_map_bar_2()
3770 sc->udbs_res = bus_alloc_resource_any(sc->dev, SYS_RES_MEMORY, in t4_map_bar_2()
3771 &sc->udbs_rid, RF_ACTIVE); in t4_map_bar_2()
3772 if (sc->udbs_res == NULL) { in t4_map_bar_2()
3773 device_printf(sc->dev, "cannot map doorbell BAR.\n"); in t4_map_bar_2()
3776 sc->udbs_base = rman_get_virtual(sc->udbs_res); in t4_map_bar_2()
3779 setbit(&sc->doorbells, DOORBELL_UDB); in t4_map_bar_2()
3793 rc = pmap_change_attr((vm_offset_t)sc->udbs_base, in t4_map_bar_2()
3794 rman_get_size(sc->udbs_res), PAT_WRITE_COMBINING); in t4_map_bar_2()
3796 clrbit(&sc->doorbells, DOORBELL_UDB); in t4_map_bar_2()
3797 setbit(&sc->doorbells, DOORBELL_WCWR); in t4_map_bar_2()
3798 setbit(&sc->doorbells, DOORBELL_UDBWC); in t4_map_bar_2()
3800 device_printf(sc->dev, in t4_map_bar_2()
3811 sc->iwt.wc_en = isset(&sc->doorbells, DOORBELL_UDBWC) ? 1 : 0; in t4_map_bar_2()
3819 if ((sc->doorbells & t4_doorbells_allowed) != 0) { in t4_adj_doorbells()
3820 sc->doorbells &= t4_doorbells_allowed; in t4_adj_doorbells()
3824 sc->doorbells, t4_doorbells_allowed); in t4_adj_doorbells()
3872 for (i = 0, mw = &sc->memwin[0]; i < NUM_MEMWIN; i++, mw_init++, mw++) { in setup_memwin()
3873 if (!rw_initialized(&mw->mw_lock)) { in setup_memwin()
3874 rw_init(&mw->mw_lock, "memory window access"); in setup_memwin()
3875 mw->mw_base = mw_init->base; in setup_memwin()
3876 mw->mw_aperture = mw_init->aperture; in setup_memwin()
3877 mw->mw_curpos = 0; in setup_memwin()
3881 (mw->mw_base + bar0) | V_BIR(0) | in setup_memwin()
3882 V_WINDOW(ilog2(mw->mw_aperture) - 10)); in setup_memwin()
3883 rw_wlock(&mw->mw_lock); in setup_memwin()
3884 position_memwin(sc, i, mw->mw_curpos); in setup_memwin()
3885 rw_wunlock(&mw->mw_lock); in setup_memwin()
3895 * address prior to the requested address. mw->mw_curpos always has the actual
3906 mw = &sc->memwin[idx]; in position_memwin()
3907 rw_assert(&mw->mw_lock, RA_WLOCKED); in position_memwin()
3911 mw->mw_curpos = addr & ~0xf; /* start must be 16B aligned */ in position_memwin()
3913 pf = V_PFNUM(sc->pf); in position_memwin()
3914 mw->mw_curpos = addr & ~0x7f; /* start must be 128B aligned */ in position_memwin()
3917 t4_write_reg(sc, reg, mw->mw_curpos | pf); in position_memwin()
3934 mw = &sc->memwin[idx]; in rw_via_memwin()
3936 rw_rlock(&mw->mw_lock); in rw_via_memwin()
3937 mw_end = mw->mw_curpos + mw->mw_aperture; in rw_via_memwin()
3938 if (addr >= mw_end || addr < mw->mw_curpos) { in rw_via_memwin()
3940 if (!rw_try_upgrade(&mw->mw_lock)) { in rw_via_memwin()
3941 rw_runlock(&mw->mw_lock); in rw_via_memwin()
3942 rw_wlock(&mw->mw_lock); in rw_via_memwin()
3944 rw_assert(&mw->mw_lock, RA_WLOCKED); in rw_via_memwin()
3946 rw_downgrade(&mw->mw_lock); in rw_via_memwin()
3947 mw_end = mw->mw_curpos + mw->mw_aperture; in rw_via_memwin()
3949 rw_assert(&mw->mw_lock, RA_RLOCKED); in rw_via_memwin()
3952 v = t4_read_reg(sc, mw->mw_base + addr - in rw_via_memwin()
3953 mw->mw_curpos); in rw_via_memwin()
3957 t4_write_reg(sc, mw->mw_base + addr - in rw_via_memwin()
3958 mw->mw_curpos, htole32(v)); in rw_via_memwin()
3961 len -= 4; in rw_via_memwin()
3963 rw_runlock(&mw->mw_lock); in rw_via_memwin()
3978 t = &sc->tids; in t4_init_atid_table()
3979 if (t->natids == 0) in t4_init_atid_table()
3982 MPASS(t->atid_tab == NULL); in t4_init_atid_table()
3984 t->atid_tab = malloc(t->natids * sizeof(*t->atid_tab), M_CXGBE, in t4_init_atid_table()
3986 mtx_init(&t->atid_lock, "atid lock", NULL, MTX_DEF); in t4_init_atid_table()
3987 t->afree = t->atid_tab; in t4_init_atid_table()
3988 t->atids_in_use = 0; in t4_init_atid_table()
3989 t->atid_alloc_stopped = false; in t4_init_atid_table()
3990 for (i = 1; i < t->natids; i++) in t4_init_atid_table()
3991 t->atid_tab[i - 1].next = &t->atid_tab[i]; in t4_init_atid_table()
3992 t->atid_tab[t->natids - 1].next = NULL; in t4_init_atid_table()
4000 t = &sc->tids; in t4_free_atid_table()
4002 KASSERT(t->atids_in_use == 0, in t4_free_atid_table()
4003 ("%s: %d atids still in use.", __func__, t->atids_in_use)); in t4_free_atid_table()
4005 if (mtx_initialized(&t->atid_lock)) in t4_free_atid_table()
4006 mtx_destroy(&t->atid_lock); in t4_free_atid_table()
4007 free(t->atid_tab, M_CXGBE); in t4_free_atid_table()
4008 t->atid_tab = NULL; in t4_free_atid_table()
4014 struct tid_info *t = &sc->tids; in stop_atid_allocator()
4016 mtx_lock(&t->atid_lock); in stop_atid_allocator()
4017 t->atid_alloc_stopped = true; in stop_atid_allocator()
4018 mtx_unlock(&t->atid_lock); in stop_atid_allocator()
4024 struct tid_info *t = &sc->tids; in restart_atid_allocator()
4026 mtx_lock(&t->atid_lock); in restart_atid_allocator()
4027 KASSERT(t->atids_in_use == 0, in restart_atid_allocator()
4028 ("%s: %d atids still in use.", __func__, t->atids_in_use)); in restart_atid_allocator()
4029 t->atid_alloc_stopped = false; in restart_atid_allocator()
4030 mtx_unlock(&t->atid_lock); in restart_atid_allocator()
4036 struct tid_info *t = &sc->tids; in alloc_atid()
4037 int atid = -1; in alloc_atid()
4039 mtx_lock(&t->atid_lock); in alloc_atid()
4040 if (t->afree && !t->atid_alloc_stopped) { in alloc_atid()
4041 union aopen_entry *p = t->afree; in alloc_atid()
4043 atid = p - t->atid_tab; in alloc_atid()
4045 t->afree = p->next; in alloc_atid()
4046 p->data = ctx; in alloc_atid()
4047 t->atids_in_use++; in alloc_atid()
4049 mtx_unlock(&t->atid_lock); in alloc_atid()
4056 struct tid_info *t = &sc->tids; in lookup_atid()
4058 return (t->atid_tab[atid].data); in lookup_atid()
4064 struct tid_info *t = &sc->tids; in free_atid()
4065 union aopen_entry *p = &t->atid_tab[atid]; in free_atid()
4067 mtx_lock(&t->atid_lock); in free_atid()
4068 p->next = t->afree; in free_atid()
4069 t->afree = p; in free_atid()
4070 t->atids_in_use--; in free_atid()
4071 mtx_unlock(&t->atid_lock); in free_atid()
4102 return ((const struct t4_range *)a)->start - in t4_range_cmp()
4103 ((const struct t4_range *)b)->start; in t4_range_cmp()
4129 r->size = G_EDRAM0_SIZE(addr_len) << 20; in validate_mem_range()
4130 if (r->size > 0) { in validate_mem_range()
4131 r->start = G_EDRAM0_BASE(addr_len) << 20; in validate_mem_range()
4132 if (addr >= r->start && in validate_mem_range()
4133 addr + len <= r->start + r->size) in validate_mem_range()
4141 r->size = G_EDRAM1_SIZE(addr_len) << 20; in validate_mem_range()
4142 if (r->size > 0) { in validate_mem_range()
4143 r->start = G_EDRAM1_BASE(addr_len) << 20; in validate_mem_range()
4144 if (addr >= r->start && in validate_mem_range()
4145 addr + len <= r->start + r->size) in validate_mem_range()
4153 r->size = G_EXT_MEM_SIZE(addr_len) << 20; in validate_mem_range()
4154 if (r->size > 0) { in validate_mem_range()
4155 r->start = G_EXT_MEM_BASE(addr_len) << 20; in validate_mem_range()
4156 if (addr >= r->start && in validate_mem_range()
4157 addr + len <= r->start + r->size) in validate_mem_range()
4165 r->size = G_EXT_MEM1_SIZE(addr_len) << 20; in validate_mem_range()
4166 if (r->size > 0) { in validate_mem_range()
4167 r->start = G_EXT_MEM1_BASE(addr_len) << 20; in validate_mem_range()
4168 if (addr >= r->start && in validate_mem_range()
4169 addr + len <= r->start + r->size) in validate_mem_range()
4181 /* Start from index 0 and examine the next n - 1 entries. */ in validate_mem_range()
4183 for (remaining = n - 1; remaining > 0; remaining--, r++) { in validate_mem_range()
4185 MPASS(r->size > 0); /* r is a valid entry. */ in validate_mem_range()
4187 MPASS(next->size > 0); /* and so is the next one. */ in validate_mem_range()
4189 while (r->start + r->size >= next->start) { in validate_mem_range()
4191 r->size = max(r->start + r->size, in validate_mem_range()
4192 next->start + next->size) - r->start; in validate_mem_range()
4193 n--; /* One fewer entry in total. */ in validate_mem_range()
4194 if (--remaining == 0) in validate_mem_range()
4204 MPASS(next->size > 0); /* must be valid */ in validate_mem_range()
4208 * This so that the foo->size assertion in the in validate_mem_range()
4214 bzero(&mem_ranges[n], (nitems(mem_ranges) - n) * in validate_mem_range()
4224 if (addr >= r->start && in validate_mem_range()
4225 addr + len <= r->start + r->size) in validate_mem_range()
4303 struct devlog_params *dparams = &sc->params.devlog; in fixup_devlog_params()
4306 rc = validate_mt_off_len(sc, dparams->memtype, dparams->start, in fixup_devlog_params()
4307 dparams->size, &dparams->addr); in fixup_devlog_params()
4316 iaq->nirq = T4_EXTRA_INTR; in update_nirq()
4317 iaq->nirq += nports * max(iaq->nrxq, iaq->nnmrxq); in update_nirq()
4318 iaq->nirq += nports * iaq->nofldrxq; in update_nirq()
4319 iaq->nirq += nports * (iaq->num_vis - 1) * in update_nirq()
4320 max(iaq->nrxq_vi, iaq->nnmrxq_vi); in update_nirq()
4321 iaq->nirq += nports * (iaq->num_vis - 1) * iaq->nofldrxq_vi; in update_nirq()
4332 const int nports = sc->params.nports; in calculate_iaq()
4338 iaq->intr_type = itype; in calculate_iaq()
4339 iaq->num_vis = t4_num_vis; in calculate_iaq()
4340 iaq->ntxq = t4_ntxq; in calculate_iaq()
4341 iaq->ntxq_vi = t4_ntxq_vi; in calculate_iaq()
4342 iaq->nrxq = t4_nrxq; in calculate_iaq()
4343 iaq->nrxq_vi = t4_nrxq_vi; in calculate_iaq()
4346 iaq->nofldtxq = t4_nofldtxq; in calculate_iaq()
4347 iaq->nofldtxq_vi = t4_nofldtxq_vi; in calculate_iaq()
4352 iaq->nofldrxq = t4_nofldrxq; in calculate_iaq()
4353 iaq->nofldrxq_vi = t4_nofldrxq_vi; in calculate_iaq()
4358 iaq->nnmtxq = t4_nnmtxq; in calculate_iaq()
4359 iaq->nnmrxq = t4_nnmrxq; in calculate_iaq()
4362 iaq->nnmtxq_vi = t4_nnmtxq_vi; in calculate_iaq()
4363 iaq->nnmrxq_vi = t4_nnmrxq_vi; in calculate_iaq()
4368 if (iaq->nirq <= navail && in calculate_iaq()
4369 (itype != INTR_MSI || powerof2(iaq->nirq))) { in calculate_iaq()
4371 * This is the normal case -- there are enough interrupts for in calculate_iaq()
4381 while (iaq->num_vis > 1) { in calculate_iaq()
4382 iaq->num_vis--; in calculate_iaq()
4384 if (iaq->nirq <= navail && in calculate_iaq()
4385 (itype != INTR_MSI || powerof2(iaq->nirq))) { in calculate_iaq()
4386 device_printf(sc->dev, "virtual interfaces per port " in calculate_iaq()
4390 iaq->num_vis, t4_num_vis, iaq->nrxq, iaq->nofldrxq, in calculate_iaq()
4391 iaq->nrxq_vi, iaq->nofldrxq_vi, iaq->nnmrxq_vi, in calculate_iaq()
4392 itype, navail, iaq->nirq); in calculate_iaq()
4400 MPASS(iaq->num_vis == 1); in calculate_iaq()
4401 iaq->ntxq_vi = iaq->nrxq_vi = 0; in calculate_iaq()
4402 iaq->nofldtxq_vi = iaq->nofldrxq_vi = 0; in calculate_iaq()
4403 iaq->nnmtxq_vi = iaq->nnmrxq_vi = 0; in calculate_iaq()
4404 if (iaq->num_vis != t4_num_vis) { in calculate_iaq()
4405 device_printf(sc->dev, "extra virtual interfaces disabled. " in calculate_iaq()
4408 iaq->nrxq, iaq->nofldrxq, iaq->nrxq_vi, iaq->nofldrxq_vi, in calculate_iaq()
4409 iaq->nnmrxq_vi, itype, navail, iaq->nirq); in calculate_iaq()
4418 if (iaq->nrxq > 1) { in calculate_iaq()
4419 iaq->nrxq = rounddown_pow_of_two(iaq->nrxq - 1); in calculate_iaq()
4420 if (iaq->nnmrxq > iaq->nrxq) in calculate_iaq()
4421 iaq->nnmrxq = iaq->nrxq; in calculate_iaq()
4423 if (iaq->nofldrxq > 1) in calculate_iaq()
4424 iaq->nofldrxq >>= 1; in calculate_iaq()
4426 old_nirq = iaq->nirq; in calculate_iaq()
4428 if (iaq->nirq <= navail && in calculate_iaq()
4429 (itype != INTR_MSI || powerof2(iaq->nirq))) { in calculate_iaq()
4430 device_printf(sc->dev, "running with reduced number of " in calculate_iaq()
4433 "itype %d, navail %u, nirq %d.\n", iaq->nrxq, in calculate_iaq()
4434 iaq->nofldrxq, itype, navail, iaq->nirq); in calculate_iaq()
4437 } while (old_nirq != iaq->nirq); in calculate_iaq()
4440 device_printf(sc->dev, "running with minimal number of queues. " in calculate_iaq()
4442 iaq->nirq = 1; in calculate_iaq()
4443 iaq->nrxq = 1; in calculate_iaq()
4444 iaq->ntxq = 1; in calculate_iaq()
4445 if (iaq->nofldrxq > 0) { in calculate_iaq()
4446 iaq->nofldrxq = 1; in calculate_iaq()
4447 iaq->nofldtxq = 1; in calculate_iaq()
4449 iaq->nnmtxq = 0; in calculate_iaq()
4450 iaq->nnmrxq = 0; in calculate_iaq()
4452 MPASS(iaq->num_vis > 0); in calculate_iaq()
4453 if (iaq->num_vis > 1) { in calculate_iaq()
4454 MPASS(iaq->nrxq_vi > 0); in calculate_iaq()
4455 MPASS(iaq->ntxq_vi > 0); in calculate_iaq()
4457 MPASS(iaq->nirq > 0); in calculate_iaq()
4458 MPASS(iaq->nrxq > 0); in calculate_iaq()
4459 MPASS(iaq->ntxq > 0); in calculate_iaq()
4461 MPASS(powerof2(iaq->nirq)); in calculate_iaq()
4476 navail = pci_msix_count(sc->dev); in cfg_itype_and_nqueues()
4478 navail = pci_msi_count(sc->dev); in cfg_itype_and_nqueues()
4486 nalloc = iaq->nirq; in cfg_itype_and_nqueues()
4489 rc = pci_alloc_msix(sc->dev, &nalloc); in cfg_itype_and_nqueues()
4491 rc = pci_alloc_msi(sc->dev, &nalloc); in cfg_itype_and_nqueues()
4494 if (nalloc == iaq->nirq) in cfg_itype_and_nqueues()
4501 device_printf(sc->dev, "fewer vectors than requested, " in cfg_itype_and_nqueues()
4503 itype, iaq->nirq, nalloc); in cfg_itype_and_nqueues()
4504 pci_release_msi(sc->dev); in cfg_itype_and_nqueues()
4509 device_printf(sc->dev, in cfg_itype_and_nqueues()
4511 itype, rc, iaq->nirq, nalloc); in cfg_itype_and_nqueues()
4514 device_printf(sc->dev, in cfg_itype_and_nqueues()
4516 "allowed=%d, msi-x=%d, msi=%d, intx=1", t4_intr_types, in cfg_itype_and_nqueues()
4517 pci_msix_count(sc->dev), pci_msi_count(sc->dev)); in cfg_itype_and_nqueues()
4628 if (hdr1->chip == hdr2->chip && hdr1->fw_ver == hdr2->fw_ver) in fw_compatible()
4635 #define SAME_INTF(x) (hdr1->intfver_##x == hdr2->intfver_##x) in fw_compatible()
4636 if (hdr1->chip == hdr2->chip && SAME_INTF(nic) && SAME_INTF(vnic) && in fw_compatible()
4657 device_printf(sc->dev, in load_fw_module()
4663 *dcfg = firmware_get(fw_info->kld_name); in load_fw_module()
4666 *fw = firmware_get(fw_info->fw_mod_name); in load_fw_module()
4695 const uint32_t c = be32toh(card_fw->fw_ver); in install_kld_firmware()
4703 fw_install = t4_fw_install < 0 ? -t4_fw_install : t4_fw_install; in install_kld_firmware()
4709 device_printf(sc->dev, in install_kld_firmware()
4711 " will use compiled-in firmware version for" in install_kld_firmware()
4715 memcpy(&bundled_fw, fw->data, sizeof(bundled_fw)); in install_kld_firmware()
4724 if ((sc->flags & FW_OK) == 0) { in install_kld_firmware()
4760 device_printf(sc->dev, "firmware on card (%u.%u.%u.%u) is %s, " in install_kld_firmware()
4776 device_printf(sc->dev, in install_kld_firmware()
4783 device_printf(sc->dev, "firmware on card (%u.%u.%u.%u) is %s, " in install_kld_firmware()
4788 rc = sc->flags & FW_OK ? 0 : ENOENT; in install_kld_firmware()
4791 k = be32toh(((const struct fw_hdr *)fw->data)->fw_ver); in install_kld_firmware()
4794 device_printf(sc->dev, in install_kld_firmware()
4801 rc = sc->flags & FW_OK ? 0 : EINVAL; in install_kld_firmware()
4805 device_printf(sc->dev, "firmware on card (%u.%u.%u.%u) is %s, " in install_kld_firmware()
4812 rc = -t4_fw_upgrade(sc, sc->mbox, fw->data, fw->datasize, 0); in install_kld_firmware()
4814 device_printf(sc->dev, "failed to install firmware: %d\n", rc); in install_kld_firmware()
4818 memcpy(card_fw, fw->data, sizeof(*card_fw)); in install_kld_firmware()
4843 device_printf(sc->dev, in contact_firmware()
4848 drv_fw = &fw_info->fw_h; in contact_firmware()
4853 rc = -t4_get_fw_hdr(sc, card_fw); in contact_firmware()
4855 device_printf(sc->dev, in contact_firmware()
4868 rc = t4_fw_hello(sc, sc->mbox, sc->mbox, MASTER_MAY, &state); in contact_firmware()
4870 rc = -rc; in contact_firmware()
4871 device_printf(sc->dev, in contact_firmware()
4881 MPASS(be32toh(card_fw->flags) & FW_HDR_FLAGS_RESET_HALT); in contact_firmware()
4882 sc->flags |= FW_OK; /* The firmware responded to the FW_HELLO. */ in contact_firmware()
4884 if (rc == sc->pf) { in contact_firmware()
4885 sc->flags |= MASTER_PF; in contact_firmware()
4898 device_printf(sc->dev, "couldn't be master(%d), " in contact_firmware()
4908 device_printf(sc->dev, "PF%d is master, device state %d. " in contact_firmware()
4910 snprintf(sc->cfg_file, sizeof(sc->cfg_file), "pf%d", rc); in contact_firmware()
4911 sc->cfcsum = 0; in contact_firmware()
4915 if (rc != 0 && sc->flags & FW_OK) { in contact_firmware()
4916 t4_fw_bye(sc, sc->mbox); in contact_firmware()
4917 sc->flags &= ~FW_OK; in contact_firmware()
4937 if (pci_get_device(sc->dev) == 0x440a) in copy_cfg_file_to_card()
4945 device_printf(sc->dev, in copy_cfg_file_to_card()
4950 cfdata = dcfg->data; in copy_cfg_file_to_card()
4951 cflen = dcfg->datasize & ~3; in copy_cfg_file_to_card()
4957 device_printf(sc->dev, in copy_cfg_file_to_card()
4963 snprintf(s, sizeof(s), "%s_%s", fw_info->kld_name, cfg_file); in copy_cfg_file_to_card()
4967 device_printf(sc->dev, in copy_cfg_file_to_card()
4973 cfdata = rcfg->data; in copy_cfg_file_to_card()
4974 cflen = rcfg->datasize & ~3; in copy_cfg_file_to_card()
4978 device_printf(sc->dev, in copy_cfg_file_to_card()
4987 device_printf(sc->dev, in copy_cfg_file_to_card()
5033 rc = -t4_fw_reset(sc, sc->mbox, F_PIORSTMODE | F_PIORST); in apply_cfg_and_initialize()
5035 device_printf(sc->dev, "firmware reset failed: %d.\n", rc); in apply_cfg_and_initialize()
5058 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, &param, &val); in apply_cfg_and_initialize()
5061 device_printf(sc->dev, in apply_cfg_and_initialize()
5074 device_printf(sc->dev, in apply_cfg_and_initialize()
5079 rc = -t4_wr_mbox(sc, sc->mbox, &caps, sizeof(caps), &caps); in apply_cfg_and_initialize()
5081 device_printf(sc->dev, "failed to pre-process config file: %d " in apply_cfg_and_initialize()
5089 device_printf(sc->dev, in apply_cfg_and_initialize()
5093 sc->cfcsum = cfcsum; in apply_cfg_and_initialize()
5094 snprintf(sc->cfg_file, sizeof(sc->cfg_file), "%s", cfg_file); in apply_cfg_and_initialize()
5101 caps.x##caps &= htobe16(caps_allowed->x##caps); \ in apply_cfg_and_initialize()
5117 * to cope with the situation in non-debug builds by disabling in apply_cfg_and_initialize()
5130 rc = -t4_wr_mbox(sc, sc->mbox, &caps, sizeof(caps), NULL); in apply_cfg_and_initialize()
5132 device_printf(sc->dev, in apply_cfg_and_initialize()
5141 rc = -t4_fw_initialize(sc, sc->mbox); in apply_cfg_and_initialize()
5143 device_printf(sc->dev, "fw_initialize failed: %d.\n", rc); in apply_cfg_and_initialize()
5162 MPASS(sc->flags & MASTER_PF); in partition_resources()
5177 fallback = sc->debug_flags & DF_DISABLE_CFG_RETRY ? false : true; in partition_resources()
5183 device_printf(sc->dev, in partition_resources()
5209 snprintf(sc->fw_version, sizeof(sc->fw_version), "%u.%u.%u.%u", in get_params__pre_init()
5210 G_FW_HDR_FW_VER_MAJOR(sc->params.fw_vers), in get_params__pre_init()
5211 G_FW_HDR_FW_VER_MINOR(sc->params.fw_vers), in get_params__pre_init()
5212 G_FW_HDR_FW_VER_MICRO(sc->params.fw_vers), in get_params__pre_init()
5213 G_FW_HDR_FW_VER_BUILD(sc->params.fw_vers)); in get_params__pre_init()
5215 snprintf(sc->bs_version, sizeof(sc->bs_version), "%u.%u.%u.%u", in get_params__pre_init()
5216 G_FW_HDR_FW_VER_MAJOR(sc->params.bs_vers), in get_params__pre_init()
5217 G_FW_HDR_FW_VER_MINOR(sc->params.bs_vers), in get_params__pre_init()
5218 G_FW_HDR_FW_VER_MICRO(sc->params.bs_vers), in get_params__pre_init()
5219 G_FW_HDR_FW_VER_BUILD(sc->params.bs_vers)); in get_params__pre_init()
5221 snprintf(sc->tp_version, sizeof(sc->tp_version), "%u.%u.%u.%u", in get_params__pre_init()
5222 G_FW_HDR_FW_VER_MAJOR(sc->params.tp_vers), in get_params__pre_init()
5223 G_FW_HDR_FW_VER_MINOR(sc->params.tp_vers), in get_params__pre_init()
5224 G_FW_HDR_FW_VER_MICRO(sc->params.tp_vers), in get_params__pre_init()
5225 G_FW_HDR_FW_VER_BUILD(sc->params.tp_vers)); in get_params__pre_init()
5227 snprintf(sc->er_version, sizeof(sc->er_version), "%u.%u.%u.%u", in get_params__pre_init()
5228 G_FW_HDR_FW_VER_MAJOR(sc->params.er_vers), in get_params__pre_init()
5229 G_FW_HDR_FW_VER_MINOR(sc->params.er_vers), in get_params__pre_init()
5230 G_FW_HDR_FW_VER_MICRO(sc->params.er_vers), in get_params__pre_init()
5231 G_FW_HDR_FW_VER_BUILD(sc->params.er_vers)); in get_params__pre_init()
5235 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 2, param, val); in get_params__pre_init()
5237 device_printf(sc->dev, in get_params__pre_init()
5242 sc->params.portvec = val[0]; in get_params__pre_init()
5243 sc->params.nports = bitcount32(val[0]); in get_params__pre_init()
5244 sc->params.vpd.cclk = val[1]; in get_params__pre_init()
5247 rc = -t4_init_devlog_params(sc, 1); in get_params__pre_init()
5251 device_printf(sc->dev, in get_params__pre_init()
5271 rc = -t4_set_params(sc, sc->mbox, sc->pf, 0, 1, &param, &val); in set_params__pre_init()
5274 sc->params.fw_vers < FW_VERSION32(1, 20, 1, 0)) { in set_params__pre_init()
5278 device_printf(sc->dev, in set_params__pre_init()
5284 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, &param, &val); in set_params__pre_init()
5286 rc = -t4_set_params(sc, sc->mbox, sc->pf, 0, 1, &param, in set_params__pre_init()
5289 device_printf(sc->dev, in set_params__pre_init()
5298 rc = -t4_set_params(sc, sc->mbox, sc->pf, 0, 1, &param, &val); in set_params__pre_init()
5300 sc->params.viid_smt_extn_support = true; in set_params__pre_init()
5302 sc->params.viid_smt_extn_support = false; in set_params__pre_init()
5327 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 7, param, val); in get_params__post_init()
5329 device_printf(sc->dev, in get_params__post_init()
5334 sc->sge.iq_start = val[0]; in get_params__post_init()
5335 sc->sge.eq_start = val[1]; in get_params__post_init()
5337 sc->tids.ftid_base = val[2]; in get_params__post_init()
5338 sc->tids.ftid_end = val[3]; in get_params__post_init()
5339 sc->tids.nftids = val[3] - val[2] + 1; in get_params__post_init()
5341 sc->vres.l2t.start = val[4]; in get_params__post_init()
5342 sc->vres.l2t.size = val[5] - val[4] + 1; in get_params__post_init()
5344 if (sc->vres.l2t.size > 0) in get_params__post_init()
5346 sc->params.core_vdd = val[6]; in get_params__post_init()
5350 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 2, param, val); in get_params__post_init()
5352 device_printf(sc->dev, in get_params__post_init()
5356 MPASS((int)val[0] >= sc->sge.iq_start); in get_params__post_init()
5357 sc->sge.iqmap_sz = val[0] - sc->sge.iq_start + 1; in get_params__post_init()
5358 MPASS((int)val[1] >= sc->sge.eq_start); in get_params__post_init()
5359 sc->sge.eqmap_sz = val[1] - sc->sge.eq_start + 1; in get_params__post_init()
5363 sc->tids.tid_base = t4_read_reg(sc, in get_params__post_init()
5368 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 2, param, val); in get_params__post_init()
5370 device_printf(sc->dev, in get_params__post_init()
5375 sc->tids.hpftid_base = val[0]; in get_params__post_init()
5376 sc->tids.hpftid_end = val[1]; in get_params__post_init()
5377 sc->tids.nhpftids = val[1] - val[0] + 1; in get_params__post_init()
5383 MPASS(sc->tids.hpftid_base == 0); in get_params__post_init()
5384 MPASS(sc->tids.tid_base == sc->tids.nhpftids); in get_params__post_init()
5389 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 2, param, val); in get_params__post_init()
5391 device_printf(sc->dev, in get_params__post_init()
5396 sc->rawf_base = val[0]; in get_params__post_init()
5397 sc->nrawf = val[1] - val[0] + 1; in get_params__post_init()
5412 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, param, val); in get_params__post_init()
5414 sc->params.mps_bg_map = val[0]; in get_params__post_init()
5416 sc->params.mps_bg_map = UINT32_MAX; /* Not a legal value. */ in get_params__post_init()
5420 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, param, val); in get_params__post_init()
5422 sc->params.tp_ch_map = val[0]; in get_params__post_init()
5424 sc->params.tp_ch_map = UINT32_MAX; /* Not a legal value. */ in get_params__post_init()
5431 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, param, val); in get_params__post_init()
5433 sc->params.filter2_wr_support = val[0] != 0; in get_params__post_init()
5435 sc->params.filter2_wr_support = 0; in get_params__post_init()
5442 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, param, val); in get_params__post_init()
5444 sc->params.ulptx_memwrite_dsgl = val[0] != 0; in get_params__post_init()
5446 sc->params.ulptx_memwrite_dsgl = false; in get_params__post_init()
5450 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, param, val); in get_params__post_init()
5452 sc->params.fr_nsmr_tpte_wr_support = val[0] != 0; in get_params__post_init()
5454 sc->params.fr_nsmr_tpte_wr_support = false; in get_params__post_init()
5458 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, param, val); in get_params__post_init()
5460 sc->params.dev_512sgl_mr = val[0] != 0; in get_params__post_init()
5462 sc->params.dev_512sgl_mr = false; in get_params__post_init()
5465 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, param, val); in get_params__post_init()
5467 sc->params.max_pkts_per_eth_tx_pkts_wr = val[0]; in get_params__post_init()
5469 sc->params.max_pkts_per_eth_tx_pkts_wr = 15; in get_params__post_init()
5472 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, param, val); in get_params__post_init()
5475 sc->params.nsched_cls = val[0]; in get_params__post_init()
5477 sc->params.nsched_cls = sc->chip_params->nsched_cls; in get_params__post_init()
5484 rc = -t4_wr_mbox(sc, sc->mbox, &caps, sizeof(caps), &caps); in get_params__post_init()
5486 device_printf(sc->dev, in get_params__post_init()
5492 sc->x = htobe16(caps.x); \ in get_params__post_init()
5504 if (sc->niccaps & FW_CAPS_CONFIG_NIC_HASHFILTER) { in get_params__post_init()
5506 MPASS(sc->toecaps == 0); in get_params__post_init()
5507 sc->toecaps = 0; in get_params__post_init()
5510 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, param, val); in get_params__post_init()
5512 device_printf(sc->dev, in get_params__post_init()
5516 sc->tids.ntids = val[0]; in get_params__post_init()
5517 if (sc->params.fw_vers < FW_VERSION32(1, 20, 5, 0)) { in get_params__post_init()
5518 MPASS(sc->tids.ntids >= sc->tids.nhpftids); in get_params__post_init()
5519 sc->tids.ntids -= sc->tids.nhpftids; in get_params__post_init()
5521 sc->tids.natids = min(sc->tids.ntids / 2, MAX_ATIDS); in get_params__post_init()
5522 sc->params.hash_filter = 1; in get_params__post_init()
5524 if (sc->niccaps & FW_CAPS_CONFIG_NIC_ETHOFLD) { in get_params__post_init()
5528 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 3, param, val); in get_params__post_init()
5530 device_printf(sc->dev, in get_params__post_init()
5535 sc->tids.etid_base = val[0]; in get_params__post_init()
5536 sc->tids.etid_end = val[1]; in get_params__post_init()
5537 sc->tids.netids = val[1] - val[0] + 1; in get_params__post_init()
5538 sc->params.eo_wr_cred = val[2]; in get_params__post_init()
5539 sc->params.ethoffload = 1; in get_params__post_init()
5542 if (sc->toecaps) { in get_params__post_init()
5543 /* query offload-related parameters */ in get_params__post_init()
5550 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 6, param, val); in get_params__post_init()
5552 device_printf(sc->dev, in get_params__post_init()
5556 sc->tids.ntids = val[0]; in get_params__post_init()
5557 if (sc->params.fw_vers < FW_VERSION32(1, 20, 5, 0)) { in get_params__post_init()
5558 MPASS(sc->tids.ntids >= sc->tids.nhpftids); in get_params__post_init()
5559 sc->tids.ntids -= sc->tids.nhpftids; in get_params__post_init()
5561 sc->tids.natids = min(sc->tids.ntids / 2, MAX_ATIDS); in get_params__post_init()
5563 sc->tids.stid_base = val[1]; in get_params__post_init()
5564 sc->tids.nstids = val[2] - val[1] + 1; in get_params__post_init()
5566 sc->vres.ddp.start = val[3]; in get_params__post_init()
5567 sc->vres.ddp.size = val[4] - val[3] + 1; in get_params__post_init()
5568 sc->params.ofldq_wr_cred = val[5]; in get_params__post_init()
5569 sc->params.offload = 1; in get_params__post_init()
5572 * The firmware attempts memfree TOE configuration for -SO cards in get_params__post_init()
5579 sc->iscsicaps = 0; in get_params__post_init()
5580 sc->rdmacaps = 0; in get_params__post_init()
5582 if (sc->rdmacaps) { in get_params__post_init()
5589 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 6, param, val); in get_params__post_init()
5591 device_printf(sc->dev, in get_params__post_init()
5595 sc->vres.stag.start = val[0]; in get_params__post_init()
5596 sc->vres.stag.size = val[1] - val[0] + 1; in get_params__post_init()
5597 sc->vres.rq.start = val[2]; in get_params__post_init()
5598 sc->vres.rq.size = val[3] - val[2] + 1; in get_params__post_init()
5599 sc->vres.pbl.start = val[4]; in get_params__post_init()
5600 sc->vres.pbl.size = val[5] - val[4] + 1; in get_params__post_init()
5608 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 6, param, val); in get_params__post_init()
5610 device_printf(sc->dev, in get_params__post_init()
5614 sc->vres.qp.start = val[0]; in get_params__post_init()
5615 sc->vres.qp.size = val[1] - val[0] + 1; in get_params__post_init()
5616 sc->vres.cq.start = val[2]; in get_params__post_init()
5617 sc->vres.cq.size = val[3] - val[2] + 1; in get_params__post_init()
5618 sc->vres.ocq.start = val[4]; in get_params__post_init()
5619 sc->vres.ocq.size = val[5] - val[4] + 1; in get_params__post_init()
5625 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 4, param, val); in get_params__post_init()
5627 device_printf(sc->dev, in get_params__post_init()
5631 sc->vres.srq.start = val[0]; in get_params__post_init()
5632 sc->vres.srq.size = val[1] - val[0] + 1; in get_params__post_init()
5633 sc->params.max_ordird_qp = val[2]; in get_params__post_init()
5634 sc->params.max_ird_adapter = val[3]; in get_params__post_init()
5636 if (sc->iscsicaps) { in get_params__post_init()
5639 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 2, param, val); in get_params__post_init()
5641 device_printf(sc->dev, in get_params__post_init()
5645 sc->vres.iscsi.start = val[0]; in get_params__post_init()
5646 sc->vres.iscsi.size = val[1] - val[0] + 1; in get_params__post_init()
5648 if (sc->cryptocaps & FW_CAPS_CONFIG_TLSKEYS) { in get_params__post_init()
5651 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 2, param, val); in get_params__post_init()
5653 device_printf(sc->dev, in get_params__post_init()
5657 sc->vres.key.start = val[0]; in get_params__post_init()
5658 sc->vres.key.size = val[1] - val[0] + 1; in get_params__post_init()
5667 t4_read_mtu_tbl(sc, sc->params.mtus, NULL); in get_params__post_init()
5668 t4_load_mtus(sc, sc->params.mtus, sc->params.a_wnd, sc->params.b_wnd); in get_params__post_init()
5689 callout_schedule_sbt(&sc->ktls_tick, SBT_1MS, 0, C_HARDCLOCK); in ktls_tick()
5701 rc = -t4_set_params(sc, sc->mbox, sc->pf, 0, 1, &param, &param); in t6_config_kern_tls()
5709 sc->flags |= KERN_TLS_ON; in t6_config_kern_tls()
5710 callout_reset_sbt(&sc->ktls_tick, SBT_1MS, 0, ktls_tick, sc, in t6_config_kern_tls()
5713 sc->flags &= ~KERN_TLS_ON; in t6_config_kern_tls()
5714 callout_stop(&sc->ktls_tick); in t6_config_kern_tls()
5732 (void)t4_set_params(sc, sc->mbox, sc->pf, 0, 1, &param, &val); in set_params__post_init()
5737 if (t4_set_params(sc, sc->mbox, sc->pf, 0, 1, &param, &val) == 0) in set_params__post_init()
5738 sc->params.port_caps32 = 1; in set_params__post_init()
5741 val = 1 << (G_MASKSIZE(t4_read_reg(sc, A_TP_RSS_CONFIG_TNL)) - 1); in set_params__post_init()
5743 V_MASKFILTER(val - 1)); in set_params__post_init()
5819 if (t4_toe_rexmt_backoff[i] != -1) { in set_params__post_init()
5838 sc->tlst.inline_keys = t4_tls_inline_keys; in set_params__post_init()
5839 sc->tlst.combo_wrs = t4_tls_combo_wrs; in set_params__post_init()
5853 struct adapter_params *p = &sc->params; in t4_set_desc()
5855 device_set_descf(sc->dev, "Chelsio %s", p->vpd.id); in t4_set_desc()
5884 ifm = &pi->media; in set_current_media()
5885 if (ifm->ifm_cur != NULL && in set_current_media()
5886 IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_NONE) in set_current_media()
5889 lc = &pi->link_cfg; in set_current_media()
5890 if (lc->requested_aneg != AUTONEG_DISABLE && in set_current_media()
5891 lc->pcaps & FW_PORT_CAP32_ANEG) { in set_current_media()
5896 if (lc->requested_fc & PAUSE_TX) in set_current_media()
5898 if (lc->requested_fc & PAUSE_RX) in set_current_media()
5900 if (lc->requested_speed == 0) in set_current_media()
5901 speed = port_top_speed(pi) * 1000; /* Gbps -> Mbps */ in set_current_media()
5903 speed = lc->requested_speed; in set_current_media()
5915 return (pi->port_type == FW_PORT_TYPE_BT_SGMII || in fixed_ifmedia()
5916 pi->port_type == FW_PORT_TYPE_BT_XFI || in fixed_ifmedia()
5917 pi->port_type == FW_PORT_TYPE_BT_XAUI || in fixed_ifmedia()
5918 pi->port_type == FW_PORT_TYPE_KX4 || in fixed_ifmedia()
5919 pi->port_type == FW_PORT_TYPE_KX || in fixed_ifmedia()
5920 pi->port_type == FW_PORT_TYPE_KR || in fixed_ifmedia()
5921 pi->port_type == FW_PORT_TYPE_BP_AP || in fixed_ifmedia()
5922 pi->port_type == FW_PORT_TYPE_BP4_AP || in fixed_ifmedia()
5923 pi->port_type == FW_PORT_TYPE_BP40_BA || in fixed_ifmedia()
5924 pi->port_type == FW_PORT_TYPE_KR4_100G || in fixed_ifmedia()
5925 pi->port_type == FW_PORT_TYPE_KR_SFP28 || in fixed_ifmedia()
5926 pi->port_type == FW_PORT_TYPE_KR_XLAUI); in fixed_ifmedia()
5939 if (pi->flags & FIXED_IFMEDIA) in build_medialist()
5945 ifm = &pi->media; in build_medialist()
5947 lc = &pi->link_cfg; in build_medialist()
5948 ss = G_FW_PORT_CAP32_SPEED(lc->pcaps); /* Supported Speeds */ in build_medialist()
5952 MPASS(LIST_EMPTY(&ifm->ifm_list)); in build_medialist()
5974 if (lc->pcaps & FW_PORT_CAP32_ANEG) in build_medialist()
5986 struct link_config *lc = &pi->link_cfg; in init_link_config()
5990 lc->requested_caps = 0; in init_link_config()
5991 lc->requested_speed = 0; in init_link_config()
5994 lc->requested_aneg = AUTONEG_DISABLE; in init_link_config()
5996 lc->requested_aneg = AUTONEG_ENABLE; in init_link_config()
5998 lc->requested_aneg = AUTONEG_AUTO; in init_link_config()
6000 lc->requested_fc = t4_pause_settings & (PAUSE_TX | PAUSE_RX | in init_link_config()
6004 lc->requested_fec = FEC_AUTO; in init_link_config()
6006 lc->requested_fec = FEC_NONE; in init_link_config()
6008 /* -1 is handled by the FEC_AUTO block above and not here. */ in init_link_config()
6009 lc->requested_fec = t4_fec & in init_link_config()
6011 if (lc->requested_fec == 0) in init_link_config()
6012 lc->requested_fec = FEC_AUTO; in init_link_config()
6015 lc->force_fec = -1; in init_link_config()
6017 lc->force_fec = 1; in init_link_config()
6019 lc->force_fec = 0; in init_link_config()
6030 struct link_config *lc = &pi->link_cfg; in fixup_link_config()
6036 if (lc->requested_speed != 0) { in fixup_link_config()
6037 fwspeed = speed_to_fwcap(lc->requested_speed); in fixup_link_config()
6038 if ((fwspeed & lc->pcaps) == 0) { in fixup_link_config()
6040 lc->requested_speed = 0; in fixup_link_config()
6045 MPASS(lc->requested_aneg == AUTONEG_ENABLE || in fixup_link_config()
6046 lc->requested_aneg == AUTONEG_DISABLE || in fixup_link_config()
6047 lc->requested_aneg == AUTONEG_AUTO); in fixup_link_config()
6048 if (lc->requested_aneg == AUTONEG_ENABLE && in fixup_link_config()
6049 !(lc->pcaps & FW_PORT_CAP32_ANEG)) { in fixup_link_config()
6051 lc->requested_aneg = AUTONEG_AUTO; in fixup_link_config()
6055 MPASS((lc->requested_fc & ~(PAUSE_TX | PAUSE_RX | PAUSE_AUTONEG)) == 0); in fixup_link_config()
6056 if (lc->requested_fc & PAUSE_TX && in fixup_link_config()
6057 !(lc->pcaps & FW_PORT_CAP32_FC_TX)) { in fixup_link_config()
6059 lc->requested_fc &= ~PAUSE_TX; in fixup_link_config()
6061 if (lc->requested_fc & PAUSE_RX && in fixup_link_config()
6062 !(lc->pcaps & FW_PORT_CAP32_FC_RX)) { in fixup_link_config()
6064 lc->requested_fc &= ~PAUSE_RX; in fixup_link_config()
6066 if (!(lc->requested_fc & PAUSE_AUTONEG) && in fixup_link_config()
6067 !(lc->pcaps & FW_PORT_CAP32_FORCE_PAUSE)) { in fixup_link_config()
6069 lc->requested_fc |= PAUSE_AUTONEG; in fixup_link_config()
6073 if ((lc->requested_fec & FEC_RS && in fixup_link_config()
6074 !(lc->pcaps & FW_PORT_CAP32_FEC_RS)) || in fixup_link_config()
6075 (lc->requested_fec & FEC_BASER_RS && in fixup_link_config()
6076 !(lc->pcaps & FW_PORT_CAP32_FEC_BASER_RS))) { in fixup_link_config()
6078 lc->requested_fec = FEC_AUTO; in fixup_link_config()
6091 struct adapter *sc = pi->adapter; in apply_link_config()
6092 struct link_config *lc = &pi->link_cfg; in apply_link_config()
6099 if (lc->requested_aneg == AUTONEG_ENABLE) in apply_link_config()
6100 MPASS(lc->pcaps & FW_PORT_CAP32_ANEG); in apply_link_config()
6101 if (!(lc->requested_fc & PAUSE_AUTONEG)) in apply_link_config()
6102 MPASS(lc->pcaps & FW_PORT_CAP32_FORCE_PAUSE); in apply_link_config()
6103 if (lc->requested_fc & PAUSE_TX) in apply_link_config()
6104 MPASS(lc->pcaps & FW_PORT_CAP32_FC_TX); in apply_link_config()
6105 if (lc->requested_fc & PAUSE_RX) in apply_link_config()
6106 MPASS(lc->pcaps & FW_PORT_CAP32_FC_RX); in apply_link_config()
6107 if (lc->requested_fec & FEC_RS) in apply_link_config()
6108 MPASS(lc->pcaps & FW_PORT_CAP32_FEC_RS); in apply_link_config()
6109 if (lc->requested_fec & FEC_BASER_RS) in apply_link_config()
6110 MPASS(lc->pcaps & FW_PORT_CAP32_FEC_BASER_RS); in apply_link_config()
6112 if (!(sc->flags & IS_VF)) { in apply_link_config()
6113 rc = -t4_link_l1cfg(sc, sc->mbox, pi->tx_chan, lc); in apply_link_config()
6115 device_printf(pi->dev, "l1cfg failed: %d\n", rc); in apply_link_config()
6121 * An L1_CFG will almost always result in a link-change event if the in apply_link_config()
6129 if (lc->link_ok && !(lc->requested_fc & PAUSE_AUTONEG)) in apply_link_config()
6130 lc->fc = lc->requested_fc & (PAUSE_TX | PAUSE_RX); in apply_link_config()
6149 struct vi_info *vi = if_getsoftc(ctx->ifp); in add_maddr()
6150 struct port_info *pi = vi->pi; in add_maddr()
6151 struct adapter *sc = pi->adapter; in add_maddr()
6153 if (ctx->rc < 0) in add_maddr()
6156 ctx->mcaddr[ctx->i] = LLADDR(sdl); in add_maddr()
6157 MPASS(ETHER_IS_MULTICAST(ctx->mcaddr[ctx->i])); in add_maddr()
6158 ctx->i++; in add_maddr()
6160 if (ctx->i == FW_MAC_EXACT_CHUNK) { in add_maddr()
6161 ctx->rc = t4_alloc_mac_filt(sc, sc->mbox, vi->viid, ctx->del, in add_maddr()
6162 ctx->i, ctx->mcaddr, NULL, &ctx->hash, 0); in add_maddr()
6163 if (ctx->rc < 0) { in add_maddr()
6166 for (j = 0; j < ctx->i; j++) { in add_maddr()
6167 if_printf(ctx->ifp, in add_maddr()
6171 ctx->mcaddr[j][0], ctx->mcaddr[j][1], in add_maddr()
6172 ctx->mcaddr[j][2], ctx->mcaddr[j][3], in add_maddr()
6173 ctx->mcaddr[j][4], ctx->mcaddr[j][5], in add_maddr()
6174 -ctx->rc); in add_maddr()
6178 ctx->del = 0; in add_maddr()
6179 ctx->i = 0; in add_maddr()
6194 struct port_info *pi = vi->pi; in update_mac_settings()
6195 struct adapter *sc = pi->adapter; in update_mac_settings()
6196 int mtu = -1, promisc = -1, allmulti = -1, vlanex = -1; in update_mac_settings()
6215 rc = -t4_set_rxmode(sc, sc->mbox, vi->viid, mtu, promisc, in update_mac_settings()
6228 rc = t4_change_mac(sc, sc->mbox, vi->viid, vi->xact_addr_filt, in update_mac_settings()
6229 ucaddr, true, &vi->smt_idx); in update_mac_settings()
6231 rc = -rc; in update_mac_settings()
6235 vi->xact_addr_filt = rc; in update_mac_settings()
6260 rc = -ctx.rc; in update_mac_settings()
6264 rc = t4_alloc_mac_filt(sc, sc->mbox, vi->viid, in update_mac_settings()
6268 rc = -rc; in update_mac_settings()
6285 rc = -t4_set_addr_hash(sc, sc->mbox, vi->viid, 0, ctx.hash, 0); in update_mac_settings()
6291 pi->vxlan_tcam_entry = false; in update_mac_settings()
6295 if (IS_MAIN_VI(vi) && sc->vxlan_refcount > 0 && in update_mac_settings()
6296 pi->vxlan_tcam_entry == false) { in update_mac_settings()
6297 rc = t4_alloc_raw_mac_filt(sc, vi->viid, match_all_mac, in update_mac_settings()
6298 match_all_mac, sc->rawf_base + pi->port_id, 1, pi->port_id, in update_mac_settings()
6301 rc = -rc; in update_mac_settings()
6305 MPASS(rc == sc->rawf_base + pi->port_id); in update_mac_settings()
6307 pi->vxlan_tcam_entry = true; in update_mac_settings()
6353 if (mtx_sleep(&sc->flags, &sc->sc_lock, pri, wmesg, 0)) { in begin_synchronized_op()
6362 sc->last_op = wmesg; in begin_synchronized_op()
6363 sc->last_op_thr = curthread; in begin_synchronized_op()
6364 sc->last_op_flags = flags; in begin_synchronized_op()
6384 wakeup(&sc->flags); in begin_vi_detach()
6386 mtx_sleep(&sc->flags, &sc->sc_lock, 0, "t4detach", 0); in begin_vi_detach()
6389 sc->last_op = "t4detach"; in begin_vi_detach()
6390 sc->last_op_thr = curthread; in begin_vi_detach()
6391 sc->last_op_flags = 0; in begin_vi_detach()
6403 wakeup(&sc->flags); in end_vi_detach()
6421 wakeup(&sc->flags); in end_synchronized_op()
6428 struct port_info *pi = vi->pi; in cxgbe_init_synchronized()
6429 struct adapter *sc = pi->adapter; in cxgbe_init_synchronized()
6430 if_t ifp = vi->ifp; in cxgbe_init_synchronized()
6439 if (!(sc->flags & FULL_INIT_DONE) && ((rc = adapter_init(sc)) != 0)) in cxgbe_init_synchronized()
6442 if (!(vi->flags & VI_INIT_DONE) && ((rc = vi_init(vi)) != 0)) in cxgbe_init_synchronized()
6450 if (pi->up_vis == 0) { in cxgbe_init_synchronized()
6457 rc = -t4_enable_vi(sc, sc->mbox, vi->viid, true, true); in cxgbe_init_synchronized()
6471 txq->eq.flags |= EQ_ENABLED; in cxgbe_init_synchronized()
6478 if (sc->traceq < 0 && IS_MAIN_VI(vi)) { in cxgbe_init_synchronized()
6479 sc->traceq = sc->sge.rxq[vi->first_rxq].iq.abs_id; in cxgbe_init_synchronized()
6481 A_MPS_T5_TRC_RSS_CONTROL, V_RSSCONTROL(pi->tx_chan) | in cxgbe_init_synchronized()
6482 V_QUEUENUMBER(sc->traceq)); in cxgbe_init_synchronized()
6483 pi->flags |= HAS_TRACEQ; in cxgbe_init_synchronized()
6487 pi->up_vis++; in cxgbe_init_synchronized()
6489 if (pi->link_cfg.link_ok) in cxgbe_init_synchronized()
6493 mtx_lock(&vi->tick_mtx); in cxgbe_init_synchronized()
6494 if (vi->pi->nvi > 1 || sc->flags & IS_VF) in cxgbe_init_synchronized()
6495 callout_reset(&vi->tick, hz, vi_tick, vi); in cxgbe_init_synchronized()
6497 callout_reset(&vi->tick, hz, cxgbe_tick, vi); in cxgbe_init_synchronized()
6498 mtx_unlock(&vi->tick_mtx); in cxgbe_init_synchronized()
6512 struct port_info *pi = vi->pi; in cxgbe_uninit_synchronized()
6513 struct adapter *sc = pi->adapter; in cxgbe_uninit_synchronized()
6514 if_t ifp = vi->ifp; in cxgbe_uninit_synchronized()
6520 if (!(vi->flags & VI_INIT_DONE)) { in cxgbe_uninit_synchronized()
6524 "vi->flags 0x%016lx, if_flags 0x%08x, " in cxgbe_uninit_synchronized()
6525 "if_drv_flags 0x%08x\n", vi->flags, if_getflags(ifp), in cxgbe_uninit_synchronized()
6538 rc = -t4_enable_vi(sc, sc->mbox, vi->viid, false, false); in cxgbe_uninit_synchronized()
6546 txq->eq.flags &= ~EQ_ENABLED; in cxgbe_uninit_synchronized()
6550 mtx_lock(&vi->tick_mtx); in cxgbe_uninit_synchronized()
6551 callout_stop(&vi->tick); in cxgbe_uninit_synchronized()
6552 mtx_unlock(&vi->tick_mtx); in cxgbe_uninit_synchronized()
6560 pi->up_vis--; in cxgbe_uninit_synchronized()
6561 if (pi->up_vis > 0) { in cxgbe_uninit_synchronized()
6566 pi->link_cfg.link_ok = false; in cxgbe_uninit_synchronized()
6567 pi->link_cfg.speed = 0; in cxgbe_uninit_synchronized()
6568 pi->link_cfg.link_down_rc = 255; in cxgbe_uninit_synchronized()
6577 * will walk the entire sc->irq list and clean up whatever is valid.
6587 struct sge *sge = &sc->sge; in t4_setup_intr_handlers()
6602 irq = &sc->irq[0]; in t4_setup_intr_handlers()
6603 rid = sc->intr_type == INTR_INTX ? 0 : 1; in t4_setup_intr_handlers()
6608 if (sc->flags & IS_VF) in t4_setup_intr_handlers()
6609 KASSERT(sc->intr_count >= T4VF_EXTRA_INTR + sc->params.nports, in t4_setup_intr_handlers()
6612 KASSERT(sc->intr_count >= T4_EXTRA_INTR + sc->params.nports, in t4_setup_intr_handlers()
6616 if (!(sc->flags & IS_VF)) { in t4_setup_intr_handlers()
6625 rc = t4_alloc_irq(sc, irq, rid, t4_intr_evt, &sge->fwq, "evt"); in t4_setup_intr_handlers()
6632 pi = sc->port[p]; in t4_setup_intr_handlers()
6634 vi->first_intr = rid - 1; in t4_setup_intr_handlers()
6636 if (vi->nnmrxq > 0) { in t4_setup_intr_handlers()
6637 int n = max(vi->nrxq, vi->nnmrxq); in t4_setup_intr_handlers()
6639 rxq = &sge->rxq[vi->first_rxq]; in t4_setup_intr_handlers()
6641 nm_rxq = &sge->nm_rxq[vi->first_nm_rxq]; in t4_setup_intr_handlers()
6646 if (q < vi->nrxq) in t4_setup_intr_handlers()
6647 irq->rxq = rxq++; in t4_setup_intr_handlers()
6649 if (q < vi->nnmrxq) in t4_setup_intr_handlers()
6650 irq->nm_rxq = nm_rxq++; in t4_setup_intr_handlers()
6652 if (irq->nm_rxq != NULL && in t4_setup_intr_handlers()
6653 irq->rxq == NULL) { in t4_setup_intr_handlers()
6656 t4_nm_intr, irq->nm_rxq, s); in t4_setup_intr_handlers()
6658 if (irq->nm_rxq != NULL && in t4_setup_intr_handlers()
6659 irq->rxq != NULL) { in t4_setup_intr_handlers()
6665 if (irq->rxq != NULL && in t4_setup_intr_handlers()
6666 irq->nm_rxq == NULL) { in t4_setup_intr_handlers()
6669 t4_intr, irq->rxq, s); in t4_setup_intr_handlers()
6674 if (q < vi->nrxq) { in t4_setup_intr_handlers()
6675 bus_bind_intr(sc->dev, irq->res, in t4_setup_intr_handlers()
6681 vi->nintr++; in t4_setup_intr_handlers()
6692 bus_bind_intr(sc->dev, irq->res, in t4_setup_intr_handlers()
6697 vi->nintr++; in t4_setup_intr_handlers()
6709 vi->nintr++; in t4_setup_intr_handlers()
6714 MPASS(irq == &sc->irq[sc->intr_count]); in t4_setup_intr_handlers()
6731 rss_key[i] = htobe32(raw_rss_key[nitems(rss_key) - 1 - i]); in write_global_rss_key()
6733 t4_write_rss_key(sc, &rss_key[0], -1, 1); in write_global_rss_key()
6754 MPASS(sc->params.nports <= nitems(sc->tq)); in adapter_full_init()
6755 for (i = 0; i < sc->params.nports; i++) { in adapter_full_init()
6756 if (sc->tq[i] != NULL) in adapter_full_init()
6758 sc->tq[i] = taskqueue_create("t4 taskq", M_NOWAIT, in adapter_full_init()
6759 taskqueue_thread_enqueue, &sc->tq[i]); in adapter_full_init()
6760 if (sc->tq[i] == NULL) { in adapter_full_init()
6764 taskqueue_start_threads(&sc->tq[i], 1, PI_NET, "%s tq%d", in adapter_full_init()
6765 device_get_nameunit(sc->dev), i); in adapter_full_init()
6768 if (!(sc->flags & IS_VF)) { in adapter_full_init()
6782 KASSERT((sc->flags & FULL_INIT_DONE) == 0, in adapter_init()
6789 sc->flags |= FULL_INIT_DONE; in adapter_init()
6804 for (i = 0; i < nitems(sc->tq); i++) { in adapter_full_uninit()
6805 if (sc->tq[i] == NULL) in adapter_full_uninit()
6807 taskqueue_free(sc->tq[i]); in adapter_full_uninit()
6808 sc->tq[i] = NULL; in adapter_full_uninit()
6811 sc->flags &= ~FULL_INIT_DONE; in adapter_full_uninit()
6856 * enabling any 4-tuple hash is nonsense configuration. in hashen_to_hashconfig()
6885 struct adapter *sc = vi->adapter; in vi_full_init()
6906 if (vi->nrxq > vi->rss_size) { in vi_full_init()
6908 "some queues will never receive traffic.\n", vi->nrxq, in vi_full_init()
6909 vi->rss_size); in vi_full_init()
6910 } else if (vi->rss_size % vi->nrxq) { in vi_full_init()
6912 "expect uneven traffic distribution.\n", vi->nrxq, in vi_full_init()
6913 vi->rss_size); in vi_full_init()
6916 if (vi->nrxq != nbuckets) { in vi_full_init()
6918 "performance will be impacted.\n", vi->nrxq, nbuckets); in vi_full_init()
6921 if (vi->rss == NULL) in vi_full_init()
6922 vi->rss = malloc(vi->rss_size * sizeof (*vi->rss), M_CXGBE, in vi_full_init()
6924 for (i = 0; i < vi->rss_size;) { in vi_full_init()
6927 j %= vi->nrxq; in vi_full_init()
6928 rxq = &sc->sge.rxq[vi->first_rxq + j]; in vi_full_init()
6929 vi->rss[i++] = rxq->iq.abs_id; in vi_full_init()
6932 vi->rss[i++] = rxq->iq.abs_id; in vi_full_init()
6933 if (i == vi->rss_size) in vi_full_init()
6939 rc = -t4_config_rss_range(sc, sc->mbox, vi->viid, 0, vi->rss_size, in vi_full_init()
6940 vi->rss, vi->rss_size); in vi_full_init()
6947 vi->hashen = hashconfig_to_hashen(hashconfig); in vi_full_init()
6954 extra = hashen_to_hashconfig(vi->hashen) ^ hashconfig; in vi_full_init()
6971 CH_ALERT(vi, "IPv4 2-tuple hashing forced on.\n"); in vi_full_init()
6973 CH_ALERT(vi, "TCP/IPv4 4-tuple hashing forced on.\n"); in vi_full_init()
6975 CH_ALERT(vi, "IPv6 2-tuple hashing forced on.\n"); in vi_full_init()
6977 CH_ALERT(vi, "TCP/IPv6 4-tuple hashing forced on.\n"); in vi_full_init()
6979 CH_ALERT(vi, "UDP/IPv4 4-tuple hashing forced on.\n"); in vi_full_init()
6981 CH_ALERT(vi, "UDP/IPv6 4-tuple hashing forced on.\n"); in vi_full_init()
6983 vi->hashen = F_FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN | in vi_full_init()
6988 rc = -t4_config_vi_rss(sc, sc->mbox, vi->viid, vi->hashen, vi->rss[0], in vi_full_init()
7003 ASSERT_SYNCHRONIZED_OP(vi->adapter); in vi_init()
7004 KASSERT((vi->flags & VI_INIT_DONE) == 0, in vi_init()
7011 vi->flags |= VI_INIT_DONE; in vi_init()
7023 if (vi->flags & VI_INIT_DONE) { in vi_full_uninit()
7025 free(vi->rss, M_CXGBE); in vi_full_uninit()
7026 free(vi->nm_rss, M_CXGBE); in vi_full_uninit()
7030 vi->flags &= ~VI_INIT_DONE; in vi_full_uninit()
7036 struct sge_eq *eq = &txq->eq; in quiesce_txq()
7037 struct sge_qstat *spg = (void *)&eq->desc[eq->sidx]; in quiesce_txq()
7039 MPASS(eq->flags & EQ_SW_ALLOCATED); in quiesce_txq()
7040 MPASS(!(eq->flags & EQ_ENABLED)); in quiesce_txq()
7043 while (!mp_ring_is_idle(txq->r)) { in quiesce_txq()
7044 mp_ring_check_drainage(txq->r, 4096); in quiesce_txq()
7047 MPASS(txq->txp.npkt == 0); in quiesce_txq()
7049 if (eq->flags & EQ_HW_ALLOCATED) { in quiesce_txq()
7055 while (spg->cidx != htobe16(eq->pidx)) in quiesce_txq()
7057 while (eq->cidx != eq->pidx) in quiesce_txq()
7065 while (eq->cidx != eq->pidx) { in quiesce_txq()
7069 txsd = &txq->sdesc[eq->cidx]; in quiesce_txq()
7070 for (m = txsd->m; m != NULL; m = nextpkt) { in quiesce_txq()
7071 nextpkt = m->m_nextpkt; in quiesce_txq()
7072 m->m_nextpkt = NULL; in quiesce_txq()
7075 IDXINCR(eq->cidx, txsd->desc_used, eq->sidx); in quiesce_txq()
7077 spg->pidx = spg->cidx = htobe16(eq->cidx); in quiesce_txq()
7088 while ((wr = STAILQ_FIRST(&wrq->wr_list)) != NULL) { in quiesce_wrq()
7089 STAILQ_REMOVE_HEAD(&wrq->wr_list, link); in quiesce_wrq()
7091 wrq->nwr_pending--; in quiesce_wrq()
7092 wrq->ndesc_needed -= howmany(wr->wr_len, EQ_ESIZE); in quiesce_wrq()
7096 MPASS(wrq->nwr_pending == 0); in quiesce_wrq()
7097 MPASS(wrq->ndesc_needed == 0); in quiesce_wrq()
7098 wrq->nwr_pending = 0; in quiesce_wrq()
7099 wrq->ndesc_needed = 0; in quiesce_wrq()
7107 while (!atomic_cmpset_int(&iq->state, IQS_IDLE, IQS_DISABLED)) in quiesce_iq_fl()
7111 MPASS(iq->flags & IQ_HAS_FL); in quiesce_iq_fl()
7113 mtx_lock(&sc->sfl_lock); in quiesce_iq_fl()
7115 fl->flags |= FL_DOOMED; in quiesce_iq_fl()
7117 callout_stop(&sc->sfl_callout); in quiesce_iq_fl()
7118 mtx_unlock(&sc->sfl_lock); in quiesce_iq_fl()
7120 KASSERT((fl->flags & FL_STARVING) == 0, in quiesce_iq_fl()
7124 if (!(iq->flags & IQ_HW_ALLOCATED)) in quiesce_iq_fl()
7138 struct adapter *sc = vi->adapter; in quiesce_vi()
7148 if (!(vi->flags & VI_INIT_DONE)) in quiesce_vi()
7157 quiesce_wrq(&ofld_txq->wrq); in quiesce_vi()
7162 quiesce_iq_fl(sc, &rxq->iq, &rxq->fl); in quiesce_vi()
7167 quiesce_iq_fl(sc, &ofld_rxq->iq, &ofld_rxq->fl); in quiesce_vi()
7178 irq->rid = rid; in t4_alloc_irq()
7179 irq->res = bus_alloc_resource_any(sc->dev, SYS_RES_IRQ, &irq->rid, in t4_alloc_irq()
7181 if (irq->res == NULL) { in t4_alloc_irq()
7182 device_printf(sc->dev, in t4_alloc_irq()
7187 rc = bus_setup_intr(sc->dev, irq->res, INTR_MPSAFE | INTR_TYPE_NET, in t4_alloc_irq()
7188 NULL, handler, arg, &irq->tag); in t4_alloc_irq()
7190 device_printf(sc->dev, in t4_alloc_irq()
7194 bus_describe_intr(sc->dev, irq->res, irq->tag, "%s", name); in t4_alloc_irq()
7202 if (irq->tag) in t4_free_irq()
7203 bus_teardown_intr(sc->dev, irq->res, irq->tag); in t4_free_irq()
7204 if (irq->res) in t4_free_irq()
7205 bus_release_resource(sc->dev, SYS_RES_IRQ, irq->rid, irq->res); in t4_free_irq()
7216 regs->version = chip_id(sc) | chip_rev(sc) << 10; in get_regs()
7217 t4_get_regs(sc, buf, regs->len); in get_regs()
7242 u32 stats[2]; in read_vf_stat() local
7244 if (sc->flags & IS_VF) { in read_vf_stat()
7245 stats[0] = t4_read_reg(sc, VF_MPS_REG(reg)); in read_vf_stat()
7246 stats[1] = t4_read_reg(sc, VF_MPS_REG(reg + 4)); in read_vf_stat()
7248 mtx_assert(&sc->reg_lock, MA_OWNED); in read_vf_stat()
7251 stats[0] = t4_read_reg(sc, A_PL_INDIR_DATA); in read_vf_stat()
7252 stats[1] = t4_read_reg(sc, A_PL_INDIR_DATA); in read_vf_stat()
7254 return (((uint64_t)stats[1]) << 32 | stats[0]); in read_vf_stat()
7258 t4_get_vi_stats(struct adapter *sc, u_int vin, struct fw_vi_stats_vf *stats) in t4_get_vi_stats() argument
7264 if (!(sc->flags & IS_VF)) in t4_get_vi_stats()
7265 mtx_lock(&sc->reg_lock); in t4_get_vi_stats()
7266 stats->tx_bcast_bytes = GET_STAT(TX_VF_BCAST_BYTES); in t4_get_vi_stats()
7267 stats->tx_bcast_frames = GET_STAT(TX_VF_BCAST_FRAMES); in t4_get_vi_stats()
7268 stats->tx_mcast_bytes = GET_STAT(TX_VF_MCAST_BYTES); in t4_get_vi_stats()
7269 stats->tx_mcast_frames = GET_STAT(TX_VF_MCAST_FRAMES); in t4_get_vi_stats()
7270 stats->tx_ucast_bytes = GET_STAT(TX_VF_UCAST_BYTES); in t4_get_vi_stats()
7271 stats->tx_ucast_frames = GET_STAT(TX_VF_UCAST_FRAMES); in t4_get_vi_stats()
7272 stats->tx_drop_frames = GET_STAT(TX_VF_DROP_FRAMES); in t4_get_vi_stats()
7273 stats->tx_offload_bytes = GET_STAT(TX_VF_OFFLOAD_BYTES); in t4_get_vi_stats()
7274 stats->tx_offload_frames = GET_STAT(TX_VF_OFFLOAD_FRAMES); in t4_get_vi_stats()
7275 stats->rx_bcast_bytes = GET_STAT(RX_VF_BCAST_BYTES); in t4_get_vi_stats()
7276 stats->rx_bcast_frames = GET_STAT(RX_VF_BCAST_FRAMES); in t4_get_vi_stats()
7277 stats->rx_mcast_bytes = GET_STAT(RX_VF_MCAST_BYTES); in t4_get_vi_stats()
7278 stats->rx_mcast_frames = GET_STAT(RX_VF_MCAST_FRAMES); in t4_get_vi_stats()
7279 stats->rx_ucast_bytes = GET_STAT(RX_VF_UCAST_BYTES); in t4_get_vi_stats()
7280 stats->rx_ucast_frames = GET_STAT(RX_VF_UCAST_FRAMES); in t4_get_vi_stats()
7281 stats->rx_err_frames = GET_STAT(RX_VF_ERR_FRAMES); in t4_get_vi_stats()
7282 if (!(sc->flags & IS_VF)) in t4_get_vi_stats()
7283 mtx_unlock(&sc->reg_lock); in t4_get_vi_stats()
7306 mtx_assert(&vi->tick_mtx, MA_OWNED); in vi_refresh_stats()
7308 if (vi->flags & VI_SKIP_STATS) in vi_refresh_stats()
7313 if (timevalcmp(&tv, &vi->last_refreshed, <)) in vi_refresh_stats()
7316 t4_get_vi_stats(vi->adapter, vi->vin, &vi->stats); in vi_refresh_stats()
7317 getmicrotime(&vi->last_refreshed); in vi_refresh_stats()
7329 mtx_assert(&vi->tick_mtx, MA_OWNED); in cxgbe_refresh_stats()
7331 if (vi->flags & VI_SKIP_STATS) in cxgbe_refresh_stats()
7336 if (timevalcmp(&tv, &vi->last_refreshed, <)) in cxgbe_refresh_stats()
7339 pi = vi->pi; in cxgbe_refresh_stats()
7340 sc = vi->adapter; in cxgbe_refresh_stats()
7342 t4_get_port_stats(sc, pi->port_id, &pi->stats); in cxgbe_refresh_stats()
7343 chan_map = pi->rx_e_chan_map; in cxgbe_refresh_stats()
7345 i = ffs(chan_map) - 1; in cxgbe_refresh_stats()
7346 mtx_lock(&sc->reg_lock); in cxgbe_refresh_stats()
7349 mtx_unlock(&sc->reg_lock); in cxgbe_refresh_stats()
7353 pi->tnl_cong_drops = tnl_cong_drops; in cxgbe_refresh_stats()
7354 getmicrotime(&vi->last_refreshed); in cxgbe_refresh_stats()
7363 mtx_assert(&vi->tick_mtx, MA_OWNED); in cxgbe_tick()
7366 callout_schedule(&vi->tick, hz); in cxgbe_tick()
7374 mtx_assert(&vi->tick_mtx, MA_OWNED); in vi_tick()
7377 callout_schedule(&vi->tick, hz); in vi_tick()
7405 struct sysctl_ctx_list *ctx = &sc->ctx; in t4_sysctls()
7413 oid = device_get_sysctl_tree(sc->dev); in t4_sysctls()
7416 sc->sc_do_rxcopy = 1; in t4_sysctls()
7418 &sc->sc_do_rxcopy, 1, "Do RX copy of small frames"); in t4_sysctls()
7421 sc->params.nports, "# of ports"); in t4_sysctls()
7425 (uintptr_t)&sc->doorbells, sysctl_bitfield_8b, "A", in t4_sysctls()
7429 sc->params.vpd.cclk, "core clock frequency (in KHz)"); in t4_sysctls()
7433 sc->params.sge.timer_val, sizeof(sc->params.sge.timer_val), in t4_sysctls()
7438 sc->params.sge.counter_val, sizeof(sc->params.sge.counter_val), in t4_sysctls()
7443 sc->lro_timeout = 100; in t4_sysctls()
7445 &sc->lro_timeout, 0, "lro inactive-flush timeout (in us)"); in t4_sysctls()
7448 &sc->debug_flags, 0, "flags to enable runtime debugging"); in t4_sysctls()
7451 CTLFLAG_RD, sc->tp_version, 0, "TP microcode version"); in t4_sysctls()
7454 CTLFLAG_RD, sc->fw_version, 0, "firmware version"); in t4_sysctls()
7456 if (sc->flags & IS_VF) in t4_sysctls()
7463 CTLFLAG_RD, sc->params.vpd.sn, 0, "serial number"); in t4_sysctls()
7466 CTLFLAG_RD, sc->params.vpd.pn, 0, "part number"); in t4_sysctls()
7469 CTLFLAG_RD, sc->params.vpd.ec, 0, "engineering change"); in t4_sysctls()
7472 CTLFLAG_RD, sc->params.vpd.md, 0, "manufacturing diags version"); in t4_sysctls()
7475 CTLFLAG_RD, sc->params.vpd.na, 0, "network address"); in t4_sysctls()
7478 sc->er_version, 0, "expansion ROM version"); in t4_sysctls()
7481 sc->bs_version, 0, "bootstrap firmware version"); in t4_sysctls()
7484 NULL, sc->params.scfg_vers, "serial config version"); in t4_sysctls()
7487 NULL, sc->params.vpd_vers, "VPD version"); in t4_sysctls()
7490 CTLFLAG_RD, sc->cfg_file, 0, "configuration file"); in t4_sysctls()
7493 sc->cfcsum, "config file checksum"); in t4_sysctls()
7498 (uintptr_t)&sc->name, sysctl_bitfield_16b, "A", \ in t4_sysctls()
7513 NULL, sc->tids.nftids, "number of filters"); in t4_sysctls()
7540 &sc->swintr, 0, "software triggered interrupts"); in t4_sysctls()
7618 "CIM OBQ 6 (SGE0-RX)"); in t4_sysctls()
7623 "CIM OBQ 7 (SGE1-RX)"); in t4_sysctls()
7640 sysctl_ddp_stats, "A", "non-TCP DDP statistics"); in t4_sysctls()
7644 sysctl_tid_stats, "A", "tid stats"); in t4_sysctls()
7745 CTLFLAG_RW, &sc->tlst.inline_keys, 0, "Always pass TLS " in t4_sysctls()
7751 CTLFLAG_RW, &sc->tlst.combo_wrs, 0, "Attempt to " in t4_sysctls()
7769 sc->tt.cong_algorithm = -1; in t4_sysctls()
7771 CTLFLAG_RW, &sc->tt.cong_algorithm, 0, "congestion control " in t4_sysctls()
7772 "(-1 = default, 0 = reno, 1 = tahoe, 2 = newreno, " in t4_sysctls()
7775 sc->tt.sndbuf = -1; in t4_sysctls()
7777 &sc->tt.sndbuf, 0, "hardware send buffer"); in t4_sysctls()
7779 sc->tt.ddp = 0; in t4_sysctls()
7781 CTLFLAG_RW | CTLFLAG_SKIP, &sc->tt.ddp, 0, ""); in t4_sysctls()
7783 &sc->tt.ddp, 0, "Enable zero-copy aio_read(2)"); in t4_sysctls()
7785 sc->tt.rx_coalesce = -1; in t4_sysctls()
7787 CTLFLAG_RW, &sc->tt.rx_coalesce, 0, "receive coalescing"); in t4_sysctls()
7789 sc->tt.tls = 1; in t4_sysctls()
7794 sc->tt.tx_align = -1; in t4_sysctls()
7796 CTLFLAG_RW, &sc->tt.tx_align, 0, "chop and align payload"); in t4_sysctls()
7798 sc->tt.tx_zcopy = 0; in t4_sysctls()
7800 CTLFLAG_RW, &sc->tt.tx_zcopy, 0, in t4_sysctls()
7801 "Enable zero-copy aio_write(2)"); in t4_sysctls()
7803 sc->tt.cop_managed_offloading = !!t4_cop_managed_offloading; in t4_sysctls()
7806 &sc->tt.cop_managed_offloading, 0, in t4_sysctls()
7809 sc->tt.autorcvbuf_inc = 16 * 1024; in t4_sysctls()
7811 CTLFLAG_RW, &sc->tt.autorcvbuf_inc, 0, in t4_sysctls()
7814 sc->tt.update_hc_on_pmtu_change = 1; in t4_sysctls()
7817 &sc->tt.update_hc_on_pmtu_change, 0, in t4_sysctls()
7820 sc->tt.iso = 1; in t4_sysctls()
7822 &sc->tt.iso, 0, "Enable iSCSI segmentation offload"); in t4_sysctls()
7912 struct sysctl_ctx_list *ctx = &vi->ctx; in vi_sysctls()
7919 oid = device_get_sysctl_tree(vi->dev); in vi_sysctls()
7923 vi->viid, "VI identifer"); in vi_sysctls()
7925 &vi->nrxq, 0, "# of rx queues"); in vi_sysctls()
7927 &vi->ntxq, 0, "# of tx queues"); in vi_sysctls()
7929 &vi->first_rxq, 0, "index of first rx queue"); in vi_sysctls()
7931 &vi->first_txq, 0, "index of first tx queue"); in vi_sysctls()
7933 vi->rss_base, "start of RSS indirection table"); in vi_sysctls()
7935 vi->rss_size, "size of RSS indirection table"); in vi_sysctls()
7941 "Reserve queue 0 for non-flowid packets"); in vi_sysctls()
7944 if (vi->adapter->flags & IS_VF) { in vi_sysctls()
7945 MPASS(vi->flags & TX_USES_VM_WR); in vi_sysctls()
7955 if (vi->nofldrxq != 0) { in vi_sysctls()
7957 &vi->nofldrxq, 0, in vi_sysctls()
7960 CTLFLAG_RD, &vi->first_ofld_rxq, 0, in vi_sysctls()
7973 if (vi->nofldtxq != 0) { in vi_sysctls()
7975 &vi->nofldtxq, 0, in vi_sysctls()
7978 CTLFLAG_RD, &vi->first_ofld_txq, 0, in vi_sysctls()
7983 if (vi->nnmrxq != 0) { in vi_sysctls()
7985 &vi->nnmrxq, 0, "# of netmap rx queues"); in vi_sysctls()
7987 &vi->nnmtxq, 0, "# of netmap tx queues"); in vi_sysctls()
7989 CTLFLAG_RD, &vi->first_nm_rxq, 0, in vi_sysctls()
7992 CTLFLAG_RD, &vi->first_nm_txq, 0, in vi_sysctls()
8015 struct sysctl_ctx_list *ctx = &pi->ctx; in cxgbe_sysctls()
8018 struct adapter *sc = pi->adapter; in cxgbe_sysctls()
8026 oid = device_get_sysctl_tree(pi->dev); in cxgbe_sysctls()
8032 if (pi->port_type == FW_PORT_TYPE_BT_XAUI) { in cxgbe_sysctls()
8058 "autonegotiation (-1 = not supported)"); in cxgbe_sysctls()
8064 &pi->link_cfg.requested_caps, 0, "L1 config requested by driver"); in cxgbe_sysctls()
8066 &pi->link_cfg.pcaps, 0, "port capabilities"); in cxgbe_sysctls()
8068 &pi->link_cfg.acaps, 0, "advertised capabilities"); in cxgbe_sysctls()
8070 &pi->link_cfg.lpacaps, 0, "link partner advertised capabilities"); in cxgbe_sysctls()
8075 pi->mps_bg_map, "MPS buffer group map"); in cxgbe_sysctls()
8077 NULL, pi->rx_e_chan_map, "TP rx e-channel map"); in cxgbe_sysctls()
8079 pi->tx_chan, "TP tx c-channel"); in cxgbe_sysctls()
8081 pi->rx_chan, "TP rx c-channel"); in cxgbe_sysctls()
8083 if (sc->flags & IS_VF) in cxgbe_sysctls()
8094 CTLFLAG_RW, &pi->sched_params->pktsize, 0, in cxgbe_sysctls()
8095 "pktsize for per-flow cl-rl (0 means up to the driver )"); in cxgbe_sysctls()
8097 CTLFLAG_RW, &pi->sched_params->burstsize, 0, in cxgbe_sysctls()
8098 "burstsize for per-flow cl-rl (0 means up to the driver)"); in cxgbe_sysctls()
8099 for (i = 0; i < sc->params.nsched_cls; i++) { in cxgbe_sysctls()
8100 struct tx_cl_rl_params *tc = &pi->sched_params->cl_rl[i]; in cxgbe_sysctls()
8107 CTLFLAG_RD, &tc->state, 0, "current state"); in cxgbe_sysctls()
8110 (uintptr_t)&tc->flags, sysctl_bitfield_8b, "A", "flags"); in cxgbe_sysctls()
8112 CTLFLAG_RD, &tc->refcount, 0, "references to this class"); in cxgbe_sysctls()
8115 (pi->port_id << 16) | i, sysctl_tc_params, "A", in cxgbe_sysctls()
8120 * dev.cxgbe.X.stats. in cxgbe_sysctls()
8122 oid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, "stats", in cxgbe_sysctls()
8126 &pi->tx_parse_error, 0, in cxgbe_sysctls()
8132 t4_port_reg(sc, pi->tx_chan, A_MPS_PORT_STAT_##stat##_L), \ in cxgbe_sysctls()
8138 &pi->stats.name, desc) in cxgbe_sysctls()
8198 T4_PORTSTAT(rx_ovflow0, "# drops due to buffer-group 0 overflows"); in cxgbe_sysctls()
8199 T4_PORTSTAT(rx_ovflow1, "# drops due to buffer-group 1 overflows"); in cxgbe_sysctls()
8200 T4_PORTSTAT(rx_ovflow2, "# drops due to buffer-group 2 overflows"); in cxgbe_sysctls()
8201 T4_PORTSTAT(rx_ovflow3, "# drops due to buffer-group 3 overflows"); in cxgbe_sysctls()
8202 T4_PORTSTAT(rx_trunc0, "# of buffer-group 0 truncated packets"); in cxgbe_sysctls()
8203 T4_PORTSTAT(rx_trunc1, "# of buffer-group 1 truncated packets"); in cxgbe_sysctls()
8204 T4_PORTSTAT(rx_trunc2, "# of buffer-group 2 truncated packets"); in cxgbe_sysctls()
8205 T4_PORTSTAT(rx_trunc3, "# of buffer-group 3 truncated packets"); in cxgbe_sysctls()
8218 for (i = arg1; arg2; arg2 -= sizeof(int), i++) { in sysctl_int_array()
8268 struct adapter *sc = pi->adapter; in sysctl_btphy()
8272 rc = begin_synchronized_op(sc, &pi->vi[0], SLEEP_OK | INTR_OK, "t4btt"); in sysctl_btphy()
8279 rc = -t4_mdio_rd(sc, sc->mbox, pi->mdio_addr, 0x1e, in sysctl_btphy()
8298 val = vi->rsrv_noflowq; in sysctl_noflowq()
8300 if (rc != 0 || req->newptr == NULL) in sysctl_noflowq()
8303 if ((val >= 1) && (vi->ntxq > 1)) in sysctl_noflowq()
8304 vi->rsrv_noflowq = 1; in sysctl_noflowq()
8306 vi->rsrv_noflowq = 0; in sysctl_noflowq()
8315 struct adapter *sc = vi->adapter; in sysctl_tx_vm_wr()
8318 MPASS(!(sc->flags & IS_VF)); in sysctl_tx_vm_wr()
8320 val = vi->flags & TX_USES_VM_WR ? 1 : 0; in sysctl_tx_vm_wr()
8322 if (rc != 0 || req->newptr == NULL) in sysctl_tx_vm_wr()
8334 else if (if_getdrvflags(vi->ifp) & IFF_DRV_RUNNING) { in sysctl_tx_vm_wr()
8342 struct port_info *pi = vi->pi; in sysctl_tx_vm_wr()
8345 uint8_t npkt = sc->params.max_pkts_per_eth_tx_pkts_wr; in sysctl_tx_vm_wr()
8348 vi->flags |= TX_USES_VM_WR; in sysctl_tx_vm_wr()
8349 if_sethwtsomaxsegcount(vi->ifp, TX_SGL_SEGS_VM_TSO); in sysctl_tx_vm_wr()
8351 V_TXPKT_INTF(pi->tx_chan)); in sysctl_tx_vm_wr()
8352 if (!(sc->flags & IS_VF)) in sysctl_tx_vm_wr()
8353 npkt--; in sysctl_tx_vm_wr()
8355 vi->flags &= ~TX_USES_VM_WR; in sysctl_tx_vm_wr()
8356 if_sethwtsomaxsegcount(vi->ifp, TX_SGL_SEGS_TSO); in sysctl_tx_vm_wr()
8358 V_TXPKT_INTF(pi->tx_chan) | V_TXPKT_PF(sc->pf) | in sysctl_tx_vm_wr()
8359 V_TXPKT_VF(vi->vin) | V_TXPKT_VF_VLD(vi->vfvld)); in sysctl_tx_vm_wr()
8362 txq->cpl_ctrl0 = ctrl0; in sysctl_tx_vm_wr()
8363 txq->txp.max_npkt = npkt; in sysctl_tx_vm_wr()
8374 struct adapter *sc = vi->adapter; in sysctl_holdoff_tmr_idx()
8379 idx = vi->tmr_idx; in sysctl_holdoff_tmr_idx()
8382 if (rc != 0 || req->newptr == NULL) in sysctl_holdoff_tmr_idx()
8393 v = V_QINTR_TIMER_IDX(idx) | V_QINTR_CNT_EN(vi->pktc_idx != -1); in sysctl_holdoff_tmr_idx()
8396 atomic_store_rel_8(&rxq->iq.intr_params, v); in sysctl_holdoff_tmr_idx()
8398 rxq->iq.intr_params = v; in sysctl_holdoff_tmr_idx()
8401 vi->tmr_idx = idx; in sysctl_holdoff_tmr_idx()
8411 struct adapter *sc = vi->adapter; in sysctl_holdoff_pktc_idx()
8414 idx = vi->pktc_idx; in sysctl_holdoff_pktc_idx()
8417 if (rc != 0 || req->newptr == NULL) in sysctl_holdoff_pktc_idx()
8420 if (idx < -1 || idx >= SGE_NCOUNTERS) in sysctl_holdoff_pktc_idx()
8428 if (vi->flags & VI_INIT_DONE) in sysctl_holdoff_pktc_idx()
8431 vi->pktc_idx = idx; in sysctl_holdoff_pktc_idx()
8441 struct adapter *sc = vi->adapter; in sysctl_qsize_rxq()
8444 qsize = vi->qsize_rxq; in sysctl_qsize_rxq()
8447 if (rc != 0 || req->newptr == NULL) in sysctl_qsize_rxq()
8458 if (vi->flags & VI_INIT_DONE) in sysctl_qsize_rxq()
8461 vi->qsize_rxq = qsize; in sysctl_qsize_rxq()
8471 struct adapter *sc = vi->adapter; in sysctl_qsize_txq()
8474 qsize = vi->qsize_txq; in sysctl_qsize_txq()
8477 if (rc != 0 || req->newptr == NULL) in sysctl_qsize_txq()
8488 if (vi->flags & VI_INIT_DONE) in sysctl_qsize_txq()
8491 vi->qsize_txq = qsize; in sysctl_qsize_txq()
8501 struct adapter *sc = pi->adapter; in sysctl_pause_settings()
8502 struct link_config *lc = &pi->link_cfg; in sysctl_pause_settings()
8505 if (req->newptr == NULL) { in sysctl_pause_settings()
8513 if (lc->link_ok) { in sysctl_pause_settings()
8514 sbuf_printf(sb, "%b", (lc->fc & (PAUSE_TX | PAUSE_RX)) | in sysctl_pause_settings()
8515 (lc->requested_fc & PAUSE_AUTONEG), bits); in sysctl_pause_settings()
8517 sbuf_printf(sb, "%b", lc->requested_fc & (PAUSE_TX | in sysctl_pause_settings()
8526 s[0] = '0' + (lc->requested_fc & (PAUSE_TX | PAUSE_RX | in sysctl_pause_settings()
8538 n = s[0] - '0'; in sysctl_pause_settings()
8542 rc = begin_synchronized_op(sc, &pi->vi[0], SLEEP_OK | INTR_OK, in sysctl_pause_settings()
8548 lc->requested_fc = n; in sysctl_pause_settings()
8550 if (pi->up_vis > 0) in sysctl_pause_settings()
8565 struct link_config *lc = &pi->link_cfg; in sysctl_link_fec()
8568 static char *bits = "\20\1RS-FEC\2FC-FEC\3NO-FEC\4RSVD1\5RSVD2"; in sysctl_link_fec()
8573 if (lc->link_ok) in sysctl_link_fec()
8574 sbuf_printf(sb, "%b", lc->fec, bits); in sysctl_link_fec()
8587 struct adapter *sc = pi->adapter; in sysctl_requested_fec()
8588 struct link_config *lc = &pi->link_cfg; in sysctl_requested_fec()
8592 if (req->newptr == NULL) { in sysctl_requested_fec()
8594 static char *bits = "\20\1RS-FEC\2FC-FEC\3NO-FEC\4RSVD2" in sysctl_requested_fec()
8601 sbuf_printf(sb, "%b", lc->requested_fec, bits); in sysctl_requested_fec()
8609 lc->requested_fec == FEC_AUTO ? -1 : in sysctl_requested_fec()
8610 lc->requested_fec & (M_FW_PORT_CAP32_FEC | FEC_MODULE)); in sysctl_requested_fec()
8622 rc = begin_synchronized_op(sc, &pi->vi[0], SLEEP_OK | INTR_OK, in sysctl_requested_fec()
8627 old = lc->requested_fec; in sysctl_requested_fec()
8629 lc->requested_fec = FEC_AUTO; in sysctl_requested_fec()
8631 lc->requested_fec = FEC_NONE; in sysctl_requested_fec()
8633 if ((lc->pcaps | in sysctl_requested_fec()
8635 lc->pcaps) { in sysctl_requested_fec()
8639 lc->requested_fec = n & (M_FW_PORT_CAP32_FEC | in sysctl_requested_fec()
8644 if (pi->up_vis > 0) { in sysctl_requested_fec()
8647 lc->requested_fec = old; in sysctl_requested_fec()
8665 struct adapter *sc = pi->adapter; in sysctl_module_fec()
8666 struct link_config *lc = &pi->link_cfg; in sysctl_module_fec()
8670 static char *bits = "\20\1RS-FEC\2FC-FEC\3NO-FEC\4RSVD2\5RSVD3"; in sysctl_module_fec()
8685 if (pi->up_vis == 0) { in sysctl_module_fec()
8695 fec = lc->fec_hint; in sysctl_module_fec()
8696 if (pi->mod_type == FW_PORT_MOD_TYPE_NONE || in sysctl_module_fec()
8697 !fec_supported(lc->pcaps)) { in sysctl_module_fec()
8718 struct adapter *sc = pi->adapter; in sysctl_autoneg()
8719 struct link_config *lc = &pi->link_cfg; in sysctl_autoneg()
8722 if (lc->pcaps & FW_PORT_CAP32_ANEG) in sysctl_autoneg()
8723 val = lc->requested_aneg == AUTONEG_DISABLE ? 0 : 1; in sysctl_autoneg()
8725 val = -1; in sysctl_autoneg()
8727 if (rc != 0 || req->newptr == NULL) in sysctl_autoneg()
8736 rc = begin_synchronized_op(sc, &pi->vi[0], SLEEP_OK | INTR_OK, in sysctl_autoneg()
8741 if (val == AUTONEG_ENABLE && !(lc->pcaps & FW_PORT_CAP32_ANEG)) { in sysctl_autoneg()
8745 lc->requested_aneg = val; in sysctl_autoneg()
8748 if (pi->up_vis > 0) in sysctl_autoneg()
8762 struct adapter *sc = pi->adapter; in sysctl_force_fec()
8763 struct link_config *lc = &pi->link_cfg; in sysctl_force_fec()
8766 val = lc->force_fec; in sysctl_force_fec()
8767 MPASS(val >= -1 && val <= 1); in sysctl_force_fec()
8769 if (rc != 0 || req->newptr == NULL) in sysctl_force_fec()
8771 if (!(lc->pcaps & FW_PORT_CAP32_FORCE_FEC)) in sysctl_force_fec()
8773 if (val < -1 || val > 1) in sysctl_force_fec()
8776 rc = begin_synchronized_op(sc, &pi->vi[0], SLEEP_OK | INTR_OK, "t4ff"); in sysctl_force_fec()
8780 lc->force_fec = val; in sysctl_force_fec()
8783 if (pi->up_vis > 0) in sysctl_force_fec()
8798 mtx_lock(&sc->reg_lock); in sysctl_handle_t4_reg64()
8805 mtx_unlock(&sc->reg_lock); in sysctl_handle_t4_reg64()
8827 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, &param, &val); in sysctl_temperature()
8833 /* unknown is returned as 0 but we display -1 in that case */ in sysctl_temperature()
8834 t = val == 0 ? -1 : val; in sysctl_temperature()
8847 if (sc->params.core_vdd == 0) { in sysctl_vdd()
8858 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, in sysctl_vdd()
8864 sc->params.core_vdd = val; in sysctl_vdd()
8867 return (sysctl_handle_int(oidp, &sc->params.core_vdd, 0, req)); in sysctl_vdd()
8877 v = sc->sensor_resets; in sysctl_reset_sensor()
8879 if (rc != 0 || req->newptr == NULL || v <= 0) in sysctl_reset_sensor()
8882 if (sc->params.fw_vers < FW_VERSION32(1, 24, 7, 0) || in sysctl_reset_sensor()
8896 rc = -t4_set_params(sc, sc->mbox, sc->pf, 0, 1, &param, &val); in sysctl_reset_sensor()
8900 sc->sensor_resets++; in sysctl_reset_sensor()
8920 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, &param, &val); in sysctl_loadavg()
8960 mtx_lock(&sc->reg_lock); in sysctl_cctrl()
8965 mtx_unlock(&sc->reg_lock); in sysctl_cctrl()
8976 sc->params.a_wnd[i], dec_fac[sc->params.b_wnd[i]]); in sysctl_cctrl()
8986 "TP0", "TP1", "ULP", "SGE0", "SGE1", "NC-SI", /* ibq's */
8987 "ULP0", "ULP1", "ULP2", "ULP3", "SGE", "NC-SI", /* obq's */
8988 "SGE0-RX", "SGE1-RX" /* additional obq's (T5 onwards) */
8999 u_int cim_num_obq = sc->chip_params->cim_num_obq; in sysctl_cim_ibq_obq()
9009 mtx_lock(&sc->reg_lock); in sysctl_cim_ibq_obq()
9011 rc = -ENXIO; in sysctl_cim_ibq_obq()
9014 mtx_unlock(&sc->reg_lock); in sysctl_cim_ibq_obq()
9018 qid -= CIM_NUM_IBQ; in sysctl_cim_ibq_obq()
9021 mtx_lock(&sc->reg_lock); in sysctl_cim_ibq_obq()
9023 rc = -ENXIO; in sysctl_cim_ibq_obq()
9026 mtx_unlock(&sc->reg_lock); in sysctl_cim_ibq_obq()
9030 rc = -rc; in sysctl_cim_ibq_obq()
9062 for (p = buf; p <= &buf[sc->params.cim_la_size - 8]; p += 8) { in sbuf_cim_la4()
9092 for (p = buf; p <= &buf[sc->params.cim_la_size - 10]; p += 10) { in sbuf_cim_la6()
9122 buf = malloc(sc->params.cim_la_size * sizeof(uint32_t), M_CXGBE, in sbuf_cim_la()
9127 mtx_lock(&sc->reg_lock); in sbuf_cim_la()
9131 rc = -t4_cim_read(sc, A_UP_UP_DBG_LA_CFG, 1, &cfg); in sbuf_cim_la()
9133 rc = -t4_cim_read_la(sc, buf, NULL); in sbuf_cim_la()
9135 mtx_unlock(&sc->reg_lock); in sbuf_cim_la()
9168 device_get_nameunit(sc->dev), in dump_cim_regs()
9175 device_get_nameunit(sc->dev), in dump_cim_regs()
9191 device_get_nameunit(sc->dev)); in dump_cimla()
9199 device_get_nameunit(sc->dev), sbuf_data(&sb)); in dump_cimla()
9208 atomic_set_int(&sc->error_flags, ADAP_CIM_ERR); in t4_os_cim_err()
9228 mtx_lock(&sc->reg_lock); in sysctl_cim_ma_la()
9233 mtx_unlock(&sc->reg_lock); in sysctl_cim_ma_la()
9276 mtx_lock(&sc->reg_lock); in sysctl_cim_pif_la()
9281 mtx_unlock(&sc->reg_lock); in sysctl_cim_pif_la()
9319 cim_num_obq = sc->chip_params->cim_num_obq; in sysctl_cim_qcfg()
9329 mtx_lock(&sc->reg_lock); in sysctl_cim_qcfg()
9333 rc = -t4_cim_read(sc, ibq_rdaddr, 4 * nq, stat); in sysctl_cim_qcfg()
9335 rc = -t4_cim_read(sc, obq_rdaddr, 2 * cim_num_obq, in sysctl_cim_qcfg()
9341 mtx_unlock(&sc->reg_lock); in sysctl_cim_qcfg()
9360 wr[0] - base[i], G_QUESOPCNT(p[3]), G_QUEEOPCNT(p[3]), in sysctl_cim_qcfg()
9375 struct tp_cpl_stats stats; in sysctl_cpl_stats() local
9382 mtx_lock(&sc->reg_lock); in sysctl_cpl_stats()
9386 t4_tp_get_cpl_stats(sc, &stats, 0); in sysctl_cpl_stats()
9387 mtx_unlock(&sc->reg_lock); in sysctl_cpl_stats()
9391 if (sc->chip_params->nchan > 2) { in sysctl_cpl_stats()
9395 stats.req[0], stats.req[1], stats.req[2], stats.req[3]); in sysctl_cpl_stats()
9397 stats.rsp[0], stats.rsp[1], stats.rsp[2], stats.rsp[3]); in sysctl_cpl_stats()
9401 stats.req[0], stats.req[1]); in sysctl_cpl_stats()
9403 stats.rsp[0], stats.rsp[1]); in sysctl_cpl_stats()
9418 struct tp_usm_stats stats; in sysctl_ddp_stats() local
9425 mtx_lock(&sc->reg_lock); in sysctl_ddp_stats()
9429 t4_get_usm_stats(sc, &stats, 1); in sysctl_ddp_stats()
9430 mtx_unlock(&sc->reg_lock); in sysctl_ddp_stats()
9432 sbuf_printf(sb, "Frames: %u\n", stats.frames); in sysctl_ddp_stats()
9433 sbuf_printf(sb, "Octets: %ju\n", stats.octets); in sysctl_ddp_stats()
9434 sbuf_printf(sb, "Drops: %u", stats.drops); in sysctl_ddp_stats()
9448 struct tp_tid_stats stats; in sysctl_tid_stats() local
9455 mtx_lock(&sc->reg_lock); in sysctl_tid_stats()
9459 t4_tp_get_tid_stats(sc, &stats, 1); in sysctl_tid_stats()
9460 mtx_unlock(&sc->reg_lock); in sysctl_tid_stats()
9462 sbuf_printf(sb, "Delete: %u\n", stats.del); in sysctl_tid_stats()
9463 sbuf_printf(sb, "Invalidate: %u\n", stats.inv); in sysctl_tid_stats()
9464 sbuf_printf(sb, "Active: %u\n", stats.act); in sysctl_tid_stats()
9465 sbuf_printf(sb, "Passive: %u", stats.pas); in sysctl_tid_stats()
9514 struct devlog_params *dparams = &sc->params.devlog; in sbuf_devlog()
9518 if (dparams->addr == 0) in sbuf_devlog()
9522 buf = malloc(dparams->size, M_CXGBE, M_ZERO | flags); in sbuf_devlog()
9526 mtx_lock(&sc->reg_lock); in sbuf_devlog()
9530 rc = read_via_memwin(sc, 1, dparams->addr, (void *)buf, in sbuf_devlog()
9531 dparams->size); in sbuf_devlog()
9532 mtx_unlock(&sc->reg_lock); in sbuf_devlog()
9536 nentries = dparams->size / sizeof(struct fw_devlog_e); in sbuf_devlog()
9540 if (e->timestamp == 0) in sbuf_devlog()
9543 e->timestamp = be64toh(e->timestamp); in sbuf_devlog()
9544 e->seqno = be32toh(e->seqno); in sbuf_devlog()
9546 e->params[j] = be32toh(e->params[j]); in sbuf_devlog()
9548 if (e->timestamp < ftstamp) { in sbuf_devlog()
9549 ftstamp = e->timestamp; in sbuf_devlog()
9563 if (e->timestamp == 0) in sbuf_devlog()
9567 e->seqno, e->timestamp, in sbuf_devlog()
9568 (e->level < nitems(devlog_level_strings) ? in sbuf_devlog()
9569 devlog_level_strings[e->level] : "UNKNOWN"), in sbuf_devlog()
9570 (e->facility < nitems(devlog_facility_strings) ? in sbuf_devlog()
9571 devlog_facility_strings[e->facility] : "UNKNOWN")); in sbuf_devlog()
9572 sbuf_printf(sb, e->fmt, e->params[0], e->params[1], in sbuf_devlog()
9573 e->params[2], e->params[3], e->params[4], in sbuf_devlog()
9574 e->params[5], e->params[6], e->params[7]); in sbuf_devlog()
9610 device_get_nameunit(sc->dev)); in dump_devlog()
9618 device_get_nameunit(sc->dev), sbuf_data(&sb)); in dump_devlog()
9630 struct tp_fcoe_stats stats[MAX_NCHAN]; in sysctl_fcoe_stats() local
9631 int i, nchan = sc->chip_params->nchan; in sysctl_fcoe_stats()
9634 mtx_lock(&sc->reg_lock); in sysctl_fcoe_stats()
9639 t4_get_fcoe_stats(sc, i, &stats[i], 1); in sysctl_fcoe_stats()
9641 mtx_unlock(&sc->reg_lock); in sysctl_fcoe_stats()
9653 stats[0].octets_ddp, stats[1].octets_ddp, in sysctl_fcoe_stats()
9654 stats[2].octets_ddp, stats[3].octets_ddp); in sysctl_fcoe_stats()
9656 stats[0].frames_ddp, stats[1].frames_ddp, in sysctl_fcoe_stats()
9657 stats[2].frames_ddp, stats[3].frames_ddp); in sysctl_fcoe_stats()
9659 stats[0].frames_drop, stats[1].frames_drop, in sysctl_fcoe_stats()
9660 stats[2].frames_drop, stats[3].frames_drop); in sysctl_fcoe_stats()
9664 stats[0].octets_ddp, stats[1].octets_ddp); in sysctl_fcoe_stats()
9666 stats[0].frames_ddp, stats[1].frames_ddp); in sysctl_fcoe_stats()
9668 stats[0].frames_drop, stats[1].frames_drop); in sysctl_fcoe_stats()
9690 mtx_lock(&sc->reg_lock); in sysctl_hw_sched()
9692 mtx_unlock(&sc->reg_lock); in sysctl_hw_sched()
9700 mtx_unlock(&sc->reg_lock); in sysctl_hw_sched()
9707 sbuf_printf(sb, "\n %u %-5s %u ", i, in sysctl_hw_sched()
9755 for (i = 0; i < sc->chip_params->nchan; i += 2) { in sysctl_lb_stats()
9756 mtx_lock(&sc->reg_lock); in sysctl_lb_stats()
9763 mtx_unlock(&sc->reg_lock); in sysctl_lb_stats()
9773 sbuf_printf(sb, "\n%-17s %20ju %20ju", stat_name[j], in sysctl_lb_stats()
9789 struct link_config *lc = &pi->link_cfg; in sysctl_linkdnrc()
9796 if (lc->link_ok || lc->link_down_rc == 255) in sysctl_linkdnrc()
9799 sbuf_printf(sb, "%s", t4_link_down_rc_str(lc->link_down_rc)); in sysctl_linkdnrc()
9816 const u_int v1 = ((const struct mem_desc *)a)->base; in mem_desc_cmp()
9817 const u_int v2 = ((const struct mem_desc *)b)->base; in mem_desc_cmp()
9820 return (-1); in mem_desc_cmp()
9836 size = to - from + 1; in mem_region_show()
9841 sbuf_printf(sb, "%-15s %#x-%#x [%u]\n", name, from, to, size); in mem_region_show()
9861 "ULPTX state:", "On-chip queues:", in sysctl_meminfo()
9880 mtx_lock(&sc->reg_lock); in sysctl_meminfo()
9929 (md++)->base = t4_read_reg(sc, A_SGE_DBQ_CTXT_BADDR); in sysctl_meminfo()
9930 (md++)->base = t4_read_reg(sc, A_SGE_IMSG_CTXT_BADDR); in sysctl_meminfo()
9931 (md++)->base = t4_read_reg(sc, A_SGE_FLM_CACHE_BADDR); in sysctl_meminfo()
9932 (md++)->base = t4_read_reg(sc, A_TP_CMM_TCB_BASE); in sysctl_meminfo()
9933 (md++)->base = t4_read_reg(sc, A_TP_CMM_MM_BASE); in sysctl_meminfo()
9934 (md++)->base = t4_read_reg(sc, A_TP_CMM_TIMER_BASE); in sysctl_meminfo()
9935 (md++)->base = t4_read_reg(sc, A_TP_CMM_MM_RX_FLST_BASE); in sysctl_meminfo()
9936 (md++)->base = t4_read_reg(sc, A_TP_CMM_MM_TX_FLST_BASE); in sysctl_meminfo()
9937 (md++)->base = t4_read_reg(sc, A_TP_CMM_MM_PS_FLST_BASE); in sysctl_meminfo()
9940 md->base = t4_read_reg(sc, A_TP_PMM_TX_BASE); in sysctl_meminfo()
9941 md->limit = md->base - 1 + in sysctl_meminfo()
9946 md->base = t4_read_reg(sc, A_TP_PMM_RX_BASE); in sysctl_meminfo()
9947 md->limit = md->base - 1 + in sysctl_meminfo()
9954 md->base = t4_read_reg(sc, A_LE_DB_HASH_TID_BASE); in sysctl_meminfo()
9956 md->base = t4_read_reg(sc, A_LE_DB_HASH_TBL_BASE_ADDR); in sysctl_meminfo()
9957 md->limit = 0; in sysctl_meminfo()
9959 md->base = 0; in sysctl_meminfo()
9960 md->idx = nitems(region); /* hide it */ in sysctl_meminfo()
9965 md->base = t4_read_reg(sc, A_ULP_ ## reg ## _LLIMIT);\ in sysctl_meminfo()
9966 (md++)->limit = t4_read_reg(sc, A_ULP_ ## reg ## _ULIMIT) in sysctl_meminfo()
9976 if (sc->cryptocaps & FW_CAPS_CONFIG_TLSKEYS) { in sysctl_meminfo()
9981 md->base = 0; in sysctl_meminfo()
9983 md->idx = nitems(region); in sysctl_meminfo()
9996 md->base = t4_read_reg(sc, A_SGE_DBVFIFO_BADDR); in sysctl_meminfo()
9997 md->limit = md->base + size - 1; in sysctl_meminfo()
9999 md->idx = nitems(region); in sysctl_meminfo()
10003 md->base = t4_read_reg(sc, A_ULP_RX_CTX_BASE); in sysctl_meminfo()
10004 md->limit = 0; in sysctl_meminfo()
10006 md->base = t4_read_reg(sc, A_ULP_TX_ERR_TABLE_BASE); in sysctl_meminfo()
10007 md->limit = 0; in sysctl_meminfo()
10010 md->base = sc->vres.ocq.start; in sysctl_meminfo()
10011 if (sc->vres.ocq.size) in sysctl_meminfo()
10012 md->limit = md->base + sc->vres.ocq.size - 1; in sysctl_meminfo()
10014 md->idx = nitems(region); /* hide it */ in sysctl_meminfo()
10017 /* add any address-space holes, there can be up to 3 */ in sysctl_meminfo()
10018 for (n = 0; n < i - 1; n++) in sysctl_meminfo()
10020 (md++)->base = avail[n].limit; in sysctl_meminfo()
10022 (md++)->base = avail[n].limit; in sysctl_meminfo()
10024 n = md - mem; in sysctl_meminfo()
10030 avail[lo].limit - 1); in sysctl_meminfo()
10037 mem[i].limit = i < n - 1 ? mem[i + 1].base - 1 : ~0; in sysctl_meminfo()
10044 hi = t4_read_reg(sc, A_CIM_SDRAM_ADDR_SIZE) + lo - 1; in sysctl_meminfo()
10048 hi = t4_read_reg(sc, A_CIM_EXTMEM2_ADDR_SIZE) + lo - 1; in sysctl_meminfo()
10067 sbuf_printf(sb, "%u p-structs (%u free)\n", in sysctl_meminfo()
10087 for (i = 0; i < sc->chip_params->nchan; i++) { in sysctl_meminfo()
10105 mtx_unlock(&sc->reg_lock); in sysctl_meminfo()
10137 for (i = 0; i < sc->chip_params->mps_tcam_size; i++) { in sysctl_mps_tcam()
10142 mtx_lock(&sc->reg_lock); in sysctl_mps_tcam()
10149 mtx_unlock(&sc->reg_lock); in sysctl_mps_tcam()
10155 mtx_lock(&sc->reg_lock); in sysctl_mps_tcam()
10162 mtx_unlock(&sc->reg_lock); in sysctl_mps_tcam()
10170 (cls_lo & F_VF_VALID) ? G_VF(cls_lo) : -1); in sysctl_mps_tcam()
10192 rc = -t4_wr_mbox(sc, sc->mbox, &ldst_cmd, in sysctl_mps_tcam()
10240 for (i = 0; i < sc->chip_params->mps_tcam_size; i++) { in sysctl_mps_tcam_t6()
10251 ctl |= V_CTLTCAMINDEX(i - 256) | V_CTLTCAMSEL(1); in sysctl_mps_tcam_t6()
10252 mtx_lock(&sc->reg_lock); in sysctl_mps_tcam_t6()
10262 mtx_unlock(&sc->reg_lock); in sysctl_mps_tcam_t6()
10282 mtx_lock(&sc->reg_lock); in sysctl_mps_tcam_t6()
10292 mtx_unlock(&sc->reg_lock); in sysctl_mps_tcam_t6()
10307 mtx_lock(&sc->reg_lock); in sysctl_mps_tcam_t6()
10314 mtx_unlock(&sc->reg_lock); in sysctl_mps_tcam_t6()
10320 "%012jx %06x %06x - - %3c" in sysctl_mps_tcam_t6()
10326 cls_lo & F_T6_VF_VALID ? G_T6_VF(cls_lo) : -1); in sysctl_mps_tcam_t6()
10329 "%012jx - - ", i, addr[0], addr[1], in sysctl_mps_tcam_t6()
10336 sbuf_printf(sb, " - N "); in sysctl_mps_tcam_t6()
10338 sbuf_printf(sb, "- %3c %4x %3c %#x%4u%4d", in sysctl_mps_tcam_t6()
10342 cls_lo & F_T6_VF_VALID ? G_T6_VF(cls_lo) : -1); in sysctl_mps_tcam_t6()
10366 rc = -t4_wr_mbox(sc, sc->mbox, &ldst_cmd, in sysctl_mps_tcam_t6()
10410 mtx_lock(&sc->reg_lock); in sysctl_path_mtus()
10415 mtx_unlock(&sc->reg_lock); in sysctl_path_mtus()
10452 mtx_lock(&sc->reg_lock); in sysctl_pm_stats()
10459 mtx_unlock(&sc->reg_lock); in sysctl_pm_stats()
10469 sbuf_printf(sb, "\n%-13s %10u %20ju", tx_stats[i], tx_cnt[i], in sysctl_pm_stats()
10475 sbuf_printf(sb, "\n%-13s %10u %20ju", rx_stats[i], rx_cnt[i], in sysctl_pm_stats()
10482 sbuf_printf(sb, "\n%-13s %10u %20ju", tx_stats[i], tx_cnt[i], in sysctl_pm_stats()
10484 sbuf_printf(sb, "\n%-13s %10u %20ju", rx_stats[i], rx_cnt[i], in sysctl_pm_stats()
10492 sbuf_printf(sb, "\n%-13s %10u %20ju", tx_stats[i], tx_cnt[i], in sysctl_pm_stats()
10494 sbuf_printf(sb, "\n%-13s %10u %20ju", rx_stats[i], rx_cnt[i], in sysctl_pm_stats()
10510 struct tp_rdma_stats stats; in sysctl_rdma_stats() local
10513 mtx_lock(&sc->reg_lock); in sysctl_rdma_stats()
10517 t4_tp_get_rdma_stats(sc, &stats, 0); in sysctl_rdma_stats()
10518 mtx_unlock(&sc->reg_lock); in sysctl_rdma_stats()
10526 sbuf_printf(sb, "NoRQEModDefferals: %u\n", stats.rqe_dfr_mod); in sysctl_rdma_stats()
10527 sbuf_printf(sb, "NoRQEPktDefferals: %u", stats.rqe_dfr_pkt); in sysctl_rdma_stats()
10544 mtx_lock(&sc->reg_lock); in sysctl_tcp_stats()
10549 mtx_unlock(&sc->reg_lock); in sysctl_tcp_stats()
10581 struct tid_info *t = &sc->tids; in sysctl_tids()
10588 if (t->natids) { in sysctl_tids()
10589 sbuf_printf(sb, "ATID range: 0-%u, in use: %u\n", t->natids - 1, in sysctl_tids()
10590 t->atids_in_use); in sysctl_tids()
10593 if (t->nhpftids) { in sysctl_tids()
10594 sbuf_printf(sb, "HPFTID range: %u-%u, in use: %u\n", in sysctl_tids()
10595 t->hpftid_base, t->hpftid_end, t->hpftids_in_use); in sysctl_tids()
10598 if (t->ntids) { in sysctl_tids()
10601 mtx_lock(&sc->reg_lock); in sysctl_tids()
10614 mtx_unlock(&sc->reg_lock); in sysctl_tids()
10621 sbuf_printf(sb, "%u-%u, ", t->tid_base, x - 1); in sysctl_tids()
10622 sbuf_printf(sb, "%u-%u", y, t->ntids - 1); in sysctl_tids()
10624 sbuf_printf(sb, "%u-%u", t->tid_base, t->tid_base + in sysctl_tids()
10625 t->ntids - 1); in sysctl_tids()
10628 atomic_load_acq_int(&t->tids_in_use)); in sysctl_tids()
10631 if (t->nstids) { in sysctl_tids()
10632 sbuf_printf(sb, "STID range: %u-%u, in use: %u\n", t->stid_base, in sysctl_tids()
10633 t->stid_base + t->nstids - 1, t->stids_in_use); in sysctl_tids()
10636 if (t->nftids) { in sysctl_tids()
10637 sbuf_printf(sb, "FTID range: %u-%u, in use: %u\n", t->ftid_base, in sysctl_tids()
10638 t->ftid_end, t->ftids_in_use); in sysctl_tids()
10641 if (t->netids) { in sysctl_tids()
10642 sbuf_printf(sb, "ETID range: %u-%u, in use: %u\n", t->etid_base, in sysctl_tids()
10643 t->etid_base + t->netids - 1, t->etids_in_use); in sysctl_tids()
10646 mtx_lock(&sc->reg_lock); in sysctl_tids()
10653 mtx_unlock(&sc->reg_lock); in sysctl_tids()
10673 struct tp_err_stats stats; in sysctl_tp_err_stats() local
10676 mtx_lock(&sc->reg_lock); in sysctl_tp_err_stats()
10680 t4_tp_get_err_stats(sc, &stats, 0); in sysctl_tp_err_stats()
10681 mtx_unlock(&sc->reg_lock); in sysctl_tp_err_stats()
10689 if (sc->chip_params->nchan > 2) { in sysctl_tp_err_stats()
10693 stats.mac_in_errs[0], stats.mac_in_errs[1], in sysctl_tp_err_stats()
10694 stats.mac_in_errs[2], stats.mac_in_errs[3]); in sysctl_tp_err_stats()
10696 stats.hdr_in_errs[0], stats.hdr_in_errs[1], in sysctl_tp_err_stats()
10697 stats.hdr_in_errs[2], stats.hdr_in_errs[3]); in sysctl_tp_err_stats()
10699 stats.tcp_in_errs[0], stats.tcp_in_errs[1], in sysctl_tp_err_stats()
10700 stats.tcp_in_errs[2], stats.tcp_in_errs[3]); in sysctl_tp_err_stats()
10702 stats.tcp6_in_errs[0], stats.tcp6_in_errs[1], in sysctl_tp_err_stats()
10703 stats.tcp6_in_errs[2], stats.tcp6_in_errs[3]); in sysctl_tp_err_stats()
10705 stats.tnl_cong_drops[0], stats.tnl_cong_drops[1], in sysctl_tp_err_stats()
10706 stats.tnl_cong_drops[2], stats.tnl_cong_drops[3]); in sysctl_tp_err_stats()
10708 stats.tnl_tx_drops[0], stats.tnl_tx_drops[1], in sysctl_tp_err_stats()
10709 stats.tnl_tx_drops[2], stats.tnl_tx_drops[3]); in sysctl_tp_err_stats()
10711 stats.ofld_vlan_drops[0], stats.ofld_vlan_drops[1], in sysctl_tp_err_stats()
10712 stats.ofld_vlan_drops[2], stats.ofld_vlan_drops[3]); in sysctl_tp_err_stats()
10714 stats.ofld_chan_drops[0], stats.ofld_chan_drops[1], in sysctl_tp_err_stats()
10715 stats.ofld_chan_drops[2], stats.ofld_chan_drops[3]); in sysctl_tp_err_stats()
10719 stats.mac_in_errs[0], stats.mac_in_errs[1]); in sysctl_tp_err_stats()
10721 stats.hdr_in_errs[0], stats.hdr_in_errs[1]); in sysctl_tp_err_stats()
10723 stats.tcp_in_errs[0], stats.tcp_in_errs[1]); in sysctl_tp_err_stats()
10725 stats.tcp6_in_errs[0], stats.tcp6_in_errs[1]); in sysctl_tp_err_stats()
10727 stats.tnl_cong_drops[0], stats.tnl_cong_drops[1]); in sysctl_tp_err_stats()
10729 stats.tnl_tx_drops[0], stats.tnl_tx_drops[1]); in sysctl_tp_err_stats()
10731 stats.ofld_vlan_drops[0], stats.ofld_vlan_drops[1]); in sysctl_tp_err_stats()
10733 stats.ofld_chan_drops[0], stats.ofld_chan_drops[1]); in sysctl_tp_err_stats()
10737 stats.ofld_no_neigh, stats.ofld_cong_defer); in sysctl_tp_err_stats()
10751 struct tp_tnl_stats stats; in sysctl_tnl_stats() local
10754 mtx_lock(&sc->reg_lock); in sysctl_tnl_stats()
10758 t4_tp_get_tnl_stats(sc, &stats, 1); in sysctl_tnl_stats()
10759 mtx_unlock(&sc->reg_lock); in sysctl_tnl_stats()
10767 if (sc->chip_params->nchan > 2) { in sysctl_tnl_stats()
10771 stats.out_pkt[0], stats.out_pkt[1], in sysctl_tnl_stats()
10772 stats.out_pkt[2], stats.out_pkt[3]); in sysctl_tnl_stats()
10774 stats.in_pkt[0], stats.in_pkt[1], in sysctl_tnl_stats()
10775 stats.in_pkt[2], stats.in_pkt[3]); in sysctl_tnl_stats()
10779 stats.out_pkt[0], stats.out_pkt[1]); in sysctl_tnl_stats()
10781 stats.in_pkt[0], stats.in_pkt[1]); in sysctl_tnl_stats()
10794 struct tp_params *tpp = &sc->params.tp; in sysctl_tp_la_mask()
10798 mask = tpp->la_mask >> 16; in sysctl_tp_la_mask()
10800 if (rc != 0 || req->newptr == NULL) in sysctl_tp_la_mask()
10804 mtx_lock(&sc->reg_lock); in sysctl_tp_la_mask()
10808 tpp->la_mask = mask << 16; in sysctl_tp_la_mask()
10810 tpp->la_mask); in sysctl_tp_la_mask()
10812 mtx_unlock(&sc->reg_lock); in sysctl_tp_la_mask()
10829 while (f->name) { in field_desc_show()
10830 uint64_t mask = (1ULL << f->width) - 1; in field_desc_show()
10831 int len = snprintf(buf, sizeof(buf), "%s: %ju", f->name, in field_desc_show()
10832 ((uintmax_t)v >> f->start) & mask); in field_desc_show()
10992 if (idx < (TPLA_SIZE / 2 - 1) || p[1] != ~0ULL) in tp_la_show2()
11003 if (idx < (TPLA_SIZE / 2 - 1) || p[1] != ~0ULL) in tp_la_show3()
11024 mtx_lock(&sc->reg_lock); in sysctl_tp_la()
11043 mtx_unlock(&sc->reg_lock); in sysctl_tp_la()
11066 mtx_lock(&sc->reg_lock); in sysctl_tx_rate()
11071 mtx_unlock(&sc->reg_lock); in sysctl_tx_rate()
11079 if (sc->chip_params->nchan > 2) { in sysctl_tx_rate()
11116 mtx_lock(&sc->reg_lock); in sysctl_ulprx_la()
11121 mtx_unlock(&sc->reg_lock); in sysctl_ulprx_la()
11150 mtx_lock(&sc->reg_lock); in sysctl_wcwr_stats()
11158 mtx_unlock(&sc->reg_lock); in sysctl_wcwr_stats()
11195 rc = bus_get_cpus(sc->dev, op, sizeof(cpuset), &cpuset); in sysctl_cpus()
11218 val = atomic_load_int(&sc->num_resets); in sysctl_reset()
11220 if (rc != 0 || req->newptr == NULL) in sysctl_reset()
11225 atomic_store_int(&sc->num_resets, 0); in sysctl_reset()
11235 taskqueue_enqueue(reset_tq, &sc->reset_task); in sysctl_reset()
11247 v = sc->tt.tls; in sysctl_tls()
11249 if (rc != 0 || req->newptr == NULL) in sysctl_tls()
11252 if (v != 0 && !(sc->cryptocaps & FW_CAPS_CONFIG_TLSKEYS)) in sysctl_tls()
11261 sc->tt.tls = !!v; in sysctl_tls()
11263 for_each_vi(sc->port[i], j, vi) { in sysctl_tls()
11264 if (vi->flags & VI_INIT_DONE) in sysctl_tls()
11265 t4_update_fl_bufsize(vi->ifp); in sysctl_tls()
11295 u_int cclk_ps = 1000000000 / sc->params.vpd.cclk; in sysctl_tp_tick()
11297 mtx_lock(&sc->reg_lock); in sysctl_tp_tick()
11299 res = (u_int)-1; in sysctl_tp_tick()
11302 mtx_unlock(&sc->reg_lock); in sysctl_tp_tick()
11303 if (res == (u_int)-1) in sysctl_tp_tick()
11334 u_int cclk_ps = 1000000000 / sc->params.vpd.cclk; in sysctl_tp_dack_timer()
11336 mtx_lock(&sc->reg_lock); in sysctl_tp_dack_timer()
11345 mtx_unlock(&sc->reg_lock); in sysctl_tp_dack_timer()
11361 u_int cclk_ps = 1000000000 / sc->params.vpd.cclk; in sysctl_tp_timer()
11368 mtx_lock(&sc->reg_lock); in sysctl_tp_timer()
11380 mtx_unlock(&sc->reg_lock); in sysctl_tp_timer()
11400 mtx_lock(&sc->reg_lock); in sysctl_tp_shift_cnt()
11407 mtx_unlock(&sc->reg_lock); in sysctl_tp_shift_cnt()
11425 mtx_lock(&sc->reg_lock); in sysctl_tp_backoff()
11432 mtx_unlock(&sc->reg_lock); in sysctl_tp_backoff()
11443 struct adapter *sc = vi->adapter; in sysctl_holdoff_tmr_idx_ofld()
11448 idx = vi->ofld_tmr_idx; in sysctl_holdoff_tmr_idx_ofld()
11451 if (rc != 0 || req->newptr == NULL) in sysctl_holdoff_tmr_idx_ofld()
11462 v = V_QINTR_TIMER_IDX(idx) | V_QINTR_CNT_EN(vi->ofld_pktc_idx != -1); in sysctl_holdoff_tmr_idx_ofld()
11465 atomic_store_rel_8(&ofld_rxq->iq.intr_params, v); in sysctl_holdoff_tmr_idx_ofld()
11467 ofld_rxq->iq.intr_params = v; in sysctl_holdoff_tmr_idx_ofld()
11470 vi->ofld_tmr_idx = idx; in sysctl_holdoff_tmr_idx_ofld()
11480 struct adapter *sc = vi->adapter; in sysctl_holdoff_pktc_idx_ofld()
11483 idx = vi->ofld_pktc_idx; in sysctl_holdoff_pktc_idx_ofld()
11486 if (rc != 0 || req->newptr == NULL) in sysctl_holdoff_pktc_idx_ofld()
11489 if (idx < -1 || idx >= SGE_NCOUNTERS) in sysctl_holdoff_pktc_idx_ofld()
11497 if (vi->flags & VI_INIT_DONE) in sysctl_holdoff_pktc_idx_ofld()
11500 vi->ofld_pktc_idx = idx; in sysctl_holdoff_pktc_idx_ofld()
11512 if (cntxt->cid > M_CTXTQID) in get_sge_context()
11515 if (cntxt->mem_id != CTXT_EGRESS && cntxt->mem_id != CTXT_INGRESS && in get_sge_context()
11516 cntxt->mem_id != CTXT_FLM && cntxt->mem_id != CTXT_CNM) in get_sge_context()
11528 if (sc->flags & FW_OK) { in get_sge_context()
11529 rc = -t4_sge_ctxt_rd(sc, sc->mbox, cntxt->cid, cntxt->mem_id, in get_sge_context()
11530 &cntxt->data[0]); in get_sge_context()
11539 rc = -t4_sge_ctxt_rd_bd(sc, cntxt->cid, cntxt->mem_id, &cntxt->data[0]); in get_sge_context()
11566 if (sc->flags & FULL_INIT_DONE && in load_fw()
11567 (sc->debug_flags & DF_LOAD_FW_ANYTIME) == 0) { in load_fw()
11572 fw_data = malloc(fw->len, M_CXGBE, M_WAITOK); in load_fw()
11574 rc = copyin(fw->data, fw_data, fw->len); in load_fw()
11576 rc = -t4_load_fw(sc, fw_data, fw->len); in load_fw()
11599 if (cfg->len == 0) { in load_cfg()
11601 rc = -t4_load_cfg(sc, NULL, 0); in load_cfg()
11605 cfg_data = malloc(cfg->len, M_CXGBE, M_WAITOK); in load_cfg()
11607 rc = copyin(cfg->data, cfg_data, cfg->len); in load_cfg()
11609 rc = -t4_load_cfg(sc, cfg_data, cfg->len); in load_cfg()
11624 if (br->len > 1024 * 1024) in load_boot()
11627 if (br->pf_offset == 0) { in load_boot()
11629 if (br->pfidx_addr > 7) in load_boot()
11631 offset = G_OFFSET(t4_read_reg(sc, PF_REG(br->pfidx_addr, in load_boot()
11633 } else if (br->pf_offset == 1) { in load_boot()
11635 offset = G_OFFSET(br->pfidx_addr); in load_boot()
11649 if (br->len == 0) { in load_boot()
11651 rc = -t4_load_boot(sc, NULL, offset, 0); in load_boot()
11655 br_data = malloc(br->len, M_CXGBE, M_WAITOK); in load_boot()
11657 rc = copyin(br->data, br_data, br->len); in load_boot()
11659 rc = -t4_load_boot(sc, br_data, offset, br->len); in load_boot()
11682 if (bc->len == 0) { in load_bootcfg()
11684 rc = -t4_load_bootcfg(sc, NULL, 0); in load_bootcfg()
11688 bc_data = malloc(bc->len, M_CXGBE, M_WAITOK); in load_bootcfg()
11690 rc = copyin(bc->data, bc_data, bc->len); in load_bootcfg()
11692 rc = -t4_load_bootcfg(sc, bc_data, bc->len); in load_bootcfg()
11708 buf = malloc(dump->len, M_CXGBE, M_NOWAIT | M_ZERO); in cudbg_dump()
11719 cudbg->adap = sc; in cudbg_dump()
11720 cudbg->print = (cudbg_print_cb)printf; in cudbg_dump()
11723 device_printf(sc->dev, "%s: wr_flash %u, len %u, data %p.\n", in cudbg_dump()
11724 __func__, dump->wr_flash, dump->len, dump->data); in cudbg_dump()
11727 if (dump->wr_flash) in cudbg_dump()
11728 cudbg->use_flash = 1; in cudbg_dump()
11729 MPASS(sizeof(cudbg->dbg_bitmap) == sizeof(dump->bitmap)); in cudbg_dump()
11730 memcpy(cudbg->dbg_bitmap, dump->bitmap, sizeof(cudbg->dbg_bitmap)); in cudbg_dump()
11732 rc = cudbg_collect(handle, buf, &dump->len); in cudbg_dump()
11736 rc = copyout(buf, dump->data, dump->len); in cudbg_dump()
11752 r = &op->rule[0]; in free_offload_policy()
11753 for (i = 0; i < op->nrules; i++, r++) { in free_offload_policy()
11754 free(r->bpf_prog.bf_insns, M_CXGBE); in free_offload_policy()
11756 free(op->rule, M_CXGBE); in free_offload_policy()
11773 if (uop->nrules == 0) { in set_offload_policy()
11777 } else if (uop->nrules > 256) { /* arbitrary */ in set_offload_policy()
11783 op->nrules = uop->nrules; in set_offload_policy()
11784 len = op->nrules * sizeof(struct offload_rule); in set_offload_policy()
11785 op->rule = malloc(len, M_CXGBE, M_ZERO | M_WAITOK); in set_offload_policy()
11786 rc = copyin(uop->rule, op->rule, len); in set_offload_policy()
11788 free(op->rule, M_CXGBE); in set_offload_policy()
11793 r = &op->rule[0]; in set_offload_policy()
11794 for (i = 0; i < op->nrules; i++, r++) { in set_offload_policy()
11797 if (r->open_type != OPEN_TYPE_LISTEN && in set_offload_policy()
11798 r->open_type != OPEN_TYPE_ACTIVE && in set_offload_policy()
11799 r->open_type != OPEN_TYPE_PASSIVE && in set_offload_policy()
11800 r->open_type != OPEN_TYPE_DONTCARE) { in set_offload_policy()
11807 op->nrules = i; in set_offload_policy()
11813 s = &r->settings; in set_offload_policy()
11814 if ((s->offload != 0 && s->offload != 1) || in set_offload_policy()
11815 s->cong_algo < -1 || s->cong_algo > CONG_ALG_HIGHSPEED || in set_offload_policy()
11816 s->sched_class < -1 || in set_offload_policy()
11817 s->sched_class >= sc->params.nsched_cls) { in set_offload_policy()
11822 bf = &r->bpf_prog; in set_offload_policy()
11823 u = bf->bf_insns; /* userspace ptr */ in set_offload_policy()
11824 bf->bf_insns = NULL; in set_offload_policy()
11825 if (bf->bf_len == 0) { in set_offload_policy()
11829 len = bf->bf_len * sizeof(*bf->bf_insns); in set_offload_policy()
11830 bf->bf_insns = malloc(len, M_CXGBE, M_ZERO | M_WAITOK); in set_offload_policy()
11831 rc = copyin(u, bf->bf_insns, len); in set_offload_policy()
11835 if (!bpf_validate(bf->bf_insns, bf->bf_len)) { in set_offload_policy()
11841 rw_wlock(&sc->policy_lock); in set_offload_policy()
11842 old = sc->policy; in set_offload_policy()
11843 sc->policy = op; in set_offload_policy()
11844 rw_wunlock(&sc->policy_lock); in set_offload_policy()
11859 mtx_lock(&sc->reg_lock); in read_card_mem()
11863 rc = validate_mem_range(sc, mr->addr, mr->len); in read_card_mem()
11864 mtx_unlock(&sc->reg_lock); in read_card_mem()
11868 buf = malloc(min(mr->len, MAX_READ_BUF_SIZE), M_CXGBE, M_WAITOK); in read_card_mem()
11869 addr = mr->addr; in read_card_mem()
11870 remaining = mr->len; in read_card_mem()
11871 dst = (void *)mr->data; in read_card_mem()
11875 mtx_lock(&sc->reg_lock); in read_card_mem()
11880 mtx_unlock(&sc->reg_lock); in read_card_mem()
11889 remaining -= n; in read_card_mem()
11903 if (i2cd->len == 0 || i2cd->port_id >= sc->params.nports) in read_i2c()
11906 if (i2cd->len > sizeof(i2cd->data)) in read_i2c()
11915 rc = -t4_i2c_rd(sc, sc->mbox, i2cd->port_id, i2cd->dev_addr, in read_i2c()
11916 i2cd->offset, i2cd->len, &i2cd->data[0]); in read_i2c()
11938 if (port_id >= sc->params.nports) in clear_stats()
11940 pi = sc->port[port_id]; in clear_stats()
11944 mtx_lock(&sc->reg_lock); in clear_stats()
11946 /* MAC stats */ in clear_stats()
11947 t4_clr_port_stats(sc, pi->tx_chan); in clear_stats()
11949 if (pi->fcs_reg != -1) in clear_stats()
11950 pi->fcs_base = t4_read_reg64(sc, pi->fcs_reg); in clear_stats()
11952 pi->stats.rx_fcs_err = 0; in clear_stats()
11955 if (vi->flags & VI_INIT_DONE) in clear_stats()
11956 t4_clr_vi_stats(sc, vi->vin); in clear_stats()
11958 chan_map = pi->rx_e_chan_map; in clear_stats()
11961 i = ffs(chan_map) - 1; in clear_stats()
11967 mtx_unlock(&sc->reg_lock); in clear_stats()
11968 pi->tx_parse_error = 0; in clear_stats()
11969 pi->tnl_cong_drops = 0; in clear_stats()
11972 * Since this command accepts a port, clear stats for in clear_stats()
11976 if (vi->flags & VI_INIT_DONE) { in clear_stats()
11980 rxq->lro.lro_queued = 0; in clear_stats()
11981 rxq->lro.lro_flushed = 0; in clear_stats()
11983 rxq->rxcsum = 0; in clear_stats()
11984 rxq->vlan_extraction = 0; in clear_stats()
11985 rxq->vxlan_rxcsum = 0; in clear_stats()
11987 rxq->fl.cl_allocated = 0; in clear_stats()
11988 rxq->fl.cl_recycled = 0; in clear_stats()
11989 rxq->fl.cl_fast_recycled = 0; in clear_stats()
11993 txq->txcsum = 0; in clear_stats()
11994 txq->tso_wrs = 0; in clear_stats()
11995 txq->vlan_insertion = 0; in clear_stats()
11996 txq->imm_wrs = 0; in clear_stats()
11997 txq->sgl_wrs = 0; in clear_stats()
11998 txq->txpkt_wrs = 0; in clear_stats()
11999 txq->txpkts0_wrs = 0; in clear_stats()
12000 txq->txpkts1_wrs = 0; in clear_stats()
12001 txq->txpkts0_pkts = 0; in clear_stats()
12002 txq->txpkts1_pkts = 0; in clear_stats()
12003 txq->txpkts_flush = 0; in clear_stats()
12004 txq->raw_wrs = 0; in clear_stats()
12005 txq->vxlan_tso_wrs = 0; in clear_stats()
12006 txq->vxlan_txcsum = 0; in clear_stats()
12007 txq->kern_tls_records = 0; in clear_stats()
12008 txq->kern_tls_short = 0; in clear_stats()
12009 txq->kern_tls_partial = 0; in clear_stats()
12010 txq->kern_tls_full = 0; in clear_stats()
12011 txq->kern_tls_octets = 0; in clear_stats()
12012 txq->kern_tls_waste = 0; in clear_stats()
12013 txq->kern_tls_options = 0; in clear_stats()
12014 txq->kern_tls_header = 0; in clear_stats()
12015 txq->kern_tls_fin = 0; in clear_stats()
12016 txq->kern_tls_fin_short = 0; in clear_stats()
12017 txq->kern_tls_cbc = 0; in clear_stats()
12018 txq->kern_tls_gcm = 0; in clear_stats()
12019 mp_ring_reset_stats(txq->r); in clear_stats()
12024 ofld_txq->wrq.tx_wrs_direct = 0; in clear_stats()
12025 ofld_txq->wrq.tx_wrs_copied = 0; in clear_stats()
12026 counter_u64_zero(ofld_txq->tx_iscsi_pdus); in clear_stats()
12027 counter_u64_zero(ofld_txq->tx_iscsi_octets); in clear_stats()
12028 counter_u64_zero(ofld_txq->tx_iscsi_iso_wrs); in clear_stats()
12029 counter_u64_zero(ofld_txq->tx_aio_jobs); in clear_stats()
12030 counter_u64_zero(ofld_txq->tx_aio_octets); in clear_stats()
12031 counter_u64_zero(ofld_txq->tx_toe_tls_records); in clear_stats()
12032 counter_u64_zero(ofld_txq->tx_toe_tls_octets); in clear_stats()
12037 ofld_rxq->fl.cl_allocated = 0; in clear_stats()
12038 ofld_rxq->fl.cl_recycled = 0; in clear_stats()
12039 ofld_rxq->fl.cl_fast_recycled = 0; in clear_stats()
12041 ofld_rxq->rx_iscsi_ddp_setup_ok); in clear_stats()
12043 ofld_rxq->rx_iscsi_ddp_setup_error); in clear_stats()
12044 ofld_rxq->rx_iscsi_ddp_pdus = 0; in clear_stats()
12045 ofld_rxq->rx_iscsi_ddp_octets = 0; in clear_stats()
12046 ofld_rxq->rx_iscsi_fl_pdus = 0; in clear_stats()
12047 ofld_rxq->rx_iscsi_fl_octets = 0; in clear_stats()
12048 ofld_rxq->rx_aio_ddp_jobs = 0; in clear_stats()
12049 ofld_rxq->rx_aio_ddp_octets = 0; in clear_stats()
12050 ofld_rxq->rx_toe_tls_records = 0; in clear_stats()
12051 ofld_rxq->rx_toe_tls_octets = 0; in clear_stats()
12052 ofld_rxq->rx_toe_ddp_octets = 0; in clear_stats()
12053 counter_u64_zero(ofld_rxq->ddp_buffer_alloc); in clear_stats()
12054 counter_u64_zero(ofld_rxq->ddp_buffer_reuse); in clear_stats()
12055 counter_u64_zero(ofld_rxq->ddp_buffer_free); in clear_stats()
12060 wrq = &sc->sge.ctrlq[pi->port_id]; in clear_stats()
12061 wrq->tx_wrs_direct = 0; in clear_stats()
12062 wrq->tx_wrs_copied = 0; in clear_stats()
12076 bcopy(&ca->addr[0], &in6.s6_addr[0], sizeof(in6.s6_addr)); in hold_clip_addr()
12092 bcopy(&ca->addr[0], &in6.s6_addr[0], sizeof(in6.s6_addr)); in release_clip_addr()
12104 return (pci_find_cap(sc->dev, cap, &i) == 0 ? i : 0); in t4_os_find_pci_capability()
12113 dev = sc->dev; in t4_os_pci_save_state()
12126 dev = sc->dev; in t4_os_pci_restore_state()
12136 struct adapter *sc = pi->adapter; in t4_os_portmod_changed()
12143 KASSERT((pi->flags & FIXED_IFMEDIA) == 0, in t4_os_portmod_changed()
12144 ("%s: port_type %u", __func__, pi->port_type)); in t4_os_portmod_changed()
12146 vi = &pi->vi[0]; in t4_os_portmod_changed()
12150 if (pi->mod_type != FW_PORT_MOD_TYPE_NONE) { in t4_os_portmod_changed()
12158 ifp = vi->ifp; in t4_os_portmod_changed()
12159 if (pi->mod_type == FW_PORT_MOD_TYPE_NONE) in t4_os_portmod_changed()
12161 else if (pi->mod_type == FW_PORT_MOD_TYPE_UNKNOWN) in t4_os_portmod_changed()
12163 else if (pi->mod_type == FW_PORT_MOD_TYPE_NOTSUPPORTED) in t4_os_portmod_changed()
12165 else if (pi->mod_type > 0 && pi->mod_type < nitems(mod_str)) { in t4_os_portmod_changed()
12167 port_top_speed(pi), mod_str[pi->mod_type]); in t4_os_portmod_changed()
12170 pi->mod_type); in t4_os_portmod_changed()
12179 struct link_config *lc = &pi->link_cfg; in t4_os_link_changed()
12180 struct adapter *sc = pi->adapter; in t4_os_link_changed()
12186 if (lc->link_ok) { in t4_os_link_changed()
12187 if (lc->speed > 25000 || in t4_os_link_changed()
12188 (lc->speed == 25000 && lc->fec == FEC_RS)) { in t4_os_link_changed()
12189 pi->fcs_reg = T5_PORT_REG(pi->tx_chan, in t4_os_link_changed()
12192 pi->fcs_reg = T5_PORT_REG(pi->tx_chan, in t4_os_link_changed()
12195 pi->fcs_base = t4_read_reg64(sc, pi->fcs_reg); in t4_os_link_changed()
12196 pi->stats.rx_fcs_err = 0; in t4_os_link_changed()
12198 pi->fcs_reg = -1; in t4_os_link_changed()
12201 MPASS(pi->fcs_reg != -1); in t4_os_link_changed()
12202 MPASS(pi->fcs_base == 0); in t4_os_link_changed()
12206 ifp = vi->ifp; in t4_os_link_changed()
12210 if (lc->link_ok) { in t4_os_link_changed()
12211 if_setbaudrate(ifp, IF_Mbps(lc->speed)); in t4_os_link_changed()
12228 * in - the only guarantee is that sc->sc_lock is a valid lock. in t4_iterate()
12240 struct adapter *sc = dev->si_drv1; in t4_ioctl()
12250 if ((edata->addr & 0x3) != 0 || edata->addr >= sc->mmio_len) in t4_ioctl()
12253 mtx_lock(&sc->reg_lock); in t4_ioctl()
12256 else if (edata->size == 4) in t4_ioctl()
12257 edata->val = t4_read_reg(sc, edata->addr); in t4_ioctl()
12258 else if (edata->size == 8) in t4_ioctl()
12259 edata->val = t4_read_reg64(sc, edata->addr); in t4_ioctl()
12262 mtx_unlock(&sc->reg_lock); in t4_ioctl()
12269 if ((edata->addr & 0x3) != 0 || edata->addr >= sc->mmio_len) in t4_ioctl()
12272 mtx_lock(&sc->reg_lock); in t4_ioctl()
12275 else if (edata->size == 4) { in t4_ioctl()
12276 if (edata->val & 0xffffffff00000000) in t4_ioctl()
12278 t4_write_reg(sc, edata->addr, (uint32_t) edata->val); in t4_ioctl()
12279 } else if (edata->size == 8) in t4_ioctl()
12280 t4_write_reg64(sc, edata->addr, edata->val); in t4_ioctl()
12283 mtx_unlock(&sc->reg_lock); in t4_ioctl()
12292 if (regs->len < reglen) { in t4_ioctl()
12293 regs->len = reglen; /* hint to the caller */ in t4_ioctl()
12297 regs->len = reglen; in t4_ioctl()
12299 mtx_lock(&sc->reg_lock); in t4_ioctl()
12304 mtx_unlock(&sc->reg_lock); in t4_ioctl()
12306 rc = copyout(buf, regs->data, reglen); in t4_ioctl()
12388 struct port_info *pi = vi->pi; in toe_capability()
12389 struct adapter *sc = pi->adapter; in toe_capability()
12400 if (sc->flags & KERN_TLS_ON && is_t6(sc)) { in toe_capability()
12411 p = sc->port[i]; in toe_capability()
12413 if (if_getcapenable(v->ifp) & IFCAP_TXTLS) { in toe_capability()
12416 device_get_nameunit(v->dev)); in toe_capability()
12432 if ((if_getcapenable(vi->ifp) & IFCAP_TOE) != 0) { in toe_capability()
12442 if (!(vi->flags & VI_INIT_DONE) && ((rc = vi_init(vi)) != 0)) in toe_capability()
12444 if (!(pi->vi[0].flags & VI_INIT_DONE) && in toe_capability()
12445 ((rc = vi_init(&pi->vi[0])) != 0)) in toe_capability()
12448 if (isset(&sc->offload_map, pi->port_id)) { in toe_capability()
12450 MPASS(pi->uld_vis > 0); in toe_capability()
12451 pi->uld_vis++; in toe_capability()
12464 KASSERT(sc->tom_softc != NULL, in toe_capability()
12476 if (pi->uld_vis++ == 0) in toe_capability()
12477 setbit(&sc->offload_map, pi->port_id); in toe_capability()
12479 if ((if_getcapenable(vi->ifp) & IFCAP_TOE) == 0) { in toe_capability()
12483 MPASS(isset(&sc->offload_map, pi->port_id)); in toe_capability()
12484 MPASS(pi->uld_vis > 0); in toe_capability()
12485 if (--pi->uld_vis == 0) in toe_capability()
12486 clrbit(&sc->offload_map, pi->port_id); in toe_capability()
12537 if (!(sc->flags & FULL_INIT_DONE)) { in t4_activate_uld()
12547 rc = t4_uld_list[id]->uld_activate(sc); in t4_activate_uld()
12549 setbit(&sc->active_ulds, id); in t4_activate_uld()
12570 rc = t4_uld_list[id]->uld_deactivate(sc); in t4_deactivate_uld()
12572 clrbit(&sc->active_ulds, id); in t4_deactivate_uld()
12591 rc = t4_uld_list[i]->uld_deactivate(sc); in deactivate_all_uld()
12594 clrbit(&sc->active_ulds, i); in deactivate_all_uld()
12612 t4_uld_list[i]->uld_stop == NULL) in stop_all_uld()
12614 (void) t4_uld_list[i]->uld_stop(sc); in stop_all_uld()
12630 t4_uld_list[i]->uld_restart == NULL) in restart_all_uld()
12632 (void) t4_uld_list[i]->uld_restart(sc); in restart_all_uld()
12644 return (isset(&sc->active_ulds, id)); in uld_active()
12662 if (sc->flags & KERN_TLS_ON) in ktls_capability()
12664 if (sc->offload_map != 0) { in ktls_capability()
12693 nq = *t < 0 ? -*t : c; in calculate_nqueues()
12736 if (t4_toecaps_allowed == -1) in tweak_tunables()
12739 if (t4_toecaps_allowed == -1) in tweak_tunables()
12744 if (t4_rdmacaps_allowed == -1) { in tweak_tunables()
12749 if (t4_iscsicaps_allowed == -1) { in tweak_tunables()
12758 if (t4_pktc_idx_ofld < -1 || t4_pktc_idx_ofld >= SGE_NCOUNTERS) in tweak_tunables()
12761 if (t4_rdmacaps_allowed == -1) in tweak_tunables()
12764 if (t4_iscsicaps_allowed == -1) in tweak_tunables()
12778 if (t4_pktc_idx < -1 || t4_pktc_idx >= SGE_NCOUNTERS) in tweak_tunables()
12792 * Number of VIs to create per-port. The first VI is the "main" regular in tweak_tunables()
12824 base = sc->memwin[2].mw_base; in t4_dump_mem()
12830 pf = V_PFNUM(sc->pf); in t4_dump_mem()
12833 off = addr - win_pos; in t4_dump_mem()
12848 len -= sizeof(buf); in t4_dump_mem()
12869 struct devlog_params *dparams = &sc->params.devlog; in t4_dump_devlog()
12874 if (dparams->start == 0) { in t4_dump_devlog()
12879 nentries = dparams->size / sizeof(struct fw_devlog_e); in t4_dump_devlog()
12880 m = fwmtype_to_hwmtype(dparams->memtype); in t4_dump_devlog()
12883 first = -1; in t4_dump_devlog()
12885 rc = -t4_mem_read(sc, m, dparams->start + i * sizeof(e), in t4_dump_devlog()
12900 if (first == -1) in t4_dump_devlog()
12905 rc = -t4_mem_read(sc, m, dparams->start + i * sizeof(e), in t4_dump_devlog()
13061 t4_write_reg(sc, A_MPS_RX_VXLAN_TYPE, V_VXLAN(sc->vxlan_port) | in enable_vxlan_rx()
13064 pi = sc->port[i]; in enable_vxlan_rx()
13065 if (pi->vxlan_tcam_entry == true) in enable_vxlan_rx()
13067 rc = t4_alloc_raw_mac_filt(sc, pi->vi[0].viid, match_all_mac, in enable_vxlan_rx()
13068 match_all_mac, sc->rawf_base + pi->port_id, 1, pi->port_id, in enable_vxlan_rx()
13071 rc = -rc; in enable_vxlan_rx()
13072 CH_ERR(&pi->vi[0], in enable_vxlan_rx()
13075 MPASS(rc == sc->rawf_base + pi->port_id); in enable_vxlan_rx()
13076 pi->vxlan_tcam_entry = true; in enable_vxlan_rx()
13086 if (sc->nrawf == 0 || chip_id(sc) <= CHELSIO_T5) in t4_vxlan_start()
13091 if (sc->vxlan_refcount == 0) { in t4_vxlan_start()
13092 sc->vxlan_port = v->port; in t4_vxlan_start()
13093 sc->vxlan_refcount = 1; in t4_vxlan_start()
13096 } else if (sc->vxlan_port == v->port) { in t4_vxlan_start()
13097 sc->vxlan_refcount++; in t4_vxlan_start()
13101 sc->vxlan_port, v->port); in t4_vxlan_start()
13111 if (sc->nrawf == 0 || chip_id(sc) <= CHELSIO_T5) in t4_vxlan_stop()
13121 if (sc->vxlan_port != v->port) in t4_vxlan_stop()
13123 if (sc->vxlan_refcount == 0) { in t4_vxlan_stop()
13125 "ignoring attempt to stop it again.\n", sc->vxlan_port); in t4_vxlan_stop()
13126 } else if (--sc->vxlan_refcount == 0 && !hw_off_limits(sc)) in t4_vxlan_stop()
13219 if (--loaded == 0) { in mod_event()