Lines Matching +full:container +full:- +full:rules

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
328 u32 bitno; /* bit position in pf->flags */
337 ICE_PRIV_FLAG("link-down-on-close", ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA),
338 ICE_PRIV_FLAG("fw-lldp-agent", ICE_FLAG_FW_LLDP_AGENT),
339 ICE_PRIV_FLAG("vf-true-promisc-support",
341 ICE_PRIV_FLAG("mdd-auto-reset-vf", ICE_FLAG_MDD_AUTO_RESET_VF),
342 ICE_PRIV_FLAG("vf-vlan-pruning", ICE_FLAG_VF_VLAN_PRUNING),
343 ICE_PRIV_FLAG("legacy-rx", ICE_FLAG_LEGACY_RX),
352 struct ice_pf *pf = vsi->back; in __ice_get_drvinfo()
353 struct ice_hw *hw = &pf->hw; in __ice_get_drvinfo()
357 nvm = &hw->flash.nvm; in __ice_get_drvinfo()
358 orom = &hw->flash.orom; in __ice_get_drvinfo()
360 strscpy(drvinfo->driver, KBUILD_MODNAME, sizeof(drvinfo->driver)); in __ice_get_drvinfo()
365 snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), in __ice_get_drvinfo()
366 "%x.%02x 0x%x %d.%d.%d", nvm->major, nvm->minor, in __ice_get_drvinfo()
367 nvm->eetrack, orom->major, orom->build, orom->patch); in __ice_get_drvinfo()
369 strscpy(drvinfo->bus_info, pci_name(pf->pdev), in __ice_get_drvinfo()
370 sizeof(drvinfo->bus_info)); in __ice_get_drvinfo()
378 __ice_get_drvinfo(netdev, drvinfo, np->vsi); in ice_get_drvinfo()
379 drvinfo->n_priv_flags = ICE_PRIV_FLAG_ARRAY_SIZE; in ice_get_drvinfo()
391 struct ice_pf *pf = np->vsi->back; in ice_get_regs()
392 struct ice_hw *hw = &pf->hw; in ice_get_regs()
396 regs->version = 1; in ice_get_regs()
405 struct ice_pf *pf = np->vsi->back; in ice_get_msglevel()
408 if (pf->hw.debug_mask) in ice_get_msglevel()
410 pf->hw.debug_mask); in ice_get_msglevel()
413 return pf->msg_enable; in ice_get_msglevel()
419 struct ice_pf *pf = np->vsi->back; in ice_set_msglevel()
423 pf->hw.debug_mask = data; in ice_set_msglevel()
425 pf->msg_enable = data; in ice_set_msglevel()
427 pf->msg_enable = data; in ice_set_msglevel()
434 struct ice_pf *pf = np->vsi->back; in ice_get_eeprom_len()
436 return (int)pf->hw.flash.flash_size; in ice_get_eeprom_len()
444 struct ice_vsi *vsi = np->vsi; in ice_get_eeprom()
445 struct ice_pf *pf = vsi->back; in ice_get_eeprom()
446 struct ice_hw *hw = &pf->hw; in ice_get_eeprom()
453 eeprom->magic = hw->vendor_id | (hw->device_id << 16); in ice_get_eeprom()
455 eeprom->cmd, eeprom->offset, eeprom->len); in ice_get_eeprom()
457 buf = kzalloc(eeprom->len, GFP_KERNEL); in ice_get_eeprom()
459 return -ENOMEM; in ice_get_eeprom()
464 ret, ice_aq_str(hw->adminq.sq_last_status)); in ice_get_eeprom()
468 ret = ice_read_flat_nvm(hw, eeprom->offset, &eeprom->len, buf, in ice_get_eeprom()
472 ret, ice_aq_str(hw->adminq.sq_last_status)); in ice_get_eeprom()
476 memcpy(bytes, buf, eeprom->len); in ice_get_eeprom()
485 * ice_active_vfs - check if there are any active VFs
498 if (test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states)) { in ice_active_vfs()
509 * ice_link_test - perform a link test on a given net_device
512 * This function performs one of the self-tests required by ethtool.
513 * Returns 0 on success, non-zero on failure.
522 status = ice_get_link_status(np->vsi->port_info, &link_up); in ice_link_test()
536 * ice_eeprom_test - perform an EEPROM test on a given net_device
539 * This function performs one of the self-tests required by ethtool.
540 * Returns 0 on success, non-zero on failure.
545 struct ice_pf *pf = np->vsi->back; in ice_eeprom_test()
548 return !!(ice_nvm_validate_checksum(&pf->hw)); in ice_eeprom_test()
559 struct ice_pf *pf = (struct ice_pf *)hw->back; in ice_reg_pattern_test()
576 dev_err(dev, "%s: reg pattern test failed - reg 0x%08x pat 0x%08x val 0x%08x\n" in ice_reg_pattern_test()
584 dev_err(dev, "%s: reg restore test failed - reg 0x%08x orig 0x%08x val 0x%08x\n" in ice_reg_pattern_test()
593 * ice_reg_test - perform a register test on a given net_device
596 * This function performs one of the self-tests required by ethtool.
597 * Returns 0 on success, non-zero on failure.
602 struct ice_hw *hw = np->vsi->port_info->hw; in ice_reg_test()
603 u32 int_elements = hw->func_caps.common_cap.num_msix_vectors ? in ice_reg_test()
604 hw->func_caps.common_cap.num_msix_vectors - 1 : 1; in ice_reg_test()
612 GLINT_ITR(0, 1) - GLINT_ITR(0, 0)}, in ice_reg_test()
614 GLINT_ITR(1, 1) - GLINT_ITR(1, 0)}, in ice_reg_test()
616 GLINT_ITR(2, 1) - GLINT_ITR(2, 0)}, in ice_reg_test()
630 /* bail on failure (non-zero return) */ in ice_reg_test()
640 * ice_lbtest_prepare_rings - configure Tx/Rx test rings
681 * ice_lbtest_disable_rings - disable Tx/Rx test rings after loopback test
693 netdev_err(vsi->netdev, "Failed to stop Tx rings, VSI %d error %d\n", in ice_lbtest_disable_rings()
694 vsi->vsi_num, status); in ice_lbtest_disable_rings()
698 netdev_err(vsi->netdev, "Failed to stop Rx rings, VSI %d error %d\n", in ice_lbtest_disable_rings()
699 vsi->vsi_num, status); in ice_lbtest_disable_rings()
708 * ice_lbtest_create_frame - create test packet
714 * Returns 0 on success, non-zero on failure.
721 return -EINVAL; in ice_lbtest_create_frame()
725 return -ENOMEM; in ice_lbtest_create_frame()
742 * ice_lbtest_check_frame - verify received loopback frame
762 * ice_diag_send - send test frames to the test ring
776 tx_desc = ICE_TX_DESC(tx_ring, tx_ring->next_to_use); in ice_diag_send()
777 tx_buf = &tx_ring->tx_buf[tx_ring->next_to_use]; in ice_diag_send()
779 dma = dma_map_single(tx_ring->dev, data, size, DMA_TO_DEVICE); in ice_diag_send()
780 if (dma_mapping_error(tx_ring->dev, dma)) in ice_diag_send()
781 return -EINVAL; in ice_diag_send()
783 tx_desc->buf_addr = cpu_to_le64(dma); in ice_diag_send()
787 tx_desc->cmd_type_offset_bsz = in ice_diag_send()
794 tx_buf->next_to_watch = tx_desc; in ice_diag_send()
801 tx_ring->next_to_use++; in ice_diag_send()
802 if (tx_ring->next_to_use >= tx_ring->count) in ice_diag_send()
803 tx_ring->next_to_use = 0; in ice_diag_send()
805 writel_relaxed(tx_ring->next_to_use, tx_ring->tail); in ice_diag_send()
809 dma_unmap_single(tx_ring->dev, dma, size, DMA_TO_DEVICE); in ice_diag_send()
816 * ice_lbtest_receive_frames - receive and verify test frames
830 for (i = 0; i < rx_ring->count; i++) { in ice_lbtest_receive_frames()
835 if (!(rx_desc->wb.status_error0 & in ice_lbtest_receive_frames()
840 rx_buf = &rx_ring->rx_buf[i]; in ice_lbtest_receive_frames()
841 received_buf = page_address(rx_buf->page) + rx_buf->page_offset; in ice_lbtest_receive_frames()
851 * ice_loopback_test - perform a loopback test on a given net_device
854 * This function performs one of the self-tests required by ethtool.
855 * Returns 0 on success, non-zero on failure.
860 struct ice_vsi *orig_vsi = np->vsi, *test_vsi; in ice_loopback_test()
861 struct ice_pf *pf = orig_vsi->back; in ice_loopback_test()
873 test_vsi = ice_lb_vsi_setup(pf, pf->hw.port_info); in ice_loopback_test()
879 test_vsi->netdev = netdev; in ice_loopback_test()
880 tx_ring = test_vsi->tx_rings[0]; in ice_loopback_test()
881 rx_ring = test_vsi->rx_rings[0]; in ice_loopback_test()
888 if (ice_alloc_rx_bufs(rx_ring, rx_ring->count)) { in ice_loopback_test()
894 if (ice_aq_set_mac_loopback(&pf->hw, true, NULL)) { in ice_loopback_test()
911 num_frames = min_t(int, tx_ring->count, 32); in ice_loopback_test()
932 if (ice_aq_set_mac_loopback(&pf->hw, false, NULL)) in ice_loopback_test()
938 test_vsi->netdev = NULL; in ice_loopback_test()
946 * ice_intr_test - perform an interrupt test on a given net_device
949 * This function performs one of the self-tests required by ethtool.
950 * Returns 0 on success, non-zero on failure.
955 struct ice_pf *pf = np->vsi->back; in ice_intr_test()
956 u16 swic_old = pf->sw_int_count; in ice_intr_test()
960 wr32(&pf->hw, GLINT_DYN_CTL(pf->oicr_irq.index), in ice_intr_test()
966 return (swic_old == pf->sw_int_count); in ice_intr_test()
970 * ice_self_test - handler function for performing a self-test by ethtool
975 * This function is called after invoking 'ethtool -t devname' command where
977 * It performs a set of self-tests to check if a device works properly.
985 struct ice_pf *pf = np->vsi->back; in ice_self_test()
990 if (eth_test->flags == ETH_TEST_FL_OFFLINE) { in ice_self_test()
993 set_bit(ICE_TESTING, pf->state); in ice_self_test()
1002 eth_test->flags |= ETH_TEST_FL_FAILED; in ice_self_test()
1003 clear_bit(ICE_TESTING, pf->state); in ice_self_test()
1022 eth_test->flags |= ETH_TEST_FL_FAILED; in ice_self_test()
1024 clear_bit(ICE_TESTING, pf->state); in ice_self_test()
1031 pf->int_name, status); in ice_self_test()
1040 eth_test->flags |= ETH_TEST_FL_FAILED; in ice_self_test()
1079 if (vsi->type != ICE_VSI_PF) in __ice_get_strings()
1111 __ice_get_strings(netdev, stringset, data, np->vsi); in ice_get_strings()
1128 return -EINVAL; in ice_set_phys_id()
1131 if (ice_aq_set_port_id_led(np->vsi->port_info, !led_active, NULL)) in ice_set_phys_id()
1132 return -EIO; in ice_set_phys_id()
1138 * ice_set_fec_cfg - Set link FEC options
1146 struct ice_vsi *vsi = np->vsi; in ice_set_fec_cfg()
1149 pi = vsi->port_info; in ice_set_fec_cfg()
1151 return -EOPNOTSUPP; in ice_set_fec_cfg()
1154 if (vsi->type != ICE_VSI_PF) { in ice_set_fec_cfg()
1156 return -EOPNOTSUPP; in ice_set_fec_cfg()
1160 if (pi->phy.curr_user_fec_req == req_fec) in ice_set_fec_cfg()
1167 memcpy(&config, &pi->phy.curr_user_phy_cfg, sizeof(config)); in ice_set_fec_cfg()
1172 if (ice_aq_set_phy_cfg(pi->hw, pi, &config, NULL)) in ice_set_fec_cfg()
1173 return -EAGAIN; in ice_set_fec_cfg()
1176 pi->phy.curr_user_fec_req = req_fec; in ice_set_fec_cfg()
1182 * ice_set_fecparam - Set FEC link options
1190 struct ice_vsi *vsi = np->vsi; in ice_set_fecparam()
1193 switch (fecparam->fec) { in ice_set_fecparam()
1208 dev_warn(ice_pf_to_dev(vsi->back), "Unsupported FEC mode: %d\n", in ice_set_fecparam()
1209 fecparam->fec); in ice_set_fecparam()
1210 return -EINVAL; in ice_set_fecparam()
1217 * ice_get_fecparam - Get link FEC options
1227 struct ice_vsi *vsi = np->vsi; in ice_get_fecparam()
1231 pi = vsi->port_info; in ice_get_fecparam()
1234 return -EOPNOTSUPP; in ice_get_fecparam()
1235 link_info = &pi->phy.link_info; in ice_get_fecparam()
1238 switch (link_info->fec_info) { in ice_get_fecparam()
1240 fecparam->active_fec = ETHTOOL_FEC_BASER; in ice_get_fecparam()
1244 fecparam->active_fec = ETHTOOL_FEC_RS; in ice_get_fecparam()
1247 fecparam->active_fec = ETHTOOL_FEC_OFF; in ice_get_fecparam()
1253 return -ENOMEM; in ice_get_fecparam()
1261 if (caps->caps & ICE_AQC_PHY_EN_AUTO_FEC) in ice_get_fecparam()
1262 fecparam->fec |= ETHTOOL_FEC_AUTO; in ice_get_fecparam()
1263 if (caps->link_fec_options & ICE_AQC_PHY_FEC_10G_KR_40G_KR4_EN || in ice_get_fecparam()
1264 caps->link_fec_options & ICE_AQC_PHY_FEC_10G_KR_40G_KR4_REQ || in ice_get_fecparam()
1265 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_KR_CLAUSE74_EN || in ice_get_fecparam()
1266 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_KR_REQ) in ice_get_fecparam()
1267 fecparam->fec |= ETHTOOL_FEC_BASER; in ice_get_fecparam()
1268 if (caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_528_REQ || in ice_get_fecparam()
1269 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_544_REQ || in ice_get_fecparam()
1270 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_CLAUSE91_EN) in ice_get_fecparam()
1271 fecparam->fec |= ETHTOOL_FEC_RS; in ice_get_fecparam()
1272 if (caps->link_fec_options == 0) in ice_get_fecparam()
1273 fecparam->fec |= ETHTOOL_FEC_OFF; in ice_get_fecparam()
1281 * ice_nway_reset - restart autonegotiation
1287 struct ice_vsi *vsi = np->vsi; in ice_nway_reset()
1291 if (!test_bit(ICE_DOWN, vsi->back->state)) in ice_nway_reset()
1300 * ice_get_priv_flags - report device private flags
1312 struct ice_vsi *vsi = np->vsi; in ice_get_priv_flags()
1313 struct ice_pf *pf = vsi->back; in ice_get_priv_flags()
1321 if (test_bit(priv_flag->bitno, pf->flags)) in ice_get_priv_flags()
1329 * ice_set_priv_flags - set private flags
1338 struct ice_vsi *vsi = np->vsi; in ice_set_priv_flags()
1339 struct ice_pf *pf = vsi->back; in ice_set_priv_flags()
1345 return -EINVAL; in ice_set_priv_flags()
1348 set_bit(ICE_FLAG_ETHTOOL_CTXT, pf->flags); in ice_set_priv_flags()
1350 bitmap_copy(orig_flags, pf->flags, ICE_PF_FLAGS_NBITS); in ice_set_priv_flags()
1357 set_bit(priv_flag->bitno, pf->flags); in ice_set_priv_flags()
1359 clear_bit(priv_flag->bitno, pf->flags); in ice_set_priv_flags()
1362 bitmap_xor(change_flags, pf->flags, orig_flags, ICE_PF_FLAGS_NBITS); in ice_set_priv_flags()
1364 /* Do not allow change to link-down-on-close when Total Port Shutdown in ice_set_priv_flags()
1368 test_bit(ICE_FLAG_TOTAL_PORT_SHUTDOWN_ENA, pf->flags)) { in ice_set_priv_flags()
1369 dev_err(dev, "Setting link-down-on-close not supported on this port\n"); in ice_set_priv_flags()
1370 set_bit(ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA, pf->flags); in ice_set_priv_flags()
1371 ret = -EINVAL; in ice_set_priv_flags()
1376 if (!test_bit(ICE_FLAG_FW_LLDP_AGENT, pf->flags)) { in ice_set_priv_flags()
1380 status = ice_cfg_lldp_mib_change(&pf->hw, false); in ice_set_priv_flags()
1392 status = ice_aq_stop_lldp(&pf->hw, true, true, NULL); in ice_set_priv_flags()
1403 pf->dcbx_cap &= ~DCB_CAP_DCBX_LLD_MANAGED; in ice_set_priv_flags()
1404 pf->dcbx_cap |= DCB_CAP_DCBX_HOST; in ice_set_priv_flags()
1410 clear_bit(ICE_FLAG_FW_LLDP_AGENT, pf->flags); in ice_set_priv_flags()
1412 ret = -EOPNOTSUPP; in ice_set_priv_flags()
1424 status = ice_aq_start_lldp(&pf->hw, true, NULL); in ice_set_priv_flags()
1431 status = ice_aq_start_stop_dcbx(&pf->hw, true, in ice_set_priv_flags()
1450 status = ice_cfg_lldp_mib_change(&pf->hw, true); in ice_set_priv_flags()
1454 pf->dcbx_cap &= ~DCB_CAP_DCBX_HOST; in ice_set_priv_flags()
1455 pf->dcbx_cap |= DCB_CAP_DCBX_LLD_MANAGED; in ice_set_priv_flags()
1469 …dev_err(dev, "Changing vf-true-promisc-support flag while VF(s) are in promiscuous mode not suppor… in ice_set_priv_flags()
1471 change_bit(ICE_FLAG_VF_TRUE_PROMISC_ENA, pf->flags); in ice_set_priv_flags()
1472 ret = -EAGAIN; in ice_set_priv_flags()
1477 dev_err(dev, "vf-vlan-pruning: VLAN pruning cannot be changed while VFs are active.\n"); in ice_set_priv_flags()
1479 change_bit(ICE_FLAG_VF_VLAN_PRUNING, pf->flags); in ice_set_priv_flags()
1480 ret = -EOPNOTSUPP; in ice_set_priv_flags()
1483 clear_bit(ICE_FLAG_ETHTOOL_CTXT, pf->flags); in ice_set_priv_flags()
1502 * undefined memory access or incorrect string<->value in ice_get_sset_count()
1515 return -EOPNOTSUPP; in ice_get_sset_count()
1524 struct ice_pf *pf = vsi->back; in __ice_get_ethtool_stats()
1547 tx_ring = READ_ONCE(vsi->tx_rings[j]); in __ice_get_ethtool_stats()
1548 if (tx_ring && tx_ring->ring_stats) { in __ice_get_ethtool_stats()
1549 data[i++] = tx_ring->ring_stats->stats.pkts; in __ice_get_ethtool_stats()
1550 data[i++] = tx_ring->ring_stats->stats.bytes; in __ice_get_ethtool_stats()
1558 rx_ring = READ_ONCE(vsi->rx_rings[j]); in __ice_get_ethtool_stats()
1559 if (rx_ring && rx_ring->ring_stats) { in __ice_get_ethtool_stats()
1560 data[i++] = rx_ring->ring_stats->stats.pkts; in __ice_get_ethtool_stats()
1561 data[i++] = rx_ring->ring_stats->stats.bytes; in __ice_get_ethtool_stats()
1570 if (vsi->type != ICE_VSI_PF) in __ice_get_ethtool_stats()
1580 data[i++] = pf->stats.priority_xon_tx[j]; in __ice_get_ethtool_stats()
1581 data[i++] = pf->stats.priority_xoff_tx[j]; in __ice_get_ethtool_stats()
1585 data[i++] = pf->stats.priority_xon_rx[j]; in __ice_get_ethtool_stats()
1586 data[i++] = pf->stats.priority_xoff_rx[j]; in __ice_get_ethtool_stats()
1596 __ice_get_ethtool_stats(netdev, stats, data, np->vsi); in ice_get_ethtool_stats()
1663 * ice_linkmode_set_bit - set link mode bit
1675 linkmode_set_bit(phy_to_ethtool->link_mode, ks->link_modes.supported); in ice_linkmode_set_bit()
1677 if (req_speeds & phy_to_ethtool->aq_link_speed || in ice_linkmode_set_bit()
1679 linkmode_set_bit(phy_to_ethtool->link_mode, in ice_linkmode_set_bit()
1680 ks->link_modes.advertising); in ice_linkmode_set_bit()
1684 * ice_phy_type_to_ethtool - convert the phy_types to ethtool link modes
1693 struct ice_vsi *vsi = np->vsi; in ice_phy_type_to_ethtool()
1694 struct ice_pf *pf = vsi->back; in ice_phy_type_to_ethtool()
1702 req_speeds = vsi->port_info->phy.link_info.req_speeds; in ice_phy_type_to_ethtool()
1714 if (test_bit(ICE_FLAG_LINK_LENIENT_MODE_ENA, pf->flags)) { in ice_phy_type_to_ethtool()
1715 phy_types_low = le64_to_cpu(pf->nvm_phy_type_lo); in ice_phy_type_to_ethtool()
1716 phy_types_high = le64_to_cpu(pf->nvm_phy_type_hi); in ice_phy_type_to_ethtool()
1718 ice_mask_min_supported_speeds(&pf->hw, phy_types_high, in ice_phy_type_to_ethtool()
1724 if (ice_fw_supports_link_override(&pf->hw) && in ice_phy_type_to_ethtool()
1725 !ice_fw_supports_report_dflt_cfg(&pf->hw)) { in ice_phy_type_to_ethtool()
1728 ldo = &pf->link_dflt_override; in ice_phy_type_to_ethtool()
1733 if (ldo->options & ICE_LINK_OVERRIDE_EN && in ice_phy_type_to_ethtool()
1734 (ldo->phy_type_low || ldo->phy_type_high)) { in ice_phy_type_to_ethtool()
1736 le64_to_cpu(pf->nvm_phy_type_lo) & in ice_phy_type_to_ethtool()
1737 ldo->phy_type_low; in ice_phy_type_to_ethtool()
1739 le64_to_cpu(pf->nvm_phy_type_hi) & in ice_phy_type_to_ethtool()
1740 ldo->phy_type_high; in ice_phy_type_to_ethtool()
1745 phy_types_low = vsi->port_info->phy.phy_type_low; in ice_phy_type_to_ethtool()
1746 phy_types_high = vsi->port_info->phy.phy_type_high; in ice_phy_type_to_ethtool()
1753 advert_phy_type_lo = vsi->port_info->phy.phy_type_low; in ice_phy_type_to_ethtool()
1754 advert_phy_type_hi = vsi->port_info->phy.phy_type_high; in ice_phy_type_to_ethtool()
1757 linkmode_zero(ks->link_modes.supported); in ice_phy_type_to_ethtool()
1758 linkmode_zero(ks->link_modes.advertising); in ice_phy_type_to_ethtool()
1780 * ice_get_settings_link_up - Get Link settings for when link is up
1789 struct ice_port_info *pi = np->vsi->port_info; in ice_get_settings_link_up()
1791 struct ice_vsi *vsi = np->vsi; in ice_get_settings_link_up()
1793 link_info = &vsi->port_info->phy.link_info; in ice_get_settings_link_up()
1798 switch (link_info->link_speed) { in ice_get_settings_link_up()
1800 ks->base.speed = SPEED_100000; in ice_get_settings_link_up()
1803 ks->base.speed = SPEED_50000; in ice_get_settings_link_up()
1806 ks->base.speed = SPEED_40000; in ice_get_settings_link_up()
1809 ks->base.speed = SPEED_25000; in ice_get_settings_link_up()
1812 ks->base.speed = SPEED_20000; in ice_get_settings_link_up()
1815 ks->base.speed = SPEED_10000; in ice_get_settings_link_up()
1818 ks->base.speed = SPEED_5000; in ice_get_settings_link_up()
1821 ks->base.speed = SPEED_2500; in ice_get_settings_link_up()
1824 ks->base.speed = SPEED_1000; in ice_get_settings_link_up()
1827 ks->base.speed = SPEED_100; in ice_get_settings_link_up()
1831 link_info->link_speed); in ice_get_settings_link_up()
1834 ks->base.duplex = DUPLEX_FULL; in ice_get_settings_link_up()
1836 if (link_info->an_info & ICE_AQ_AN_COMPLETED) in ice_get_settings_link_up()
1841 switch (pi->fc.current_mode) { in ice_get_settings_link_up()
1864 * ice_get_settings_link_down - Get the Link settings when link is down
1880 ks->base.speed = SPEED_UNKNOWN; in ice_get_settings_link_down()
1881 ks->base.duplex = DUPLEX_UNKNOWN; in ice_get_settings_link_down()
1885 * ice_get_link_ksettings - Get Link Speed and Duplex settings
1898 struct ice_vsi *vsi = np->vsi; in ice_get_link_ksettings()
1904 hw_link_info = &vsi->port_info->phy.link_info; in ice_get_link_ksettings()
1907 if (hw_link_info->link_info & ICE_AQ_LINK_UP) in ice_get_link_ksettings()
1913 ks->base.autoneg = (hw_link_info->an_info & ICE_AQ_AN_COMPLETED) ? in ice_get_link_ksettings()
1917 switch (vsi->port_info->phy.media_type) { in ice_get_link_ksettings()
1920 ks->base.port = PORT_FIBRE; in ice_get_link_ksettings()
1925 ks->base.port = PORT_TP; in ice_get_link_ksettings()
1931 ks->base.port = PORT_NONE; in ice_get_link_ksettings()
1936 ks->base.port = PORT_DA; in ice_get_link_ksettings()
1939 ks->base.port = PORT_OTHER; in ice_get_link_ksettings()
1948 return -ENOMEM; in ice_get_link_ksettings()
1950 err = ice_aq_get_phy_caps(vsi->port_info, false, in ice_get_link_ksettings()
1956 if ((caps->caps & ICE_AQC_PHY_EN_TX_LINK_PAUSE) && in ice_get_link_ksettings()
1957 (caps->caps & ICE_AQC_PHY_EN_RX_LINK_PAUSE)) { in ice_get_link_ksettings()
1961 } else if (caps->caps & ICE_AQC_PHY_EN_TX_LINK_PAUSE) { in ice_get_link_ksettings()
1964 } else if (caps->caps & ICE_AQC_PHY_EN_RX_LINK_PAUSE) { in ice_get_link_ksettings()
1977 if (caps->link_fec_options & ICE_AQC_PHY_FEC_10G_KR_40G_KR4_REQ || in ice_get_link_ksettings()
1978 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_KR_REQ) in ice_get_link_ksettings()
1981 if (caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_528_REQ || in ice_get_link_ksettings()
1982 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_544_REQ) in ice_get_link_ksettings()
1985 err = ice_aq_get_phy_caps(vsi->port_info, false, in ice_get_link_ksettings()
1993 if (caps->link_fec_options & ICE_AQC_PHY_FEC_10G_KR_40G_KR4_EN || in ice_get_link_ksettings()
1994 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_KR_CLAUSE74_EN) in ice_get_link_ksettings()
1996 if (caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_CLAUSE91_EN) in ice_get_link_ksettings()
2011 * ice_ksettings_find_adv_link_speed - Find advertising link speed
2112 if (!(p->phy.link_info.an_info & ICE_AQ_AN_COMPLETED)) { in ice_setup_autoneg()
2118 err = -EINVAL; in ice_setup_autoneg()
2121 config->caps |= ICE_AQ_PHY_ENA_AUTO_LINK_UPDT; in ice_setup_autoneg()
2127 if (p->phy.link_info.an_info & ICE_AQ_AN_COMPLETED) { in ice_setup_autoneg()
2135 err = -EINVAL; in ice_setup_autoneg()
2138 config->caps &= ~ICE_AQ_PHY_ENA_AUTO_LINK_UPDT; in ice_setup_autoneg()
2148 * ice_set_phy_type_from_speed - set phy_types based on speeds
2184 * ice_set_link_ksettings - Set Speed and Duplex
2201 struct ice_pf *pf = np->vsi->back; in ice_set_link_ksettings()
2209 pi = np->vsi->port_info; in ice_set_link_ksettings()
2212 return -EIO; in ice_set_link_ksettings()
2214 if (pi->phy.media_type != ICE_MEDIA_BASET && in ice_set_link_ksettings()
2215 pi->phy.media_type != ICE_MEDIA_FIBER && in ice_set_link_ksettings()
2216 pi->phy.media_type != ICE_MEDIA_BACKPLANE && in ice_set_link_ksettings()
2217 pi->phy.media_type != ICE_MEDIA_DA && in ice_set_link_ksettings()
2218 pi->phy.link_info.link_info & ICE_AQ_LINK_UP) in ice_set_link_ksettings()
2219 return -EOPNOTSUPP; in ice_set_link_ksettings()
2223 return -ENOMEM; in ice_set_link_ksettings()
2226 if (ice_fw_supports_report_dflt_cfg(pi->hw)) in ice_set_link_ksettings()
2247 if (!test_bit(ICE_FLAG_LINK_LENIENT_MODE_ENA, pf->flags)) in ice_set_link_ksettings()
2249 err = -EOPNOTSUPP; in ice_set_link_ksettings()
2269 err = -EOPNOTSUPP; in ice_set_link_ksettings()
2273 while (test_and_set_bit(ICE_CFG_BUSY, pf->state)) { in ice_set_link_ksettings()
2274 timeout--; in ice_set_link_ksettings()
2276 err = -EBUSY; in ice_set_link_ksettings()
2286 config = pi->phy.curr_user_phy_cfg; in ice_set_link_ksettings()
2298 pi->phy.get_link_info = true; in ice_set_link_ksettings()
2303 curr_link_speed = pi->phy.curr_user_speed_req; in ice_set_link_ksettings()
2323 pi->phy.link_info.req_speeds = adv_link_speed; in ice_set_link_ksettings()
2331 err = -EOPNOTSUPP; in ice_set_link_ksettings()
2339 phy_caps->phy_type_high; in ice_set_link_ksettings()
2341 phy_caps->phy_type_low; in ice_set_link_ksettings()
2348 if (test_bit(ICE_FLAG_LINK_LENIENT_MODE_ENA, pf->flags)) { in ice_set_link_ksettings()
2350 pf->nvm_phy_type_hi; in ice_set_link_ksettings()
2352 pf->nvm_phy_type_lo; in ice_set_link_ksettings()
2355 err = -EOPNOTSUPP; in ice_set_link_ksettings()
2361 if (pi->phy.link_info.link_info & ICE_AQ_LINK_UP) { in ice_set_link_ksettings()
2365 ice_print_link_msg(np->vsi, false); in ice_set_link_ksettings()
2371 err = ice_aq_set_phy_cfg(&pf->hw, pi, &config, NULL); in ice_set_link_ksettings()
2378 pi->phy.curr_user_speed_req = adv_link_speed; in ice_set_link_ksettings()
2381 clear_bit(ICE_CFG_BUSY, pf->state); in ice_set_link_ksettings()
2387 * ice_parse_hdrs - parses headers from RSS hash input
2397 switch (nfc->flow_type) { in ice_parse_hdrs()
2436 * ice_parse_hash_flds - parses hash fields from RSS hash input
2446 if (nfc->data & RXH_IP_SRC || nfc->data & RXH_IP_DST) { in ice_parse_hash_flds()
2447 switch (nfc->flow_type) { in ice_parse_hash_flds()
2451 if (nfc->data & RXH_IP_SRC) in ice_parse_hash_flds()
2453 if (nfc->data & RXH_IP_DST) in ice_parse_hash_flds()
2459 if (nfc->data & RXH_IP_SRC) in ice_parse_hash_flds()
2461 if (nfc->data & RXH_IP_DST) in ice_parse_hash_flds()
2469 if (nfc->data & RXH_L4_B_0_1 || nfc->data & RXH_L4_B_2_3) { in ice_parse_hash_flds()
2470 switch (nfc->flow_type) { in ice_parse_hash_flds()
2473 if (nfc->data & RXH_L4_B_0_1) in ice_parse_hash_flds()
2475 if (nfc->data & RXH_L4_B_2_3) in ice_parse_hash_flds()
2480 if (nfc->data & RXH_L4_B_0_1) in ice_parse_hash_flds()
2482 if (nfc->data & RXH_L4_B_2_3) in ice_parse_hash_flds()
2487 if (nfc->data & RXH_L4_B_0_1) in ice_parse_hash_flds()
2489 if (nfc->data & RXH_L4_B_2_3) in ice_parse_hash_flds()
2501 * ice_set_rss_hash_opt - Enable/Disable flow types for RSS hash
2510 struct ice_pf *pf = vsi->back; in ice_set_rss_hash_opt()
2519 vsi->vsi_num); in ice_set_rss_hash_opt()
2520 return -EINVAL; in ice_set_rss_hash_opt()
2526 vsi->vsi_num); in ice_set_rss_hash_opt()
2527 return -EINVAL; in ice_set_rss_hash_opt()
2533 vsi->vsi_num); in ice_set_rss_hash_opt()
2534 return -EINVAL; in ice_set_rss_hash_opt()
2537 status = ice_add_rss_cfg(&pf->hw, vsi->idx, hashed_flds, hdrs); in ice_set_rss_hash_opt()
2540 vsi->vsi_num, status); in ice_set_rss_hash_opt()
2548 * ice_get_rss_hash_opt - Retrieve hash fields for a given flow-type
2555 struct ice_pf *pf = vsi->back; in ice_get_rss_hash_opt()
2562 nfc->data = 0; in ice_get_rss_hash_opt()
2565 vsi->vsi_num); in ice_get_rss_hash_opt()
2572 vsi->vsi_num); in ice_get_rss_hash_opt()
2576 hash_flds = ice_get_rss_cfg(&pf->hw, vsi->idx, hdrs); in ice_get_rss_hash_opt()
2579 vsi->vsi_num); in ice_get_rss_hash_opt()
2585 nfc->data |= (u64)RXH_IP_SRC; in ice_get_rss_hash_opt()
2589 nfc->data |= (u64)RXH_IP_DST; in ice_get_rss_hash_opt()
2594 nfc->data |= (u64)RXH_L4_B_0_1; in ice_get_rss_hash_opt()
2599 nfc->data |= (u64)RXH_L4_B_2_3; in ice_get_rss_hash_opt()
2603 * ice_set_rxnfc - command to set Rx flow rules.
2612 struct ice_vsi *vsi = np->vsi; in ice_set_rxnfc()
2614 switch (cmd->cmd) { in ice_set_rxnfc()
2624 return -EOPNOTSUPP; in ice_set_rxnfc()
2628 * ice_get_rxnfc - command to get Rx flow classification rules
2631 * @rule_locs: buffer to rturn Rx flow classification rules
2640 struct ice_vsi *vsi = np->vsi; in ice_get_rxnfc()
2641 int ret = -EOPNOTSUPP; in ice_get_rxnfc()
2644 hw = &vsi->back->hw; in ice_get_rxnfc()
2646 switch (cmd->cmd) { in ice_get_rxnfc()
2648 cmd->data = vsi->rss_size; in ice_get_rxnfc()
2652 cmd->rule_cnt = hw->fdir_active_fltr; in ice_get_rxnfc()
2654 cmd->data = ice_get_fdir_cnt_all(hw); in ice_get_rxnfc()
2680 struct ice_vsi *vsi = np->vsi; in ice_get_ringparam()
2682 ring->rx_max_pending = ICE_MAX_NUM_DESC; in ice_get_ringparam()
2683 ring->tx_max_pending = ICE_MAX_NUM_DESC; in ice_get_ringparam()
2684 if (vsi->tx_rings && vsi->rx_rings) { in ice_get_ringparam()
2685 ring->rx_pending = vsi->rx_rings[0]->count; in ice_get_ringparam()
2686 ring->tx_pending = vsi->tx_rings[0]->count; in ice_get_ringparam()
2688 ring->rx_pending = 0; in ice_get_ringparam()
2689 ring->tx_pending = 0; in ice_get_ringparam()
2693 ring->rx_mini_max_pending = 0; in ice_get_ringparam()
2694 ring->rx_jumbo_max_pending = 0; in ice_get_ringparam()
2695 ring->rx_mini_pending = 0; in ice_get_ringparam()
2696 ring->rx_jumbo_pending = 0; in ice_get_ringparam()
2708 struct ice_vsi *vsi = np->vsi; in ice_set_ringparam()
2709 struct ice_pf *pf = vsi->back; in ice_set_ringparam()
2713 if (ring->tx_pending > ICE_MAX_NUM_DESC || in ice_set_ringparam()
2714 ring->tx_pending < ICE_MIN_NUM_DESC || in ice_set_ringparam()
2715 ring->rx_pending > ICE_MAX_NUM_DESC || in ice_set_ringparam()
2716 ring->rx_pending < ICE_MIN_NUM_DESC) { in ice_set_ringparam()
2717 …netdev_err(netdev, "Descriptors requested (Tx: %d / Rx: %d) out of range [%d-%d] (increment %d)\n", in ice_set_ringparam()
2718 ring->tx_pending, ring->rx_pending, in ice_set_ringparam()
2721 return -EINVAL; in ice_set_ringparam()
2725 if (!vsi->tx_rings || !vsi->rx_rings) in ice_set_ringparam()
2726 return -EBUSY; in ice_set_ringparam()
2728 new_tx_cnt = ALIGN(ring->tx_pending, ICE_REQ_DESC_MULTIPLE); in ice_set_ringparam()
2729 if (new_tx_cnt != ring->tx_pending) in ice_set_ringparam()
2732 new_rx_cnt = ALIGN(ring->rx_pending, ICE_REQ_DESC_MULTIPLE); in ice_set_ringparam()
2733 if (new_rx_cnt != ring->rx_pending) in ice_set_ringparam()
2738 if (new_tx_cnt == vsi->tx_rings[0]->count && in ice_set_ringparam()
2739 new_rx_cnt == vsi->rx_rings[0]->count) { in ice_set_ringparam()
2745 * disallow changing the number of descriptors -- regardless in ice_set_ringparam()
2749 return -EBUSY; in ice_set_ringparam()
2751 while (test_and_set_bit(ICE_CFG_BUSY, pf->state)) { in ice_set_ringparam()
2752 timeout--; in ice_set_ringparam()
2754 return -EBUSY; in ice_set_ringparam()
2759 if (!netif_running(vsi->netdev)) { in ice_set_ringparam()
2761 vsi->tx_rings[i]->count = new_tx_cnt; in ice_set_ringparam()
2763 vsi->rx_rings[i]->count = new_rx_cnt; in ice_set_ringparam()
2766 vsi->xdp_rings[i]->count = new_tx_cnt; in ice_set_ringparam()
2767 vsi->num_tx_desc = (u16)new_tx_cnt; in ice_set_ringparam()
2768 vsi->num_rx_desc = (u16)new_rx_cnt; in ice_set_ringparam()
2773 if (new_tx_cnt == vsi->tx_rings[0]->count) in ice_set_ringparam()
2778 vsi->tx_rings[0]->count, new_tx_cnt); in ice_set_ringparam()
2780 tx_rings = kcalloc(vsi->num_txq, sizeof(*tx_rings), GFP_KERNEL); in ice_set_ringparam()
2782 err = -ENOMEM; in ice_set_ringparam()
2788 tx_rings[i] = *vsi->tx_rings[i]; in ice_set_ringparam()
2792 tx_rings[i].tx_tstamps = &pf->ptp.port.tx; in ice_set_ringparam()
2795 while (i--) in ice_set_ringparam()
2807 vsi->xdp_rings[0]->count, new_tx_cnt); in ice_set_ringparam()
2809 xdp_rings = kcalloc(vsi->num_xdp_txq, sizeof(*xdp_rings), GFP_KERNEL); in ice_set_ringparam()
2811 err = -ENOMEM; in ice_set_ringparam()
2817 xdp_rings[i] = *vsi->xdp_rings[i]; in ice_set_ringparam()
2823 while (i--) in ice_set_ringparam()
2832 if (new_rx_cnt == vsi->rx_rings[0]->count) in ice_set_ringparam()
2837 vsi->rx_rings[0]->count, new_rx_cnt); in ice_set_ringparam()
2839 rx_rings = kcalloc(vsi->num_rxq, sizeof(*rx_rings), GFP_KERNEL); in ice_set_ringparam()
2841 err = -ENOMEM; in ice_set_ringparam()
2847 rx_rings[i] = *vsi->rx_rings[i]; in ice_set_ringparam()
2849 rx_rings[i].cached_phctime = pf->ptp.cached_phc_time; in ice_set_ringparam()
2855 rx_rings[i].tail = vsi->back->hw.hw_addr + PRTGEN_STATUS; in ice_set_ringparam()
2867 i--; in ice_set_ringparam()
2871 err = -ENOMEM; in ice_set_ringparam()
2880 if (!test_and_set_bit(ICE_VSI_DOWN, vsi->state)) { in ice_set_ringparam()
2885 ice_free_tx_ring(vsi->tx_rings[i]); in ice_set_ringparam()
2886 *vsi->tx_rings[i] = tx_rings[i]; in ice_set_ringparam()
2893 ice_free_rx_ring(vsi->rx_rings[i]); in ice_set_ringparam()
2895 rx_rings[i].tail = vsi->rx_rings[i]->tail; in ice_set_ringparam()
2898 * but the recycling logic will let us re-use in ice_set_ringparam()
2904 *vsi->rx_rings[i] = rx_rings[i]; in ice_set_ringparam()
2911 ice_free_tx_ring(vsi->xdp_rings[i]); in ice_set_ringparam()
2912 *vsi->xdp_rings[i] = xdp_rings[i]; in ice_set_ringparam()
2917 vsi->num_tx_desc = new_tx_cnt; in ice_set_ringparam()
2918 vsi->num_rx_desc = new_rx_cnt; in ice_set_ringparam()
2932 clear_bit(ICE_CFG_BUSY, pf->state); in ice_set_ringparam()
2937 * ice_get_pauseparam - Get Flow Control status
2950 struct ice_port_info *pi = np->vsi->port_info; in ice_get_pauseparam()
2956 pause->rx_pause = 0; in ice_get_pauseparam()
2957 pause->tx_pause = 0; in ice_get_pauseparam()
2959 dcbx_cfg = &pi->qos_cfg.local_dcbx_cfg; in ice_get_pauseparam()
2971 pause->autoneg = ice_is_phy_caps_an_enabled(pcaps) ? AUTONEG_ENABLE : in ice_get_pauseparam()
2974 if (dcbx_cfg->pfc.pfcena) in ice_get_pauseparam()
2978 if (pcaps->caps & ICE_AQC_PHY_EN_TX_LINK_PAUSE) in ice_get_pauseparam()
2979 pause->tx_pause = 1; in ice_get_pauseparam()
2980 if (pcaps->caps & ICE_AQC_PHY_EN_RX_LINK_PAUSE) in ice_get_pauseparam()
2981 pause->rx_pause = 1; in ice_get_pauseparam()
2988 * ice_set_pauseparam - Set Flow Control parameter
2998 struct ice_pf *pf = np->vsi->back; in ice_set_pauseparam()
3000 struct ice_vsi *vsi = np->vsi; in ice_set_pauseparam()
3001 struct ice_hw *hw = &pf->hw; in ice_set_pauseparam()
3008 pi = vsi->port_info; in ice_set_pauseparam()
3009 hw_link_info = &pi->phy.link_info; in ice_set_pauseparam()
3010 dcbx_cfg = &pi->qos_cfg.local_dcbx_cfg; in ice_set_pauseparam()
3011 link_up = hw_link_info->link_info & ICE_AQ_LINK_UP; in ice_set_pauseparam()
3016 if (vsi->type != ICE_VSI_PF) { in ice_set_pauseparam()
3018 return -EOPNOTSUPP; in ice_set_pauseparam()
3023 * defined get pause param pause->autoneg reports SW configured setting, in ice_set_pauseparam()
3024 * so compare pause->autoneg with SW configured to prevent the user from in ice_set_pauseparam()
3029 return -ENOMEM; in ice_set_pauseparam()
3044 if (pause->autoneg != is_an) { in ice_set_pauseparam()
3045 netdev_info(netdev, "To change autoneg please use: ethtool -s <dev> autoneg <on|off>\n"); in ice_set_pauseparam()
3046 return -EOPNOTSUPP; in ice_set_pauseparam()
3050 if (!test_bit(ICE_DOWN, pf->state) && in ice_set_pauseparam()
3051 !(hw_link_info->an_info & ICE_AQ_AN_COMPLETED)) { in ice_set_pauseparam()
3056 if (dcbx_cfg->pfc.pfcena) { in ice_set_pauseparam()
3058 return -EOPNOTSUPP; in ice_set_pauseparam()
3060 if (pause->rx_pause && pause->tx_pause) in ice_set_pauseparam()
3061 pi->fc.req_mode = ICE_FC_FULL; in ice_set_pauseparam()
3062 else if (pause->rx_pause && !pause->tx_pause) in ice_set_pauseparam()
3063 pi->fc.req_mode = ICE_FC_RX_PAUSE; in ice_set_pauseparam()
3064 else if (!pause->rx_pause && pause->tx_pause) in ice_set_pauseparam()
3065 pi->fc.req_mode = ICE_FC_TX_PAUSE; in ice_set_pauseparam()
3066 else if (!pause->rx_pause && !pause->tx_pause) in ice_set_pauseparam()
3067 pi->fc.req_mode = ICE_FC_NONE; in ice_set_pauseparam()
3069 return -EINVAL; in ice_set_pauseparam()
3076 err, ice_aq_str(hw->adminq.sq_last_status)); in ice_set_pauseparam()
3077 err = -EAGAIN; in ice_set_pauseparam()
3080 err, ice_aq_str(hw->adminq.sq_last_status)); in ice_set_pauseparam()
3081 err = -EAGAIN; in ice_set_pauseparam()
3084 err, ice_aq_str(hw->adminq.sq_last_status)); in ice_set_pauseparam()
3085 err = -EAGAIN; in ice_set_pauseparam()
3092 * ice_get_rxfh_key_size - get the RSS hash key size
3103 * ice_get_rxfh_indir_size - get the Rx flow hash indirection table size
3112 return np->vsi->rss_table_size; in ice_get_rxfh_indir_size()
3120 struct ice_vsi *vsi = np->vsi; in ice_get_rxfh_context()
3121 struct ice_pf *pf = vsi->back; in ice_get_rxfh_context()
3126 if (!test_bit(ICE_FLAG_RSS_ENA, pf->flags)) { in ice_get_rxfh_context()
3128 return -EOPNOTSUPP; in ice_get_rxfh_context()
3132 netdev_err(netdev, "RSS context cannot be non-zero when ADQ is not configured.\n"); in ice_get_rxfh_context()
3133 return -EINVAL; in ice_get_rxfh_context()
3136 qcount = vsi->mqprio_qopt.qopt.count[rss_context]; in ice_get_rxfh_context()
3137 offset = vsi->mqprio_qopt.qopt.offset[rss_context]; in ice_get_rxfh_context()
3140 num_tc = vsi->mqprio_qopt.qopt.num_tc; in ice_get_rxfh_context()
3144 return -EINVAL; in ice_get_rxfh_context()
3147 vsi = vsi->tc_map_vsi[rss_context]; in ice_get_rxfh_context()
3156 lut = kzalloc(vsi->rss_table_size, GFP_KERNEL); in ice_get_rxfh_context()
3158 return -ENOMEM; in ice_get_rxfh_context()
3164 err = ice_get_rss_lut(vsi, lut, vsi->rss_table_size); in ice_get_rxfh_context()
3169 for (i = 0; i < vsi->rss_table_size; i++) in ice_get_rxfh_context()
3174 for (i = 0; i < vsi->rss_table_size; i++) in ice_get_rxfh_context()
3183 * ice_get_rxfh - get the Rx flow hash indirection table
3198 * ice_set_rxfh - set the Rx flow hash indirection table
3204 * Returns -EINVAL if the table specifies an invalid queue ID, otherwise
3212 struct ice_vsi *vsi = np->vsi; in ice_set_rxfh()
3213 struct ice_pf *pf = vsi->back; in ice_set_rxfh()
3219 return -EOPNOTSUPP; in ice_set_rxfh()
3221 if (!test_bit(ICE_FLAG_RSS_ENA, pf->flags)) { in ice_set_rxfh()
3224 return -EIO; in ice_set_rxfh()
3229 return -EOPNOTSUPP; in ice_set_rxfh()
3233 if (!vsi->rss_hkey_user) { in ice_set_rxfh()
3234 vsi->rss_hkey_user = in ice_set_rxfh()
3237 if (!vsi->rss_hkey_user) in ice_set_rxfh()
3238 return -ENOMEM; in ice_set_rxfh()
3240 memcpy(vsi->rss_hkey_user, key, ICE_VSIQF_HKEY_ARRAY_SIZE); in ice_set_rxfh()
3242 err = ice_set_rss_key(vsi, vsi->rss_hkey_user); in ice_set_rxfh()
3247 if (!vsi->rss_lut_user) { in ice_set_rxfh()
3248 vsi->rss_lut_user = devm_kzalloc(dev, vsi->rss_table_size, in ice_set_rxfh()
3250 if (!vsi->rss_lut_user) in ice_set_rxfh()
3251 return -ENOMEM; in ice_set_rxfh()
3258 for (i = 0; i < vsi->rss_table_size; i++) in ice_set_rxfh()
3259 vsi->rss_lut_user[i] = (u8)(indir[i]); in ice_set_rxfh()
3261 ice_fill_rss_lut(vsi->rss_lut_user, vsi->rss_table_size, in ice_set_rxfh()
3262 vsi->rss_size); in ice_set_rxfh()
3265 err = ice_set_rss_lut(vsi, vsi->rss_lut_user, vsi->rss_table_size); in ice_set_rxfh()
3278 if (!test_bit(ICE_FLAG_PTP, pf->flags)) in ice_get_ts_info()
3281 info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE | in ice_get_ts_info()
3288 info->phc_index = ice_get_ptp_clock_index(pf); in ice_get_ts_info()
3290 info->tx_types = BIT(HWTSTAMP_TX_OFF) | BIT(HWTSTAMP_TX_ON); in ice_get_ts_info()
3292 info->rx_filters = BIT(HWTSTAMP_FILTER_NONE) | BIT(HWTSTAMP_FILTER_ALL); in ice_get_ts_info()
3298 * ice_get_max_txq - return the maximum number of Tx queues for in a PF
3303 return min3(pf->num_lan_msix, (u16)num_online_cpus(), in ice_get_max_txq()
3304 (u16)pf->hw.func_caps.common_cap.num_txq); in ice_get_max_txq()
3308 * ice_get_max_rxq - return the maximum number of Rx queues for in a PF
3313 return min3(pf->num_lan_msix, (u16)num_online_cpus(), in ice_get_max_rxq()
3314 (u16)pf->hw.func_caps.common_cap.num_rxq); in ice_get_max_rxq()
3318 * ice_get_combined_cnt - return the current number of combined channels
3330 struct ice_q_vector *q_vector = vsi->q_vectors[q_idx]; in ice_get_combined_cnt()
3332 if (q_vector->rx.rx_ring && q_vector->tx.tx_ring) in ice_get_combined_cnt()
3340 * ice_get_channels - get the current and max supported channels
3348 struct ice_vsi *vsi = np->vsi; in ice_get_channels()
3349 struct ice_pf *pf = vsi->back; in ice_get_channels()
3352 ch->max_rx = ice_get_max_rxq(pf); in ice_get_channels()
3353 ch->max_tx = ice_get_max_txq(pf); in ice_get_channels()
3354 ch->max_combined = min_t(int, ch->max_rx, ch->max_tx); in ice_get_channels()
3357 ch->combined_count = ice_get_combined_cnt(vsi); in ice_get_channels()
3358 ch->rx_count = vsi->num_rxq - ch->combined_count; in ice_get_channels()
3359 ch->tx_count = vsi->num_txq - ch->combined_count; in ice_get_channels()
3362 ch->other_count = test_bit(ICE_FLAG_FD_ENA, pf->flags) ? 1 : 0; in ice_get_channels()
3363 ch->max_other = ch->other_count; in ice_get_channels()
3367 * ice_get_valid_rss_size - return valid number of RSS queues
3373 struct ice_hw_common_caps *caps = &hw->func_caps.common_cap; in ice_get_valid_rss_size()
3375 return min_t(int, new_size, BIT(caps->rss_table_entry_width)); in ice_get_valid_rss_size()
3379 * ice_vsi_set_dflt_rss_lut - set default RSS LUT with requested RSS size
3387 struct ice_pf *pf = vsi->back; in ice_vsi_set_dflt_rss_lut()
3394 hw = &pf->hw; in ice_vsi_set_dflt_rss_lut()
3397 return -EINVAL; in ice_vsi_set_dflt_rss_lut()
3399 lut = kzalloc(vsi->rss_table_size, GFP_KERNEL); in ice_vsi_set_dflt_rss_lut()
3401 return -ENOMEM; in ice_vsi_set_dflt_rss_lut()
3404 if (!test_bit(ICE_FLAG_RSS_ENA, pf->flags)) in ice_vsi_set_dflt_rss_lut()
3405 vsi->rss_size = 1; in ice_vsi_set_dflt_rss_lut()
3407 vsi->rss_size = ice_get_valid_rss_size(hw, req_rss_size); in ice_vsi_set_dflt_rss_lut()
3410 ice_fill_rss_lut(lut, vsi->rss_table_size, vsi->rss_size); in ice_vsi_set_dflt_rss_lut()
3411 err = ice_set_rss_lut(vsi, lut, vsi->rss_table_size); in ice_vsi_set_dflt_rss_lut()
3414 ice_aq_str(hw->adminq.sq_last_status)); in ice_vsi_set_dflt_rss_lut()
3421 * ice_set_channels - set the number channels
3428 struct ice_vsi *vsi = np->vsi; in ice_set_channels()
3429 struct ice_pf *pf = vsi->back; in ice_set_channels()
3438 return -EOPNOTSUPP; in ice_set_channels()
3441 if (ch->other_count != (test_bit(ICE_FLAG_FD_ENA, pf->flags) ? 1U : 0U)) in ice_set_channels()
3442 return -EINVAL; in ice_set_channels()
3446 return -EOPNOTSUPP; in ice_set_channels()
3449 if (test_bit(ICE_FLAG_FD_ENA, pf->flags) && pf->hw.fdir_active_fltr) { in ice_set_channels()
3451 return -EOPNOTSUPP; in ice_set_channels()
3457 * value on cmd line but we get non-zero value anyway via in ice_set_channels()
3461 if (ch->rx_count == vsi->num_rxq - curr_combined) in ice_set_channels()
3462 ch->rx_count = 0; in ice_set_channels()
3463 if (ch->tx_count == vsi->num_txq - curr_combined) in ice_set_channels()
3464 ch->tx_count = 0; in ice_set_channels()
3465 if (ch->combined_count == curr_combined) in ice_set_channels()
3466 ch->combined_count = 0; in ice_set_channels()
3468 if (!(ch->combined_count || (ch->rx_count && ch->tx_count))) { in ice_set_channels()
3470 return -EINVAL; in ice_set_channels()
3473 new_rx = ch->combined_count + ch->rx_count; in ice_set_channels()
3474 new_tx = ch->combined_count + ch->tx_count; in ice_set_channels()
3476 if (new_rx < vsi->tc_cfg.numtc) { in ice_set_channels()
3478 vsi->tc_cfg.numtc); in ice_set_channels()
3479 return -EINVAL; in ice_set_channels()
3481 if (new_tx < vsi->tc_cfg.numtc) { in ice_set_channels()
3483 vsi->tc_cfg.numtc); in ice_set_channels()
3484 return -EINVAL; in ice_set_channels()
3489 return -EINVAL; in ice_set_channels()
3494 return -EINVAL; in ice_set_channels()
3497 if (pf->adev) { in ice_set_channels()
3498 mutex_lock(&pf->adev_mutex); in ice_set_channels()
3499 device_lock(&pf->adev->dev); in ice_set_channels()
3501 if (pf->adev->dev.driver) { in ice_set_channels()
3503 ret = -EBUSY; in ice_set_channels()
3516 vsi->rss_size = ice_get_valid_rss_size(&pf->hw, new_rx); in ice_set_channels()
3520 device_unlock(&pf->adev->dev); in ice_set_channels()
3521 mutex_unlock(&pf->adev_mutex); in ice_set_channels()
3527 * ice_get_wol - get current Wake on LAN configuration
3534 struct ice_pf *pf = np->vsi->back; in ice_get_wol()
3536 if (np->vsi->type != ICE_VSI_PF) in ice_get_wol()
3540 if (ice_is_wol_supported(&pf->hw)) { in ice_get_wol()
3541 wol->supported = WAKE_MAGIC; in ice_get_wol()
3542 wol->wolopts = pf->wol_ena ? WAKE_MAGIC : 0; in ice_get_wol()
3544 wol->supported = 0; in ice_get_wol()
3545 wol->wolopts = 0; in ice_get_wol()
3550 * ice_set_wol - set Wake on LAN on supported device
3557 struct ice_vsi *vsi = np->vsi; in ice_set_wol()
3558 struct ice_pf *pf = vsi->back; in ice_set_wol()
3560 if (vsi->type != ICE_VSI_PF || !ice_is_wol_supported(&pf->hw)) in ice_set_wol()
3561 return -EOPNOTSUPP; in ice_set_wol()
3564 if (wol->wolopts && wol->wolopts != WAKE_MAGIC) in ice_set_wol()
3565 return -EOPNOTSUPP; in ice_set_wol()
3568 if (pf->wol_ena != !!wol->wolopts) { in ice_set_wol()
3569 pf->wol_ena = !!wol->wolopts; in ice_set_wol()
3570 device_set_wakeup_enable(ice_pf_to_dev(pf), pf->wol_ena); in ice_set_wol()
3572 pf->wol_ena ? "en" : "dis"); in ice_set_wol()
3579 * ice_get_rc_coalesce - get ITR values for specific ring container
3581 * @rc: ring container that the ITR values will come from
3592 if (!rc->rx_ring) in ice_get_rc_coalesce()
3593 return -EINVAL; in ice_get_rc_coalesce()
3595 switch (rc->type) { in ice_get_rc_coalesce()
3597 ec->use_adaptive_rx_coalesce = ITR_IS_DYNAMIC(rc); in ice_get_rc_coalesce()
3598 ec->rx_coalesce_usecs = rc->itr_setting; in ice_get_rc_coalesce()
3599 ec->rx_coalesce_usecs_high = rc->rx_ring->q_vector->intrl; in ice_get_rc_coalesce()
3602 ec->use_adaptive_tx_coalesce = ITR_IS_DYNAMIC(rc); in ice_get_rc_coalesce()
3603 ec->tx_coalesce_usecs = rc->itr_setting; in ice_get_rc_coalesce()
3606 dev_dbg(ice_pf_to_dev(rc->rx_ring->vsi->back), "Invalid c_type %d\n", rc->type); in ice_get_rc_coalesce()
3607 return -EINVAL; in ice_get_rc_coalesce()
3614 * ice_get_q_coalesce - get a queue's ITR/INTRL (coalesce) settings
3626 if (q_num < vsi->num_rxq && q_num < vsi->num_txq) { in ice_get_q_coalesce()
3628 &vsi->rx_rings[q_num]->q_vector->rx)) in ice_get_q_coalesce()
3629 return -EINVAL; in ice_get_q_coalesce()
3631 &vsi->tx_rings[q_num]->q_vector->tx)) in ice_get_q_coalesce()
3632 return -EINVAL; in ice_get_q_coalesce()
3633 } else if (q_num < vsi->num_rxq) { in ice_get_q_coalesce()
3635 &vsi->rx_rings[q_num]->q_vector->rx)) in ice_get_q_coalesce()
3636 return -EINVAL; in ice_get_q_coalesce()
3637 } else if (q_num < vsi->num_txq) { in ice_get_q_coalesce()
3639 &vsi->tx_rings[q_num]->q_vector->tx)) in ice_get_q_coalesce()
3640 return -EINVAL; in ice_get_q_coalesce()
3642 return -EINVAL; in ice_get_q_coalesce()
3649 * __ice_get_coalesce - get ITR/INTRL values for the device
3662 struct ice_vsi *vsi = np->vsi; in __ice_get_coalesce()
3668 return -EINVAL; in __ice_get_coalesce()
3678 return __ice_get_coalesce(netdev, ec, -1); in ice_get_coalesce()
3689 * ice_set_rc_coalesce - set ITR values for specific ring container
3691 * @rc: ring container that the ITR values will come from
3692 * @vsi: VSI associated to the ring container
3704 const char *c_type_str = (rc->type == ICE_RX_CONTAINER) ? "rx" : "tx"; in ice_set_rc_coalesce()
3706 struct ice_pf *pf = vsi->back; in ice_set_rc_coalesce()
3709 if (!rc->rx_ring) in ice_set_rc_coalesce()
3710 return -EINVAL; in ice_set_rc_coalesce()
3712 switch (rc->type) { in ice_set_rc_coalesce()
3715 struct ice_q_vector *q_vector = rc->rx_ring->q_vector; in ice_set_rc_coalesce()
3717 if (ec->rx_coalesce_usecs_high > ICE_MAX_INTRL || in ice_set_rc_coalesce()
3718 (ec->rx_coalesce_usecs_high && in ice_set_rc_coalesce()
3719 ec->rx_coalesce_usecs_high < pf->hw.intrl_gran)) { in ice_set_rc_coalesce()
3720 netdev_info(vsi->netdev, "Invalid value, %s-usecs-high valid values are 0 (disabled), %d-%d\n", in ice_set_rc_coalesce()
3721 c_type_str, pf->hw.intrl_gran, in ice_set_rc_coalesce()
3723 return -EINVAL; in ice_set_rc_coalesce()
3725 if (ec->rx_coalesce_usecs_high != q_vector->intrl && in ice_set_rc_coalesce()
3726 (ec->use_adaptive_rx_coalesce || ec->use_adaptive_tx_coalesce)) { in ice_set_rc_coalesce()
3727 …netdev_info(vsi->netdev, "Invalid value, %s-usecs-high cannot be changed if adaptive-tx or adaptiv… in ice_set_rc_coalesce()
3729 return -EINVAL; in ice_set_rc_coalesce()
3731 if (ec->rx_coalesce_usecs_high != q_vector->intrl) in ice_set_rc_coalesce()
3732 q_vector->intrl = ec->rx_coalesce_usecs_high; in ice_set_rc_coalesce()
3734 use_adaptive_coalesce = ec->use_adaptive_rx_coalesce; in ice_set_rc_coalesce()
3735 coalesce_usecs = ec->rx_coalesce_usecs; in ice_set_rc_coalesce()
3740 use_adaptive_coalesce = ec->use_adaptive_tx_coalesce; in ice_set_rc_coalesce()
3741 coalesce_usecs = ec->tx_coalesce_usecs; in ice_set_rc_coalesce()
3745 dev_dbg(ice_pf_to_dev(pf), "Invalid container type %d\n", in ice_set_rc_coalesce()
3746 rc->type); in ice_set_rc_coalesce()
3747 return -EINVAL; in ice_set_rc_coalesce()
3750 itr_setting = rc->itr_setting; in ice_set_rc_coalesce()
3752 netdev_info(vsi->netdev, "%s interrupt throttling cannot be changed if adaptive-%s is enabled\n", in ice_set_rc_coalesce()
3754 return -EINVAL; in ice_set_rc_coalesce()
3758 netdev_info(vsi->netdev, "Invalid value, %s-usecs range is 0-%d\n", in ice_set_rc_coalesce()
3760 return -EINVAL; in ice_set_rc_coalesce()
3764 rc->itr_mode = ITR_DYNAMIC; in ice_set_rc_coalesce()
3766 rc->itr_mode = ITR_STATIC; in ice_set_rc_coalesce()
3768 rc->itr_setting = coalesce_usecs; in ice_set_rc_coalesce()
3775 ice_flush(&pf->hw); in ice_set_rc_coalesce()
3782 * ice_set_q_coalesce - set a queue's ITR/INTRL (coalesce) settings
3794 if (q_num < vsi->num_rxq && q_num < vsi->num_txq) { in ice_set_q_coalesce()
3796 &vsi->rx_rings[q_num]->q_vector->rx, in ice_set_q_coalesce()
3798 return -EINVAL; in ice_set_q_coalesce()
3801 &vsi->tx_rings[q_num]->q_vector->tx, in ice_set_q_coalesce()
3803 return -EINVAL; in ice_set_q_coalesce()
3804 } else if (q_num < vsi->num_rxq) { in ice_set_q_coalesce()
3806 &vsi->rx_rings[q_num]->q_vector->rx, in ice_set_q_coalesce()
3808 return -EINVAL; in ice_set_q_coalesce()
3809 } else if (q_num < vsi->num_txq) { in ice_set_q_coalesce()
3811 &vsi->tx_rings[q_num]->q_vector->tx, in ice_set_q_coalesce()
3813 return -EINVAL; in ice_set_q_coalesce()
3815 return -EINVAL; in ice_set_q_coalesce()
3822 * ice_print_if_odd_usecs - print message if user tries to set odd [tx|rx]-usecs
3826 * @coalesce_usecs: requested value of [tx|rx]-usecs
3827 * @c_type_str: either "rx" or "tx" to match user set field of [tx|rx]-usecs
3838 …netdev_info(netdev, "User set %s-usecs to %d, device only supports even values. Rounding down and … in ice_print_if_odd_usecs()
3844 * __ice_set_coalesce - set ITR/INTRL values for the device
3857 struct ice_vsi *vsi = np->vsi; in __ice_set_coalesce()
3860 struct ice_q_vector *q_vector = vsi->q_vectors[0]; in __ice_set_coalesce()
3864 ice_print_if_odd_usecs(netdev, q_vector->rx.itr_setting, in __ice_set_coalesce()
3865 ec->use_adaptive_rx_coalesce, in __ice_set_coalesce()
3866 ec->rx_coalesce_usecs, "rx"); in __ice_set_coalesce()
3868 ice_print_if_odd_usecs(netdev, q_vector->tx.itr_setting, in __ice_set_coalesce()
3869 ec->use_adaptive_tx_coalesce, in __ice_set_coalesce()
3870 ec->tx_coalesce_usecs, "tx"); in __ice_set_coalesce()
3875 * can be less than vsi->num_q_vectors. This check in __ice_set_coalesce()
3878 if (v_idx >= vsi->num_rxq && v_idx >= vsi->num_txq) in __ice_set_coalesce()
3882 return -EINVAL; in __ice_set_coalesce()
3884 ice_set_q_vector_intrl(vsi->q_vectors[v_idx]); in __ice_set_coalesce()
3890 return -EINVAL; in __ice_set_coalesce()
3892 ice_set_q_vector_intrl(vsi->q_vectors[q_num]); in __ice_set_coalesce()
3903 return __ice_set_coalesce(netdev, ec, -1); in ice_set_coalesce()
3919 if (ice_check_vf_ready_for_cfg(repr->vf)) in ice_repr_get_drvinfo()
3922 __ice_get_drvinfo(netdev, drvinfo, repr->src_vsi); in ice_repr_get_drvinfo()
3931 if (ice_check_vf_ready_for_cfg(repr->vf) || in ice_repr_get_strings()
3935 __ice_get_strings(netdev, stringset, data, repr->src_vsi); in ice_repr_get_strings()
3945 if (ice_check_vf_ready_for_cfg(repr->vf)) in ice_repr_get_ethtool_stats()
3948 __ice_get_ethtool_stats(netdev, stats, data, repr->src_vsi); in ice_repr_get_ethtool_stats()
3957 return -EOPNOTSUPP; in ice_repr_get_sset_count()
3974 * ice_get_module_info - get SFF module type and revision information
3983 struct ice_vsi *vsi = np->vsi; in ice_get_module_info()
3984 struct ice_pf *pf = vsi->back; in ice_get_module_info()
3985 struct ice_hw *hw = &pf->hw; in ice_get_module_info()
4011 modinfo->type = ETH_MODULE_SFF_8079; in ice_get_module_info()
4012 modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN; in ice_get_module_info()
4015 modinfo->type = ETH_MODULE_SFF_8472; in ice_get_module_info()
4016 modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN; in ice_get_module_info()
4018 modinfo->type = ETH_MODULE_SFF_8079; in ice_get_module_info()
4019 modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN; in ice_get_module_info()
4031 /* Module is SFF-8636 compliant */ in ice_get_module_info()
4032 modinfo->type = ETH_MODULE_SFF_8636; in ice_get_module_info()
4033 modinfo->eeprom_len = ICE_MODULE_QSFP_MAX_LEN; in ice_get_module_info()
4035 modinfo->type = ETH_MODULE_SFF_8436; in ice_get_module_info()
4036 modinfo->eeprom_len = ICE_MODULE_QSFP_MAX_LEN; in ice_get_module_info()
4041 return -EINVAL; in ice_get_module_info()
4047 * ice_get_module_eeprom - fill buffer with SFF EEPROM contents
4060 struct ice_vsi *vsi = np->vsi; in ice_get_module_eeprom()
4061 struct ice_pf *pf = vsi->back; in ice_get_module_eeprom()
4062 struct ice_hw *hw = &pf->hw; in ice_get_module_eeprom()
4069 if (!ee || !ee->len || !data) in ice_get_module_eeprom()
4070 return -EINVAL; in ice_get_module_eeprom()
4080 memset(data, 0, ee->len); in ice_get_module_eeprom()
4081 for (i = 0; i < ee->len; i += SFF_READ_BLOCK_SIZE) { in ice_get_module_eeprom()
4082 offset = i + ee->offset; in ice_get_module_eeprom()
4088 offset -= ETH_MODULE_SFF_8079_LEN; in ice_get_module_eeprom()
4094 offset -= ETH_MODULE_SFF_8436_LEN / 2; in ice_get_module_eeprom()
4129 copy_len = min_t(u32, SFF_READ_BLOCK_SIZE, ee->len - i); in ice_get_module_eeprom()
4207 * ice_set_ethtool_safe_mode_ops - setup safe mode ethtool ops
4212 netdev->ethtool_ops = &ice_ethtool_safe_mode_ops; in ice_set_ethtool_safe_mode_ops()
4224 * ice_set_ethtool_repr_ops - setup VF's port representor ethtool ops
4229 netdev->ethtool_ops = &ice_ethtool_repr_ops; in ice_set_ethtool_repr_ops()
4233 * ice_set_ethtool_ops - setup netdev ethtool ops
4240 netdev->ethtool_ops = &ice_ethtool_ops; in ice_set_ethtool_ops()