Lines Matching +full:traffic +full:- +full:patterns
1 // SPDX-License-Identifier: GPL-2.0
35 return ((np->vsi->alloc_txq + np->vsi->alloc_rxq) * in ice_q_stats_len()
94 * The PF_STATs are appended to the netdev stats only when ethtool -S
327 u32 bitno; /* bit position in pf->flags */
336 ICE_PRIV_FLAG("link-down-on-close", ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA),
337 ICE_PRIV_FLAG("fw-lldp-agent", ICE_FLAG_FW_LLDP_AGENT),
338 ICE_PRIV_FLAG("vf-true-promisc-support",
340 ICE_PRIV_FLAG("mdd-auto-reset-vf", ICE_FLAG_MDD_AUTO_RESET_VF),
341 ICE_PRIV_FLAG("vf-vlan-pruning", ICE_FLAG_VF_VLAN_PRUNING),
342 ICE_PRIV_FLAG("legacy-rx", ICE_FLAG_LEGACY_RX),
433 struct ice_pf *pf = vsi->back; in __ice_get_drvinfo()
434 struct ice_hw *hw = &pf->hw; in __ice_get_drvinfo()
438 nvm = &hw->flash.nvm; in __ice_get_drvinfo()
439 orom = &hw->flash.orom; in __ice_get_drvinfo()
441 strscpy(drvinfo->driver, KBUILD_MODNAME, sizeof(drvinfo->driver)); in __ice_get_drvinfo()
446 snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), in __ice_get_drvinfo()
447 "%x.%02x 0x%x %d.%d.%d", nvm->major, nvm->minor, in __ice_get_drvinfo()
448 nvm->eetrack, orom->major, orom->build, orom->patch); in __ice_get_drvinfo()
450 strscpy(drvinfo->bus_info, pci_name(pf->pdev), in __ice_get_drvinfo()
451 sizeof(drvinfo->bus_info)); in __ice_get_drvinfo()
459 __ice_get_drvinfo(netdev, drvinfo, np->vsi); in ice_get_drvinfo()
460 drvinfo->n_priv_flags = ICE_PRIV_FLAG_ARRAY_SIZE; in ice_get_drvinfo()
472 struct ice_pf *pf = np->vsi->back; in ice_get_regs()
473 struct ice_hw *hw = &pf->hw; in ice_get_regs()
477 regs->version = 1; in ice_get_regs()
486 struct ice_pf *pf = np->vsi->back; in ice_get_msglevel()
489 if (pf->hw.debug_mask) in ice_get_msglevel()
491 pf->hw.debug_mask); in ice_get_msglevel()
494 return pf->msg_enable; in ice_get_msglevel()
500 struct ice_pf *pf = np->vsi->back; in ice_set_msglevel()
504 pf->hw.debug_mask = data; in ice_set_msglevel()
506 pf->msg_enable = data; in ice_set_msglevel()
508 pf->msg_enable = data; in ice_set_msglevel()
515 struct ice_pf *pf = np->vsi->back; in ice_get_eeprom_len()
517 return (int)pf->hw.flash.flash_size; in ice_get_eeprom_len()
525 struct ice_vsi *vsi = np->vsi; in ice_get_eeprom()
526 struct ice_pf *pf = vsi->back; in ice_get_eeprom()
527 struct ice_hw *hw = &pf->hw; in ice_get_eeprom()
534 eeprom->magic = hw->vendor_id | (hw->device_id << 16); in ice_get_eeprom()
536 eeprom->cmd, eeprom->offset, eeprom->len); in ice_get_eeprom()
538 buf = kzalloc(eeprom->len, GFP_KERNEL); in ice_get_eeprom()
540 return -ENOMEM; in ice_get_eeprom()
545 ret, ice_aq_str(hw->adminq.sq_last_status)); in ice_get_eeprom()
549 ret = ice_read_flat_nvm(hw, eeprom->offset, &eeprom->len, buf, in ice_get_eeprom()
553 ret, ice_aq_str(hw->adminq.sq_last_status)); in ice_get_eeprom()
557 memcpy(bytes, buf, eeprom->len); in ice_get_eeprom()
566 * ice_active_vfs - check if there are any active VFs
579 if (test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states)) { in ice_active_vfs()
590 * ice_link_test - perform a link test on a given net_device
593 * This function performs one of the self-tests required by ethtool.
594 * Returns 0 on success, non-zero on failure.
603 status = ice_get_link_status(np->vsi->port_info, &link_up); in ice_link_test()
617 * ice_eeprom_test - perform an EEPROM test on a given net_device
620 * This function performs one of the self-tests required by ethtool.
621 * Returns 0 on success, non-zero on failure.
626 struct ice_pf *pf = np->vsi->back; in ice_eeprom_test()
629 return !!(ice_nvm_validate_checksum(&pf->hw)); in ice_eeprom_test()
640 struct ice_pf *pf = (struct ice_pf *)hw->back; in ice_reg_pattern_test()
642 static const u32 patterns[] = { in ice_reg_pattern_test() local
650 for (i = 0; i < ARRAY_SIZE(patterns); ++i) { in ice_reg_pattern_test()
651 u32 pattern = patterns[i] & mask; in ice_reg_pattern_test()
657 dev_err(dev, "%s: reg pattern test failed - reg 0x%08x pat 0x%08x val 0x%08x\n" in ice_reg_pattern_test()
665 dev_err(dev, "%s: reg restore test failed - reg 0x%08x orig 0x%08x val 0x%08x\n" in ice_reg_pattern_test()
674 * ice_reg_test - perform a register test on a given net_device
677 * This function performs one of the self-tests required by ethtool.
678 * Returns 0 on success, non-zero on failure.
683 struct ice_hw *hw = np->vsi->port_info->hw; in ice_reg_test()
684 u32 int_elements = hw->func_caps.common_cap.num_msix_vectors ? in ice_reg_test()
685 hw->func_caps.common_cap.num_msix_vectors - 1 : 1; in ice_reg_test()
693 GLINT_ITR(0, 1) - GLINT_ITR(0, 0)}, in ice_reg_test()
695 GLINT_ITR(1, 1) - GLINT_ITR(1, 0)}, in ice_reg_test()
697 GLINT_ITR(2, 1) - GLINT_ITR(2, 0)}, in ice_reg_test()
711 /* bail on failure (non-zero return) */ in ice_reg_test()
721 * ice_lbtest_prepare_rings - configure Tx/Rx test rings
762 * ice_lbtest_disable_rings - disable Tx/Rx test rings after loopback test
774 netdev_err(vsi->netdev, "Failed to stop Tx rings, VSI %d error %d\n", in ice_lbtest_disable_rings()
775 vsi->vsi_num, status); in ice_lbtest_disable_rings()
779 netdev_err(vsi->netdev, "Failed to stop Rx rings, VSI %d error %d\n", in ice_lbtest_disable_rings()
780 vsi->vsi_num, status); in ice_lbtest_disable_rings()
789 * ice_lbtest_create_frame - create test packet
795 * Returns 0 on success, non-zero on failure.
802 return -EINVAL; in ice_lbtest_create_frame()
806 return -ENOMEM; in ice_lbtest_create_frame()
823 * ice_lbtest_check_frame - verify received loopback frame
843 * ice_diag_send - send test frames to the test ring
857 tx_desc = ICE_TX_DESC(tx_ring, tx_ring->next_to_use); in ice_diag_send()
858 tx_buf = &tx_ring->tx_buf[tx_ring->next_to_use]; in ice_diag_send()
860 dma = dma_map_single(tx_ring->dev, data, size, DMA_TO_DEVICE); in ice_diag_send()
861 if (dma_mapping_error(tx_ring->dev, dma)) in ice_diag_send()
862 return -EINVAL; in ice_diag_send()
864 tx_desc->buf_addr = cpu_to_le64(dma); in ice_diag_send()
868 tx_desc->cmd_type_offset_bsz = in ice_diag_send()
875 tx_buf->next_to_watch = tx_desc; in ice_diag_send()
882 tx_ring->next_to_use++; in ice_diag_send()
883 if (tx_ring->next_to_use >= tx_ring->count) in ice_diag_send()
884 tx_ring->next_to_use = 0; in ice_diag_send()
886 writel_relaxed(tx_ring->next_to_use, tx_ring->tail); in ice_diag_send()
890 dma_unmap_single(tx_ring->dev, dma, size, DMA_TO_DEVICE); in ice_diag_send()
897 * ice_lbtest_receive_frames - receive and verify test frames
911 for (i = 0; i < rx_ring->count; i++) { in ice_lbtest_receive_frames()
916 if (!(rx_desc->wb.status_error0 & in ice_lbtest_receive_frames()
921 rx_buf = &rx_ring->rx_buf[i]; in ice_lbtest_receive_frames()
922 received_buf = page_address(rx_buf->page) + rx_buf->page_offset; in ice_lbtest_receive_frames()
932 * ice_loopback_test - perform a loopback test on a given net_device
935 * This function performs one of the self-tests required by ethtool.
936 * Returns 0 on success, non-zero on failure.
941 struct ice_vsi *orig_vsi = np->vsi, *test_vsi; in ice_loopback_test()
942 struct ice_pf *pf = orig_vsi->back; in ice_loopback_test()
954 test_vsi = ice_lb_vsi_setup(pf, pf->hw.port_info); in ice_loopback_test()
960 test_vsi->netdev = netdev; in ice_loopback_test()
961 tx_ring = test_vsi->tx_rings[0]; in ice_loopback_test()
962 rx_ring = test_vsi->rx_rings[0]; in ice_loopback_test()
969 if (ice_alloc_rx_bufs(rx_ring, rx_ring->count)) { in ice_loopback_test()
975 if (ice_aq_set_mac_loopback(&pf->hw, true, NULL)) { in ice_loopback_test()
992 num_frames = min_t(int, tx_ring->count, 32); in ice_loopback_test()
1013 if (ice_aq_set_mac_loopback(&pf->hw, false, NULL)) in ice_loopback_test()
1019 test_vsi->netdev = NULL; in ice_loopback_test()
1027 * ice_intr_test - perform an interrupt test on a given net_device
1030 * This function performs one of the self-tests required by ethtool.
1031 * Returns 0 on success, non-zero on failure.
1036 struct ice_pf *pf = np->vsi->back; in ice_intr_test()
1037 u16 swic_old = pf->sw_int_count; in ice_intr_test()
1041 wr32(&pf->hw, GLINT_DYN_CTL(pf->oicr_irq.index), in ice_intr_test()
1047 return (swic_old == pf->sw_int_count); in ice_intr_test()
1051 * ice_self_test - handler function for performing a self-test by ethtool
1056 * This function is called after invoking 'ethtool -t devname' command where
1058 * It performs a set of self-tests to check if a device works properly.
1066 struct ice_pf *pf = np->vsi->back; in ice_self_test()
1071 if (eth_test->flags == ETH_TEST_FL_OFFLINE) { in ice_self_test()
1074 set_bit(ICE_TESTING, pf->state); in ice_self_test()
1083 eth_test->flags |= ETH_TEST_FL_FAILED; in ice_self_test()
1084 clear_bit(ICE_TESTING, pf->state); in ice_self_test()
1103 eth_test->flags |= ETH_TEST_FL_FAILED; in ice_self_test()
1105 clear_bit(ICE_TESTING, pf->state); in ice_self_test()
1112 pf->int_name, status); in ice_self_test()
1121 eth_test->flags |= ETH_TEST_FL_FAILED; in ice_self_test()
1159 if (vsi->type != ICE_VSI_PF) in __ice_get_strings()
1190 __ice_get_strings(netdev, stringset, data, np->vsi); in ice_get_strings()
1207 return -EINVAL; in ice_set_phys_id()
1210 if (ice_aq_set_port_id_led(np->vsi->port_info, !led_active, NULL)) in ice_set_phys_id()
1211 return -EIO; in ice_set_phys_id()
1217 * ice_set_fec_cfg - Set link FEC options
1225 struct ice_vsi *vsi = np->vsi; in ice_set_fec_cfg()
1228 pi = vsi->port_info; in ice_set_fec_cfg()
1230 return -EOPNOTSUPP; in ice_set_fec_cfg()
1233 if (vsi->type != ICE_VSI_PF) { in ice_set_fec_cfg()
1235 return -EOPNOTSUPP; in ice_set_fec_cfg()
1239 if (pi->phy.curr_user_fec_req == req_fec) in ice_set_fec_cfg()
1246 memcpy(&config, &pi->phy.curr_user_phy_cfg, sizeof(config)); in ice_set_fec_cfg()
1251 if (ice_aq_set_phy_cfg(pi->hw, pi, &config, NULL)) in ice_set_fec_cfg()
1252 return -EAGAIN; in ice_set_fec_cfg()
1255 pi->phy.curr_user_fec_req = req_fec; in ice_set_fec_cfg()
1261 * ice_set_fecparam - Set FEC link options
1269 struct ice_vsi *vsi = np->vsi; in ice_set_fecparam()
1272 switch (fecparam->fec) { in ice_set_fecparam()
1287 dev_warn(ice_pf_to_dev(vsi->back), "Unsupported FEC mode: %d\n", in ice_set_fecparam()
1288 fecparam->fec); in ice_set_fecparam()
1289 return -EINVAL; in ice_set_fecparam()
1296 * ice_get_fecparam - Get link FEC options
1306 struct ice_vsi *vsi = np->vsi; in ice_get_fecparam()
1310 pi = vsi->port_info; in ice_get_fecparam()
1313 return -EOPNOTSUPP; in ice_get_fecparam()
1314 link_info = &pi->phy.link_info; in ice_get_fecparam()
1317 switch (link_info->fec_info) { in ice_get_fecparam()
1319 fecparam->active_fec = ETHTOOL_FEC_BASER; in ice_get_fecparam()
1323 fecparam->active_fec = ETHTOOL_FEC_RS; in ice_get_fecparam()
1326 fecparam->active_fec = ETHTOOL_FEC_OFF; in ice_get_fecparam()
1332 return -ENOMEM; in ice_get_fecparam()
1340 if (caps->caps & ICE_AQC_PHY_EN_AUTO_FEC) in ice_get_fecparam()
1341 fecparam->fec |= ETHTOOL_FEC_AUTO; in ice_get_fecparam()
1342 if (caps->link_fec_options & ICE_AQC_PHY_FEC_10G_KR_40G_KR4_EN || in ice_get_fecparam()
1343 caps->link_fec_options & ICE_AQC_PHY_FEC_10G_KR_40G_KR4_REQ || in ice_get_fecparam()
1344 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_KR_CLAUSE74_EN || in ice_get_fecparam()
1345 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_KR_REQ) in ice_get_fecparam()
1346 fecparam->fec |= ETHTOOL_FEC_BASER; in ice_get_fecparam()
1347 if (caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_528_REQ || in ice_get_fecparam()
1348 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_544_REQ || in ice_get_fecparam()
1349 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_CLAUSE91_EN) in ice_get_fecparam()
1350 fecparam->fec |= ETHTOOL_FEC_RS; in ice_get_fecparam()
1351 if (caps->link_fec_options == 0) in ice_get_fecparam()
1352 fecparam->fec |= ETHTOOL_FEC_OFF; in ice_get_fecparam()
1360 * ice_nway_reset - restart autonegotiation
1366 struct ice_vsi *vsi = np->vsi; in ice_nway_reset()
1370 if (!test_bit(ICE_DOWN, vsi->back->state)) in ice_nway_reset()
1379 * ice_get_priv_flags - report device private flags
1391 struct ice_vsi *vsi = np->vsi; in ice_get_priv_flags()
1392 struct ice_pf *pf = vsi->back; in ice_get_priv_flags()
1400 if (test_bit(priv_flag->bitno, pf->flags)) in ice_get_priv_flags()
1408 * ice_set_priv_flags - set private flags
1417 struct ice_vsi *vsi = np->vsi; in ice_set_priv_flags()
1418 struct ice_pf *pf = vsi->back; in ice_set_priv_flags()
1424 return -EINVAL; in ice_set_priv_flags()
1427 set_bit(ICE_FLAG_ETHTOOL_CTXT, pf->flags); in ice_set_priv_flags()
1429 bitmap_copy(orig_flags, pf->flags, ICE_PF_FLAGS_NBITS); in ice_set_priv_flags()
1436 set_bit(priv_flag->bitno, pf->flags); in ice_set_priv_flags()
1438 clear_bit(priv_flag->bitno, pf->flags); in ice_set_priv_flags()
1441 bitmap_xor(change_flags, pf->flags, orig_flags, ICE_PF_FLAGS_NBITS); in ice_set_priv_flags()
1443 /* Do not allow change to link-down-on-close when Total Port Shutdown in ice_set_priv_flags()
1447 test_bit(ICE_FLAG_TOTAL_PORT_SHUTDOWN_ENA, pf->flags)) { in ice_set_priv_flags()
1448 dev_err(dev, "Setting link-down-on-close not supported on this port\n"); in ice_set_priv_flags()
1449 set_bit(ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA, pf->flags); in ice_set_priv_flags()
1450 ret = -EINVAL; in ice_set_priv_flags()
1455 if (!test_bit(ICE_FLAG_FW_LLDP_AGENT, pf->flags)) { in ice_set_priv_flags()
1459 status = ice_cfg_lldp_mib_change(&pf->hw, false); in ice_set_priv_flags()
1471 status = ice_aq_stop_lldp(&pf->hw, true, true, NULL); in ice_set_priv_flags()
1482 pf->dcbx_cap &= ~DCB_CAP_DCBX_LLD_MANAGED; in ice_set_priv_flags()
1483 pf->dcbx_cap |= DCB_CAP_DCBX_HOST; in ice_set_priv_flags()
1489 clear_bit(ICE_FLAG_FW_LLDP_AGENT, pf->flags); in ice_set_priv_flags()
1491 ret = -EOPNOTSUPP; in ice_set_priv_flags()
1503 status = ice_aq_start_lldp(&pf->hw, true, NULL); in ice_set_priv_flags()
1510 status = ice_aq_start_stop_dcbx(&pf->hw, true, in ice_set_priv_flags()
1529 status = ice_cfg_lldp_mib_change(&pf->hw, true); in ice_set_priv_flags()
1533 pf->dcbx_cap &= ~DCB_CAP_DCBX_HOST; in ice_set_priv_flags()
1534 pf->dcbx_cap |= DCB_CAP_DCBX_LLD_MANAGED; in ice_set_priv_flags()
1548 …dev_err(dev, "Changing vf-true-promisc-support flag while VF(s) are in promiscuous mode not suppor… in ice_set_priv_flags()
1550 change_bit(ICE_FLAG_VF_TRUE_PROMISC_ENA, pf->flags); in ice_set_priv_flags()
1551 ret = -EAGAIN; in ice_set_priv_flags()
1556 dev_err(dev, "vf-vlan-pruning: VLAN pruning cannot be changed while VFs are active.\n"); in ice_set_priv_flags()
1558 change_bit(ICE_FLAG_VF_VLAN_PRUNING, pf->flags); in ice_set_priv_flags()
1559 ret = -EOPNOTSUPP; in ice_set_priv_flags()
1562 clear_bit(ICE_FLAG_ETHTOOL_CTXT, pf->flags); in ice_set_priv_flags()
1581 * undefined memory access or incorrect string<->value in ice_get_sset_count()
1594 return -EOPNOTSUPP; in ice_get_sset_count()
1603 struct ice_pf *pf = vsi->back; in __ice_get_ethtool_stats()
1626 tx_ring = READ_ONCE(vsi->tx_rings[j]); in __ice_get_ethtool_stats()
1627 if (tx_ring && tx_ring->ring_stats) { in __ice_get_ethtool_stats()
1628 data[i++] = tx_ring->ring_stats->stats.pkts; in __ice_get_ethtool_stats()
1629 data[i++] = tx_ring->ring_stats->stats.bytes; in __ice_get_ethtool_stats()
1637 rx_ring = READ_ONCE(vsi->rx_rings[j]); in __ice_get_ethtool_stats()
1638 if (rx_ring && rx_ring->ring_stats) { in __ice_get_ethtool_stats()
1639 data[i++] = rx_ring->ring_stats->stats.pkts; in __ice_get_ethtool_stats()
1640 data[i++] = rx_ring->ring_stats->stats.bytes; in __ice_get_ethtool_stats()
1649 if (vsi->type != ICE_VSI_PF) in __ice_get_ethtool_stats()
1659 data[i++] = pf->stats.priority_xon_tx[j]; in __ice_get_ethtool_stats()
1660 data[i++] = pf->stats.priority_xoff_tx[j]; in __ice_get_ethtool_stats()
1664 data[i++] = pf->stats.priority_xon_rx[j]; in __ice_get_ethtool_stats()
1665 data[i++] = pf->stats.priority_xoff_rx[j]; in __ice_get_ethtool_stats()
1675 __ice_get_ethtool_stats(netdev, stats, data, np->vsi); in ice_get_ethtool_stats()
1752 * ice_linkmode_set_bit - set link mode bit
1764 linkmode_set_bit(phy_to_ethtool->link_mode, ks->link_modes.supported); in ice_linkmode_set_bit()
1766 if (req_speeds & phy_to_ethtool->aq_link_speed || in ice_linkmode_set_bit()
1768 linkmode_set_bit(phy_to_ethtool->link_mode, in ice_linkmode_set_bit()
1769 ks->link_modes.advertising); in ice_linkmode_set_bit()
1773 * ice_phy_type_to_ethtool - convert the phy_types to ethtool link modes
1782 struct ice_vsi *vsi = np->vsi; in ice_phy_type_to_ethtool()
1783 struct ice_pf *pf = vsi->back; in ice_phy_type_to_ethtool()
1791 req_speeds = vsi->port_info->phy.link_info.req_speeds; in ice_phy_type_to_ethtool()
1803 if (test_bit(ICE_FLAG_LINK_LENIENT_MODE_ENA, pf->flags)) { in ice_phy_type_to_ethtool()
1804 phy_types_low = le64_to_cpu(pf->nvm_phy_type_lo); in ice_phy_type_to_ethtool()
1805 phy_types_high = le64_to_cpu(pf->nvm_phy_type_hi); in ice_phy_type_to_ethtool()
1807 ice_mask_min_supported_speeds(&pf->hw, phy_types_high, in ice_phy_type_to_ethtool()
1813 if (ice_fw_supports_link_override(&pf->hw) && in ice_phy_type_to_ethtool()
1814 !ice_fw_supports_report_dflt_cfg(&pf->hw)) { in ice_phy_type_to_ethtool()
1817 ldo = &pf->link_dflt_override; in ice_phy_type_to_ethtool()
1822 if (ldo->options & ICE_LINK_OVERRIDE_EN && in ice_phy_type_to_ethtool()
1823 (ldo->phy_type_low || ldo->phy_type_high)) { in ice_phy_type_to_ethtool()
1825 le64_to_cpu(pf->nvm_phy_type_lo) & in ice_phy_type_to_ethtool()
1826 ldo->phy_type_low; in ice_phy_type_to_ethtool()
1828 le64_to_cpu(pf->nvm_phy_type_hi) & in ice_phy_type_to_ethtool()
1829 ldo->phy_type_high; in ice_phy_type_to_ethtool()
1834 phy_types_low = vsi->port_info->phy.phy_type_low; in ice_phy_type_to_ethtool()
1835 phy_types_high = vsi->port_info->phy.phy_type_high; in ice_phy_type_to_ethtool()
1842 advert_phy_type_lo = vsi->port_info->phy.phy_type_low; in ice_phy_type_to_ethtool()
1843 advert_phy_type_hi = vsi->port_info->phy.phy_type_high; in ice_phy_type_to_ethtool()
1846 linkmode_zero(ks->link_modes.supported); in ice_phy_type_to_ethtool()
1847 linkmode_zero(ks->link_modes.advertising); in ice_phy_type_to_ethtool()
1869 * ice_get_settings_link_up - Get Link settings for when link is up
1878 struct ice_port_info *pi = np->vsi->port_info; in ice_get_settings_link_up()
1880 struct ice_vsi *vsi = np->vsi; in ice_get_settings_link_up()
1882 link_info = &vsi->port_info->phy.link_info; in ice_get_settings_link_up()
1887 switch (link_info->link_speed) { in ice_get_settings_link_up()
1889 ks->base.speed = SPEED_200000; in ice_get_settings_link_up()
1892 ks->base.speed = SPEED_100000; in ice_get_settings_link_up()
1895 ks->base.speed = SPEED_50000; in ice_get_settings_link_up()
1898 ks->base.speed = SPEED_40000; in ice_get_settings_link_up()
1901 ks->base.speed = SPEED_25000; in ice_get_settings_link_up()
1904 ks->base.speed = SPEED_20000; in ice_get_settings_link_up()
1907 ks->base.speed = SPEED_10000; in ice_get_settings_link_up()
1910 ks->base.speed = SPEED_5000; in ice_get_settings_link_up()
1913 ks->base.speed = SPEED_2500; in ice_get_settings_link_up()
1916 ks->base.speed = SPEED_1000; in ice_get_settings_link_up()
1919 ks->base.speed = SPEED_100; in ice_get_settings_link_up()
1923 link_info->link_speed); in ice_get_settings_link_up()
1926 ks->base.duplex = DUPLEX_FULL; in ice_get_settings_link_up()
1928 if (link_info->an_info & ICE_AQ_AN_COMPLETED) in ice_get_settings_link_up()
1933 switch (pi->fc.current_mode) { in ice_get_settings_link_up()
1956 * ice_get_settings_link_down - Get the Link settings when link is down
1972 ks->base.speed = SPEED_UNKNOWN; in ice_get_settings_link_down()
1973 ks->base.duplex = DUPLEX_UNKNOWN; in ice_get_settings_link_down()
1977 * ice_get_link_ksettings - Get Link Speed and Duplex settings
1990 struct ice_vsi *vsi = np->vsi; in ice_get_link_ksettings()
1996 hw_link_info = &vsi->port_info->phy.link_info; in ice_get_link_ksettings()
1999 if (hw_link_info->link_info & ICE_AQ_LINK_UP) in ice_get_link_ksettings()
2005 ks->base.autoneg = (hw_link_info->an_info & ICE_AQ_AN_COMPLETED) ? in ice_get_link_ksettings()
2009 switch (vsi->port_info->phy.media_type) { in ice_get_link_ksettings()
2012 ks->base.port = PORT_FIBRE; in ice_get_link_ksettings()
2017 ks->base.port = PORT_TP; in ice_get_link_ksettings()
2023 ks->base.port = PORT_NONE; in ice_get_link_ksettings()
2028 ks->base.port = PORT_DA; in ice_get_link_ksettings()
2031 ks->base.port = PORT_OTHER; in ice_get_link_ksettings()
2040 return -ENOMEM; in ice_get_link_ksettings()
2042 err = ice_aq_get_phy_caps(vsi->port_info, false, in ice_get_link_ksettings()
2048 if ((caps->caps & ICE_AQC_PHY_EN_TX_LINK_PAUSE) && in ice_get_link_ksettings()
2049 (caps->caps & ICE_AQC_PHY_EN_RX_LINK_PAUSE)) { in ice_get_link_ksettings()
2053 } else if (caps->caps & ICE_AQC_PHY_EN_TX_LINK_PAUSE) { in ice_get_link_ksettings()
2056 } else if (caps->caps & ICE_AQC_PHY_EN_RX_LINK_PAUSE) { in ice_get_link_ksettings()
2069 if (caps->link_fec_options & ICE_AQC_PHY_FEC_10G_KR_40G_KR4_REQ || in ice_get_link_ksettings()
2070 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_KR_REQ) in ice_get_link_ksettings()
2073 if (caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_528_REQ || in ice_get_link_ksettings()
2074 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_544_REQ) in ice_get_link_ksettings()
2077 err = ice_aq_get_phy_caps(vsi->port_info, false, in ice_get_link_ksettings()
2085 if (caps->link_fec_options & ICE_AQC_PHY_FEC_10G_KR_40G_KR4_EN || in ice_get_link_ksettings()
2086 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_KR_CLAUSE74_EN) in ice_get_link_ksettings()
2088 if (caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_CLAUSE91_EN) in ice_get_link_ksettings()
2103 * ice_speed_to_aq_link - Get AQ link speed by Ethtool forced speed
2152 * ice_ksettings_find_adv_link_speed - Find advertising link speed
2163 if (linkmode_intersects(ks->link_modes.advertising, map->caps)) in ice_ksettings_find_adv_link_speed()
2164 adv_link_speed |= ice_speed_to_aq_link(map->speed); in ice_ksettings_find_adv_link_speed()
2194 if (!(p->phy.link_info.an_info & ICE_AQ_AN_COMPLETED)) { in ice_setup_autoneg()
2200 err = -EINVAL; in ice_setup_autoneg()
2203 config->caps |= ICE_AQ_PHY_ENA_AUTO_LINK_UPDT; in ice_setup_autoneg()
2209 if (p->phy.link_info.an_info & ICE_AQ_AN_COMPLETED) { in ice_setup_autoneg()
2217 err = -EINVAL; in ice_setup_autoneg()
2220 config->caps &= ~ICE_AQ_PHY_ENA_AUTO_LINK_UPDT; in ice_setup_autoneg()
2230 * ice_set_phy_type_from_speed - set phy_types based on speeds
2266 * ice_set_link_ksettings - Set Speed and Duplex
2283 struct ice_pf *pf = np->vsi->back; in ice_set_link_ksettings()
2291 pi = np->vsi->port_info; in ice_set_link_ksettings()
2294 return -EIO; in ice_set_link_ksettings()
2296 if (pi->phy.media_type != ICE_MEDIA_BASET && in ice_set_link_ksettings()
2297 pi->phy.media_type != ICE_MEDIA_FIBER && in ice_set_link_ksettings()
2298 pi->phy.media_type != ICE_MEDIA_BACKPLANE && in ice_set_link_ksettings()
2299 pi->phy.media_type != ICE_MEDIA_DA && in ice_set_link_ksettings()
2300 pi->phy.link_info.link_info & ICE_AQ_LINK_UP) in ice_set_link_ksettings()
2301 return -EOPNOTSUPP; in ice_set_link_ksettings()
2305 return -ENOMEM; in ice_set_link_ksettings()
2308 if (ice_fw_supports_report_dflt_cfg(pi->hw)) in ice_set_link_ksettings()
2329 if (!test_bit(ICE_FLAG_LINK_LENIENT_MODE_ENA, pf->flags)) in ice_set_link_ksettings()
2331 err = -EOPNOTSUPP; in ice_set_link_ksettings()
2351 err = -EOPNOTSUPP; in ice_set_link_ksettings()
2355 while (test_and_set_bit(ICE_CFG_BUSY, pf->state)) { in ice_set_link_ksettings()
2356 timeout--; in ice_set_link_ksettings()
2358 err = -EBUSY; in ice_set_link_ksettings()
2368 config = pi->phy.curr_user_phy_cfg; in ice_set_link_ksettings()
2380 pi->phy.get_link_info = true; in ice_set_link_ksettings()
2385 curr_link_speed = pi->phy.curr_user_speed_req; in ice_set_link_ksettings()
2405 pi->phy.link_info.req_speeds = adv_link_speed; in ice_set_link_ksettings()
2413 err = -EOPNOTSUPP; in ice_set_link_ksettings()
2421 phy_caps->phy_type_high; in ice_set_link_ksettings()
2423 phy_caps->phy_type_low; in ice_set_link_ksettings()
2430 if (test_bit(ICE_FLAG_LINK_LENIENT_MODE_ENA, pf->flags)) { in ice_set_link_ksettings()
2432 pf->nvm_phy_type_hi; in ice_set_link_ksettings()
2434 pf->nvm_phy_type_lo; in ice_set_link_ksettings()
2437 err = -EOPNOTSUPP; in ice_set_link_ksettings()
2443 if (pi->phy.link_info.link_info & ICE_AQ_LINK_UP) { in ice_set_link_ksettings()
2447 ice_print_link_msg(np->vsi, false); in ice_set_link_ksettings()
2453 err = ice_aq_set_phy_cfg(&pf->hw, pi, &config, NULL); in ice_set_link_ksettings()
2460 pi->phy.curr_user_speed_req = adv_link_speed; in ice_set_link_ksettings()
2463 clear_bit(ICE_CFG_BUSY, pf->state); in ice_set_link_ksettings()
2469 * ice_parse_hdrs - parses headers from RSS hash input
2479 switch (nfc->flow_type) { in ice_parse_hdrs()
2505 * ice_parse_hash_flds - parses hash fields from RSS hash input
2516 if (nfc->data & RXH_IP_SRC || nfc->data & RXH_IP_DST) { in ice_parse_hash_flds()
2517 switch (nfc->flow_type) { in ice_parse_hash_flds()
2521 if (nfc->data & RXH_IP_SRC) in ice_parse_hash_flds()
2523 if (nfc->data & RXH_IP_DST) in ice_parse_hash_flds()
2529 if (nfc->data & RXH_IP_SRC) in ice_parse_hash_flds()
2531 if (nfc->data & RXH_IP_DST) in ice_parse_hash_flds()
2539 if (nfc->data & RXH_L4_B_0_1 || nfc->data & RXH_L4_B_2_3) { in ice_parse_hash_flds()
2540 switch (nfc->flow_type) { in ice_parse_hash_flds()
2543 if (nfc->data & RXH_L4_B_0_1) in ice_parse_hash_flds()
2545 if (nfc->data & RXH_L4_B_2_3) in ice_parse_hash_flds()
2550 if (nfc->data & RXH_L4_B_0_1) in ice_parse_hash_flds()
2552 if (nfc->data & RXH_L4_B_2_3) in ice_parse_hash_flds()
2557 if (nfc->data & RXH_L4_B_0_1) in ice_parse_hash_flds()
2559 if (nfc->data & RXH_L4_B_2_3) in ice_parse_hash_flds()
2571 * ice_set_rss_hash_opt - Enable/Disable flow types for RSS hash
2580 struct ice_pf *pf = vsi->back; in ice_set_rss_hash_opt()
2591 vsi->vsi_num); in ice_set_rss_hash_opt()
2592 return -EINVAL; in ice_set_rss_hash_opt()
2595 symm = !!(vsi->rss_hfunc == ICE_AQ_VSI_Q_OPT_RSS_HASH_SYM_TPLZ); in ice_set_rss_hash_opt()
2599 vsi->vsi_num); in ice_set_rss_hash_opt()
2600 return -EINVAL; in ice_set_rss_hash_opt()
2606 vsi->vsi_num); in ice_set_rss_hash_opt()
2607 return -EINVAL; in ice_set_rss_hash_opt()
2615 status = ice_add_rss_cfg(&pf->hw, vsi, &cfg); in ice_set_rss_hash_opt()
2618 vsi->vsi_num, status); in ice_set_rss_hash_opt()
2626 * ice_get_rss_hash_opt - Retrieve hash fields for a given flow-type
2633 struct ice_pf *pf = vsi->back; in ice_get_rss_hash_opt()
2641 nfc->data = 0; in ice_get_rss_hash_opt()
2644 vsi->vsi_num); in ice_get_rss_hash_opt()
2651 vsi->vsi_num); in ice_get_rss_hash_opt()
2655 hash_flds = ice_get_rss_cfg(&pf->hw, vsi->idx, hdrs, &symm); in ice_get_rss_hash_opt()
2658 vsi->vsi_num); in ice_get_rss_hash_opt()
2664 nfc->data |= (u64)RXH_IP_SRC; in ice_get_rss_hash_opt()
2668 nfc->data |= (u64)RXH_IP_DST; in ice_get_rss_hash_opt()
2673 nfc->data |= (u64)RXH_L4_B_0_1; in ice_get_rss_hash_opt()
2678 nfc->data |= (u64)RXH_L4_B_2_3; in ice_get_rss_hash_opt()
2682 * ice_set_rxnfc - command to set Rx flow rules.
2691 struct ice_vsi *vsi = np->vsi; in ice_set_rxnfc()
2693 switch (cmd->cmd) { in ice_set_rxnfc()
2703 return -EOPNOTSUPP; in ice_set_rxnfc()
2707 * ice_get_rxnfc - command to get Rx flow classification rules
2719 struct ice_vsi *vsi = np->vsi; in ice_get_rxnfc()
2720 int ret = -EOPNOTSUPP; in ice_get_rxnfc()
2723 hw = &vsi->back->hw; in ice_get_rxnfc()
2725 switch (cmd->cmd) { in ice_get_rxnfc()
2727 cmd->data = vsi->rss_size; in ice_get_rxnfc()
2731 cmd->rule_cnt = hw->fdir_active_fltr; in ice_get_rxnfc()
2733 cmd->data = ice_get_fdir_cnt_all(hw); in ice_get_rxnfc()
2759 struct ice_vsi *vsi = np->vsi; in ice_get_ringparam()
2761 ring->rx_max_pending = ICE_MAX_NUM_DESC; in ice_get_ringparam()
2762 ring->tx_max_pending = ICE_MAX_NUM_DESC; in ice_get_ringparam()
2763 if (vsi->tx_rings && vsi->rx_rings) { in ice_get_ringparam()
2764 ring->rx_pending = vsi->rx_rings[0]->count; in ice_get_ringparam()
2765 ring->tx_pending = vsi->tx_rings[0]->count; in ice_get_ringparam()
2767 ring->rx_pending = 0; in ice_get_ringparam()
2768 ring->tx_pending = 0; in ice_get_ringparam()
2772 ring->rx_mini_max_pending = 0; in ice_get_ringparam()
2773 ring->rx_jumbo_max_pending = 0; in ice_get_ringparam()
2774 ring->rx_mini_pending = 0; in ice_get_ringparam()
2775 ring->rx_jumbo_pending = 0; in ice_get_ringparam()
2787 struct ice_vsi *vsi = np->vsi; in ice_set_ringparam()
2788 struct ice_pf *pf = vsi->back; in ice_set_ringparam()
2792 if (ring->tx_pending > ICE_MAX_NUM_DESC || in ice_set_ringparam()
2793 ring->tx_pending < ICE_MIN_NUM_DESC || in ice_set_ringparam()
2794 ring->rx_pending > ICE_MAX_NUM_DESC || in ice_set_ringparam()
2795 ring->rx_pending < ICE_MIN_NUM_DESC) { in ice_set_ringparam()
2796 …netdev_err(netdev, "Descriptors requested (Tx: %d / Rx: %d) out of range [%d-%d] (increment %d)\n", in ice_set_ringparam()
2797 ring->tx_pending, ring->rx_pending, in ice_set_ringparam()
2800 return -EINVAL; in ice_set_ringparam()
2804 if (!vsi->tx_rings || !vsi->rx_rings) in ice_set_ringparam()
2805 return -EBUSY; in ice_set_ringparam()
2807 new_tx_cnt = ALIGN(ring->tx_pending, ICE_REQ_DESC_MULTIPLE); in ice_set_ringparam()
2808 if (new_tx_cnt != ring->tx_pending) in ice_set_ringparam()
2811 new_rx_cnt = ALIGN(ring->rx_pending, ICE_REQ_DESC_MULTIPLE); in ice_set_ringparam()
2812 if (new_rx_cnt != ring->rx_pending) in ice_set_ringparam()
2817 if (new_tx_cnt == vsi->tx_rings[0]->count && in ice_set_ringparam()
2818 new_rx_cnt == vsi->rx_rings[0]->count) { in ice_set_ringparam()
2824 * disallow changing the number of descriptors -- regardless in ice_set_ringparam()
2828 return -EBUSY; in ice_set_ringparam()
2830 while (test_and_set_bit(ICE_CFG_BUSY, pf->state)) { in ice_set_ringparam()
2831 timeout--; in ice_set_ringparam()
2833 return -EBUSY; in ice_set_ringparam()
2838 if (!netif_running(vsi->netdev)) { in ice_set_ringparam()
2840 vsi->tx_rings[i]->count = new_tx_cnt; in ice_set_ringparam()
2842 vsi->rx_rings[i]->count = new_rx_cnt; in ice_set_ringparam()
2845 vsi->xdp_rings[i]->count = new_tx_cnt; in ice_set_ringparam()
2846 vsi->num_tx_desc = (u16)new_tx_cnt; in ice_set_ringparam()
2847 vsi->num_rx_desc = (u16)new_rx_cnt; in ice_set_ringparam()
2852 if (new_tx_cnt == vsi->tx_rings[0]->count) in ice_set_ringparam()
2857 vsi->tx_rings[0]->count, new_tx_cnt); in ice_set_ringparam()
2859 tx_rings = kcalloc(vsi->num_txq, sizeof(*tx_rings), GFP_KERNEL); in ice_set_ringparam()
2861 err = -ENOMEM; in ice_set_ringparam()
2867 tx_rings[i] = *vsi->tx_rings[i]; in ice_set_ringparam()
2871 tx_rings[i].tx_tstamps = &pf->ptp.port.tx; in ice_set_ringparam()
2874 while (i--) in ice_set_ringparam()
2886 vsi->xdp_rings[0]->count, new_tx_cnt); in ice_set_ringparam()
2888 xdp_rings = kcalloc(vsi->num_xdp_txq, sizeof(*xdp_rings), GFP_KERNEL); in ice_set_ringparam()
2890 err = -ENOMEM; in ice_set_ringparam()
2896 xdp_rings[i] = *vsi->xdp_rings[i]; in ice_set_ringparam()
2902 while (i--) in ice_set_ringparam()
2911 if (new_rx_cnt == vsi->rx_rings[0]->count) in ice_set_ringparam()
2916 vsi->rx_rings[0]->count, new_rx_cnt); in ice_set_ringparam()
2918 rx_rings = kcalloc(vsi->num_rxq, sizeof(*rx_rings), GFP_KERNEL); in ice_set_ringparam()
2920 err = -ENOMEM; in ice_set_ringparam()
2926 rx_rings[i] = *vsi->rx_rings[i]; in ice_set_ringparam()
2928 rx_rings[i].cached_phctime = pf->ptp.cached_phc_time; in ice_set_ringparam()
2934 rx_rings[i].tail = vsi->back->hw.hw_addr + PRTGEN_STATUS; in ice_set_ringparam()
2946 i--; in ice_set_ringparam()
2950 err = -ENOMEM; in ice_set_ringparam()
2959 if (!test_and_set_bit(ICE_VSI_DOWN, vsi->state)) { in ice_set_ringparam()
2964 ice_free_tx_ring(vsi->tx_rings[i]); in ice_set_ringparam()
2965 *vsi->tx_rings[i] = tx_rings[i]; in ice_set_ringparam()
2972 ice_free_rx_ring(vsi->rx_rings[i]); in ice_set_ringparam()
2974 rx_rings[i].tail = vsi->rx_rings[i]->tail; in ice_set_ringparam()
2977 * but the recycling logic will let us re-use in ice_set_ringparam()
2983 *vsi->rx_rings[i] = rx_rings[i]; in ice_set_ringparam()
2990 ice_free_tx_ring(vsi->xdp_rings[i]); in ice_set_ringparam()
2991 *vsi->xdp_rings[i] = xdp_rings[i]; in ice_set_ringparam()
2996 vsi->num_tx_desc = new_tx_cnt; in ice_set_ringparam()
2997 vsi->num_rx_desc = new_rx_cnt; in ice_set_ringparam()
3011 clear_bit(ICE_CFG_BUSY, pf->state); in ice_set_ringparam()
3016 * ice_get_pauseparam - Get Flow Control status
3029 struct ice_port_info *pi = np->vsi->port_info; in ice_get_pauseparam()
3035 pause->rx_pause = 0; in ice_get_pauseparam()
3036 pause->tx_pause = 0; in ice_get_pauseparam()
3038 dcbx_cfg = &pi->qos_cfg.local_dcbx_cfg; in ice_get_pauseparam()
3050 pause->autoneg = ice_is_phy_caps_an_enabled(pcaps) ? AUTONEG_ENABLE : in ice_get_pauseparam()
3053 if (dcbx_cfg->pfc.pfcena) in ice_get_pauseparam()
3057 if (pcaps->caps & ICE_AQC_PHY_EN_TX_LINK_PAUSE) in ice_get_pauseparam()
3058 pause->tx_pause = 1; in ice_get_pauseparam()
3059 if (pcaps->caps & ICE_AQC_PHY_EN_RX_LINK_PAUSE) in ice_get_pauseparam()
3060 pause->rx_pause = 1; in ice_get_pauseparam()
3067 * ice_set_pauseparam - Set Flow Control parameter
3077 struct ice_pf *pf = np->vsi->back; in ice_set_pauseparam()
3079 struct ice_vsi *vsi = np->vsi; in ice_set_pauseparam()
3080 struct ice_hw *hw = &pf->hw; in ice_set_pauseparam()
3087 pi = vsi->port_info; in ice_set_pauseparam()
3088 hw_link_info = &pi->phy.link_info; in ice_set_pauseparam()
3089 dcbx_cfg = &pi->qos_cfg.local_dcbx_cfg; in ice_set_pauseparam()
3090 link_up = hw_link_info->link_info & ICE_AQ_LINK_UP; in ice_set_pauseparam()
3095 if (vsi->type != ICE_VSI_PF) { in ice_set_pauseparam()
3097 return -EOPNOTSUPP; in ice_set_pauseparam()
3102 * defined get pause param pause->autoneg reports SW configured setting, in ice_set_pauseparam()
3103 * so compare pause->autoneg with SW configured to prevent the user from in ice_set_pauseparam()
3108 return -ENOMEM; in ice_set_pauseparam()
3123 if (pause->autoneg != is_an) { in ice_set_pauseparam()
3124 netdev_info(netdev, "To change autoneg please use: ethtool -s <dev> autoneg <on|off>\n"); in ice_set_pauseparam()
3125 return -EOPNOTSUPP; in ice_set_pauseparam()
3129 if (!test_bit(ICE_DOWN, pf->state) && in ice_set_pauseparam()
3130 !(hw_link_info->an_info & ICE_AQ_AN_COMPLETED)) { in ice_set_pauseparam()
3135 if (dcbx_cfg->pfc.pfcena) { in ice_set_pauseparam()
3137 return -EOPNOTSUPP; in ice_set_pauseparam()
3139 if (pause->rx_pause && pause->tx_pause) in ice_set_pauseparam()
3140 pi->fc.req_mode = ICE_FC_FULL; in ice_set_pauseparam()
3141 else if (pause->rx_pause && !pause->tx_pause) in ice_set_pauseparam()
3142 pi->fc.req_mode = ICE_FC_RX_PAUSE; in ice_set_pauseparam()
3143 else if (!pause->rx_pause && pause->tx_pause) in ice_set_pauseparam()
3144 pi->fc.req_mode = ICE_FC_TX_PAUSE; in ice_set_pauseparam()
3145 else if (!pause->rx_pause && !pause->tx_pause) in ice_set_pauseparam()
3146 pi->fc.req_mode = ICE_FC_NONE; in ice_set_pauseparam()
3148 return -EINVAL; in ice_set_pauseparam()
3155 err, ice_aq_str(hw->adminq.sq_last_status)); in ice_set_pauseparam()
3156 err = -EAGAIN; in ice_set_pauseparam()
3159 err, ice_aq_str(hw->adminq.sq_last_status)); in ice_set_pauseparam()
3160 err = -EAGAIN; in ice_set_pauseparam()
3163 err, ice_aq_str(hw->adminq.sq_last_status)); in ice_set_pauseparam()
3164 err = -EAGAIN; in ice_set_pauseparam()
3171 * ice_get_rxfh_key_size - get the RSS hash key size
3182 * ice_get_rxfh_indir_size - get the Rx flow hash indirection table size
3191 return np->vsi->rss_table_size; in ice_get_rxfh_indir_size()
3195 * ice_get_rxfh - get the Rx flow hash indirection table
3205 u32 rss_context = rxfh->rss_context; in ice_get_rxfh()
3206 struct ice_vsi *vsi = np->vsi; in ice_get_rxfh()
3207 struct ice_pf *pf = vsi->back; in ice_get_rxfh()
3212 if (!test_bit(ICE_FLAG_RSS_ENA, pf->flags)) { in ice_get_rxfh()
3214 return -EOPNOTSUPP; in ice_get_rxfh()
3218 netdev_err(netdev, "RSS context cannot be non-zero when ADQ is not configured.\n"); in ice_get_rxfh()
3219 return -EINVAL; in ice_get_rxfh()
3222 qcount = vsi->mqprio_qopt.qopt.count[rss_context]; in ice_get_rxfh()
3223 offset = vsi->mqprio_qopt.qopt.offset[rss_context]; in ice_get_rxfh()
3226 num_tc = vsi->mqprio_qopt.qopt.num_tc; in ice_get_rxfh()
3230 return -EINVAL; in ice_get_rxfh()
3233 vsi = vsi->tc_map_vsi[rss_context]; in ice_get_rxfh()
3236 rxfh->hfunc = ETH_RSS_HASH_TOP; in ice_get_rxfh()
3237 if (vsi->rss_hfunc == ICE_AQ_VSI_Q_OPT_RSS_HASH_SYM_TPLZ) in ice_get_rxfh()
3238 rxfh->input_xfrm |= RXH_XFRM_SYM_XOR; in ice_get_rxfh()
3240 if (!rxfh->indir) in ice_get_rxfh()
3243 lut = kzalloc(vsi->rss_table_size, GFP_KERNEL); in ice_get_rxfh()
3245 return -ENOMEM; in ice_get_rxfh()
3247 err = ice_get_rss_key(vsi, rxfh->key); in ice_get_rxfh()
3251 err = ice_get_rss_lut(vsi, lut, vsi->rss_table_size); in ice_get_rxfh()
3256 for (i = 0; i < vsi->rss_table_size; i++) in ice_get_rxfh()
3257 rxfh->indir[i] = offset + lut[i] % qcount; in ice_get_rxfh()
3261 for (i = 0; i < vsi->rss_table_size; i++) in ice_get_rxfh()
3262 rxfh->indir[i] = lut[i]; in ice_get_rxfh()
3270 * ice_set_rxfh - set the Rx flow hash indirection table
3275 * Returns -EINVAL if the table specifies an invalid queue ID, otherwise
3284 struct ice_vsi *vsi = np->vsi; in ice_set_rxfh()
3285 struct ice_pf *pf = vsi->back; in ice_set_rxfh()
3290 if (rxfh->hfunc != ETH_RSS_HASH_NO_CHANGE && in ice_set_rxfh()
3291 rxfh->hfunc != ETH_RSS_HASH_TOP) in ice_set_rxfh()
3292 return -EOPNOTSUPP; in ice_set_rxfh()
3294 if (rxfh->rss_context) in ice_set_rxfh()
3295 return -EOPNOTSUPP; in ice_set_rxfh()
3297 if (!test_bit(ICE_FLAG_RSS_ENA, pf->flags)) { in ice_set_rxfh()
3300 return -EIO; in ice_set_rxfh()
3305 return -EOPNOTSUPP; in ice_set_rxfh()
3309 if (rxfh->input_xfrm & RXH_XFRM_SYM_XOR) in ice_set_rxfh()
3316 if (rxfh->key) { in ice_set_rxfh()
3317 if (!vsi->rss_hkey_user) { in ice_set_rxfh()
3318 vsi->rss_hkey_user = in ice_set_rxfh()
3321 if (!vsi->rss_hkey_user) in ice_set_rxfh()
3322 return -ENOMEM; in ice_set_rxfh()
3324 memcpy(vsi->rss_hkey_user, rxfh->key, in ice_set_rxfh()
3327 err = ice_set_rss_key(vsi, vsi->rss_hkey_user); in ice_set_rxfh()
3332 if (!vsi->rss_lut_user) { in ice_set_rxfh()
3333 vsi->rss_lut_user = devm_kzalloc(dev, vsi->rss_table_size, in ice_set_rxfh()
3335 if (!vsi->rss_lut_user) in ice_set_rxfh()
3336 return -ENOMEM; in ice_set_rxfh()
3340 if (rxfh->indir) { in ice_set_rxfh()
3343 for (i = 0; i < vsi->rss_table_size; i++) in ice_set_rxfh()
3344 vsi->rss_lut_user[i] = (u8)(rxfh->indir[i]); in ice_set_rxfh()
3346 ice_fill_rss_lut(vsi->rss_lut_user, vsi->rss_table_size, in ice_set_rxfh()
3347 vsi->rss_size); in ice_set_rxfh()
3350 err = ice_set_rss_lut(vsi, vsi->rss_lut_user, vsi->rss_table_size); in ice_set_rxfh()
3363 if (!test_bit(ICE_FLAG_PTP, pf->flags)) in ice_get_ts_info()
3366 info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE | in ice_get_ts_info()
3373 info->phc_index = ice_ptp_clock_index(pf); in ice_get_ts_info()
3375 info->tx_types = BIT(HWTSTAMP_TX_OFF) | BIT(HWTSTAMP_TX_ON); in ice_get_ts_info()
3377 info->rx_filters = BIT(HWTSTAMP_FILTER_NONE) | BIT(HWTSTAMP_FILTER_ALL); in ice_get_ts_info()
3383 * ice_get_max_txq - return the maximum number of Tx queues for in a PF
3388 return min3(pf->num_lan_msix, (u16)num_online_cpus(), in ice_get_max_txq()
3389 (u16)pf->hw.func_caps.common_cap.num_txq); in ice_get_max_txq()
3393 * ice_get_max_rxq - return the maximum number of Rx queues for in a PF
3398 return min3(pf->num_lan_msix, (u16)num_online_cpus(), in ice_get_max_rxq()
3399 (u16)pf->hw.func_caps.common_cap.num_rxq); in ice_get_max_rxq()
3403 * ice_get_combined_cnt - return the current number of combined channels
3415 struct ice_q_vector *q_vector = vsi->q_vectors[q_idx]; in ice_get_combined_cnt()
3417 if (q_vector->rx.rx_ring && q_vector->tx.tx_ring) in ice_get_combined_cnt()
3425 * ice_get_channels - get the current and max supported channels
3433 struct ice_vsi *vsi = np->vsi; in ice_get_channels()
3434 struct ice_pf *pf = vsi->back; in ice_get_channels()
3437 ch->max_rx = ice_get_max_rxq(pf); in ice_get_channels()
3438 ch->max_tx = ice_get_max_txq(pf); in ice_get_channels()
3439 ch->max_combined = min_t(int, ch->max_rx, ch->max_tx); in ice_get_channels()
3442 ch->combined_count = ice_get_combined_cnt(vsi); in ice_get_channels()
3443 ch->rx_count = vsi->num_rxq - ch->combined_count; in ice_get_channels()
3444 ch->tx_count = vsi->num_txq - ch->combined_count; in ice_get_channels()
3447 ch->other_count = test_bit(ICE_FLAG_FD_ENA, pf->flags) ? 1 : 0; in ice_get_channels()
3448 ch->max_other = ch->other_count; in ice_get_channels()
3452 * ice_get_valid_rss_size - return valid number of RSS queues
3458 struct ice_hw_common_caps *caps = &hw->func_caps.common_cap; in ice_get_valid_rss_size()
3460 return min_t(int, new_size, BIT(caps->rss_table_entry_width)); in ice_get_valid_rss_size()
3464 * ice_vsi_set_dflt_rss_lut - set default RSS LUT with requested RSS size
3472 struct ice_pf *pf = vsi->back; in ice_vsi_set_dflt_rss_lut()
3479 hw = &pf->hw; in ice_vsi_set_dflt_rss_lut()
3482 return -EINVAL; in ice_vsi_set_dflt_rss_lut()
3484 lut = kzalloc(vsi->rss_table_size, GFP_KERNEL); in ice_vsi_set_dflt_rss_lut()
3486 return -ENOMEM; in ice_vsi_set_dflt_rss_lut()
3489 if (!test_bit(ICE_FLAG_RSS_ENA, pf->flags)) in ice_vsi_set_dflt_rss_lut()
3490 vsi->rss_size = 1; in ice_vsi_set_dflt_rss_lut()
3492 vsi->rss_size = ice_get_valid_rss_size(hw, req_rss_size); in ice_vsi_set_dflt_rss_lut()
3495 ice_fill_rss_lut(lut, vsi->rss_table_size, vsi->rss_size); in ice_vsi_set_dflt_rss_lut()
3496 err = ice_set_rss_lut(vsi, lut, vsi->rss_table_size); in ice_vsi_set_dflt_rss_lut()
3499 ice_aq_str(hw->adminq.sq_last_status)); in ice_vsi_set_dflt_rss_lut()
3506 * ice_set_channels - set the number channels
3513 struct ice_vsi *vsi = np->vsi; in ice_set_channels()
3514 struct ice_pf *pf = vsi->back; in ice_set_channels()
3523 return -EOPNOTSUPP; in ice_set_channels()
3526 if (ch->other_count != (test_bit(ICE_FLAG_FD_ENA, pf->flags) ? 1U : 0U)) in ice_set_channels()
3527 return -EINVAL; in ice_set_channels()
3531 return -EOPNOTSUPP; in ice_set_channels()
3534 if (test_bit(ICE_FLAG_FD_ENA, pf->flags) && pf->hw.fdir_active_fltr) { in ice_set_channels()
3536 return -EOPNOTSUPP; in ice_set_channels()
3542 * value on cmd line but we get non-zero value anyway via in ice_set_channels()
3546 if (ch->rx_count == vsi->num_rxq - curr_combined) in ice_set_channels()
3547 ch->rx_count = 0; in ice_set_channels()
3548 if (ch->tx_count == vsi->num_txq - curr_combined) in ice_set_channels()
3549 ch->tx_count = 0; in ice_set_channels()
3550 if (ch->combined_count == curr_combined) in ice_set_channels()
3551 ch->combined_count = 0; in ice_set_channels()
3553 if (!(ch->combined_count || (ch->rx_count && ch->tx_count))) { in ice_set_channels()
3555 return -EINVAL; in ice_set_channels()
3558 new_rx = ch->combined_count + ch->rx_count; in ice_set_channels()
3559 new_tx = ch->combined_count + ch->tx_count; in ice_set_channels()
3561 if (new_rx < vsi->tc_cfg.numtc) { in ice_set_channels()
3562 netdev_err(dev, "Cannot set less Rx channels, than Traffic Classes you have (%u)\n", in ice_set_channels()
3563 vsi->tc_cfg.numtc); in ice_set_channels()
3564 return -EINVAL; in ice_set_channels()
3566 if (new_tx < vsi->tc_cfg.numtc) { in ice_set_channels()
3567 netdev_err(dev, "Cannot set less Tx channels, than Traffic Classes you have (%u)\n", in ice_set_channels()
3568 vsi->tc_cfg.numtc); in ice_set_channels()
3569 return -EINVAL; in ice_set_channels()
3574 return -EINVAL; in ice_set_channels()
3579 return -EINVAL; in ice_set_channels()
3582 if (pf->adev) { in ice_set_channels()
3583 mutex_lock(&pf->adev_mutex); in ice_set_channels()
3584 device_lock(&pf->adev->dev); in ice_set_channels()
3586 if (pf->adev->dev.driver) { in ice_set_channels()
3588 ret = -EBUSY; in ice_set_channels()
3601 vsi->rss_size = ice_get_valid_rss_size(&pf->hw, new_rx); in ice_set_channels()
3605 device_unlock(&pf->adev->dev); in ice_set_channels()
3606 mutex_unlock(&pf->adev_mutex); in ice_set_channels()
3612 * ice_get_wol - get current Wake on LAN configuration
3619 struct ice_pf *pf = np->vsi->back; in ice_get_wol()
3621 if (np->vsi->type != ICE_VSI_PF) in ice_get_wol()
3625 if (ice_is_wol_supported(&pf->hw)) { in ice_get_wol()
3626 wol->supported = WAKE_MAGIC; in ice_get_wol()
3627 wol->wolopts = pf->wol_ena ? WAKE_MAGIC : 0; in ice_get_wol()
3629 wol->supported = 0; in ice_get_wol()
3630 wol->wolopts = 0; in ice_get_wol()
3635 * ice_set_wol - set Wake on LAN on supported device
3642 struct ice_vsi *vsi = np->vsi; in ice_set_wol()
3643 struct ice_pf *pf = vsi->back; in ice_set_wol()
3645 if (vsi->type != ICE_VSI_PF || !ice_is_wol_supported(&pf->hw)) in ice_set_wol()
3646 return -EOPNOTSUPP; in ice_set_wol()
3649 if (wol->wolopts && wol->wolopts != WAKE_MAGIC) in ice_set_wol()
3650 return -EOPNOTSUPP; in ice_set_wol()
3653 if (pf->wol_ena != !!wol->wolopts) { in ice_set_wol()
3654 pf->wol_ena = !!wol->wolopts; in ice_set_wol()
3655 device_set_wakeup_enable(ice_pf_to_dev(pf), pf->wol_ena); in ice_set_wol()
3657 pf->wol_ena ? "en" : "dis"); in ice_set_wol()
3664 * ice_get_rc_coalesce - get ITR values for specific ring container
3677 if (!rc->rx_ring) in ice_get_rc_coalesce()
3678 return -EINVAL; in ice_get_rc_coalesce()
3680 switch (rc->type) { in ice_get_rc_coalesce()
3682 ec->use_adaptive_rx_coalesce = ITR_IS_DYNAMIC(rc); in ice_get_rc_coalesce()
3683 ec->rx_coalesce_usecs = rc->itr_setting; in ice_get_rc_coalesce()
3684 ec->rx_coalesce_usecs_high = rc->rx_ring->q_vector->intrl; in ice_get_rc_coalesce()
3687 ec->use_adaptive_tx_coalesce = ITR_IS_DYNAMIC(rc); in ice_get_rc_coalesce()
3688 ec->tx_coalesce_usecs = rc->itr_setting; in ice_get_rc_coalesce()
3691 dev_dbg(ice_pf_to_dev(rc->rx_ring->vsi->back), "Invalid c_type %d\n", rc->type); in ice_get_rc_coalesce()
3692 return -EINVAL; in ice_get_rc_coalesce()
3699 * ice_get_q_coalesce - get a queue's ITR/INTRL (coalesce) settings
3711 if (q_num < vsi->num_rxq && q_num < vsi->num_txq) { in ice_get_q_coalesce()
3713 &vsi->rx_rings[q_num]->q_vector->rx)) in ice_get_q_coalesce()
3714 return -EINVAL; in ice_get_q_coalesce()
3716 &vsi->tx_rings[q_num]->q_vector->tx)) in ice_get_q_coalesce()
3717 return -EINVAL; in ice_get_q_coalesce()
3718 } else if (q_num < vsi->num_rxq) { in ice_get_q_coalesce()
3720 &vsi->rx_rings[q_num]->q_vector->rx)) in ice_get_q_coalesce()
3721 return -EINVAL; in ice_get_q_coalesce()
3722 } else if (q_num < vsi->num_txq) { in ice_get_q_coalesce()
3724 &vsi->tx_rings[q_num]->q_vector->tx)) in ice_get_q_coalesce()
3725 return -EINVAL; in ice_get_q_coalesce()
3727 return -EINVAL; in ice_get_q_coalesce()
3734 * __ice_get_coalesce - get ITR/INTRL values for the device
3747 struct ice_vsi *vsi = np->vsi; in __ice_get_coalesce()
3753 return -EINVAL; in __ice_get_coalesce()
3763 return __ice_get_coalesce(netdev, ec, -1); in ice_get_coalesce()
3774 * ice_set_rc_coalesce - set ITR values for specific ring container
3789 const char *c_type_str = (rc->type == ICE_RX_CONTAINER) ? "rx" : "tx"; in ice_set_rc_coalesce()
3791 struct ice_pf *pf = vsi->back; in ice_set_rc_coalesce()
3794 if (!rc->rx_ring) in ice_set_rc_coalesce()
3795 return -EINVAL; in ice_set_rc_coalesce()
3797 switch (rc->type) { in ice_set_rc_coalesce()
3800 struct ice_q_vector *q_vector = rc->rx_ring->q_vector; in ice_set_rc_coalesce()
3802 if (ec->rx_coalesce_usecs_high > ICE_MAX_INTRL || in ice_set_rc_coalesce()
3803 (ec->rx_coalesce_usecs_high && in ice_set_rc_coalesce()
3804 ec->rx_coalesce_usecs_high < pf->hw.intrl_gran)) { in ice_set_rc_coalesce()
3805 netdev_info(vsi->netdev, "Invalid value, %s-usecs-high valid values are 0 (disabled), %d-%d\n", in ice_set_rc_coalesce()
3806 c_type_str, pf->hw.intrl_gran, in ice_set_rc_coalesce()
3808 return -EINVAL; in ice_set_rc_coalesce()
3810 if (ec->rx_coalesce_usecs_high != q_vector->intrl && in ice_set_rc_coalesce()
3811 (ec->use_adaptive_rx_coalesce || ec->use_adaptive_tx_coalesce)) { in ice_set_rc_coalesce()
3812 …netdev_info(vsi->netdev, "Invalid value, %s-usecs-high cannot be changed if adaptive-tx or adaptiv… in ice_set_rc_coalesce()
3814 return -EINVAL; in ice_set_rc_coalesce()
3816 if (ec->rx_coalesce_usecs_high != q_vector->intrl) in ice_set_rc_coalesce()
3817 q_vector->intrl = ec->rx_coalesce_usecs_high; in ice_set_rc_coalesce()
3819 use_adaptive_coalesce = ec->use_adaptive_rx_coalesce; in ice_set_rc_coalesce()
3820 coalesce_usecs = ec->rx_coalesce_usecs; in ice_set_rc_coalesce()
3825 use_adaptive_coalesce = ec->use_adaptive_tx_coalesce; in ice_set_rc_coalesce()
3826 coalesce_usecs = ec->tx_coalesce_usecs; in ice_set_rc_coalesce()
3831 rc->type); in ice_set_rc_coalesce()
3832 return -EINVAL; in ice_set_rc_coalesce()
3835 itr_setting = rc->itr_setting; in ice_set_rc_coalesce()
3837 netdev_info(vsi->netdev, "%s interrupt throttling cannot be changed if adaptive-%s is enabled\n", in ice_set_rc_coalesce()
3839 return -EINVAL; in ice_set_rc_coalesce()
3843 netdev_info(vsi->netdev, "Invalid value, %s-usecs range is 0-%d\n", in ice_set_rc_coalesce()
3845 return -EINVAL; in ice_set_rc_coalesce()
3849 rc->itr_mode = ITR_DYNAMIC; in ice_set_rc_coalesce()
3851 rc->itr_mode = ITR_STATIC; in ice_set_rc_coalesce()
3853 rc->itr_setting = coalesce_usecs; in ice_set_rc_coalesce()
3860 ice_flush(&pf->hw); in ice_set_rc_coalesce()
3867 * ice_set_q_coalesce - set a queue's ITR/INTRL (coalesce) settings
3879 if (q_num < vsi->num_rxq && q_num < vsi->num_txq) { in ice_set_q_coalesce()
3881 &vsi->rx_rings[q_num]->q_vector->rx, in ice_set_q_coalesce()
3883 return -EINVAL; in ice_set_q_coalesce()
3886 &vsi->tx_rings[q_num]->q_vector->tx, in ice_set_q_coalesce()
3888 return -EINVAL; in ice_set_q_coalesce()
3889 } else if (q_num < vsi->num_rxq) { in ice_set_q_coalesce()
3891 &vsi->rx_rings[q_num]->q_vector->rx, in ice_set_q_coalesce()
3893 return -EINVAL; in ice_set_q_coalesce()
3894 } else if (q_num < vsi->num_txq) { in ice_set_q_coalesce()
3896 &vsi->tx_rings[q_num]->q_vector->tx, in ice_set_q_coalesce()
3898 return -EINVAL; in ice_set_q_coalesce()
3900 return -EINVAL; in ice_set_q_coalesce()
3907 * ice_print_if_odd_usecs - print message if user tries to set odd [tx|rx]-usecs
3911 * @coalesce_usecs: requested value of [tx|rx]-usecs
3912 * @c_type_str: either "rx" or "tx" to match user set field of [tx|rx]-usecs
3923 …netdev_info(netdev, "User set %s-usecs to %d, device only supports even values. Rounding down and … in ice_print_if_odd_usecs()
3929 * __ice_set_coalesce - set ITR/INTRL values for the device
3942 struct ice_vsi *vsi = np->vsi; in __ice_set_coalesce()
3945 struct ice_q_vector *q_vector = vsi->q_vectors[0]; in __ice_set_coalesce()
3949 ice_print_if_odd_usecs(netdev, q_vector->rx.itr_setting, in __ice_set_coalesce()
3950 ec->use_adaptive_rx_coalesce, in __ice_set_coalesce()
3951 ec->rx_coalesce_usecs, "rx"); in __ice_set_coalesce()
3953 ice_print_if_odd_usecs(netdev, q_vector->tx.itr_setting, in __ice_set_coalesce()
3954 ec->use_adaptive_tx_coalesce, in __ice_set_coalesce()
3955 ec->tx_coalesce_usecs, "tx"); in __ice_set_coalesce()
3960 * can be less than vsi->num_q_vectors. This check in __ice_set_coalesce()
3963 if (v_idx >= vsi->num_rxq && v_idx >= vsi->num_txq) in __ice_set_coalesce()
3967 return -EINVAL; in __ice_set_coalesce()
3969 ice_set_q_vector_intrl(vsi->q_vectors[v_idx]); in __ice_set_coalesce()
3975 return -EINVAL; in __ice_set_coalesce()
3977 ice_set_q_vector_intrl(vsi->q_vectors[q_num]); in __ice_set_coalesce()
3988 return __ice_set_coalesce(netdev, ec, -1); in ice_set_coalesce()
4004 if (ice_check_vf_ready_for_cfg(repr->vf)) in ice_repr_get_drvinfo()
4007 __ice_get_drvinfo(netdev, drvinfo, repr->src_vsi); in ice_repr_get_drvinfo()
4016 if (ice_check_vf_ready_for_cfg(repr->vf) || in ice_repr_get_strings()
4020 __ice_get_strings(netdev, stringset, data, repr->src_vsi); in ice_repr_get_strings()
4030 if (ice_check_vf_ready_for_cfg(repr->vf)) in ice_repr_get_ethtool_stats()
4033 __ice_get_ethtool_stats(netdev, stats, data, repr->src_vsi); in ice_repr_get_ethtool_stats()
4042 return -EOPNOTSUPP; in ice_repr_get_sset_count()
4059 * ice_get_module_info - get SFF module type and revision information
4068 struct ice_vsi *vsi = np->vsi; in ice_get_module_info()
4069 struct ice_pf *pf = vsi->back; in ice_get_module_info()
4070 struct ice_hw *hw = &pf->hw; in ice_get_module_info()
4096 modinfo->type = ETH_MODULE_SFF_8079; in ice_get_module_info()
4097 modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN; in ice_get_module_info()
4100 modinfo->type = ETH_MODULE_SFF_8472; in ice_get_module_info()
4101 modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN; in ice_get_module_info()
4103 modinfo->type = ETH_MODULE_SFF_8079; in ice_get_module_info()
4104 modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN; in ice_get_module_info()
4116 /* Module is SFF-8636 compliant */ in ice_get_module_info()
4117 modinfo->type = ETH_MODULE_SFF_8636; in ice_get_module_info()
4118 modinfo->eeprom_len = ICE_MODULE_QSFP_MAX_LEN; in ice_get_module_info()
4120 modinfo->type = ETH_MODULE_SFF_8436; in ice_get_module_info()
4121 modinfo->eeprom_len = ICE_MODULE_QSFP_MAX_LEN; in ice_get_module_info()
4126 return -EINVAL; in ice_get_module_info()
4132 * ice_get_module_eeprom - fill buffer with SFF EEPROM contents
4145 struct ice_vsi *vsi = np->vsi; in ice_get_module_eeprom()
4146 struct ice_pf *pf = vsi->back; in ice_get_module_eeprom()
4147 struct ice_hw *hw = &pf->hw; in ice_get_module_eeprom()
4154 if (!ee || !ee->len || !data) in ice_get_module_eeprom()
4155 return -EINVAL; in ice_get_module_eeprom()
4165 memset(data, 0, ee->len); in ice_get_module_eeprom()
4166 for (i = 0; i < ee->len; i += SFF_READ_BLOCK_SIZE) { in ice_get_module_eeprom()
4167 offset = i + ee->offset; in ice_get_module_eeprom()
4173 offset -= ETH_MODULE_SFF_8079_LEN; in ice_get_module_eeprom()
4179 offset -= ETH_MODULE_SFF_8436_LEN / 2; in ice_get_module_eeprom()
4214 copy_len = min_t(u32, SFF_READ_BLOCK_SIZE, ee->len - i); in ice_get_module_eeprom()
4293 * ice_set_ethtool_safe_mode_ops - setup safe mode ethtool ops
4298 netdev->ethtool_ops = &ice_ethtool_safe_mode_ops; in ice_set_ethtool_safe_mode_ops()
4310 * ice_set_ethtool_repr_ops - setup VF's port representor ethtool ops
4315 netdev->ethtool_ops = &ice_ethtool_repr_ops; in ice_set_ethtool_repr_ops()
4319 * ice_set_ethtool_ops - setup netdev ethtool ops
4326 netdev->ethtool_ops = &ice_ethtool_ops; in ice_set_ethtool_ops()