Lines Matching +full:tlv +full:- +full:layout
1 /* SPDX-License-Identifier: BSD-3-Clause */
148 struct ice_link_default_override_tlv *tlv);
267 * ice_map_bar - Map PCIe BAR memory
278 if (bar->res != NULL) {
283 bar->rid = PCIR_BAR(bar_num);
284 bar->res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &bar->rid,
286 if (!bar->res) {
291 bar->tag = rman_get_bustag(bar->res);
292 bar->handle = rman_get_bushandle(bar->res);
293 bar->size = rman_get_size(bar->res);
299 * ice_free_bar - Free PCIe BAR memory
308 if (bar->res != NULL)
309 bus_release_resource(dev, SYS_RES_MEMORY, bar->rid, bar->res);
310 bar->res = NULL;
314 * ice_set_ctrlq_len - Configure ctrlq lengths for a device
323 hw->adminq.num_rq_entries = ICE_AQ_LEN;
324 hw->adminq.num_sq_entries = ICE_AQ_LEN;
325 hw->adminq.rq_buf_size = ICE_AQ_MAX_BUF_LEN;
326 hw->adminq.sq_buf_size = ICE_AQ_MAX_BUF_LEN;
328 hw->mailboxq.num_rq_entries = ICE_MBXQ_LEN;
329 hw->mailboxq.num_sq_entries = ICE_MBXQ_LEN;
330 hw->mailboxq.rq_buf_size = ICE_MBXQ_MAX_BUF_LEN;
331 hw->mailboxq.sq_buf_size = ICE_MBXQ_MAX_BUF_LEN;
333 hw->sbq.num_rq_entries = ICE_SBQ_LEN;
334 hw->sbq.num_sq_entries = ICE_SBQ_LEN;
335 hw->sbq.rq_buf_size = ICE_SBQ_MAX_BUF_LEN;
336 hw->sbq.sq_buf_size = ICE_SBQ_MAX_BUF_LEN;
340 * ice_get_next_vsi - Get the next available VSI slot
361 * ice_setup_vsi_common - Common VSI setup for both dynamic and static VSIs
376 vsi->type = type;
377 vsi->sc = sc;
378 vsi->idx = idx;
379 sc->all_vsi[idx] = vsi;
380 vsi->dynamic = dynamic;
383 vsi->rule_mir_ingress = ICE_INVAL_MIRROR_RULE_ID;
384 vsi->rule_mir_egress = ICE_INVAL_MIRROR_RULE_ID;
387 ice_add_vsi_tunables(vsi, sc->vsi_sysctls);
391 * ice_alloc_vsi - Allocate a dynamic VSI
407 idx = ice_get_next_vsi(sc->all_vsi, sc->num_available_vsi);
408 if (idx >= sc->num_available_vsi) {
409 device_printf(sc->dev, "No available VSI slots\n");
415 device_printf(sc->dev, "Unable to allocate VSI memory\n");
425 * ice_setup_pf_vsi - Setup the PF VSI
428 * Setup the PF VSI structure which is embedded as sc->pf_vsi in the device
435 ice_setup_vsi_common(sc, &sc->pf_vsi, ICE_VSI_PF, 0, false);
461 vsi->tx_qmap = malloc(sizeof(u16) * max_tx_queues, M_ICE, M_WAITOK);
464 vsi->rx_qmap = malloc(sizeof(u16) * max_rx_queues, M_ICE, M_WAITOK);
468 vsi->tx_qmap[i] = ICE_INVALID_RES_IDX;
471 vsi->rx_qmap[i] = ICE_INVALID_RES_IDX;
476 * ice_free_vsi_qmaps - Free the PF qmaps associated with a VSI
486 struct ice_softc *sc = vsi->sc;
488 if (vsi->tx_qmap) {
489 ice_resmgr_release_map(&sc->tx_qmgr, vsi->tx_qmap,
490 vsi->num_tx_queues);
491 free(vsi->tx_qmap, M_ICE);
492 vsi->tx_qmap = NULL;
495 if (vsi->rx_qmap) {
496 ice_resmgr_release_map(&sc->rx_qmgr, vsi->rx_qmap,
497 vsi->num_rx_queues);
498 free(vsi->rx_qmap, M_ICE);
499 vsi->rx_qmap = NULL;
504 * ice_set_default_vsi_ctx - Setup default VSI context parameters
514 memset(&ctx->info, 0, sizeof(ctx->info));
516 ctx->alloc_from_pool = true;
518 ctx->info.sw_flags = ICE_AQ_VSI_SW_FLAG_SRC_PRUNE;
520 ctx->info.sw_flags2 = ICE_AQ_VSI_SW_FLAG_LAN_ENA;
522 ctx->info.inner_vlan_flags = ((ICE_AQ_VSI_INNER_VLAN_TX_MODE_ALL &
526 ctx->info.inner_vlan_flags |= ((ICE_AQ_VSI_INNER_VLAN_EMODE_STR_BOTH &
538 ctx->info.ingress_table = CPU_TO_LE32(table);
539 ctx->info.egress_table = CPU_TO_LE32(table);
541 ctx->info.outer_up_table = CPU_TO_LE32(table);
546 * ice_set_rss_vsi_ctx - Setup VSI context parameters for RSS
572 ctx->info.q_opt_rss = (((lut_type << ICE_AQ_VSI_Q_OPT_RSS_LUT_S) &
579 * ice_setup_vsi_qmap - Setup the queue mapping for a VSI
586 * @pre vsi->qmap_type is set to a valid type
594 MPASS(vsi->rx_qmap != NULL);
596 switch (vsi->qmap_type) {
598 ctx->info.mapping_flags |= CPU_TO_LE16(ICE_AQ_VSI_Q_MAP_CONTIG);
600 ctx->info.q_mapping[0] = CPU_TO_LE16(vsi->rx_qmap[0]);
601 ctx->info.q_mapping[1] = CPU_TO_LE16(vsi->num_rx_queues);
605 ctx->info.mapping_flags |= CPU_TO_LE16(ICE_AQ_VSI_Q_MAP_NONCONTIG);
607 for (int i = 0; i < vsi->num_rx_queues; i++)
608 ctx->info.q_mapping[i] = CPU_TO_LE16(vsi->rx_qmap[i]);
614 /* Calculate the next power-of-2 of number of queues */
615 if (vsi->num_rx_queues)
616 pow = flsl(vsi->num_rx_queues - 1);
620 ctx->info.tc_mapping[0] = CPU_TO_LE16(qmap);
623 vsi->tc_info[0].qoffset = 0;
624 vsi->tc_info[0].qcount_rx = vsi->num_rx_queues;
625 vsi->tc_info[0].qcount_tx = vsi->num_tx_queues;
627 vsi->tc_info[i].qoffset = 0;
628 vsi->tc_info[i].qcount_rx = 1;
629 vsi->tc_info[i].qcount_tx = 1;
631 vsi->tc_map = 0x1;
637 * ice_setup_vsi_mirroring -- Setup a VSI for mirroring PF VSI traffic
640 * @pre vsi->mirror_src_vsi is set to the SW VSI num that traffic is to be
649 struct ice_softc *sc = vsi->sc;
650 struct ice_hw *hw = &sc->hw;
651 device_t dev = sc->dev;
656 rule.vsi_idx = ice_get_hw_vsi_num(hw, vsi->mirror_src_vsi);
659 dest_vsi = ice_get_hw_vsi_num(hw, vsi->idx);
668 ice_aq_str(hw->adminq.sq_last_status));
672 vsi->rule_mir_ingress = rule_id;
681 ice_aq_str(hw->adminq.sq_last_status));
685 vsi->rule_mir_egress = rule_id;
691 * ice_remove_vsi_mirroring -- Teardown any VSI mirroring rules
697 struct ice_hw *hw = &vsi->sc->hw;
701 if (vsi->rule_mir_ingress != ICE_INVAL_MIRROR_RULE_ID)
702 status = ice_aq_delete_mir_rule(hw, vsi->rule_mir_ingress, keep_alloc, NULL);
705 device_printf(vsi->sc->dev, "Could not remove mirror VSI ingress rule, err %s aq_err %s\n",
706 ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status));
710 if (vsi->rule_mir_egress != ICE_INVAL_MIRROR_RULE_ID)
711 status = ice_aq_delete_mir_rule(hw, vsi->rule_mir_egress, keep_alloc, NULL);
714 device_printf(vsi->sc->dev, "Could not remove mirror VSI egress rule, err %s aq_err %s\n",
715 ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status));
719 * ice_initialize_vsi - Initialize a VSI for use
724 * @pre vsi->num_tx_queues is set
725 * @pre vsi->num_rx_queues is set
731 struct ice_hw *hw = &vsi->sc->hw;
737 switch (vsi->type) {
749 ice_set_rss_vsi_ctx(&ctx, vsi->type);
752 ctx.info.sw_id = hw->port_info->sw_id;
763 /* (Re-)add VSI to HW VSI handle list */
764 status = ice_add_vsi(hw, vsi->idx, &ctx, NULL);
766 device_printf(vsi->sc->dev,
769 ice_aq_str(hw->adminq.sq_last_status));
772 vsi->info = ctx.info;
775 max_txqs[0] = vsi->num_tx_queues;
777 status = ice_cfg_vsi_lan(hw->port_info, vsi->idx,
780 device_printf(vsi->sc->dev,
783 ice_aq_str(hw->adminq.sq_last_status));
795 * ice_deinit_vsi - Tell firmware to release resources for a VSI
805 struct ice_softc *sc = vsi->sc;
806 struct ice_hw *hw = &sc->hw;
810 MPASS(vsi == sc->all_vsi[vsi->idx]);
812 ctx.info = vsi->info;
814 status = ice_rm_vsi_lan_cfg(hw->port_info, vsi->idx);
820 device_printf(sc->dev,
822 vsi->idx, ice_status_str(status));
826 status = ice_free_vsi(hw, vsi->idx, &ctx, false, NULL);
828 device_printf(sc->dev,
830 vsi->idx, ice_status_str(status),
831 ice_aq_str(hw->adminq.sq_last_status));
836 * ice_release_vsi - Release resources associated with a VSI
846 struct ice_softc *sc = vsi->sc;
847 int idx = vsi->idx;
850 MPASS(vsi == sc->all_vsi[idx]);
853 if (ice_is_bit_set(sc->feat_en, ICE_FEATURE_RSS))
865 if (!ice_test_state(&sc->state, ICE_STATE_RESET_FAILED))
870 if (vsi->dynamic) {
871 free(sc->all_vsi[idx], M_ICE);
874 sc->all_vsi[idx] = NULL;
878 * ice_aq_speed_to_rate - Convert AdminQ speed enum to baudrate
886 switch (pi->phy.link_info.link_speed) {
917 * ice_aq_speed_to_str - Convert AdminQ speed enum to string representation
926 switch (pi->phy.link_info.link_speed) {
958 * ice_get_phy_type_low - Get media associated with phy_type_low
1104 * ice_get_phy_type_high - Get media associated with phy_type_high
1152 * ice_phy_types_to_max_rate - Returns port's max supported baudrate
1161 uint64_t phy_low = pi->phy.phy_type_low;
1162 uint64_t phy_high = pi->phy.phy_type_high;
1274 * ice_add_media_types - Add supported media types to the media structure
1288 struct ice_port_info *pi = sc->hw.port_info;
1307 device_printf(sc->dev,
1310 ice_aq_str(sc->hw.adminq.sq_last_status));
1367 * ice_configure_rxq_interrupt - Configure HW Rx queue for an MSI-X interrupt
1370 * @vector: MSI-X vector index in PF/VF space
1389 * ice_configure_all_rxq_interrupts - Configure HW Rx queues for MSI-X interrupts
1392 * Called when setting up MSI-X interrupts to configure the Rx hardware queues.
1397 struct ice_hw *hw = &vsi->sc->hw;
1400 for (i = 0; i < vsi->num_rx_queues; i++) {
1401 struct ice_rx_queue *rxq = &vsi->rx_queues[i];
1403 ice_configure_rxq_interrupt(hw, vsi->rx_qmap[rxq->me],
1404 rxq->irqv->me, ICE_RX_ITR);
1408 i, rxq->me, vsi->rx_qmap[rxq->me], rxq->irqv->me);
1415 * ice_configure_txq_interrupt - Configure HW Tx queue for an MSI-X interrupt
1418 * @vector: MSI-X vector index in PF/VF space
1437 * ice_configure_all_txq_interrupts - Configure HW Tx queues for MSI-X interrupts
1440 * Called when setting up MSI-X interrupts to configure the Tx hardware queues.
1445 struct ice_hw *hw = &vsi->sc->hw;
1448 for (i = 0; i < vsi->num_tx_queues; i++) {
1449 struct ice_tx_queue *txq = &vsi->tx_queues[i];
1451 ice_configure_txq_interrupt(hw, vsi->tx_qmap[txq->me],
1452 txq->irqv->me, ICE_TX_ITR);
1459 * ice_flush_rxq_interrupts - Unconfigure Hw Rx queues MSI-X interrupt cause
1472 struct ice_hw *hw = &vsi->sc->hw;
1475 for (i = 0; i < vsi->num_rx_queues; i++) {
1476 struct ice_rx_queue *rxq = &vsi->rx_queues[i];
1480 reg = vsi->rx_qmap[rxq->me];
1490 wr32(hw, GLINT_DYN_CTL(rxq->irqv->me),
1496 * ice_flush_txq_interrupts - Unconfigure Hw Tx queues MSI-X interrupt cause
1509 struct ice_hw *hw = &vsi->sc->hw;
1512 for (i = 0; i < vsi->num_tx_queues; i++) {
1513 struct ice_tx_queue *txq = &vsi->tx_queues[i];
1517 reg = vsi->tx_qmap[txq->me];
1527 wr32(hw, GLINT_DYN_CTL(txq->irqv->me),
1533 * ice_configure_rx_itr - Configure the Rx ITR settings for this VSI
1541 struct ice_hw *hw = &vsi->sc->hw;
1544 /* TODO: Handle per-queue/per-vector ITR? */
1546 for (i = 0; i < vsi->num_rx_queues; i++) {
1547 struct ice_rx_queue *rxq = &vsi->rx_queues[i];
1549 wr32(hw, GLINT_ITR(ICE_RX_ITR, rxq->irqv->me),
1550 ice_itr_to_reg(hw, vsi->rx_itr));
1557 * ice_configure_tx_itr - Configure the Tx ITR settings for this VSI
1565 struct ice_hw *hw = &vsi->sc->hw;
1568 /* TODO: Handle per-queue/per-vector ITR? */
1570 for (i = 0; i < vsi->num_tx_queues; i++) {
1571 struct ice_tx_queue *txq = &vsi->tx_queues[i];
1573 wr32(hw, GLINT_ITR(ICE_TX_ITR, txq->irqv->me),
1574 ice_itr_to_reg(hw, vsi->tx_itr));
1581 * ice_setup_tx_ctx - Setup an ice_tlan_ctx structure for a queue
1589 struct ice_vsi *vsi = txq->vsi;
1590 struct ice_softc *sc = vsi->sc;
1591 struct ice_hw *hw = &sc->hw;
1593 tlan_ctx->port_num = hw->port_info->lport;
1596 tlan_ctx->qlen = txq->desc_count;
1599 tlan_ctx->base = txq->tx_paddr >> 7;
1601 tlan_ctx->pf_num = hw->pf_id;
1603 switch (vsi->type) {
1605 tlan_ctx->vmvf_type = ICE_TLAN_CTX_VMVF_TYPE_PF;
1608 tlan_ctx->vmvf_type = ICE_TLAN_CTX_VMVF_TYPE_VMQ;
1614 tlan_ctx->src_vsi = ice_get_hw_vsi_num(hw, vsi->idx);
1617 tlan_ctx->tso_ena = 1;
1618 tlan_ctx->internal_usage_flag = 1;
1620 tlan_ctx->tso_qnum = pf_q;
1626 tlan_ctx->legacy_int = 1;
1629 tlan_ctx->wb_mode = 0;
1635 * ice_cfg_vsi_for_tx - Configure the hardware for Tx
1645 struct ice_hw *hw = &vsi->sc->hw;
1646 device_t dev = vsi->sc->dev;
1657 qg->num_txqs = 1;
1659 for (i = 0; i < vsi->num_tx_queues; i++) {
1661 struct ice_tx_queue *txq = &vsi->tx_queues[i];
1663 pf_q = vsi->tx_qmap[txq->me];
1664 qg->txqs[0].txq_id = htole16(pf_q);
1670 ice_set_ctx(hw, (u8 *)&tlan_ctx, qg->txqs[0].txq_ctx,
1673 status = ice_ena_vsi_txq(hw->port_info, vsi->idx, txq->tc,
1674 txq->q_handle, 1, qg, qg_size, NULL);
1678 i, txq->tc, txq->q_handle,
1680 ice_aq_str(hw->adminq.sq_last_status));
1686 if (pf_q == le16toh(qg->txqs[0].txq_id))
1687 txq->q_teid = le32toh(qg->txqs[0].q_teid);
1697 * ice_setup_rx_ctx - Setup an Rx context structure for a receive queue
1709 struct ice_vsi *vsi = rxq->vsi;
1710 struct ice_softc *sc = vsi->sc;
1711 struct ice_hw *hw = &sc->hw;
1717 pf_q = vsi->rx_qmap[rxq->me];
1720 rlan_ctx.base = rxq->rx_paddr >> 7;
1722 rlan_ctx.qlen = rxq->desc_count;
1724 rlan_ctx.dbuf = vsi->mbuf_sz >> ICE_RLAN_CTX_DBUF_S;
1744 rlan_ctx.rxmax = min(vsi->max_frame_size,
1745 ICE_MAX_RX_SEGS * vsi->mbuf_sz);
1749 if (vsi->type != ICE_VSI_VF) {
1764 device_printf(sc->dev,
1766 ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status));
1770 wr32(hw, rxq->tail, 0);
1776 * ice_cfg_vsi_for_rx - Configure the hardware for Rx
1789 for (i = 0; i < vsi->num_rx_queues; i++) {
1790 MPASS(vsi->mbuf_sz > 0);
1791 err = ice_setup_rx_ctx(&vsi->rx_queues[i]);
1800 * ice_is_rxq_ready - Check if an Rx queue is ready
1840 * ice_control_rx_queue - Configure hardware to start or stop an Rx queue
1852 struct ice_hw *hw = &vsi->sc->hw;
1853 device_t dev = vsi->sc->dev;
1857 struct ice_rx_queue *rxq = &vsi->rx_queues[qidx];
1858 int pf_q = vsi->rx_qmap[rxq->me];
1899 * ice_control_all_rx_queues - Configure hardware to start or stop the Rx queues
1916 for (i = 0; i < vsi->num_rx_queues; i++) {
1926 * ice_add_mac_to_list - Add MAC filter to a MAC filter list
1948 entry->fltr_info.flag = ICE_FLTR_TX;
1949 entry->fltr_info.src_id = ICE_SRC_ID_VSI;
1950 entry->fltr_info.lkup_type = ICE_SW_LKUP_MAC;
1951 entry->fltr_info.fltr_act = action;
1952 entry->fltr_info.vsi_handle = vsi->idx;
1953 bcopy(addr, entry->fltr_info.l_data.mac.mac_addr, ETHER_ADDR_LEN);
1955 LIST_ADD(&entry->list_entry, list);
1961 * ice_free_fltr_list - Free memory associated with a MAC address list
1972 LIST_DEL(&e->list_entry);
1978 * ice_add_vsi_mac_filter - Add a MAC address filter for a VSI
1992 struct ice_hw *hw = &vsi->sc->hw;
1993 device_t dev = vsi->sc->dev;
2011 ice_aq_str(hw->adminq.sq_last_status));
2021 * ice_cfg_pf_default_mac_filters - Setup default unicast and broadcast addrs
2029 struct ice_vsi *vsi = &sc->pf_vsi;
2030 struct ice_hw *hw = &sc->hw;
2034 err = ice_add_vsi_mac_filter(vsi, hw->port_info->mac.lan_addr);
2047 * ice_remove_vsi_mac_filter - Remove a MAC address filter for a VSI
2062 struct ice_hw *hw = &vsi->sc->hw;
2063 device_t dev = vsi->sc->dev;
2081 ice_aq_str(hw->adminq.sq_last_status));
2091 * ice_rm_pf_default_mac_filters - Remove default unicast and broadcast addrs
2099 struct ice_vsi *vsi = &sc->pf_vsi;
2100 struct ice_hw *hw = &sc->hw;
2104 err = ice_remove_vsi_mac_filter(vsi, hw->port_info->mac.lan_addr);
2117 * ice_check_ctrlq_errors - Check for and report controlq errors
2130 struct ice_hw *hw = &sc->hw;
2134 * same register layout, so we use the PF_FW_AxQLEN defines only.
2136 val = rd32(hw, cq->rq.len);
2140 device_printf(sc->dev,
2143 device_printf(sc->dev,
2147 device_printf(sc->dev,
2152 wr32(hw, cq->rq.len, val);
2155 val = rd32(hw, cq->sq.len);
2159 device_printf(sc->dev,
2162 device_printf(sc->dev,
2166 device_printf(sc->dev,
2171 wr32(hw, cq->sq.len, val);
2176 * ice_process_link_event - Process a link event indication from firmware
2187 struct ice_port_info *pi = sc->hw.port_info;
2188 struct ice_hw *hw = &sc->hw;
2189 device_t dev = sc->dev;
2193 MPASS(le16toh(e->desc.datalen) >= ICE_GET_LINK_STATUS_DATALEN_V1);
2198 * to re-enable link events.
2200 pi->phy.get_link_info = true;
2201 ice_get_link_status(pi, &sc->link_up);
2203 if (pi->phy.link_info.topo_media_conflict &
2207 "Possible mis-configuration of the Ethernet port detected; please use the Intel (R) Ethernet Port Configuration Tool utility to address the issue.\n");
2209 if ((pi->phy.link_info.link_info & ICE_AQ_MEDIA_AVAILABLE) &&
2210 !(pi->phy.link_info.link_info & ICE_AQ_LINK_UP)) {
2211 if (!(pi->phy.link_info.an_info & ICE_AQ_QUALIFIED_MODULE))
2214 if (pi->phy.link_info.link_cfg_err & ICE_AQ_LINK_MODULE_POWER_UNSUPPORTED)
2217 if (pi->phy.link_info.link_cfg_err & ICE_AQ_LINK_INVAL_MAX_POWER_LIMIT)
2222 if (!(pi->phy.link_info.link_info & ICE_AQ_MEDIA_AVAILABLE)) {
2223 if (!ice_testandset_state(&sc->state, ICE_STATE_NO_MEDIA)) {
2225 if (status && hw->adminq.sq_last_status != ICE_AQ_RC_EMODE)
2229 ice_aq_str(hw->adminq.sq_last_status));
2235 ice_clear_state(&sc->state, ICE_STATE_LINK_STATUS_REPORTED);
2241 * ice_process_ctrlq_event - Respond to a controlq event
2254 opcode = le16toh(event->desc.opcode);
2261 ice_handle_fw_log_event(sc, &event->desc, event->msg_buf);
2273 device_printf(sc->dev,
2280 * ice_process_ctrlq - helper function to process controlq rings
2293 struct ice_hw *hw = &sc->hw;
2301 cq = &hw->adminq;
2305 cq = &hw->sbq;
2309 cq = &hw->mailboxq;
2313 device_printf(sc->dev,
2323 * holding a non-sleepable lock, so we *must* use M_NOWAIT here.
2325 event.buf_len = cq->rq_buf_size;
2328 device_printf(sc->dev,
2339 device_printf(sc->dev,
2355 * pkg_ver_empty - Check if a package version is empty
2360 * version as empty if none of the versions are non-zero and the name string
2373 pkg_ver->major == 0 &&
2374 pkg_ver->minor == 0 &&
2375 pkg_ver->update == 0 &&
2376 pkg_ver->draft == 0);
2380 * pkg_ver_compatible - Check if the package version is compatible
2387 * @returns 0 if the package version is compatible, -1 if the package version
2393 if (pkg_ver->major > ICE_PKG_SUPP_VER_MAJ)
2395 else if ((pkg_ver->major == ICE_PKG_SUPP_VER_MAJ) &&
2396 (pkg_ver->minor > ICE_PKG_SUPP_VER_MNR))
2398 else if ((pkg_ver->major == ICE_PKG_SUPP_VER_MAJ) &&
2399 (pkg_ver->minor == ICE_PKG_SUPP_VER_MNR))
2402 return (-1); /* older */
2406 * ice_os_pkg_version_str - Format OS package version info into a sbuf
2423 if (pkg_ver_empty(&hw->pkg_ver, hw->pkg_name)) {
2429 * This should already be null-terminated, but since this is a raw
2434 strlcpy(name_buf, (char *)hw->pkg_name, ICE_PKG_NAME_SIZE);
2438 hw->pkg_ver.major,
2439 hw->pkg_ver.minor,
2440 hw->pkg_ver.update,
2441 hw->pkg_ver.draft);
2445 * ice_active_pkg_version_str - Format active package version info into a sbuf
2458 if (pkg_ver_empty(&hw->active_pkg_ver, hw->active_pkg_name)) {
2464 * This should already be null-terminated, but since this is a raw
2469 strlcpy(name_buf, (char *)hw->active_pkg_name, ICE_PKG_NAME_SIZE);
2473 hw->active_pkg_ver.major,
2474 hw->active_pkg_ver.minor,
2475 hw->active_pkg_ver.update,
2476 hw->active_pkg_ver.draft);
2478 if (hw->active_track_id != 0)
2479 sbuf_printf(buf, ", track id 0x%08x", hw->active_track_id);
2483 * ice_nvm_version_str - Format the NVM version information into a sbuf
2494 struct ice_nvm_info *nvm = &hw->flash.nvm;
2495 struct ice_orom_info *orom = &hw->flash.orom;
2496 struct ice_netlist_info *netlist = &hw->flash.netlist;
2502 * 0-9.
2505 "fw %u.%u.%u api %u.%u nvm %x.%02x etid %08x netlist %x.%x.%x-%x.%x.%x.%04x oem %u.%u.%u",
2506 hw->fw_maj_ver, hw->fw_min_ver, hw->fw_patch,
2507 hw->api_maj_ver, hw->api_min_ver,
2508 nvm->major, nvm->minor, nvm->eetrack,
2509 netlist->major, netlist->minor,
2510 netlist->type >> 16, netlist->type & 0xFFFF,
2511 netlist->rev, netlist->cust_ver, netlist->hash,
2512 orom->major, orom->build, orom->patch);
2516 * ice_print_nvm_version - Print the NVM info to the kernel message log
2524 struct ice_hw *hw = &sc->hw;
2525 device_t dev = sc->dev;
2536 * ice_update_port_oversize - Update port oversize stats
2546 cur_ps = &sc->stats.cur;
2548 sc->soft_stats.rx_roc_error = rx_errors + cur_ps->rx_oversize;
2552 * ice_update_vsi_hw_stats - Update VSI-specific ethernet statistics counters
2562 struct ice_hw *hw = &vsi->sc->hw;
2565 if (!ice_is_vsi_valid(hw, vsi->idx))
2568 vsi_num = ice_get_hw_vsi_num(hw, vsi->idx); /* HW absolute index of a VSI */
2569 prev_es = &vsi->hw_stats.prev;
2570 cur_es = &vsi->hw_stats.cur;
2574 vsi->hw_stats.offsets_loaded, \
2575 &prev_es->location, &cur_es->location)
2579 vsi->hw_stats.offsets_loaded, \
2580 &prev_es->location, &cur_es->location)
2593 ice_stat_update_repc(hw, vsi->idx, vsi->hw_stats.offsets_loaded,
2595 ice_update_port_oversize(vsi->sc, cur_es->rx_errors);
2599 vsi->hw_stats.offsets_loaded = true;
2603 * ice_reset_vsi_stats - Reset VSI statistics counters
2608 * post-reset so that VSI statistics count from zero again.
2614 memset(&vsi->hw_stats.prev, 0, sizeof(vsi->hw_stats.prev));
2615 memset(&vsi->hw_stats.cur, 0, sizeof(vsi->hw_stats.cur));
2616 vsi->hw_stats.offsets_loaded = false;
2620 * ice_update_pf_stats - Update port stats counters
2630 struct ice_hw *hw = &sc->hw;
2633 MPASS(hw->port_info);
2635 prev_ps = &sc->stats.prev;
2636 cur_ps = &sc->stats.cur;
2637 lport = hw->port_info->lport;
2641 sc->stats.offsets_loaded, \
2642 &prev_ps->location[index], &cur_ps->location[index])
2646 sc->stats.offsets_loaded, \
2647 &prev_ps->location, &cur_ps->location)
2651 sc->stats.offsets_loaded, \
2652 &prev_ps->location, &cur_ps->location)
2664 sc->stats.offsets_loaded,
2665 &prev_ps->eth.rx_discards, &cur_ps->eth.rx_discards);
2710 sc->stats.offsets_loaded = true;
2714 * ice_reset_pf_stats - Reset port stats counters
2724 memset(&sc->stats.prev, 0, sizeof(sc->stats.prev));
2725 memset(&sc->stats.cur, 0, sizeof(sc->stats.cur));
2726 sc->stats.offsets_loaded = false;
2730 * ice_sysctl_show_fw - sysctl callback to show firmware information
2743 struct ice_hw *hw = &sc->hw;
2761 * ice_sysctl_pba_number - sysctl callback to show PBA number
2774 struct ice_hw *hw = &sc->hw;
2775 device_t dev = sc->dev;
2789 ice_aq_str(hw->adminq.sq_last_status));
2797 * ice_sysctl_pkg_version - sysctl to show the active package version info
2810 struct ice_hw *hw = &sc->hw;
2828 * ice_sysctl_os_pkg_version - sysctl to show the OS package version info
2841 struct ice_hw *hw = &sc->hw;
2859 * ice_sysctl_current_speed - sysctl callback to show current link speed
2872 struct ice_hw *hw = &sc->hw;
2882 sbuf_printf(sbuf, "%s", ice_aq_speed_to_str(hw->port_info));
2985 "\n\t 0x0 - Auto" \
2986 "\n\t 0x1 - 10 Mb" \
2987 "\n\t 0x2 - 100 Mb" \
2988 "\n\t 0x4 - 1G" \
2989 "\n\t 0x8 - 2.5G" \
2990 "\n\t 0x10 - 5G" \
2991 "\n\t 0x20 - 10G" \
2992 "\n\t 0x40 - 20G" \
2993 "\n\t 0x80 - 25G" \
2994 "\n\t 0x100 - 40G" \
2995 "\n\t 0x200 - 50G" \
2996 "\n\t 0x400 - 100G" \
2997 "\n\t 0x800 - 200G" \
2998 "\n\t0x8000 - Unknown" \
3000 "\nUse \"sysctl -x\" to view flags properly."
3094 * ice_aq_phy_types_to_link_speeds - Convert the PHY Types to speeds
3095 * @phy_type_low: lower 64-bit PHY Type bitmask
3096 * @phy_type_high: upper 64-bit PHY Type bitmask
3124 * ice_sysctl_speeds_to_aq_phy_types - Convert sysctl speed flags to AQ PHY flags
3125 * @sysctl_speeds: 16-bit sysctl speeds or AQ_LINK_SPEED flags
3174 u16 user_speeds_orig; /* Input from caller - See ICE_AQ_LINK_SPEED_* */
3180 * ice_intersect_phy_types_and_speeds - Return intersection of link speeds
3198 struct ice_hw *hw = &sc->hw;
3199 struct ice_port_info *pi = hw->port_info;
3205 switch (phy_data->report_mode) {
3210 report_type = phy_data->report_mode >> 1;
3213 device_printf(sc->dev,
3215 __func__, phy_data->report_mode);
3223 if (phy_data->user_speeds_orig == 0)
3224 phy_data->user_speeds_orig = USHRT_MAX;
3225 else if (ice_is_bit_set(sc->feat_en, ICE_FEATURE_LENIENT_LINK_MODE))
3228 status = ice_aq_get_phy_caps(pi, false, phy_data->report_mode, &pcaps, NULL);
3230 device_printf(sc->dev,
3234 ice_aq_str(sc->hw.adminq.sq_last_status));
3238 phy_data->phy_low_orig = le64toh(pcaps.phy_type_low);
3239 phy_data->phy_high_orig = le64toh(pcaps.phy_type_high);
3240 report_speeds = ice_aq_phy_types_to_link_speeds(phy_data->phy_low_orig,
3241 phy_data->phy_high_orig);
3245 if ((phy_data->user_speeds_orig & temp_speeds) == 0) {
3246 device_printf(sc->dev,
3247 "User-specified speeds (\"0x%04X\") not supported\n",
3248 phy_data->user_speeds_orig);
3253 ice_sysctl_speeds_to_aq_phy_types(phy_data->user_speeds_orig,
3254 &phy_data->phy_low_intr, &phy_data->phy_high_intr);
3255 phy_data->user_speeds_intr = phy_data->user_speeds_orig & report_speeds;
3256 phy_data->phy_low_intr &= phy_data->phy_low_orig;
3257 phy_data->phy_high_intr &= phy_data->phy_high_orig;
3263 * ice_sysctl_advertise_speed - Display/change link speeds supported by port
3277 struct ice_port_info *pi = sc->hw.port_info;
3279 device_t dev = sc->dev;
3299 if ((ret) || (req->newptr == NULL))
3309 pi->phy.curr_user_speed_req = sysctl_speeds;
3311 if (!ice_test_state(&sc->state, ICE_STATE_LINK_ACTIVE_ON_DOWN) &&
3312 !sc->link_up && !(if_getflags(sc->ifp) & IFF_UP))
3321 "\n\tauto - " ICE_FEC_STRING_AUTO \
3322 "\n\tfc - " ICE_FEC_STRING_BASER \
3323 "\n\trs - " ICE_FEC_STRING_RS \
3324 "\n\tnone - " ICE_FEC_STRING_NONE \
3328 * ice_sysctl_fec_config - Display/change the configured FEC mode
3342 struct ice_port_info *pi = sc->hw.port_info;
3344 device_t dev = sc->dev;
3357 if ((ret) || (req->newptr == NULL))
3362 if (sc->allow_no_fec_mod_in_auto)
3383 pi->phy.curr_user_fec_req = new_mode;
3385 if (!ice_test_state(&sc->state, ICE_STATE_LINK_ACTIVE_ON_DOWN) && !sc->link_up)
3393 * ice_sysctl_negotiated_fec - Display the negotiated FEC mode on the link
3405 struct ice_hw *hw = &sc->hw;
3416 strlcpy(neg_fec, ice_negotiated_fec_mode(hw->port_info), sizeof(neg_fec));
3419 if (req->newptr != NULL)
3427 "\t0 - " ICE_FC_STRING_NONE \
3428 "\n\t1 - " ICE_FC_STRING_RX \
3429 "\n\t2 - " ICE_FC_STRING_TX \
3430 "\n\t3 - " ICE_FC_STRING_FULL \
3434 * ice_sysctl_fc_config - Display/change the advertised flow control mode
3448 struct ice_port_info *pi = sc->hw.port_info;
3451 struct ice_hw *hw = &sc->hw;
3452 device_t dev = sc->dev;
3471 ice_aq_str(hw->adminq.sq_last_status));
3494 if ((ret) || (req->newptr == NULL))
3522 fc_num = -1;
3545 pi->phy.curr_user_fc_req = new_mode;
3548 if ((hw->port_info->qos_cfg.is_sw_lldp) &&
3549 (hw->port_info->qos_cfg.local_dcbx_cfg.pfc.pfcena != 0) &&
3556 if (!ice_test_state(&sc->state, ICE_STATE_LINK_ACTIVE_ON_DOWN) && !sc->link_up)
3564 * ice_sysctl_negotiated_fc - Display currently negotiated FC mode
3579 struct ice_port_info *pi = sc->hw.port_info;
3593 * __ice_sysctl_phy_type_handler - Display/change supported PHY types/speeds
3608 struct ice_hw *hw = &sc->hw;
3609 device_t dev = sc->dev;
3619 status = ice_aq_get_phy_caps(hw->port_info, false, ICE_AQC_REPORT_ACTIVE_CFG,
3625 ice_aq_str(hw->adminq.sq_last_status));
3635 if ((ret) || (req->newptr == NULL))
3638 ice_copy_phy_caps_to_cfg(hw->port_info, &pcaps, &cfg);
3641 cfg.phy_type_high = types & hw->port_info->phy.phy_type_high;
3643 cfg.phy_type_low = types & hw->port_info->phy.phy_type_low;
3646 status = ice_aq_set_phy_cfg(hw, hw->port_info, &cfg, NULL);
3651 ice_aq_str(hw->adminq.sq_last_status));
3660 * ice_sysctl_phy_type_low - Display/change supported lower PHY types/speeds
3676 * ice_sysctl_phy_type_high - Display/change supported higher PHY types/speeds
3692 * ice_sysctl_phy_caps - Display response from Get PHY abililties
3707 struct ice_hw *hw = &sc->hw;
3708 struct ice_port_info *pi = hw->port_info;
3709 device_t dev = sc->dev;
3727 ice_aq_str(hw->adminq.sq_last_status));
3732 if (req->newptr != NULL)
3739 * ice_sysctl_phy_sw_caps - Display response from Get PHY abililties
3756 * ice_sysctl_phy_nvm_caps - Display response from Get PHY abililties
3773 * ice_sysctl_phy_topo_caps - Display response from Get PHY abililties
3790 * ice_sysctl_phy_link_status - Display response from Get Link Status
3804 struct ice_hw *hw = &sc->hw;
3805 struct ice_port_info *pi = hw->port_info;
3808 device_t dev = sc->dev;
3827 resp->lport_num = pi->lport;
3834 ice_aq_str(hw->adminq.sq_last_status));
3839 if (req->newptr != NULL)
3846 * ice_sysctl_fw_cur_lldp_persist_status - Display current FW LLDP status
3858 struct ice_hw *hw = &sc->hw;
3859 device_t dev = sc->dev;
3874 ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status));
3887 * ice_sysctl_fw_dflt_lldp_persist_status - Display default FW LLDP status
3899 struct ice_hw *hw = &sc->hw;
3900 device_t dev = sc->dev;
3915 ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status));
3928 * ice_dscp_is_mapped - Check for non-zero DSCP to TC mappings
3931 * @return true if there exists a non-zero DSCP to TC mapping
3938 if (dcbcfg->dscp_map[i] != 0)
3946 "\n\t0 - disabled" \
3947 "\n\t1 - enabled"
3950 * ice_sysctl_fw_lldp_agent - Display or change the FW LLDP agent status
3964 struct ice_hw *hw = &sc->hw;
3965 device_t dev = sc->dev;
3981 ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status));
3991 ice_aq_str(hw->adminq.sq_last_status));
4001 if ((ret) || (req->newptr == NULL))
4011 local_dcbx_cfg = &hw->port_info->qos_cfg.local_dcbx_cfg;
4012 if ((local_dcbx_cfg->pfc_mode == ICE_QOS_MODE_DSCP) ||
4015 "Cannot enable FW-LLDP agent while DSCP QoS is active.\n");
4022 if (status && hw->adminq.sq_last_status != ICE_AQ_RC_EPERM) {
4026 ice_aq_str(hw->adminq.sq_last_status));
4030 hw->port_info->qos_cfg.is_sw_lldp = true;
4037 switch (hw->adminq.sq_last_status) {
4053 ice_aq_str(hw->adminq.sq_last_status));
4067 ice_aq_str(hw->adminq.sq_last_status));
4068 hw->port_info->qos_cfg.dcbx_status = ICE_DCBX_STATUS_NOT_STARTED;
4082 * ice_sysctl_ets_min_rate - Report/configure ETS bandwidth
4100 struct ice_hw *hw = &sc->hw;
4101 device_t dev = sc->dev;
4115 if (req->oldptr == NULL && req->newptr == NULL) {
4120 pi = hw->port_info;
4121 local_dcbx_cfg = &pi->qos_cfg.local_dcbx_cfg;
4127 sbuf_printf(sbuf, "%d", local_dcbx_cfg->etscfg.tcbwtable[i]);
4128 if (i != ICE_MAX_TRAFFIC_CLASS - 1)
4137 if ((ret) || (req->newptr == NULL))
4141 if (!hw->port_info->qos_cfg.is_sw_lldp)
4157 memcpy(local_dcbx_cfg->etscfg.tcbwtable, new_ets_table,
4163 local_dcbx_cfg->etscfg.tsatable[i] = 2;
4165 local_dcbx_cfg->etscfg.tsatable[i] = 0;
4167 local_dcbx_cfg->etscfg.willing = 0;
4168 local_dcbx_cfg->etsrec = local_dcbx_cfg->etscfg;
4169 local_dcbx_cfg->app_mode = ICE_DCBX_APPS_NON_WILLING;
4176 ice_aq_str(hw->adminq.sq_last_status));
4192 * ice_sysctl_up2tc_map - Report or configure UP2TC mapping
4210 struct ice_hw *hw = &sc->hw;
4211 device_t dev = sc->dev;
4226 if (req->oldptr == NULL && req->newptr == NULL) {
4231 pi = hw->port_info;
4232 local_dcbx_cfg = &pi->qos_cfg.local_dcbx_cfg;
4238 sbuf_printf(sbuf, "%d", local_dcbx_cfg->etscfg.prio_table[i]);
4239 if (i != ICE_MAX_TRAFFIC_CLASS - 1)
4248 if ((ret) || (req->newptr == NULL))
4252 if (!hw->port_info->qos_cfg.is_sw_lldp)
4256 ICE_MAX_TRAFFIC_CLASS - 1);
4264 memcpy(local_dcbx_cfg->etscfg.prio_table, new_up2tc,
4266 memcpy(local_dcbx_cfg->etsrec.prio_table, new_up2tc,
4274 ice_aq_str(hw->adminq.sq_last_status));
4284 * ice_config_pfc - helper function to set PFC config in FW
4290 * Configures the driver's local PFC TLV and sends it to the
4298 struct ice_hw *hw = &sc->hw;
4300 device_t dev = sc->dev;
4303 pi = hw->port_info;
4304 local_dcbx_cfg = &pi->qos_cfg.local_dcbx_cfg;
4306 /* Prepare updated PFC TLV */
4307 local_dcbx_cfg->pfc.pfcena = new_mode;
4308 local_dcbx_cfg->pfc.pfccap = ICE_MAX_TRAFFIC_CLASS;
4309 local_dcbx_cfg->pfc.willing = 0;
4310 local_dcbx_cfg->pfc.mbc = 0;
4313 if (new_mode == 0 && sc->rdma_entry.attached)
4322 ice_aq_str(hw->adminq.sq_last_status));
4338 * ice_sysctl_pfc_config - Report or configure enabled PFC TCs
4356 struct ice_hw *hw = &sc->hw;
4367 if (req->oldptr == NULL && req->newptr == NULL) {
4372 pi = hw->port_info;
4373 local_dcbx_cfg = &pi->qos_cfg.local_dcbx_cfg;
4376 user_pfc = local_dcbx_cfg->pfc.pfcena;
4380 if ((ret) || (req->newptr == NULL))
4384 if (!hw->port_info->qos_cfg.is_sw_lldp)
4388 if (user_pfc != 0 && pi->phy.curr_user_fc_req != ICE_FC_NONE) {
4389 pi->phy.curr_user_fc_req = ICE_FC_NONE;
4390 if (ice_test_state(&sc->state, ICE_STATE_LINK_ACTIVE_ON_DOWN) ||
4391 sc->link_up) {
4413 * Gets and sets whether the port is in DSCP or VLAN PCP-based
4415 * -based settings are configured for DCB.
4423 struct ice_hw *hw = &sc->hw;
4424 device_t dev = sc->dev;
4434 if (req->oldptr == NULL && req->newptr == NULL) {
4439 pi = hw->port_info;
4440 local_dcbx_cfg = &pi->qos_cfg.local_dcbx_cfg;
4442 user_pfc_mode = local_dcbx_cfg->pfc_mode;
4446 if ((ret) || (req->newptr == NULL))
4450 if (!hw->port_info->qos_cfg.is_sw_lldp)
4463 "%s: Valid input range is 0-1 (input %d)\n",
4479 ice_aq_str(hw->adminq.sq_last_status));
4486 local_dcbx_cfg->pfc_mode = user_pfc_mode;
4494 "\n\t0 - disable" \
4495 "\n\t1 - enable"
4515 mode = ice_test_state(&sc->state, ICE_STATE_LINK_ACTIVE_ON_DOWN);
4518 if ((ret) || (req->newptr == NULL))
4522 ice_set_state(&sc->state, ICE_STATE_LINK_ACTIVE_ON_DOWN);
4524 ice_clear_state(&sc->state, ICE_STATE_LINK_ACTIVE_ON_DOWN);
4548 if ((ret) || (req->newptr == NULL))
4557 * ice_add_device_sysctls - add device specific dynamic sysctls
4560 * Add per-device dynamic sysctls which show device configuration or enable
4564 * This function depends on the sysctl layout setup by ice_add_device_tunables,
4571 device_t dev = sc->dev;
4581 if (ice_is_bit_set(sc->feat_en, ICE_FEATURE_HAS_PBA)) {
4586 if (ice_is_bit_set(sc->feat_en, ICE_FEATURE_TEMP_SENSOR)) {
4641 "Allow \"No FEC\" mode in FEC auto-negotiation");
4669 ice_add_vsi_sysctls(&sc->pf_vsi);
4701 * ice_log_hmc_error - Log an HMC error message
4784 * ice_add_sysctls_eth_stats - Add sysctls for ethernet statistics
4803 { &stats->rx_bytes, "good_octets_rcvd", "Good Octets Received" },
4804 { &stats->rx_unicast, "ucast_pkts_rcvd", "Unicast Packets Received" },
4805 { &stats->rx_multicast, "mcast_pkts_rcvd", "Multicast Packets Received" },
4806 { &stats->rx_broadcast, "bcast_pkts_rcvd", "Broadcast Packets Received" },
4808 { &stats->tx_bytes, "good_octets_txd", "Good Octets Transmitted" },
4809 { &stats->tx_unicast, "ucast_pkts_txd", "Unicast Packets Transmitted" },
4810 { &stats->tx_multicast, "mcast_pkts_txd", "Multicast Packets Transmitted" },
4811 { &stats->tx_broadcast, "bcast_pkts_txd", "Broadcast Packets Transmitted" },
4819 while (entry->stat != 0) {
4820 SYSCTL_ADD_U64(ctx, parent_list, OID_AUTO, entry->name,
4821 CTLFLAG_RD | CTLFLAG_STATS, entry->stat, 0,
4822 entry->description);
4828 * ice_sysctl_tx_cso_stat - Display Tx checksum offload statistic
4834 * On read: Sums the per-queue Tx CSO stat and displays it.
4844 if (ice_driver_is_detaching(vsi->sc))
4852 for (i = 0; i < vsi->num_tx_queues; i++)
4853 stat += vsi->tx_queues[i].stats.cso[type];
4859 * ice_sysctl_rx_cso_stat - Display Rx checksum offload statistic
4865 * On read: Sums the per-queue Rx CSO stat and displays it.
4875 if (ice_driver_is_detaching(vsi->sc))
4883 for (i = 0; i < vsi->num_rx_queues; i++)
4884 stat += vsi->rx_queues[i].stats.cso[type];
4890 * ice_sysctl_rx_errors_stat - Display aggregate of Rx errors
4903 struct ice_hw_port_stats *hs = &vsi->sc->stats.cur;
4909 if (ice_driver_is_detaching(vsi->sc))
4912 stat += hs->rx_undersize;
4913 stat += hs->rx_fragments;
4914 stat += hs->rx_oversize;
4915 stat += hs->rx_jabber;
4916 stat += hs->crc_errors;
4917 stat += hs->illegal_bytes;
4920 for (i = 0; i < vsi->num_rx_queues; i++)
4924 stat += vsi->rx_queues[i].stats.cso[type];
4956 * ice_add_sysctls_sw_stats - Add sysctls for software statistics
5008 while (tx_entry->name && tx_entry->description) {
5009 SYSCTL_ADD_PROC(ctx, cso_list, OID_AUTO, tx_entry->name,
5011 vsi, tx_entry->type, ice_sysctl_tx_cso_stat, "QU",
5012 tx_entry->description);
5017 while (rx_entry->name && rx_entry->description) {
5018 SYSCTL_ADD_PROC(ctx, cso_list, OID_AUTO, rx_entry->name,
5020 vsi, rx_entry->type, ice_sysctl_rx_cso_stat, "QU",
5021 rx_entry->description);
5027 * ice_add_vsi_sysctls - Add sysctls for a VSI
5035 struct sysctl_ctx_list *ctx = &vsi->ctx;
5039 vsi_list = SYSCTL_CHILDREN(vsi->vsi_node);
5047 ice_add_sysctls_eth_stats(ctx, hw_node, &vsi->hw_stats.cur);
5050 CTLFLAG_RD | CTLFLAG_STATS, &vsi->hw_stats.cur.rx_discards,
5059 CTLFLAG_RD | CTLFLAG_STATS, &vsi->hw_stats.cur.rx_no_desc,
5063 CTLFLAG_RD | CTLFLAG_STATS, &vsi->hw_stats.cur.tx_errors,
5074 * ice_add_sysctls_mac_pfc_one_stat - Add sysctl node for a PFC statistic
5121 * ice_add_sysctls_mac_pfc_stats - Add sysctls for MAC PFC statistics
5139 ice_add_sysctls_mac_pfc_one_stat(ctx, parent_list, stats->priority_xon_rx,
5141 ice_add_sysctls_mac_pfc_one_stat(ctx, parent_list, stats->priority_xoff_rx,
5143 ice_add_sysctls_mac_pfc_one_stat(ctx, parent_list, stats->priority_xon_tx,
5145 ice_add_sysctls_mac_pfc_one_stat(ctx, parent_list, stats->priority_xoff_tx,
5147 ice_add_sysctls_mac_pfc_one_stat(ctx, parent_list, stats->priority_xon_2_xoff,
5152 * ice_add_sysctls_mac_stats - Add sysctls for global MAC statistics
5166 struct ice_hw_port_stats *stats = &sc->stats.cur;
5175 ice_add_sysctls_eth_stats(ctx, mac_node, &stats->eth);
5177 /* Add PFC stats that add per-TC counters */
5182 {&stats->rx_size_64, "rx_frames_64", "64 byte frames received"},
5183 {&stats->rx_size_127, "rx_frames_65_127", "65-127 byte frames received"},
5184 {&stats->rx_size_255, "rx_frames_128_255", "128-255 byte frames received"},
5185 {&stats->rx_size_511, "rx_frames_256_511", "256-511 byte frames received"},
5186 {&stats->rx_size_1023, "rx_frames_512_1023", "512-1023 byte frames received"},
5187 {&stats->rx_size_1522, "rx_frames_1024_1522", "1024-1522 byte frames received"},
5188 {&stats->rx_size_big, "rx_frames_big", "1523-9522 byte frames received"},
5189 {&stats->rx_undersize, "rx_undersize", "Undersized packets received"},
5190 {&stats->rx_fragments, "rx_fragmented", "Fragmented packets received"},
5191 {&stats->rx_jabber, "rx_jabber", "Received Jabber"},
5192 {&stats->eth.rx_discards, "rx_discards",
5195 {&stats->tx_size_64, "tx_frames_64", "64 byte frames transmitted"},
5196 {&stats->tx_size_127, "tx_frames_65_127", "65-127 byte frames transmitted"},
5197 {&stats->tx_size_255, "tx_frames_128_255", "128-255 byte frames transmitted"},
5198 {&stats->tx_size_511, "tx_frames_256_511", "256-511 byte frames transmitted"},
5199 {&stats->tx_size_1023, "tx_frames_512_1023", "512-1023 byte frames transmitted"},
5200 {&stats->tx_size_1522, "tx_frames_1024_1522", "1024-1522 byte frames transmitted"},
5201 {&stats->tx_size_big, "tx_frames_big", "1523-9522 byte frames transmitted"},
5202 {&stats->tx_dropped_link_down, "tx_dropped", "Tx Dropped Due To Link Down"},
5204 {&stats->link_xon_tx, "xon_txd", "Link XON transmitted"},
5205 {&stats->link_xon_rx, "xon_recvd", "Link XON received"},
5206 {&stats->link_xoff_tx, "xoff_txd", "Link XOFF transmitted"},
5207 {&stats->link_xoff_rx, "xoff_recvd", "Link XOFF received"},
5209 {&stats->crc_errors, "crc_errors", "CRC Errors"},
5210 {&stats->illegal_bytes, "illegal_bytes", "Illegal Byte Errors"},
5211 {&stats->mac_local_faults, "local_faults", "MAC Local Faults"},
5212 {&stats->mac_remote_faults, "remote_faults", "MAC Remote Faults"},
5218 while (entry->stat != 0) {
5219 SYSCTL_ADD_U64(ctx, mac_list, OID_AUTO, entry->name,
5220 CTLFLAG_RD | CTLFLAG_STATS, entry->stat, 0,
5221 entry->description);
5226 CTLFLAG_RD | CTLFLAG_STATS, &sc->soft_stats.rx_roc_error,
5232 * ice_configure_misc_interrupts - enable 'other' interrupt causes
5241 struct ice_hw *hw = &sc->hw;
5258 /* Note that since we're using MSI-X index 0, and ITR index 0, we do
5278 * ice_filter_is_mcast - Check if info is a multicast filter
5288 const u8 *addr = info->l_data.mac.mac_addr;
5294 if ((info->flag == ICE_FLTR_TX) &&
5295 (info->src_id == ICE_SRC_ID_VSI) &&
5296 (info->lkup_type == ICE_SW_LKUP_MAC) &&
5297 (info->vsi_handle == vsi->idx) &&
5319 * ice_sync_one_mcast_filter - Check if we need to program the filter
5336 struct ice_softc *sc = data->sc;
5337 struct ice_hw *hw = &sc->hw;
5338 struct ice_switch_info *sw = hw->switch_info;
5344 rules = &sw->recp_list[ICE_SW_LKUP_MAC].filt_rules;
5350 if (data->err)
5355 struct ice_fltr_info *info = &itr->fltr_info;
5356 const u8 *addr = info->l_data.mac.mac_addr;
5359 if (!ice_filter_is_mcast(&sc->pf_vsi, info))
5367 itr->marker = ICE_FLTR_FOUND;
5376 err = ice_add_mac_to_list(&sc->pf_vsi, &data->add_list, sdl_addr,
5379 device_printf(sc->dev,
5382 data->err = err;
5391 * ice_sync_multicast_filters - Synchronize OS and internal filter list
5413 struct ice_hw *hw = &sc->hw;
5414 struct ice_switch_info *sw = hw->switch_info;
5426 rules = &sw->recp_list[ICE_SW_LKUP_MAC].filt_rules;
5429 ice_acquire_lock(&sw->recp_list[ICE_SW_LKUP_MAC].filt_rule_lock);
5433 itr->marker = ICE_FLTR_NOT_FOUND;
5436 if_foreach_llmaddr(sc->ifp, ice_sync_one_mcast_filter, (void *)&data);
5440 ice_release_lock(&sw->recp_list[ICE_SW_LKUP_MAC].filt_rule_lock);
5445 struct ice_fltr_info *info = &itr->fltr_info;
5446 const u8 *addr = info->l_data.mac.mac_addr;
5449 if (!ice_filter_is_mcast(&sc->pf_vsi, info))
5456 if (itr->marker == ICE_FLTR_NOT_FOUND) {
5457 err = ice_add_mac_to_list(&sc->pf_vsi, &remove_list,
5460 device_printf(sc->dev,
5463 ice_release_lock(&sw->recp_list[ICE_SW_LKUP_MAC].filt_rule_lock);
5469 ice_release_lock(&sw->recp_list[ICE_SW_LKUP_MAC].filt_rule_lock);
5473 device_printf(sc->dev,
5475 ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status));
5482 device_printf(sc->dev,
5484 ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status));
5497 * ice_add_vlan_hw_filters - Add multiple VLAN filters for a given VSI
5507 struct ice_hw *hw = &vsi->sc->hw;
5526 vlan_entries[i].fltr_info.vsi_handle = vsi->idx;
5536 device_printf(vsi->sc->dev, "Failed to add VLAN filters:\n");
5538 device_printf(vsi->sc->dev,
5539 "- vlan %d, status %d\n",
5549 * ice_add_vlan_hw_filter - Add a VLAN filter for a given VSI
5562 * ice_remove_vlan_hw_filters - Remove multiple VLAN filters for a given VSI
5572 struct ice_hw *hw = &vsi->sc->hw;
5591 vlan_entries[i].fltr_info.vsi_handle = vsi->idx;
5601 device_printf(vsi->sc->dev, "Failed to remove VLAN filters:\n");
5603 device_printf(vsi->sc->dev,
5604 "- vlan %d, status %d\n",
5614 * ice_remove_vlan_hw_filter - Remove a VLAN filter for a given VSI
5628 "\n\t0-8160 - sets interrupt rate in usecs" \
5629 "\n\t -1 - reset the Rx itr to default"
5632 * ice_sysctl_rx_itr - Display or change the Rx ITR for a VSI
5645 struct ice_softc *sc = vsi->sc;
5653 ret = sysctl_handle_16(oidp, &vsi->rx_itr, 0, req);
5654 if ((ret) || (req->newptr == NULL))
5657 if (vsi->rx_itr < 0)
5658 vsi->rx_itr = ICE_DFLT_RX_ITR;
5659 if (vsi->rx_itr > ICE_ITR_MAX)
5660 vsi->rx_itr = ICE_ITR_MAX;
5663 increment = sc->hw.itr_gran ? : 2;
5666 vsi->rx_itr = (vsi->rx_itr / increment ) * increment;
5672 if (ice_test_state(&sc->state, ICE_STATE_DRIVER_INITIALIZED))
5680 "\n\t0-8160 - sets interrupt rate in usecs" \
5681 "\n\t -1 - reset the Tx itr to default"
5684 * ice_sysctl_tx_itr - Display or change the Tx ITR for a VSI
5697 struct ice_softc *sc = vsi->sc;
5705 ret = sysctl_handle_16(oidp, &vsi->tx_itr, 0, req);
5706 if ((ret) || (req->newptr == NULL))
5710 if (vsi->tx_itr < 0)
5711 vsi->tx_itr = ICE_DFLT_TX_ITR;
5712 if (vsi->tx_itr > ICE_ITR_MAX)
5713 vsi->tx_itr = ICE_ITR_MAX;
5716 increment = sc->hw.itr_gran ? : 2;
5719 vsi->tx_itr = (vsi->tx_itr / increment ) * increment;
5725 if (ice_test_state(&sc->state, ICE_STATE_DRIVER_INITIALIZED))
5732 * ice_add_vsi_tunables - Add tunables and nodes for a VSI
5756 sysctl_ctx_init(&vsi->ctx);
5759 snprintf(vsi_name, sizeof(vsi_name), "%u", vsi->idx);
5760 snprintf(vsi_desc, sizeof(vsi_desc), "VSI %u", vsi->idx);
5761 vsi->vsi_node = SYSCTL_ADD_NODE(&vsi->ctx, parent_list, OID_AUTO, vsi_name,
5763 vsi_list = SYSCTL_CHILDREN(vsi->vsi_node);
5765 vsi->rx_itr = ICE_DFLT_TX_ITR;
5766 SYSCTL_ADD_PROC(&vsi->ctx, vsi_list, OID_AUTO, "rx_itr",
5771 vsi->tx_itr = ICE_DFLT_TX_ITR;
5772 SYSCTL_ADD_PROC(&vsi->ctx, vsi_list, OID_AUTO, "tx_itr",
5779 * ice_del_vsi_sysctl_ctx - Delete the sysctl context(s) of a VSI
5783 * well as the per-queue sysctls.
5788 device_t dev = vsi->sc->dev;
5791 if (vsi->vsi_node) {
5792 err = sysctl_ctx_free(&vsi->ctx);
5795 vsi->idx, ice_err_str(err));
5796 vsi->vsi_node = NULL;
5801 * ice_add_dscp2tc_map_sysctls - Add sysctl tree for DSCP to TC mapping
5833 sbuf_printf(namebuf, "%d-%d", first_dscp_val, last_dscp_val);
5850 * ice_add_device_tunables - Add early tunable sysctls and sysctl nodes
5853 * Add per-device dynamic tunable sysctls, and setup the general sysctl trees
5854 * for re-use by ice_add_device_sysctls.
5859 * Any non-global sysctl marked as CTLFLAG_TUN should likely be initialized
5869 device_t dev = sc->dev;
5875 sc->enable_health_events = ice_enable_health_events;
5878 CTLFLAG_RDTUN, &sc->enable_health_events, 0,
5887 sc->vsi_sysctls = SYSCTL_ADD_NODE(ctx, ctx_list, OID_AUTO, "vsi",
5895 * ice_sysctl_dump_mac_filters - Dump a list of all HW MAC Filters
5907 struct ice_hw *hw = &sc->hw;
5908 struct ice_switch_info *sw = hw->switch_info;
5922 /* Wire the old buffer so we can take a non-sleepable lock */
5929 rule_lock = &sw->recp_list[ICE_SW_LKUP_MAC].filt_rule_lock;
5930 rule_head = &sw->recp_list[ICE_SW_LKUP_MAC].filt_rules;
5937 fi = &fm_entry->fltr_info;
5941 fi->l_data.mac.mac_addr, ":", fi->vsi_handle,
5942 ice_fltr_flag_str(fi->flag), fi->lb_en, fi->lan_en,
5943 ice_fwd_act_str(fi->fltr_act), fi->fltr_rule_id);
5946 if (fm_entry->vsi_list_info) {
5949 fm_entry->vsi_count,
5950 fm_entry->vsi_list_info->vsi_list_id,
5951 fm_entry->vsi_list_info->ref_cnt);
5964 * ice_sysctl_dump_vlan_filters - Dump a list of all HW VLAN Filters
5976 struct ice_hw *hw = &sc->hw;
5977 struct ice_switch_info *sw = hw->switch_info;
5991 /* Wire the old buffer so we can take a non-sleepable lock */
5998 rule_lock = &sw->recp_list[ICE_SW_LKUP_VLAN].filt_rule_lock;
5999 rule_head = &sw->recp_list[ICE_SW_LKUP_VLAN].filt_rules;
6006 fi = &fm_entry->fltr_info;
6010 fi->l_data.vlan.vlan_id, fi->vsi_handle,
6011 ice_fltr_flag_str(fi->flag), fi->lb_en, fi->lan_en,
6012 ice_fwd_act_str(fi->fltr_act), fi->fltr_rule_id);
6015 if (fm_entry->vsi_list_info) {
6018 fm_entry->vsi_count,
6019 fm_entry->vsi_list_info->vsi_list_id,
6020 fm_entry->vsi_list_info->ref_cnt);
6033 * ice_sysctl_dump_ethertype_filters - Dump a list of all HW Ethertype filters
6046 struct ice_hw *hw = &sc->hw;
6047 struct ice_switch_info *sw = hw->switch_info;
6061 /* Wire the old buffer so we can take a non-sleepable lock */
6068 rule_lock = &sw->recp_list[ICE_SW_LKUP_ETHERTYPE].filt_rule_lock;
6069 rule_head = &sw->recp_list[ICE_SW_LKUP_ETHERTYPE].filt_rules;
6076 fi = &fm_entry->fltr_info;
6080 fi->l_data.ethertype_mac.ethertype,
6081 fi->vsi_handle, ice_fltr_flag_str(fi->flag),
6082 fi->lb_en, fi->lan_en, ice_fwd_act_str(fi->fltr_act),
6083 fi->fltr_rule_id);
6086 if (fm_entry->vsi_list_info) {
6089 fm_entry->vsi_count,
6090 fm_entry->vsi_list_info->vsi_list_id,
6091 fm_entry->vsi_list_info->ref_cnt);
6104 * ice_sysctl_dump_ethertype_mac_filters - Dump a list of all HW Ethertype/MAC filters
6117 struct ice_hw *hw = &sc->hw;
6118 struct ice_switch_info *sw = hw->switch_info;
6132 /* Wire the old buffer so we can take a non-sleepable lock */
6139 rule_lock = &sw->recp_list[ICE_SW_LKUP_ETHERTYPE_MAC].filt_rule_lock;
6140 rule_head = &sw->recp_list[ICE_SW_LKUP_ETHERTYPE_MAC].filt_rules;
6147 fi = &fm_entry->fltr_info;
6151 fi->l_data.ethertype_mac.ethertype,
6152 fi->l_data.ethertype_mac.mac_addr, ":",
6153 fi->vsi_handle, ice_fltr_flag_str(fi->flag),
6154 fi->lb_en, fi->lan_en, ice_fwd_act_str(fi->fltr_act),
6155 fi->fltr_rule_id);
6158 if (fm_entry->vsi_list_info) {
6161 fm_entry->vsi_count,
6162 fm_entry->vsi_list_info->vsi_list_id,
6163 fm_entry->vsi_list_info->ref_cnt);
6176 * ice_sysctl_dump_state_flags - Dump device driver state flags
6200 copied_state = atomic_load_acq_32(&sc->state);
6230 "\n\t 0x1 - Function Tracing" \
6231 "\n\t 0x2 - Driver Initialization" \
6232 "\n\t 0x4 - Release" \
6233 "\n\t 0x8 - FW Logging" \
6234 "\n\t 0x10 - Link" \
6235 "\n\t 0x20 - PHY" \
6236 "\n\t 0x40 - Queue Context" \
6237 "\n\t 0x80 - NVM" \
6238 "\n\t 0x100 - LAN" \
6239 "\n\t 0x200 - Flow" \
6240 "\n\t 0x400 - DCB" \
6241 "\n\t 0x800 - Diagnostics" \
6242 "\n\t 0x1000 - Flow Director" \
6243 "\n\t 0x2000 - Switch" \
6244 "\n\t 0x4000 - Scheduler" \
6245 "\n\t 0x8000 - RDMA" \
6246 "\n\t 0x10000 - DDP Package" \
6247 "\n\t 0x20000 - Resources" \
6248 "\n\t 0x40000 - ACL" \
6249 "\n\t 0x80000 - PTP" \
6251 "\n\t 0x1000000 - Admin Queue messages" \
6252 "\n\t 0x2000000 - Admin Queue descriptors" \
6253 "\n\t 0x4000000 - Admin Queue descriptor buffers" \
6254 "\n\t 0x8000000 - Admin Queue commands" \
6255 "\n\t 0x10000000 - Parser" \
6257 "\n\t 0x80000000 - (Reserved for user)" \
6259 "\nUse \"sysctl -x\" to view flags properly."
6262 * ice_add_debug_tunables - Add tunables helpful for debugging the device driver
6276 device_t dev = sc->dev;
6282 sc->debug_sysctls = SYSCTL_ADD_NODE(ctx, ctx_list, OID_AUTO, "debug",
6285 debug_list = SYSCTL_CHILDREN(sc->debug_sysctls);
6289 &sc->hw.debug_mask, 0,
6293 sc->enable_tx_fc_filter = ice_enable_tx_fc_filter;
6297 &sc->enable_tx_fc_filter, 0,
6300 sc->tx_balance_en = ice_tx_balance_en;
6303 &sc->tx_balance_en, 0,
6304 "Enable 5-layer scheduler topology");
6307 sc->enable_tx_lldp_filter = ice_enable_tx_lldp_filter;
6311 &sc->enable_tx_lldp_filter, 0,
6314 ice_add_fw_logging_tunables(sc, sc->debug_sysctls);
6319 "\n\tpfr - Initiate a PF reset" \
6320 "\n\tcorer - Initiate a CORE reset" \
6321 "\n\tglobr - Initiate a GLOBAL reset"
6327 * Helps rate-limit the call to the sysctl which resets the device
6332 * ice_sysctl_request_reset - Request that the driver initiate a reset
6341 * "pfr" - Initiate a PF reset
6342 * "corer" - Initiate a CORE reset
6343 * "globr" - Initiate a Global reset
6349 struct ice_hw *hw = &sc->hw;
6372 if ((ret) || (req->newptr == NULL))
6385 device_printf(sc->dev, "Triggering an EMP reset via software is not currently supported\n");
6390 device_printf(sc->dev, "%s is not a valid reset request\n", reset);
6395 * Rate-limit the frequency at which this function is called.
6403 if (TICKS_2_MSEC(ticks - rl_sysctl_ticks) < 500) {
6404 device_printf(sc->dev,
6410 if (TICKS_2_MSEC(ticks - sc->rebuild_ticks) < 100) {
6411 device_printf(sc->dev, "Device rebuilding. Operation aborted.\n");
6416 device_printf(sc->dev, "Device in reset. Operation aborted.\n");
6420 device_printf(sc->dev, "%s\n", reset_message);
6424 ice_set_state(&sc->state, ICE_STATE_RESET_PFR_REQ);
6442 device_printf(sc->dev, "failed to initiate device reset, err %s\n",
6444 ice_set_state(&sc->state, ICE_STATE_RESET_FAILED);
6455 "\n\t 0 - All clusters (default)" \
6456 "\n\t 0x1 - Switch" \
6457 "\n\t 0x2 - ACL" \
6458 "\n\t 0x4 - Tx Scheduler" \
6459 "\n\t 0x8 - Profile Configuration" \
6460 "\n\t 0x20 - Link" \
6461 "\n\t 0x80 - DCB" \
6462 "\n\t 0x100 - L2P" \
6463 "\n\t 0x400000 - Manageability Transactions (excluding E830)" \
6465 "\nUse \"sysctl -x\" to view flags properly."
6468 * ice_sysctl_fw_debug_dump_cluster_setting - Set which clusters to dump
6479 device_t dev = sc->dev;
6492 clusters = sc->fw_debug_dump_cluster_mask;
6495 if ((ret) || (req->newptr == NULL))
6499 if (ice_is_e830(&sc->hw))
6508 sc->fw_debug_dump_cluster_mask = ICE_AQC_DBG_DUMP_CLUSTER_ID_INVALID;
6512 sc->fw_debug_dump_cluster_mask = clusters;
6520 * ice_fw_debug_dump_print_cluster - Print formatted cluster data from FW
6535 struct ice_hw *hw = &sc->hw;
6536 device_t dev = sc->dev;
6570 ice_debug(hw, ICE_DBG_DIAG, "---\n");
6582 ice_aq_str(hw->adminq.sq_last_status));
6611 if (ice_is_bit_set(sc->feat_en, ICE_FEATURE_NEXT_CLUSTER_ID))
6653 * ice_fw_debug_dump_print_clusters - Print data from FW clusters to sbuf
6668 u32 cluster_mask = sc->fw_debug_dump_cluster_mask;
6669 struct ice_hw *hw = &sc->hw;
6705 "\nThe \"-b\" flag must be used in order to dump this data as binary data because" \
6715 * ice_sysctl_fw_debug_dump_do_dump - Dump data from FW to sysctl output
6721 * Sysctl handler for the debug.dump.dump sysctl. Prints out a specially-
6733 device_t dev = sc->dev;
6747 if (!ice_test_state(&sc->state, ICE_STATE_DO_FW_DEBUG_DUMP)) {
6752 if (req->oldptr == NULL && req->newptr == NULL) {
6759 if ((ret) || (req->newptr == NULL))
6766 if (sc->fw_debug_dump_cluster_mask == ICE_AQC_DBG_DUMP_CLUSTER_ID_INVALID) {
6773 ice_set_state(&sc->state, ICE_STATE_DO_FW_DEBUG_DUMP);
6780 /* --- FW debug dump state is set --- */
6784 if (req->oldptr == NULL && req->newptr == NULL) {
6786 if (sc->fw_debug_dump_cluster_mask == 0)
6789 if (sc->fw_debug_dump_cluster_mask & 0x1)
6791 if (sc->fw_debug_dump_cluster_mask & 0x2)
6793 if (sc->fw_debug_dump_cluster_mask & 0x4)
6809 ice_clear_state(&sc->state, ICE_STATE_DO_FW_DEBUG_DUMP);
6814 * ice_add_debug_sysctls - Add sysctls helpful for debugging the device driver
6826 device_t dev = sc->dev;
6830 debug_list = SYSCTL_CHILDREN(sc->debug_sysctls);
6839 &sc->soft_stats.pfr_count, 0,
6844 &sc->soft_stats.corer_count, 0,
6849 &sc->soft_stats.globr_count, 0,
6854 &sc->soft_stats.empr_count, 0,
6859 &sc->soft_stats.tx_mdd_count, 0,
6864 &sc->soft_stats.rx_mdd_count, 0,
6912 ICE_CTLFLAG_DEBUG | CTLFLAG_RD, &sc->hw.fw_build, 0,
6935 if (ice_is_bit_set(sc->feat_en, ICE_FEATURE_PHY_STATISTICS)) {
6961 CTLFLAG_RD | CTLFLAG_STATS, &sc->stats.cur.rx_len_errors, 0,
7006 * ice_vsi_disable_tx - Disable (unconfigure) Tx queues for a VSI
7015 struct ice_softc *sc = vsi->sc;
7016 struct ice_hw *hw = &sc->hw;
7023 if (vsi->num_tx_queues > 255)
7026 q_teids_size = sizeof(*q_teids) * vsi->num_tx_queues;
7031 q_ids_size = sizeof(*q_ids) * vsi->num_tx_queues;
7038 q_handles_size = sizeof(*q_handles) * vsi->num_tx_queues;
7046 struct ice_tc_info *tc_info = &vsi->tc_info[tc];
7051 if (!(vsi->tc_map & BIT(tc)))
7055 start_idx = tc_info->qoffset;
7056 end_idx = start_idx + tc_info->qcount_tx;
7059 struct ice_tx_queue *txq = &vsi->tx_queues[j];
7061 q_ids[buf_idx] = vsi->tx_qmap[j];
7062 q_handles[buf_idx] = txq->q_handle;
7063 q_teids[buf_idx] = txq->q_teid;
7067 status = ice_dis_vsi_txq(hw->port_info, vsi->idx, tc, buf_idx,
7072 device_printf(sc->dev,
7076 device_printf(sc->dev,
7078 ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status));
7100 * ice_vsi_set_rss_params - Set the RSS parameters for the VSI
7109 struct ice_softc *sc = vsi->sc;
7112 cap = &sc->hw.func_caps.common_cap;
7114 switch (vsi->type) {
7117 vsi->rss_table_size = cap->rss_table_size;
7118 vsi->rss_lut_type = ICE_LUT_PF;
7122 vsi->rss_table_size = ICE_VSIQF_HLUT_ARRAY_SIZE;
7123 vsi->rss_lut_type = ICE_LUT_VSI;
7126 device_printf(sc->dev,
7128 vsi->idx, vsi->type);
7134 * ice_vsi_add_txqs_ctx - Create a sysctl context and node to store txq sysctls
7139 * used to store per-txq sysctls which may need to be released during the
7147 sysctl_ctx_init(&vsi->txqs_ctx);
7149 vsi_list = SYSCTL_CHILDREN(vsi->vsi_node);
7151 vsi->txqs_node = SYSCTL_ADD_NODE(&vsi->txqs_ctx, vsi_list, OID_AUTO, "txqs",
7156 * ice_vsi_add_rxqs_ctx - Create a sysctl context and node to store rxq sysctls
7161 * used to store per-rxq sysctls which may need to be released during the
7169 sysctl_ctx_init(&vsi->rxqs_ctx);
7171 vsi_list = SYSCTL_CHILDREN(vsi->vsi_node);
7173 vsi->rxqs_node = SYSCTL_ADD_NODE(&vsi->rxqs_ctx, vsi_list, OID_AUTO, "rxqs",
7178 * ice_vsi_del_txqs_ctx - Delete the Tx queue sysctl context for this VSI
7181 * Frees the txq sysctl context created for storing the per-queue Tx sysctls.
7188 device_t dev = vsi->sc->dev;
7191 if (vsi->txqs_node) {
7192 err = sysctl_ctx_free(&vsi->txqs_ctx);
7195 vsi->idx, ice_err_str(err));
7196 vsi->txqs_node = NULL;
7201 * ice_vsi_del_rxqs_ctx - Delete the Rx queue sysctl context for this VSI
7204 * Frees the rxq sysctl context created for storing the per-queue Rx sysctls.
7211 device_t dev = vsi->sc->dev;
7214 if (vsi->rxqs_node) {
7215 err = sysctl_ctx_free(&vsi->rxqs_ctx);
7218 vsi->idx, ice_err_str(err));
7219 vsi->rxqs_node = NULL;
7224 * ice_add_txq_sysctls - Add per-queue sysctls for a Tx queue
7227 * Add per-queue sysctls for a given Tx queue. Can't be called during
7233 struct ice_vsi *vsi = txq->vsi;
7234 struct sysctl_ctx_list *ctx = &vsi->txqs_ctx;
7240 { &txq->stats.tx_packets, "tx_packets", "Queue Packets Transmitted" },
7241 { &txq->stats.tx_bytes, "tx_bytes", "Queue Bytes Transmitted" },
7242 { &txq->stats.mss_too_small, "mss_too_small", "TSO sends with an MSS less than 64" },
7243 { &txq->stats.tso, "tso", "TSO packets" },
7249 txqs_list = SYSCTL_CHILDREN(vsi->txqs_node);
7251 snprintf(txq_name, sizeof(txq_name), "%u", txq->me);
7252 snprintf(txq_desc, sizeof(txq_desc), "Tx Queue %u", txq->me);
7258 while (entry->stat != 0) {
7259 SYSCTL_ADD_U64(ctx, this_txq_list, OID_AUTO, entry->name,
7260 CTLFLAG_RD | CTLFLAG_STATS, entry->stat, 0,
7261 entry->description);
7266 CTLFLAG_RD, &txq->tc, 0,
7271 * ice_add_rxq_sysctls - Add per-queue sysctls for an Rx queue
7274 * Add per-queue sysctls for a given Rx queue. Can't be called during
7280 struct ice_vsi *vsi = rxq->vsi;
7281 struct sysctl_ctx_list *ctx = &vsi->rxqs_ctx;
7287 { &rxq->stats.rx_packets, "rx_packets", "Queue Packets Received" },
7288 { &rxq->stats.rx_bytes, "rx_bytes", "Queue Bytes Received" },
7289 { &rxq->stats.desc_errs, "rx_desc_errs", "Queue Rx Descriptor Errors" },
7295 rxqs_list = SYSCTL_CHILDREN(vsi->rxqs_node);
7297 snprintf(rxq_name, sizeof(rxq_name), "%u", rxq->me);
7298 snprintf(rxq_desc, sizeof(rxq_desc), "Rx Queue %u", rxq->me);
7304 while (entry->stat != 0) {
7305 SYSCTL_ADD_U64(ctx, this_rxq_list, OID_AUTO, entry->name,
7306 CTLFLAG_RD | CTLFLAG_STATS, entry->stat, 0,
7307 entry->description);
7312 CTLFLAG_RD, &rxq->tc, 0,
7317 * ice_get_default_rss_key - Obtain a default RSS key
7320 * Copies a pre-generated RSS key into the seed memory. The seed pointer must
7342 * ice_set_rss_key - Configure a given VSI with the default RSS key
7347 * pre-generated hash seed from ice_get_default_rss_key().
7353 struct ice_softc *sc = vsi->sc;
7354 struct ice_hw *hw = &sc->hw;
7363 status = ice_aq_set_rss_key(hw, vsi->idx, &keydata);
7365 device_printf(sc->dev,
7367 ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status));
7375 * ice_set_rss_flow_flds - Program the RSS hash flows after package init
7386 struct ice_softc *sc = vsi->sc;
7387 struct ice_hw *hw = &sc->hw;
7389 device_t dev = sc->dev;
7398 status = ice_add_rss_cfg(hw, vsi->idx, &rss_cfg);
7402 vsi->idx, ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status));
7407 status = ice_add_rss_cfg(hw, vsi->idx, &rss_cfg);
7411 vsi->idx, ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status));
7416 status = ice_add_rss_cfg(hw, vsi->idx, &rss_cfg);
7420 vsi->idx, ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status));
7425 status = ice_add_rss_cfg(hw, vsi->idx, &rss_cfg);
7429 vsi->idx, ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status));
7434 status = ice_add_rss_cfg(hw, vsi->idx, &rss_cfg);
7438 vsi->idx, ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status));
7443 status = ice_add_rss_cfg(hw, vsi->idx, &rss_cfg);
7447 vsi->idx, ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status));
7455 vsi->idx);
7460 * ice_set_rss_lut - Program the RSS lookup table for a VSI
7466 * not available, we will fall back to a simple round-robin fashion queue
7472 struct ice_softc *sc = vsi->sc;
7473 struct ice_hw *hw = &sc->hw;
7474 device_t dev = sc->dev;
7480 lut = (u8 *)malloc(vsi->rss_table_size, M_ICE, M_NOWAIT|M_ZERO);
7490 for (i = 0; i < vsi->rss_table_size; i++) {
7493 lut[i] = rss_get_indirection_to_bucket(i) % vsi->num_rx_queues;
7496 lut_params.vsi_handle = vsi->idx;
7497 lut_params.lut_size = vsi->rss_table_size;
7498 lut_params.lut_type = vsi->rss_lut_type;
7505 ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status));
7514 * ice_config_rss - Configure RSS for a VSI
7526 if (!ice_is_bit_set(vsi->sc->feat_en, ICE_FEATURE_RSS))
7539 * ice_log_pkg_init - Log a message about status of DDP initialization
7554 struct ice_hw *hw = &sc->hw;
7555 device_t dev = sc->dev;
7602 if (pkg_ver_empty(&hw->active_pkg_ver, hw->active_pkg_name)) {
7604 if (pkg_ver_compatible(&hw->pkg_ver) > 0) {
7609 } else if (pkg_ver_compatible(&hw->pkg_ver) < 0) {
7622 if (pkg_ver_compatible(&hw->active_pkg_ver) > 0) {
7627 } else if (pkg_ver_compatible(&hw->active_pkg_ver) < 0) {
7674 * ice_load_pkg_file - Load the DDP package file using firmware_get
7689 struct ice_hw *hw = &sc->hw;
7690 device_t dev = sc->dev;
7709 if (ice_is_bit_set(sc->feat_cap, ICE_FEATURE_TX_BALANCE)) {
7710 cached_layer_count = hw->num_tx_sched_layers;
7711 buf_copy = (u8 *)malloc(pkg->datasize, M_ICE, M_NOWAIT);
7714 memcpy(buf_copy, pkg->data, pkg->datasize);
7715 status = ice_cfg_tx_topo(&sc->hw, buf_copy, pkg->datasize);
7719 /* 9 -> 5 */
7726 ice_set_bit(ICE_FEATURE_TX_BALANCE, sc->feat_en);
7731 "DDP package does not support transmit balancing feature - please update to the latest DDP package and try again\n");
7742 state = ice_copy_and_init_pkg(hw, (const u8 *)pkg->data, pkg->datasize);
7755 ice_zero_bitmap(sc->feat_cap, ICE_FEATURE_COUNT);
7756 ice_zero_bitmap(sc->feat_en, ICE_FEATURE_COUNT);
7757 ice_set_bit(ICE_FEATURE_SAFE_MODE, sc->feat_cap);
7758 ice_set_bit(ICE_FEATURE_SAFE_MODE, sc->feat_en);
7764 * ice_get_ifnet_counter - Retrieve counter value for a given ifnet counter
7774 struct ice_hw_port_stats *hs = &vsi->sc->stats.cur;
7775 struct ice_eth_stats *es = &vsi->hw_stats.cur;
7778 * not have per-VSI counters. In this case, we just report the global
7784 return (es->rx_unicast + es->rx_multicast + es->rx_broadcast);
7786 return (hs->crc_errors + hs->illegal_bytes +
7787 hs->mac_local_faults + hs->mac_remote_faults +
7788 hs->rx_undersize + hs->rx_oversize + hs->rx_fragments +
7789 hs->rx_jabber);
7791 return (es->tx_unicast + es->tx_multicast + es->tx_broadcast);
7793 return (es->tx_errors);
7797 return (es->rx_bytes);
7799 return (es->tx_bytes);
7801 return (es->rx_multicast);
7803 return (es->tx_multicast);
7805 return (es->rx_discards);
7807 return (hs->tx_dropped_link_down);
7809 return (es->rx_unknown_protocol);
7811 return if_get_counter_default(vsi->sc->ifp, counter);
7816 * ice_save_pci_info - Save PCI configuration fields in HW struct
7826 hw->vendor_id = pci_get_vendor(dev);
7827 hw->device_id = pci_get_device(dev);
7828 hw->subsystem_vendor_id = pci_get_subvendor(dev);
7829 hw->subsystem_device_id = pci_get_subdevice(dev);
7830 hw->revision_id = pci_get_revid(dev);
7831 hw->bus.device = pci_get_slot(dev);
7832 hw->bus.func = pci_get_function(dev);
7836 * ice_replay_all_vsi_cfg - Replace configuration for all VSIs after reset
7846 struct ice_hw *hw = &sc->hw;
7850 for (i = 0 ; i < sc->num_available_vsi; i++) {
7851 struct ice_vsi *vsi = sc->all_vsi[i];
7856 status = ice_replay_vsi(hw, vsi->idx);
7858 device_printf(sc->dev, "Failed to replay VSI %d, err %s aq_err %s\n",
7859 vsi->idx, ice_status_str(status),
7860 ice_aq_str(hw->adminq.sq_last_status));
7871 * ice_clean_vsi_rss_cfg - Cleanup RSS configuration for a given VSI
7885 struct ice_softc *sc = vsi->sc;
7886 struct ice_hw *hw = &sc->hw;
7887 device_t dev = sc->dev;
7890 status = ice_rem_vsi_rss_cfg(hw, vsi->idx);
7894 vsi->idx, ice_status_str(status));
7897 ice_rem_vsi_rss_list(hw, vsi->idx);
7901 * ice_clean_all_vsi_rss_cfg - Cleanup RSS configuration for all VSIs
7916 if (!ice_is_bit_set(sc->feat_en, ICE_FEATURE_RSS))
7919 for (i = 0; i < sc->num_available_vsi; i++) {
7920 struct ice_vsi *vsi = sc->all_vsi[i];
7928 * ice_requested_fec_mode - Return the requested FEC mode as a string
7945 /* Check if RS-FEC has been requested first */
7950 /* If RS FEC has not been requested, then check BASE-R */
7959 * ice_negotiated_fec_mode - Return the negotiated FEC mode as a string
7968 if (pi->phy.link_info.fec_info & (ICE_AQ_LINK_25G_RS_528_FEC_EN |
7972 /* If RS FEC has not been requested, then check BASE-R */
7973 if (pi->phy.link_info.fec_info & ICE_AQ_LINK_25G_KR_FEC_EN)
7980 * ice_autoneg_mode - Return string indicating of autoneg completed
7988 if (pi->phy.link_info.an_info & ICE_AQ_AN_COMPLETED)
7995 * ice_flowcontrol_mode - Return string indicating the Flow Control mode
8003 return ice_fc_str(pi->fc.current_mode);
8007 * ice_link_up_msg - Log a link up message with associated info
8016 struct ice_hw *hw = &sc->hw;
8017 struct ifnet *ifp = sc->ifp;
8020 speed = ice_aq_speed_to_str(hw->port_info);
8021 req_fec = ice_requested_fec_mode(hw->port_info);
8022 neg_fec = ice_negotiated_fec_mode(hw->port_info);
8023 autoneg = ice_autoneg_mode(hw->port_info);
8024 flowcontrol = ice_flowcontrol_mode(hw->port_info);
8031 * ice_update_laa_mac - Update MAC address if Locally Administered
8045 const u8 *lladdr = (const u8 *)if_getlladdr(sc->ifp);
8046 struct ice_hw *hw = &sc->hw;
8050 if (!memcmp(lladdr, hw->port_info->mac.lan_addr, ETHER_ADDR_LEN))
8059 device_printf(sc->dev, "Failed to write mac %6D to firmware, err %s aq_err %s\n",
8061 ice_aq_str(hw->adminq.sq_last_status));
8066 bcopy(lladdr, hw->port_info->mac.lan_addr, ETHER_ADDR_LEN);
8072 * ice_get_and_print_bus_info - Save (PCI) bus info and print messages
8076 * is insufficient for full-speed operation. This will not print out anything
8081 * hw->port_info has been filled out with port link topology information
8087 struct ice_hw *hw = &sc->hw;
8088 device_t dev = sc->dev;
8106 "PCI-Express bandwidth available for this device may be insufficient for optimal performance.\n");
8108 "Please move the device to a different PCI-e link with more lanes and/or higher transfer rate.\n");
8113 * ice_pcie_bus_speed_to_rate - Convert driver bus speed enum value to
8114 * a 64-bit baudrate.
8122 /* If the PCI-E speed is Gen1 or Gen2, then report
8143 * ice_pcie_lnk_width_to_int - Convert driver pci-e width enum value to
8144 * a 32-bit number.
8173 * ice_pcie_bandwidth_check - Check if PCI-E bandwidth is sufficient for
8174 * full-speed device operation.
8182 struct ice_hw *hw = &sc->hw;
8186 MPASS(hw->port_info);
8188 num_ports = bitcount32(hw->func_caps.common_cap.valid_functions);
8189 port_speed = ice_phy_types_to_max_rate(hw->port_info);
8190 pcie_speed = ice_pcie_bus_speed_to_rate(hw->bus.speed);
8191 pcie_width = ice_pcie_lnk_width_to_int(hw->bus.width);
8194 * If 2x100 on E810 or 2x200 on E830, clamp ports to 1 -- 2nd port is
8206 * ice_print_bus_link_data - Print PCI-E bandwidth information
8208 * @hw: hw struct with PCI-e link information
8214 ((hw->bus.speed == ice_pcie_speed_32_0GT) ? "32.0GT/s" :
8215 (hw->bus.speed == ice_pcie_speed_16_0GT) ? "16.0GT/s" :
8216 (hw->bus.speed == ice_pcie_speed_8_0GT) ? "8.0GT/s" :
8217 (hw->bus.speed == ice_pcie_speed_5_0GT) ? "5.0GT/s" :
8218 (hw->bus.speed == ice_pcie_speed_2_5GT) ? "2.5GT/s" : "Unknown"),
8219 (hw->bus.width == ice_pcie_lnk_x32) ? "x32" :
8220 (hw->bus.width == ice_pcie_lnk_x16) ? "x16" :
8221 (hw->bus.width == ice_pcie_lnk_x12) ? "x12" :
8222 (hw->bus.width == ice_pcie_lnk_x8) ? "x8" :
8223 (hw->bus.width == ice_pcie_lnk_x4) ? "x4" :
8224 (hw->bus.width == ice_pcie_lnk_x2) ? "x2" :
8225 (hw->bus.width == ice_pcie_lnk_x1) ? "x1" : "Unknown");
8229 * ice_set_pci_link_status_data - store PCI bus info
8240 hw->bus.type = ice_bus_pci_express;
8252 hw->bus.width = (enum ice_pcie_link_width)reg;
8255 hw->bus.width = ice_pcie_lnk_width_unknown;
8267 hw->bus.speed = (enum ice_pcie_bus_speed)reg;
8270 hw->bus.speed = ice_pcie_speed_unknown;
8276 * ice_init_link_events - Initialize Link Status Events mask
8286 struct ice_hw *hw = &sc->hw;
8296 status = ice_aq_set_event_mask(hw, hw->port_info->lport, ~wanted_events, NULL);
8298 device_printf(sc->dev,
8300 ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status));
8305 status = ice_aq_get_link_info(hw->port_info, true, NULL, NULL);
8307 device_printf(sc->dev,
8309 ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status));
8322 * ice_handle_mdd_event - Handle possibly malicious events
8332 struct ice_hw *hw = &sc->hw;
8334 device_t dev = sc->dev;
8337 if (!ice_testandclear_state(&sc->state, ICE_STATE_MDD_PENDING))
8353 if (pf_num == hw->pf_id)
8373 if (pf_num == hw->pf_id)
8392 if (pf_num == hw->pf_id)
8405 sc->soft_stats.tx_mdd_count++;
8412 sc->soft_stats.tx_mdd_count++;
8419 sc->soft_stats.rx_mdd_count++;
8426 /* request that the upper stack re-initialize the Tx/Rx queues */
8434 * ice_start_dcbx_agent - Start DCBX agent in FW via AQ command
8445 struct ice_hw *hw = &sc->hw;
8446 device_t dev = sc->dev;
8450 hw->port_info->qos_cfg.dcbx_status = ice_get_dcbx_status(hw);
8452 if (hw->port_info->qos_cfg.dcbx_status != ICE_DCBX_STATUS_DONE &&
8453 hw->port_info->qos_cfg.dcbx_status != ICE_DCBX_STATUS_IN_PROGRESS) {
8460 if (status && hw->adminq.sq_last_status != ICE_AQ_RC_EPERM)
8464 ice_aq_str(hw->adminq.sq_last_status));
8469 * ice_init_dcb_setup - Initialize DCB settings for HW
8482 struct ice_hw *hw = &sc->hw;
8483 device_t dev = sc->dev;
8488 if (!ice_is_bit_set(sc->feat_cap, ICE_FEATURE_DCB)) {
8496 /* This sets hw->port_info->qos_cfg.is_sw_lldp */
8506 hw->adminq.sq_last_status == ICE_AQ_RC_EPERM)) {
8509 ice_aq_str(hw->adminq.sq_last_status));
8511 hw->port_info->qos_cfg.dcbx_status = ICE_DCBX_STATUS_NOT_STARTED;
8514 switch (hw->port_info->qos_cfg.dcbx_status) {
8529 if (hw->port_info->qos_cfg.is_sw_lldp) {
8539 ice_aq_str(hw->adminq.sq_last_status));
8541 local_dcbx_cfg = &hw->port_info->qos_cfg.local_dcbx_cfg;
8544 local_dcbx_cfg->pfc_mode = ICE_QOS_MODE_VLAN;
8547 local_dcbx_cfg->pfc_mode = ICE_QOS_MODE_DSCP;
8557 ice_set_bit(ICE_FEATURE_DCB, sc->feat_en);
8561 * ice_dcb_get_tc_map - Scans config to get bitmap of enabled TCs
8573 switch (dcbcfg->pfc_mode) {
8580 tc_map |= BIT(dcbcfg->etscfg.prio_table[i]);
8584 tc_map |= BIT(dcbcfg->dscp_map[i]);
8596 * ice_dcb_get_num_tc - Get the number of TCs from DCBX config
8601 * non-contiguous TCs used (e.g. assigning 1 and 3 without using 2),
8615 * ice_debug_print_mib_change_event - helper function to log LLDP MIB change events
8625 (struct ice_aqc_lldp_get_mib *)&event->desc.params.lldp_get_mib;
8636 "Non-TPMR Bridge",
8647 mib_type = (params->type & ICE_AQ_LLDP_MIB_TYPE_M) >>
8649 bridge_type = (params->type & ICE_AQ_LLDP_BRID_TYPE_M) >>
8651 tx_status = (params->type & ICE_AQ_LLDP_TX_M) >>
8654 ice_debug(&sc->hw, ICE_DBG_DCB, "LLDP MIB Change Event (%s, %s, %s)\n",
8659 if (!event->msg_buf)
8662 ice_debug(&sc->hw, ICE_DBG_DCB, "- %s contents:\n", mib_type_strings[mib_type]);
8663 ice_debug_array(&sc->hw, ICE_DBG_DCB, 16, 1, event->msg_buf,
8664 event->msg_len);
8668 * ice_dcb_needs_reconfig - Returns true if driver needs to reconfigure
8680 struct ice_hw *hw = &sc->hw;
8691 if (memcmp(&new_cfg->etscfg, &old_cfg->etscfg,
8692 sizeof(new_cfg->etscfg))) {
8694 if (memcmp(&new_cfg->etscfg.prio_table,
8695 &old_cfg->etscfg.prio_table,
8696 sizeof(new_cfg->etscfg.prio_table))) {
8702 if (memcmp(&new_cfg->etscfg.tcbwtable,
8703 &old_cfg->etscfg.tcbwtable,
8704 sizeof(new_cfg->etscfg.tcbwtable))) {
8709 if (memcmp(&new_cfg->etscfg.tsatable,
8710 &old_cfg->etscfg.tsatable,
8711 sizeof(new_cfg->etscfg.tsatable))) {
8718 if (memcmp(&new_cfg->pfc, &old_cfg->pfc, sizeof(new_cfg->pfc))) {
8724 if (memcmp(&new_cfg->app, &old_cfg->app, sizeof(new_cfg->app)))
8733 * ice_stop_pf_vsi - Stop queues for PF LAN VSI
8742 ice_flush_txq_interrupts(&sc->pf_vsi);
8743 ice_flush_rxq_interrupts(&sc->pf_vsi);
8745 if (!ice_testandclear_state(&sc->state, ICE_STATE_DRIVER_INITIALIZED))
8749 ice_vsi_disable_tx(&sc->pf_vsi);
8750 ice_control_all_rx_queues(&sc->pf_vsi, false);
8754 * ice_vsi_setup_q_map - Setup a VSI queue map
8766 if (vsi->num_tcs == 0) {
8768 vsi->num_tcs = 1;
8769 vsi->tc_map = 0x1;
8772 qcount_rx = vsi->num_rx_queues;
8773 num_q_per_tc = min(qcount_rx / vsi->num_tcs, ICE_MAX_RXQS_PER_TC);
8780 if (i < vsi->num_tcs)
8784 rem_queues = qcount_rx % vsi->num_tcs;
8791 * queues allocated to TC0. No:of queues is a power-of-2.
8800 if (!(vsi->tc_map & BIT(i))) {
8802 vsi->tc_info[i].qoffset = 0;
8803 vsi->tc_info[i].qcount_rx = 1;
8804 vsi->tc_info[i].qcount_tx = 1;
8806 ctxt->info.tc_mapping[i] = 0;
8811 vsi->tc_info[i].qoffset = offset;
8812 vsi->tc_info[i].qcount_rx = qcounts[i];
8813 vsi->tc_info[i].qcount_tx = qcounts[i];
8815 /* find the (rounded up) log-2 of queue count for current TC */
8816 pow = fls(qcounts[i] - 1);
8822 ctxt->info.tc_mapping[i] = CPU_TO_LE16(qmap);
8826 vsi->tx_queues[j].q_handle = k;
8827 vsi->tx_queues[j].tc = i;
8829 vsi->rx_queues[j].tc = i;
8836 ctxt->info.mapping_flags |= CPU_TO_LE16(ICE_AQ_VSI_Q_MAP_CONTIG);
8837 ctxt->info.q_mapping[0] = CPU_TO_LE16(vsi->rx_qmap[0]);
8838 ctxt->info.q_mapping[1] = CPU_TO_LE16(vsi->num_rx_queues);
8842 * ice_pf_vsi_cfg_tc - Configure PF VSI for a given TC map
8856 struct ice_vsi *vsi = &sc->pf_vsi;
8857 struct ice_hw *hw = &sc->hw;
8859 device_t dev = sc->dev;
8869 vsi->tc_map = tc_map;
8870 vsi->num_tcs = num_tcs;
8874 ctx.info = vsi->info;
8881 status = ice_update_vsi(hw, vsi->idx, &ctx, NULL);
8886 ice_aq_str(hw->adminq.sq_last_status));
8889 vsi->info = ctx.info;
8893 max_txqs[i] = vsi->tc_info[i].qcount_tx;
8895 if (hw->debug_mask & ICE_DBG_DCB) {
8903 status = ice_cfg_vsi_lan(hw->port_info, vsi->idx, vsi->tc_map,
8909 ice_aq_str(hw->adminq.sq_last_status));
8913 vsi->info.valid_sections = 0;
8919 * ice_dcb_tc_contig - Count TCs if they're contiguous
8923 * an 8-bit TC bitmap, or if there is a gap, then returns 0.
8937 /* Non-contiguous TCs detected */
8948 * ice_dcb_recfg - Reconfigure VSI with new DCB settings
8959 &sc->hw.port_info->qos_cfg.local_dcbx_cfg;
8960 device_t dev = sc->dev;
8966 /* If non-contiguous TCs are used, then configure
8968 * non-contiguous TCs being used.
8985 * ice_set_default_local_mib_settings - Set Local LLDP MIB to default settings
8996 struct ice_hw *hw = &sc->hw;
9000 pi = hw->port_info;
9002 dcbcfg = &pi->qos_cfg.local_dcbx_cfg;
9004 maxtcs = hw->func_caps.common_cap.maxtc;
9009 old_pfc_mode = dcbcfg->pfc_mode;
9018 dcbcfg->etscfg.willing = 1;
9019 dcbcfg->etscfg.tcbwtable[0] = 100;
9020 dcbcfg->etscfg.maxtcs = maxtcs_ets;
9021 dcbcfg->etscfg.tsatable[0] = 2;
9023 dcbcfg->etsrec = dcbcfg->etscfg;
9024 dcbcfg->etsrec.willing = 0;
9026 dcbcfg->pfc.willing = 1;
9027 dcbcfg->pfc.pfccap = maxtcs;
9029 dcbcfg->pfc_mode = old_pfc_mode;
9033 * ice_do_dcb_reconfig - notify RDMA and reconfigure PF LAN VSI
9047 struct ice_hw *hw = &sc->hw;
9049 device_t dev = sc->dev;
9052 pi = sc->hw.port_info;
9053 local_dcbx_cfg = &pi->qos_cfg.local_dcbx_cfg;
9062 (hw->adminq.sq_last_status == ICE_AQ_RC_ENOENT)) {
9069 ice_aq_str(hw->adminq.sq_last_status));
9077 ice_set_state(&sc->state, ICE_STATE_MULTIPLE_TCS);
9080 ice_clear_state(&sc->state, ICE_STATE_MULTIPLE_TCS);
9092 ice_aq_str(hw->adminq.sq_last_status));
9106 * ice_handle_mib_change_event - helper function to handle LLDP MIB change events
9118 (struct ice_aqc_lldp_get_mib *)&event->desc.params.lldp_get_mib;
9121 device_t dev = sc->dev;
9122 struct ice_hw *hw = &sc->hw;
9131 pi = sc->hw.port_info;
9133 mib_type = (params->type & ICE_AQ_LLDP_MIB_TYPE_M) >>
9135 bridge_type = (params->type & ICE_AQ_LLDP_BRID_TYPE_M) >>
9137 mib_is_pending = (params->state & ICE_AQ_LLDP_MIB_CHANGE_STATE_M) >>
9147 status = ice_aq_get_dcb_cfg(pi->hw, ICE_AQ_LLDP_MIB_REMOTE,
9149 &pi->qos_cfg.remote_dcbx_cfg);
9154 ice_aq_str(hw->adminq.sq_last_status));
9160 local_dcbx_cfg = &pi->qos_cfg.local_dcbx_cfg;
9175 ice_aq_str(hw->adminq.sq_last_status));
9187 /* Reconfigure -- this will also notify FW that configuration is done,
9194 * ice_send_version - Send driver version to firmware
9204 struct ice_hw *hw = &sc->hw;
9205 device_t dev = sc->dev;
9219 ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status));
9227 * ice_handle_lan_overflow_event - helper function to log LAN overflow events
9238 (struct ice_aqc_event_lan_overflow *)&event->desc.params.lan_overflow;
9239 struct ice_hw *hw = &sc->hw;
9242 LE32_TO_CPU(params->prtdcb_ruptq),
9243 LE32_TO_CPU(params->qtx_ctl));
9247 * ice_add_ethertype_to_list - Add an Ethertype filter to a filter list
9272 entry->fltr_info.flag = direction;
9273 entry->fltr_info.src_id = ICE_SRC_ID_VSI;
9274 entry->fltr_info.lkup_type = ICE_SW_LKUP_ETHERTYPE;
9275 entry->fltr_info.fltr_act = action;
9276 entry->fltr_info.vsi_handle = vsi->idx;
9277 entry->fltr_info.l_data.ethertype_mac.ethertype = ethertype;
9279 LIST_ADD(&entry->list_entry, list);
9288 * ice_cfg_pf_ethertype_filters - Configure switch to drop ethertypes
9299 struct ice_vsi *vsi = &sc->pf_vsi;
9300 struct ice_hw *hw = &sc->hw;
9301 device_t dev = sc->dev;
9314 if (sc->enable_tx_fc_filter) {
9323 if (sc->enable_tx_lldp_filter) {
9336 ice_aq_str(hw->adminq.sq_last_status));
9346 * ice_add_rx_lldp_filter - add ethertype filter for Rx LLDP frames
9357 struct ice_vsi *vsi = &sc->pf_vsi;
9358 struct ice_hw *hw = &sc->hw;
9359 device_t dev = sc->dev;
9369 vsi_num = ice_get_hw_vsi_num(hw, vsi->idx);
9375 ice_aq_str(hw->adminq.sq_last_status));
9377 ice_set_state(&sc->state,
9400 ice_aq_str(hw->adminq.sq_last_status));
9406 ice_set_state(&sc->state, ICE_STATE_LLDP_RX_FLTR_FROM_DRIVER);
9414 * ice_del_rx_lldp_filter - Remove ethertype filter for Rx LLDP frames
9425 struct ice_vsi *vsi = &sc->pf_vsi;
9426 struct ice_hw *hw = &sc->hw;
9427 device_t dev = sc->dev;
9437 if (!ice_test_state(&sc->state, ICE_STATE_LLDP_RX_FLTR_FROM_DRIVER))
9445 vsi_num = ice_get_hw_vsi_num(hw, vsi->idx);
9451 ice_aq_str(hw->adminq.sq_last_status));
9476 ice_aq_str(hw->adminq.sq_last_status));
9484 * ice_init_link_configuration -- Setup link in different ways depending
9495 struct ice_port_info *pi = sc->hw.port_info;
9496 struct ice_hw *hw = &sc->hw;
9497 device_t dev = sc->dev;
9501 pi->phy.get_link_info = true;
9502 status = ice_get_link_status(pi, &sc->link_up);
9505 if (hw->adminq.sq_last_status == ICE_AQ_RC_EAGAIN) {
9518 ice_aq_str(hw->adminq.sq_last_status));
9523 if (pi->phy.link_info.link_info & ICE_AQ_MEDIA_AVAILABLE) {
9524 ice_clear_state(&sc->state, ICE_STATE_NO_MEDIA);
9526 if (!ice_test_state(&sc->state, ICE_STATE_LINK_ACTIVE_ON_DOWN)) {
9528 ice_set_state(&sc->state, ICE_STATE_LINK_STATUS_REPORTED);
9533 * driver from receiving spurious link-related events.
9535 ice_set_state(&sc->state, ICE_STATE_NO_MEDIA);
9537 if (status && hw->adminq.sq_last_status != ICE_AQ_RC_EMODE)
9541 ice_aq_str(hw->adminq.sq_last_status));
9546 * ice_apply_saved_phy_req_to_cfg -- Write saved user PHY settings to cfg data
9560 struct ice_port_info *pi = sc->hw.port_info;
9565 link_speeds = pi->phy.curr_user_speed_req;
9567 if (ice_is_bit_set(sc->feat_en, ICE_FEATURE_LINK_MGMT_VER_2)) {
9581 if (ice_is_bit_set(sc->feat_en, ICE_FEATURE_LENIENT_LINK_MODE)) {
9608 (sc->ldo_tlv.phy_type_low || sc->ldo_tlv.phy_type_high))
9621 if (!ice_is_bit_set(sc->feat_en, ICE_FEATURE_LENIENT_LINK_MODE)) {
9623 device_printf(sc->dev,
9629 if (sc->ldo_tlv.phy_type_low & phy_low ||
9630 sc->ldo_tlv.phy_type_high & phy_high) {
9631 phy_low &= sc->ldo_tlv.phy_type_low;
9632 phy_high &= sc->ldo_tlv.phy_type_high;
9656 pi->phy.curr_user_speed_req = phy_data.user_speeds_intr;
9657 cfg->phy_type_low = htole64(phy_low);
9658 cfg->phy_type_high = htole64(phy_high);
9664 * ice_apply_saved_fec_req_to_cfg -- Write saved user FEC mode to cfg data
9676 struct ice_port_info *pi = sc->hw.port_info;
9679 cfg->caps &= ~ICE_AQC_PHY_EN_AUTO_FEC;
9680 status = ice_cfg_phy_fec(pi, cfg, pi->phy.curr_user_fec_req);
9688 * ice_apply_saved_fc_req_to_cfg -- Write saved user flow control mode to cfg data
9700 cfg->caps &= ~(ICE_AQ_PHY_ENA_TX_PAUSE_ABILITY |
9703 switch (pi->phy.curr_user_fc_req) {
9705 cfg->caps |= ICE_AQ_PHY_ENA_TX_PAUSE_ABILITY |
9709 cfg->caps |= ICE_AQ_PHY_ENA_RX_PAUSE_ABILITY;
9712 cfg->caps |= ICE_AQ_PHY_ENA_TX_PAUSE_ABILITY;
9721 * ice_apply_saved_phy_cfg -- Re-apply user PHY config settings
9738 struct ice_port_info *pi = sc->hw.port_info;
9740 struct ice_hw *hw = &sc->hw;
9741 device_t dev = sc->dev;
9748 ice_debug(hw, ICE_DBG_LINK, "Settings out-of-bounds: %u\n",
9758 ice_aq_str(hw->adminq.sq_last_status));
9775 pi->phy.curr_user_speed_req = dflt_user_speed;
9781 pi->phy.curr_user_fec_req = dflt_fec_mode;
9789 /* Enable link and re-negotiate it */
9799 (hw->adminq.sq_last_status == ICE_AQ_RC_EBUSY)) {
9808 ice_aq_str(hw->adminq.sq_last_status));
9817 * ice_print_ldo_tlv - Print out LDO TLV information
9819 * @tlv: LDO TLV information from the adapter NVM
9821 * Dump out the information in tlv to the kernel message buffer; intended for
9825 ice_print_ldo_tlv(struct ice_softc *sc, struct ice_link_default_override_tlv *tlv)
9827 device_t dev = sc->dev;
9829 device_printf(dev, "TLV: -options 0x%02x\n", tlv->options);
9830 device_printf(dev, " -phy_config 0x%02x\n", tlv->phy_config);
9831 device_printf(dev, " -fec_options 0x%02x\n", tlv->fec_options);
9832 device_printf(dev, " -phy_high 0x%016llx\n",
9833 (unsigned long long)tlv->phy_type_high);
9834 device_printf(dev, " -phy_low 0x%016llx\n",
9835 (unsigned long long)tlv->phy_type_low);
9839 * ice_set_link_management_mode -- Strict or lenient link management
9851 struct ice_port_info *pi = sc->hw.port_info;
9852 device_t dev = sc->dev;
9853 struct ice_link_default_override_tlv tlv = { 0 };
9859 if (!(ice_fw_supports_link_override(&sc->hw)))
9862 status = ice_get_link_default_override(&tlv, pi);
9867 ice_aq_str(sc->hw.adminq.sq_last_status));
9871 if (sc->hw.debug_mask & ICE_DBG_LINK)
9872 ice_print_ldo_tlv(sc, &tlv);
9875 if (ice_is_bit_set(sc->feat_cap, ICE_FEATURE_LENIENT_LINK_MODE) &&
9876 (!(tlv.options & ICE_LINK_OVERRIDE_STRICT_MODE)))
9877 ice_set_bit(ICE_FEATURE_LENIENT_LINK_MODE, sc->feat_en);
9880 if (ice_is_bit_set(sc->feat_cap, ICE_FEATURE_LINK_MGMT_VER_2) &&
9881 ice_fw_supports_report_dflt_cfg(&sc->hw)) {
9882 ice_set_bit(ICE_FEATURE_LINK_MGMT_VER_2, sc->feat_en);
9891 if (ice_is_bit_set(sc->feat_cap, ICE_FEATURE_LINK_MGMT_VER_1) &&
9892 ice_is_bit_set(sc->feat_en, ICE_FEATURE_LENIENT_LINK_MODE) &&
9893 (tlv.options & ICE_LINK_OVERRIDE_EN))
9894 ice_set_bit(ICE_FEATURE_LINK_MGMT_VER_1, sc->feat_en);
9896 /* Cache the LDO TLV structure in the driver, since it
9899 sc->ldo_tlv = tlv;
9903 * ice_set_link -- Set up/down link on phy
9912 struct ice_hw *hw = &sc->hw;
9913 device_t dev = sc->dev;
9919 if (ice_test_state(&sc->state, ICE_STATE_NO_MEDIA))
9925 status = ice_aq_set_link_restart_an(hw->port_info, false, NULL);
9927 if (hw->adminq.sq_last_status == ICE_AQ_RC_EMODE)
9935 ice_aq_str(hw->adminq.sq_last_status));
9937 sc->link_up = false;
9942 * ice_init_saved_phy_cfg -- Set cached user PHY cfg settings with NVM defaults
9946 * (e.g. advertise_speed) are added -- so that these defaults don't overwrite
9956 struct ice_port_info *pi = sc->hw.port_info;
9958 struct ice_hw *hw = &sc->hw;
9959 device_t dev = sc->dev;
9964 if (ice_is_bit_set(sc->feat_en, ICE_FEATURE_LINK_MGMT_VER_2))
9973 ice_aq_str(hw->adminq.sq_last_status));
9981 pi->phy.curr_user_speed_req =
9983 pi->phy.curr_user_fec_req = ice_caps_to_fec_mode(pcaps.caps,
9985 pi->phy.curr_user_fc_req = ice_caps_to_fc_mode(pcaps.caps);
9989 * ice_module_init - Driver callback to handle module load
10002 * ice_module_exit - Driver callback to handle module exit
10007 * If this function returns non-zero, the module will not be unloaded. It
10019 * ice_module_event_handler - Callback for module events
10043 * ice_handle_nvm_access_ioctl - Handle an NVM access ioctl request
10052 size_t ifd_len = ifd->ifd_len, malloc_len;
10053 struct ice_hw *hw = &sc->hw;
10054 device_t dev = sc->dev;
10063 * that non-privileged threads cannot access this interface.
10069 if (ice_test_state(&sc->state, ICE_STATE_PREPARED_FOR_RESET)) {
10081 if (ifd->ifd_data == NULL) {
10103 err = copyin(ifd->ifd_data, nvm_buffer, ifd_len);
10125 err = copyout(nvm_buffer, ifd->ifd_data, ifd_len);
10155 * ice_read_sff_eeprom - Read data from SFF eeprom
10163 * on the contents of an SFF eeprom, refer to SFF-8724 (SFP), SFF-8636 (QSFP),
10164 * and SFF-8024 (both).
10169 struct ice_hw *hw = &sc->hw;
10176 if (ice_test_state(&sc->state, ICE_STATE_RECOVERY_MODE))
10179 if (ice_test_state(&sc->state, ICE_STATE_NO_MEDIA))
10191 hw->adminq.sq_last_status == ICE_AQ_RC_EBUSY) {
10196 hw->adminq.sq_last_status == ICE_AQ_RC_EACCES) {
10202 hw->adminq.sq_last_status == ICE_AQ_RC_EPERM) {
10203 device_printf(sc->dev,
10209 device_printf(sc->dev,
10212 ice_aq_str(hw->adminq.sq_last_status));
10219 device_printf(sc->dev,
10227 * ice_handle_i2c_req - Driver independent I2C request handler
10236 return ice_read_sff_eeprom(sc, req->dev_addr, req->offset, req->data, req->len);
10240 * ice_sysctl_read_i2c_diag_data - Read some module diagnostic data via i2c
10250 * ------------|---------|----------------
10251 * Temperature | 96-97 | 22-23
10252 * Vcc | 98-99 | 26-27
10253 * TX power | 102-103 | 34-35..40-41
10254 * RX power | 104-105 | 50-51..56-57
10260 device_t dev = sc->dev;
10271 if (req->oldptr == NULL) {
10284 * - Internally calibrated data
10285 * - Diagnostic monitoring is implemented
10336 * ice_alloc_intr_tracking - Setup interrupt tracking structures
10350 struct ice_hw *hw = &sc->hw;
10351 device_t dev = sc->dev;
10354 if (hw->func_caps.common_cap.num_msix_vectors > ICE_MAX_MSIX_VECTORS) {
10357 hw->func_caps.common_cap.num_msix_vectors);
10362 err = ice_resmgr_init_contig_only(&sc->dev_imgr,
10363 hw->func_caps.common_cap.num_msix_vectors);
10371 if (!(sc->pf_imap =
10372 (u16 *)malloc(sizeof(u16) * hw->func_caps.common_cap.num_msix_vectors,
10378 if (!(sc->rdma_imap =
10379 (u16 *)malloc(sizeof(u16) * hw->func_caps.common_cap.num_msix_vectors,
10383 free(sc->pf_imap, M_ICE);
10386 for (u32 i = 0; i < hw->func_caps.common_cap.num_msix_vectors; i++) {
10387 sc->pf_imap[i] = ICE_INVALID_RES_IDX;
10388 sc->rdma_imap[i] = ICE_INVALID_RES_IDX;
10394 ice_resmgr_destroy(&sc->dev_imgr);
10399 * ice_free_intr_tracking - Free PF interrupt tracking structures
10410 if (sc->pf_imap) {
10411 ice_resmgr_release_map(&sc->dev_imgr, sc->pf_imap,
10412 sc->lan_vectors);
10413 free(sc->pf_imap, M_ICE);
10414 sc->pf_imap = NULL;
10416 if (sc->rdma_imap) {
10417 ice_resmgr_release_map(&sc->dev_imgr, sc->rdma_imap,
10418 sc->lan_vectors);
10419 free(sc->rdma_imap, M_ICE);
10420 sc->rdma_imap = NULL;
10423 ice_resmgr_destroy(&sc->dev_imgr);
10425 ice_resmgr_destroy(&sc->os_imgr);
10429 * ice_apply_supported_speed_filter - Mask off unsupported speeds
10430 * @report_speeds: bit-field for the desired link speeds
10465 speed_mask = ~((u16)ICE_AQ_LINK_SPEED_100MB - 1);
10467 speed_mask = ~((u16)ICE_AQ_LINK_SPEED_1000MB - 1);
10469 speed_mask = ~((u16)ICE_AQ_LINK_SPEED_1000MB - 1);
10471 speed_mask = ~((u16)ICE_AQ_LINK_SPEED_1000MB - 1);
10473 speed_mask = ~((u16)ICE_AQ_LINK_SPEED_10GB - 1);
10477 speed_mask = ~((u16)ICE_AQ_LINK_SPEED_25GB - 1);
10482 * ice_init_health_events - Enable FW health event reporting
10494 if ((!ice_is_bit_set(sc->feat_cap, ICE_FEATURE_HEALTH_STATUS)) ||
10495 (!sc->enable_health_events))
10501 status = ice_aq_set_health_status_config(&sc->hw, health_mask, NULL);
10503 device_printf(sc->dev,
10506 ice_aq_str(sc->hw.adminq.sq_last_status));
10508 ice_set_bit(ICE_FEATURE_HEALTH_STATUS, sc->feat_en);
10512 * ice_print_health_status_string - Print message for given FW health event
10523 u16 status_code = le16toh(elem->health_status_code);
10556 device_printf(dev, "Possible Solution: Disable FW-LLDP and check DCBx system configuration.\n");
10657 * ice_handle_health_status_event - helper function to output health status
10672 if (!ice_is_bit_set(sc->feat_en, ICE_FEATURE_HEALTH_STATUS))
10675 health_info = (struct ice_aqc_health_status_elem *)event->msg_buf;
10676 status_count = le16toh(event->desc.params.get_health_status.health_status_count);
10678 if (status_count > (event->buf_len / sizeof(*health_info))) {
10679 device_printf(sc->dev, "Received a health status event with invalid event count\n");
10684 ice_print_health_status_string(sc->dev, health_info);
10690 * ice_set_default_local_lldp_mib - Possibly apply local LLDP MIB to FW
10694 * certain PFC/DCB settings. In certain configurations this will re-apply a
10701 struct ice_hw *hw = &sc->hw;
10703 device_t dev = sc->dev;
10707 * non-DCB-supported devices.
10709 if (!ice_is_bit_set(sc->feat_en, ICE_FEATURE_DCB))
10712 pi = hw->port_info;
10715 if (!pi->qos_cfg.is_sw_lldp &&
10716 !ice_test_state(&sc->state, ICE_STATE_MULTIPLE_TCS))
10725 ice_aq_str(hw->adminq.sq_last_status));
10729 * ice_sbuf_print_ets_cfg - Helper function to print ETS cfg
10740 sbuf_printf(sbuf, "%s.willing: %u\n", name, ets->willing);
10741 sbuf_printf(sbuf, "%s.cbs: %u\n", name, ets->cbs);
10742 sbuf_printf(sbuf, "%s.maxtcs: %u\n", name, ets->maxtcs);
10746 sbuf_printf(sbuf, " %d", ets->prio_table[i]);
10751 sbuf_printf(sbuf, " %d", ets->tcbwtable[i]);
10756 sbuf_printf(sbuf, " %d", ets->tsatable[i]);
10761 * ice_sysctl_dump_dcbx_cfg - Print out DCBX/DCB config info
10778 struct ice_hw *hw = &sc->hw;
10779 device_t dev = sc->dev;
10789 is_sw_lldp = hw->port_info->qos_cfg.is_sw_lldp;
10795 dcbcfg = &hw->port_info->qos_cfg.local_dcbx_cfg;
10802 hw->adminq.sq_last_status == ICE_AQ_RC_ENOENT) {
10810 ice_aq_str(hw->adminq.sq_last_status));
10817 dcbcfg->dcbx_mode = ICE_DCBX_MODE_CEE;
10818 else if (hw->adminq.sq_last_status == ICE_AQ_RC_ENOENT)
10819 dcbcfg->dcbx_mode = ICE_DCBX_MODE_IEEE;
10823 ice_aq_str(hw->adminq.sq_last_status));
10825 maxtcs = hw->func_caps.common_cap.maxtc;
10836 sbuf_printf(sbuf, "numapps: %u\n", dcbcfg->numapps);
10837 sbuf_printf(sbuf, "CEE TLV status: %u\n", dcbcfg->tlv_status);
10838 sbuf_printf(sbuf, "pfc_mode: %s\n", (dcbcfg->pfc_mode == ICE_QOS_MODE_DSCP) ?
10841 (dcbcfg->dcbx_mode == ICE_DCBX_MODE_IEEE) ? "IEEE" :
10842 (dcbcfg->dcbx_mode == ICE_DCBX_MODE_CEE) ? "CEE" :
10845 ice_sbuf_print_ets_cfg(sbuf, "etscfg", &dcbcfg->etscfg);
10846 ice_sbuf_print_ets_cfg(sbuf, "etsrec", &dcbcfg->etsrec);
10848 sbuf_printf(sbuf, "pfc.willing: %u\n", dcbcfg->pfc.willing);
10849 sbuf_printf(sbuf, "pfc.mbc: %u\n", dcbcfg->pfc.mbc);
10850 sbuf_printf(sbuf, "pfc.pfccap: 0x%0x\n", dcbcfg->pfc.pfccap);
10851 sbuf_printf(sbuf, "pfc.pfcena: 0x%0x\n", dcbcfg->pfc.pfcena);
10858 dcbcfg->dscp_map[i * 8 + j]);
10882 * ice_sysctl_dump_vsi_cfg - print PF LAN VSI configuration
10888 * XXX: This could be extended to apply to arbitrary PF-owned VSIs,
10896 struct ice_hw *hw = &sc->hw;
10897 device_t dev = sc->dev;
10908 ctx.vsi_num = ice_get_hw_vsi_num(hw, sc->pf_vsi.idx);
10915 ice_aq_str(hw->adminq.sq_last_status));
10931 /* The PF VSI is always contiguous, so there's no if-statement here */
10958 * ice_get_tx_rx_equalizations -- read serdes tx rx equalization params
10975 ice_aq_get_phy_equalization(hw, equ, dir, serdes_num, &(ptr->value))
11036 * ice_fec_counter_read - reads FEC stats from PHY
11040 * @output: pointer to the caller-supplied buffer to return requested fec stats
11067 * ice_get_port_fec_stats - returns fec correctable, uncorrectable stats per pcsquad, pcsport
11115 receiver_id = ICE_RS_FEC_RECEIVER_ID_PCS0; /* MTIP PCS Quad 0 -FEC */
11117 receiver_id = ICE_RS_FEC_RECEIVER_ID_PCS1; /* MTIP PCS Quad 1 -FEC */
11141 fec_stats->fec_corr_cnt_low = corr_low_val;
11142 fec_stats->fec_corr_cnt_high = corr_high_val;
11143 fec_stats->fec_uncorr_cnt_low = uncorr_low_val;
11144 fec_stats->fec_uncorr_cnt_high = uncorr_high_val;
11150 * ice_is_serdes_muxed - returns whether serdes is muxed in hardware
11163 * ice_get_maxspeed - Get the max speed for given lport
11198 * ice_update_port_topology - update port topology
11209 port_topology->pcs_quad_select = 0;
11210 port_topology->pcs_port = 0;
11211 port_topology->primary_serdes_lane = 0;
11214 port_topology->pcs_quad_select = 1;
11215 port_topology->pcs_port = 0;
11217 port_topology->primary_serdes_lane = 2;
11219 port_topology->primary_serdes_lane = 4;
11222 port_topology->pcs_quad_select = 0;
11223 port_topology->pcs_port = 1;
11224 port_topology->primary_serdes_lane = 1;
11227 port_topology->pcs_quad_select = 1;
11228 port_topology->pcs_port = 1;
11230 port_topology->primary_serdes_lane = 3;
11232 port_topology->primary_serdes_lane = 5;
11235 port_topology->pcs_quad_select = 0;
11236 port_topology->pcs_port = 2;
11237 port_topology->primary_serdes_lane = 2;
11240 port_topology->pcs_quad_select = 1;
11241 port_topology->pcs_port = 2;
11242 port_topology->primary_serdes_lane = 6;
11245 port_topology->pcs_quad_select = 0;
11246 port_topology->pcs_port = 3;
11247 port_topology->primary_serdes_lane = 3;
11250 port_topology->pcs_quad_select = 1;
11251 port_topology->pcs_port = 3;
11252 port_topology->primary_serdes_lane = 7;
11261 * ice_get_port_topology - returns physical topology
11282 if (hw->device_id >= ICE_DEV_ID_E810_XXV_BACKPLANE) {
11283 port_topology->serdes_lane_count = 1;
11285 port_topology->pcs_quad_select = 0;
11286 port_topology->pcs_port = 0;
11287 port_topology->primary_serdes_lane = 0;
11289 port_topology->pcs_quad_select = 1;
11290 port_topology->pcs_port = 0;
11291 port_topology->primary_serdes_lane = 1;
11318 port_topology->serdes_lane_count = 1;
11323 err = ice_get_maxspeed(hw, port_topology->primary_serdes_lane,
11334 port_topology->serdes_lane_count = 4;
11336 port_topology->serdes_lane_count = 2;
11338 port_topology->serdes_lane_count = 1;
11345 port_topology->serdes_lane_count);
11347 port_topology->pcs_quad_select);
11349 port_topology->pcs_port);
11351 port_topology->primary_serdes_lane);
11357 * ice_sysctl_dump_phy_stats - print PHY stats
11369 struct ice_hw *hw = &sc->hw;
11371 device_t dev = sc->dev;
11377 pi = hw->port_info;
11391 if (ice_get_port_topology(hw, pi->lport, &port_topology) != 0) {
11394 pi->lport);
11401 pi->lport,
11415 pi->lport,serdes_num, err);
11451 pi->lport, err);
11472 * ice_ets_str_to_tbl - Parse string into ETS table
11504 * ice_check_ets_bw - Check if ETS bw vals are valid
11521 * ice_cfg_pba_num - Determine if PBA Number is retrievable
11533 if ((ice_is_bit_set(sc->feat_cap, ICE_FEATURE_HAS_PBA)) &&
11534 (ice_read_pba_string(&sc->hw, pba_string, sizeof(pba_string)) == 0))
11535 ice_set_bit(ICE_FEATURE_HAS_PBA, sc->feat_en);
11539 * ice_sysctl_query_port_ets - print Port ETS Config from AQ
11550 struct ice_hw *hw = &sc->hw;
11552 device_t dev = sc->dev;
11563 pi = hw->port_info;
11570 ice_aq_str(hw->adminq.sq_last_status));
11604 * ice_sysctl_dscp2tc_map - Map DSCP to hardware TCs
11607 * @arg2: which eight DSCP to UP mappings to configure (0 - 7)
11623 struct ice_hw *hw = &sc->hw;
11624 device_t dev = sc->dev;
11636 if (req->oldptr == NULL && req->newptr == NULL) {
11641 pi = hw->port_info;
11642 local_dcbx_cfg = &pi->qos_cfg.local_dcbx_cfg;
11646 /* Format DSCP-to-UP data for output */
11648 sbuf_printf(sbuf, "%d", local_dcbx_cfg->dscp_map[arg2 * 8 + i]);
11649 if (i != ICE_MAX_TRAFFIC_CLASS - 1)
11658 if ((ret) || (req->newptr == NULL))
11662 if (!hw->port_info->qos_cfg.is_sw_lldp) {
11669 * needs to be done for ETS settings, so this function can be re-used
11673 ICE_MAX_TRAFFIC_CLASS - 1);
11680 memcpy(&local_dcbx_cfg->dscp_map[arg2 * 8], new_dscp_table_seg,
11683 local_dcbx_cfg->app_mode = ICE_DCBX_APPS_NON_WILLING;
11690 ice_aq_str(hw->adminq.sq_last_status));
11700 * ice_handle_debug_dump_ioctl - Handle a debug dump ioctl request
11707 size_t ifd_len = ifd->ifd_len;
11708 struct ice_hw *hw = &sc->hw;
11709 device_t dev = sc->dev;
11724 * that non-privileged threads cannot access this interface.
11730 if (ice_test_state(&sc->state, ICE_STATE_PREPARED_FOR_RESET)) {
11744 if (ifd->ifd_data == NULL) {
11756 err = copyin(ifd->ifd_data, ddc, ifd_len);
11764 if (ddc->data_size == 0) {
11771 if (ddc->data_size > (ifd_len - sizeof(*ddc))) {
11774 ddc->data_size, ifd_len - sizeof(*ddc));
11780 memset(ddc->data, 0, ifd_len - sizeof(*ddc));
11782 status = ice_aq_get_internal_data(hw, ddc->cluster_id, ddc->table_id, ddc->offset,
11783 (u8 *)ddc->data, ddc->data_size, &ret_buf_size,
11792 ice_aq_str(hw->adminq.sq_last_status));
11796 ddc->table_id = ret_next_table;
11797 ddc->offset = ret_next_index;
11798 ddc->data_size = ret_buf_size;
11799 ddc->cluster_id = ret_next_cluster;
11802 err = copyout(ddc, ifd->ifd_data, ifd->ifd_len);
11836 * ice_sysctl_allow_no_fec_mod_in_auto - Change Auto FEC behavior
11850 struct ice_hw *hw = &sc->hw;
11851 device_t dev = sc->dev;
11864 user_flag = (u8)sc->allow_no_fec_mod_in_auto;
11867 if ((ret) || (req->newptr == NULL))
11877 if (user_flag == (bool)sc->allow_no_fec_mod_in_auto)
11880 sc->allow_no_fec_mod_in_auto = (u8)user_flag;
11882 if (sc->allow_no_fec_mod_in_auto)
11894 * ice_sysctl_temperature - Retrieve NIC temp via AQ command
11908 struct ice_hw *hw = &sc->hw;
11909 device_t dev = sc->dev;
11924 ice_aq_str(hw->adminq.sq_last_status));
11939 * ice_sysctl_create_mirror_interface - Create a new ifnet that monitors
11946 device_t dev = sc->dev;
11959 if (!ice_test_state(&sc->state, ICE_STATE_DO_CREATE_MIRR_INTFC)) {
11964 if (req->oldptr == NULL && req->newptr == NULL) {
11971 if ((ret) || (req->newptr == NULL))
11978 if (sc->mirr_if) {
11981 if_name(sc->mirr_if->ifp));
11984 ice_set_state(&sc->state, ICE_STATE_DO_CREATE_MIRR_INTFC);
11991 /* --- "Do Create Mirror Interface" is set --- */
11994 if (req->oldptr == NULL && req->newptr == NULL) {
12005 ice_clear_state(&sc->state, ICE_STATE_DO_CREATE_MIRR_INTFC);
12012 * ice_sysctl_destroy_mirror_interface - Destroy network interface that monitors
12019 device_t dev = sc->dev;
12032 if (!ice_test_state(&sc->state, ICE_STATE_DO_DESTROY_MIRR_INTFC)) {
12037 if (req->oldptr == NULL && req->newptr == NULL) {
12044 if ((ret) || (req->newptr == NULL))
12051 if (!sc->mirr_if) {
12056 ice_set_state(&sc->state, ICE_STATE_DO_DESTROY_MIRR_INTFC);
12063 /* --- "Do Destroy Mirror Interface" is set --- */
12066 if (req->oldptr == NULL && req->newptr == NULL) {
12075 ice_clear_state(&sc->state, ICE_STATE_DO_DESTROY_MIRR_INTFC);