Lines Matching +full:self +full:- +full:advertising

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),
434 struct ice_pf *pf = vsi->back; in __ice_get_drvinfo()
435 struct ice_hw *hw = &pf->hw; in __ice_get_drvinfo()
439 nvm = &hw->flash.nvm; in __ice_get_drvinfo()
440 orom = &hw->flash.orom; in __ice_get_drvinfo()
442 strscpy(drvinfo->driver, KBUILD_MODNAME, sizeof(drvinfo->driver)); in __ice_get_drvinfo()
447 snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), in __ice_get_drvinfo()
448 "%x.%02x 0x%x %d.%d.%d", nvm->major, nvm->minor, in __ice_get_drvinfo()
449 nvm->eetrack, orom->major, orom->build, orom->patch); in __ice_get_drvinfo()
451 strscpy(drvinfo->bus_info, pci_name(pf->pdev), in __ice_get_drvinfo()
452 sizeof(drvinfo->bus_info)); in __ice_get_drvinfo()
460 __ice_get_drvinfo(netdev, drvinfo, np->vsi); in ice_get_drvinfo()
461 drvinfo->n_priv_flags = ICE_PRIV_FLAG_ARRAY_SIZE; in ice_get_drvinfo()
471 * ice_ethtool_get_maxspeed - Get the max speed for given lport
490 return -EIO; in ice_ethtool_get_maxspeed()
492 return -EINVAL; in ice_ethtool_get_maxspeed()
499 * ice_is_serdes_muxed - returns whether serdes is muxed in hardware
516 port_topology->pcs_quad_select = 0; in ice_map_port_topology_for_sfp()
517 port_topology->pcs_port = 0; in ice_map_port_topology_for_sfp()
518 port_topology->primary_serdes_lane = 0; in ice_map_port_topology_for_sfp()
521 port_topology->pcs_quad_select = 1; in ice_map_port_topology_for_sfp()
522 port_topology->pcs_port = 0; in ice_map_port_topology_for_sfp()
524 port_topology->primary_serdes_lane = 2; in ice_map_port_topology_for_sfp()
526 port_topology->primary_serdes_lane = 4; in ice_map_port_topology_for_sfp()
529 port_topology->pcs_quad_select = 0; in ice_map_port_topology_for_sfp()
530 port_topology->pcs_port = 1; in ice_map_port_topology_for_sfp()
531 port_topology->primary_serdes_lane = 1; in ice_map_port_topology_for_sfp()
534 port_topology->pcs_quad_select = 1; in ice_map_port_topology_for_sfp()
535 port_topology->pcs_port = 1; in ice_map_port_topology_for_sfp()
537 port_topology->primary_serdes_lane = 3; in ice_map_port_topology_for_sfp()
539 port_topology->primary_serdes_lane = 5; in ice_map_port_topology_for_sfp()
542 port_topology->pcs_quad_select = 0; in ice_map_port_topology_for_sfp()
543 port_topology->pcs_port = 2; in ice_map_port_topology_for_sfp()
544 port_topology->primary_serdes_lane = 2; in ice_map_port_topology_for_sfp()
547 port_topology->pcs_quad_select = 1; in ice_map_port_topology_for_sfp()
548 port_topology->pcs_port = 2; in ice_map_port_topology_for_sfp()
549 port_topology->primary_serdes_lane = 6; in ice_map_port_topology_for_sfp()
552 port_topology->pcs_quad_select = 0; in ice_map_port_topology_for_sfp()
553 port_topology->pcs_port = 3; in ice_map_port_topology_for_sfp()
554 port_topology->primary_serdes_lane = 3; in ice_map_port_topology_for_sfp()
557 port_topology->pcs_quad_select = 1; in ice_map_port_topology_for_sfp()
558 port_topology->pcs_port = 3; in ice_map_port_topology_for_sfp()
559 port_topology->primary_serdes_lane = 7; in ice_map_port_topology_for_sfp()
562 return -EINVAL; in ice_map_port_topology_for_sfp()
573 port_topology->pcs_quad_select = 0; in ice_map_port_topology_for_qsfp()
574 port_topology->pcs_port = 0; in ice_map_port_topology_for_qsfp()
575 port_topology->primary_serdes_lane = 0; in ice_map_port_topology_for_qsfp()
578 port_topology->pcs_quad_select = 1; in ice_map_port_topology_for_qsfp()
579 port_topology->pcs_port = 0; in ice_map_port_topology_for_qsfp()
581 port_topology->primary_serdes_lane = 2; in ice_map_port_topology_for_qsfp()
583 port_topology->primary_serdes_lane = 4; in ice_map_port_topology_for_qsfp()
586 port_topology->pcs_quad_select = 0; in ice_map_port_topology_for_qsfp()
587 port_topology->pcs_port = 1; in ice_map_port_topology_for_qsfp()
588 port_topology->primary_serdes_lane = 1; in ice_map_port_topology_for_qsfp()
591 port_topology->pcs_quad_select = 1; in ice_map_port_topology_for_qsfp()
592 port_topology->pcs_port = 1; in ice_map_port_topology_for_qsfp()
594 port_topology->primary_serdes_lane = 3; in ice_map_port_topology_for_qsfp()
596 port_topology->primary_serdes_lane = 5; in ice_map_port_topology_for_qsfp()
599 port_topology->pcs_quad_select = 0; in ice_map_port_topology_for_qsfp()
600 port_topology->pcs_port = 2; in ice_map_port_topology_for_qsfp()
601 port_topology->primary_serdes_lane = 2; in ice_map_port_topology_for_qsfp()
604 port_topology->pcs_quad_select = 1; in ice_map_port_topology_for_qsfp()
605 port_topology->pcs_port = 2; in ice_map_port_topology_for_qsfp()
606 port_topology->primary_serdes_lane = 6; in ice_map_port_topology_for_qsfp()
609 port_topology->pcs_quad_select = 0; in ice_map_port_topology_for_qsfp()
610 port_topology->pcs_port = 3; in ice_map_port_topology_for_qsfp()
611 port_topology->primary_serdes_lane = 3; in ice_map_port_topology_for_qsfp()
614 port_topology->pcs_quad_select = 1; in ice_map_port_topology_for_qsfp()
615 port_topology->pcs_port = 3; in ice_map_port_topology_for_qsfp()
616 port_topology->primary_serdes_lane = 7; in ice_map_port_topology_for_qsfp()
619 return -EINVAL; in ice_map_port_topology_for_qsfp()
626 * ice_get_port_topology - returns physical topology like pcsquad, pcsport,
650 return -EINVAL; in ice_get_port_topology()
656 port_topology->serdes_lane_count = 1; in ice_get_port_topology()
669 port_topology->serdes_lane_count = 4; in ice_get_port_topology()
671 port_topology->serdes_lane_count = 2; in ice_get_port_topology()
673 port_topology->serdes_lane_count = 1; in ice_get_port_topology()
679 return -EINVAL; in ice_get_port_topology()
686 * ice_get_tx_rx_equa - read serdes tx rx equaliser param
703 { ICE_AQC_TX_EQU_PRE1, tx, &ptr->tx_equ_pre1 }, in ice_get_tx_rx_equa()
704 { ICE_AQC_TX_EQU_PRE3, tx, &ptr->tx_equ_pre3 }, in ice_get_tx_rx_equa()
705 { ICE_AQC_TX_EQU_ATTEN, tx, &ptr->tx_equ_atten }, in ice_get_tx_rx_equa()
706 { ICE_AQC_TX_EQU_POST1, tx, &ptr->tx_equ_post1 }, in ice_get_tx_rx_equa()
707 { ICE_AQC_TX_EQU_PRE2, tx, &ptr->tx_equ_pre2 }, in ice_get_tx_rx_equa()
708 { ICE_AQC_RX_EQU_PRE2, rx, &ptr->rx_equ_pre2 }, in ice_get_tx_rx_equa()
709 { ICE_AQC_RX_EQU_PRE1, rx, &ptr->rx_equ_pre1 }, in ice_get_tx_rx_equa()
710 { ICE_AQC_RX_EQU_POST1, rx, &ptr->rx_equ_post1 }, in ice_get_tx_rx_equa()
711 { ICE_AQC_RX_EQU_BFLF, rx, &ptr->rx_equ_bflf }, in ice_get_tx_rx_equa()
712 { ICE_AQC_RX_EQU_BFHF, rx, &ptr->rx_equ_bfhf }, in ice_get_tx_rx_equa()
713 { ICE_AQC_RX_EQU_CTLE_GAINHF, rx, &ptr->rx_equ_ctle_gainhf }, in ice_get_tx_rx_equa()
714 { ICE_AQC_RX_EQU_CTLE_GAINLF, rx, &ptr->rx_equ_ctle_gainlf }, in ice_get_tx_rx_equa()
715 { ICE_AQC_RX_EQU_CTLE_GAINDC, rx, &ptr->rx_equ_ctle_gaindc }, in ice_get_tx_rx_equa()
716 { ICE_AQC_RX_EQU_CTLE_BW, rx, &ptr->rx_equ_ctle_bw }, in ice_get_tx_rx_equa()
717 { ICE_AQC_RX_EQU_DFE_GAIN, rx, &ptr->rx_equ_dfe_gain }, in ice_get_tx_rx_equa()
718 { ICE_AQC_RX_EQU_DFE_GAIN2, rx, &ptr->rx_equ_dfe_gain_2 }, in ice_get_tx_rx_equa()
719 { ICE_AQC_RX_EQU_DFE_2, rx, &ptr->rx_equ_dfe_2 }, in ice_get_tx_rx_equa()
720 { ICE_AQC_RX_EQU_DFE_3, rx, &ptr->rx_equ_dfe_3 }, in ice_get_tx_rx_equa()
721 { ICE_AQC_RX_EQU_DFE_4, rx, &ptr->rx_equ_dfe_4 }, in ice_get_tx_rx_equa()
722 { ICE_AQC_RX_EQU_DFE_5, rx, &ptr->rx_equ_dfe_5 }, in ice_get_tx_rx_equa()
723 { ICE_AQC_RX_EQU_DFE_6, rx, &ptr->rx_equ_dfe_6 }, in ice_get_tx_rx_equa()
724 { ICE_AQC_RX_EQU_DFE_7, rx, &ptr->rx_equ_dfe_7 }, in ice_get_tx_rx_equa()
725 { ICE_AQC_RX_EQU_DFE_8, rx, &ptr->rx_equ_dfe_8 }, in ice_get_tx_rx_equa()
726 { ICE_AQC_RX_EQU_DFE_9, rx, &ptr->rx_equ_dfe_9 }, in ice_get_tx_rx_equa()
727 { ICE_AQC_RX_EQU_DFE_10, rx, &ptr->rx_equ_dfe_10 }, in ice_get_tx_rx_equa()
728 { ICE_AQC_RX_EQU_DFE_11, rx, &ptr->rx_equ_dfe_11 }, in ice_get_tx_rx_equa()
729 { ICE_AQC_RX_EQU_DFE_12, rx, &ptr->rx_equ_dfe_12 }, in ice_get_tx_rx_equa()
745 * ice_get_extended_regs - returns FEC correctable, uncorrectable stats per
763 pf = np->vsi->back; in ice_get_extended_regs()
764 hw = &pf->hw; in ice_get_extended_regs()
765 pi = np->vsi->port_info; in ice_get_extended_regs()
768 if (np->vsi->type != ICE_VSI_PF || !pi) in ice_get_extended_regs()
769 return -EINVAL; in ice_get_extended_regs()
771 err = ice_get_port_topology(hw, pi->lport, &port_topology); in ice_get_extended_regs()
773 return -EINVAL; in ice_get_extended_regs()
775 return -EINVAL; in ice_get_extended_regs()
785 &ice_prv_regs_buf->equalization[i]); in ice_get_extended_regs()
787 return -EINVAL; in ice_get_extended_regs()
797 struct ice_pf *pf = np->vsi->back; in ice_get_regs()
798 struct ice_hw *hw = &pf->hw; in ice_get_regs()
802 regs->version = 2; in ice_get_regs()
813 struct ice_pf *pf = np->vsi->back; in ice_get_msglevel()
816 if (pf->hw.debug_mask) in ice_get_msglevel()
818 pf->hw.debug_mask); in ice_get_msglevel()
821 return pf->msg_enable; in ice_get_msglevel()
827 struct ice_pf *pf = np->vsi->back; in ice_set_msglevel()
831 pf->hw.debug_mask = data; in ice_set_msglevel()
833 pf->msg_enable = data; in ice_set_msglevel()
835 pf->msg_enable = data; in ice_set_msglevel()
842 struct ice_pf *pf = np->vsi->back; in ice_get_eeprom_len()
844 return (int)pf->hw.flash.flash_size; in ice_get_eeprom_len()
852 struct ice_vsi *vsi = np->vsi; in ice_get_eeprom()
853 struct ice_pf *pf = vsi->back; in ice_get_eeprom()
854 struct ice_hw *hw = &pf->hw; in ice_get_eeprom()
861 eeprom->magic = hw->vendor_id | (hw->device_id << 16); in ice_get_eeprom()
863 eeprom->cmd, eeprom->offset, eeprom->len); in ice_get_eeprom()
865 buf = kzalloc(eeprom->len, GFP_KERNEL); in ice_get_eeprom()
867 return -ENOMEM; in ice_get_eeprom()
872 ret, ice_aq_str(hw->adminq.sq_last_status)); in ice_get_eeprom()
876 ret = ice_read_flat_nvm(hw, eeprom->offset, &eeprom->len, buf, in ice_get_eeprom()
880 ret, ice_aq_str(hw->adminq.sq_last_status)); in ice_get_eeprom()
884 memcpy(bytes, buf, eeprom->len); in ice_get_eeprom()
893 * ice_active_vfs - check if there are any active VFs
906 if (test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states)) { in ice_active_vfs()
917 * ice_link_test - perform a link test on a given net_device
920 * This function performs one of the self-tests required by ethtool.
921 * Returns 0 on success, non-zero on failure.
930 status = ice_get_link_status(np->vsi->port_info, &link_up); in ice_link_test()
944 * ice_eeprom_test - perform an EEPROM test on a given net_device
947 * This function performs one of the self-tests required by ethtool.
948 * Returns 0 on success, non-zero on failure.
953 struct ice_pf *pf = np->vsi->back; in ice_eeprom_test()
956 return !!(ice_nvm_validate_checksum(&pf->hw)); in ice_eeprom_test()
967 struct ice_pf *pf = (struct ice_pf *)hw->back; in ice_reg_pattern_test()
984 dev_err(dev, "%s: reg pattern test failed - reg 0x%08x pat 0x%08x val 0x%08x\n" in ice_reg_pattern_test()
992 dev_err(dev, "%s: reg restore test failed - reg 0x%08x orig 0x%08x val 0x%08x\n" in ice_reg_pattern_test()
1001 * ice_reg_test - perform a register test on a given net_device
1004 * This function performs one of the self-tests required by ethtool.
1005 * Returns 0 on success, non-zero on failure.
1010 struct ice_hw *hw = np->vsi->port_info->hw; in ice_reg_test()
1011 u32 int_elements = hw->func_caps.common_cap.num_msix_vectors ? in ice_reg_test()
1012 hw->func_caps.common_cap.num_msix_vectors - 1 : 1; in ice_reg_test()
1020 GLINT_ITR(0, 1) - GLINT_ITR(0, 0)}, in ice_reg_test()
1022 GLINT_ITR(1, 1) - GLINT_ITR(1, 0)}, in ice_reg_test()
1024 GLINT_ITR(2, 1) - GLINT_ITR(2, 0)}, in ice_reg_test()
1038 /* bail on failure (non-zero return) */ in ice_reg_test()
1048 * ice_lbtest_prepare_rings - configure Tx/Rx test rings
1089 * ice_lbtest_disable_rings - disable Tx/Rx test rings after loopback test
1101 netdev_err(vsi->netdev, "Failed to stop Tx rings, VSI %d error %d\n", in ice_lbtest_disable_rings()
1102 vsi->vsi_num, status); in ice_lbtest_disable_rings()
1106 netdev_err(vsi->netdev, "Failed to stop Rx rings, VSI %d error %d\n", in ice_lbtest_disable_rings()
1107 vsi->vsi_num, status); in ice_lbtest_disable_rings()
1116 * ice_lbtest_create_frame - create test packet
1122 * Returns 0 on success, non-zero on failure.
1129 return -EINVAL; in ice_lbtest_create_frame()
1133 return -ENOMEM; in ice_lbtest_create_frame()
1150 * ice_lbtest_check_frame - verify received loopback frame
1170 * ice_diag_send - send test frames to the test ring
1184 tx_desc = ICE_TX_DESC(tx_ring, tx_ring->next_to_use); in ice_diag_send()
1185 tx_buf = &tx_ring->tx_buf[tx_ring->next_to_use]; in ice_diag_send()
1187 dma = dma_map_single(tx_ring->dev, data, size, DMA_TO_DEVICE); in ice_diag_send()
1188 if (dma_mapping_error(tx_ring->dev, dma)) in ice_diag_send()
1189 return -EINVAL; in ice_diag_send()
1191 tx_desc->buf_addr = cpu_to_le64(dma); in ice_diag_send()
1195 tx_desc->cmd_type_offset_bsz = in ice_diag_send()
1202 tx_buf->next_to_watch = tx_desc; in ice_diag_send()
1209 tx_ring->next_to_use++; in ice_diag_send()
1210 if (tx_ring->next_to_use >= tx_ring->count) in ice_diag_send()
1211 tx_ring->next_to_use = 0; in ice_diag_send()
1213 writel_relaxed(tx_ring->next_to_use, tx_ring->tail); in ice_diag_send()
1217 dma_unmap_single(tx_ring->dev, dma, size, DMA_TO_DEVICE); in ice_diag_send()
1224 * ice_lbtest_receive_frames - receive and verify test frames
1238 for (i = 0; i < rx_ring->count; i++) { in ice_lbtest_receive_frames()
1243 if (!(rx_desc->wb.status_error0 & in ice_lbtest_receive_frames()
1248 rx_buf = &rx_ring->rx_buf[i]; in ice_lbtest_receive_frames()
1249 received_buf = page_address(rx_buf->page) + rx_buf->page_offset; in ice_lbtest_receive_frames()
1259 * ice_loopback_test - perform a loopback test on a given net_device
1262 * This function performs one of the self-tests required by ethtool.
1263 * Returns 0 on success, non-zero on failure.
1268 struct ice_vsi *orig_vsi = np->vsi, *test_vsi; in ice_loopback_test()
1269 struct ice_pf *pf = orig_vsi->back; in ice_loopback_test()
1279 test_vsi = ice_lb_vsi_setup(pf, pf->hw.port_info); in ice_loopback_test()
1285 test_vsi->netdev = netdev; in ice_loopback_test()
1286 tx_ring = test_vsi->tx_rings[0]; in ice_loopback_test()
1287 rx_ring = test_vsi->rx_rings[0]; in ice_loopback_test()
1294 if (ice_alloc_rx_bufs(rx_ring, rx_ring->count)) { in ice_loopback_test()
1300 if (ice_aq_set_mac_loopback(&pf->hw, true, NULL)) { in ice_loopback_test()
1317 num_frames = min_t(int, tx_ring->count, 32); in ice_loopback_test()
1336 if (ice_aq_set_mac_loopback(&pf->hw, false, NULL)) in ice_loopback_test()
1342 test_vsi->netdev = NULL; in ice_loopback_test()
1350 * ice_intr_test - perform an interrupt test on a given net_device
1353 * This function performs one of the self-tests required by ethtool.
1354 * Returns 0 on success, non-zero on failure.
1359 struct ice_pf *pf = np->vsi->back; in ice_intr_test()
1360 u16 swic_old = pf->sw_int_count; in ice_intr_test()
1364 wr32(&pf->hw, GLINT_DYN_CTL(pf->oicr_irq.index), in ice_intr_test()
1370 return (swic_old == pf->sw_int_count); in ice_intr_test()
1374 * ice_self_test - handler function for performing a self-test by ethtool
1379 * This function is called after invoking 'ethtool -t devname' command where
1381 * It performs a set of self-tests to check if a device works properly.
1389 struct ice_pf *pf = np->vsi->back; in ice_self_test()
1394 if (eth_test->flags == ETH_TEST_FL_OFFLINE) { in ice_self_test()
1397 set_bit(ICE_TESTING, pf->state); in ice_self_test()
1406 eth_test->flags |= ETH_TEST_FL_FAILED; in ice_self_test()
1407 clear_bit(ICE_TESTING, pf->state); in ice_self_test()
1426 eth_test->flags |= ETH_TEST_FL_FAILED; in ice_self_test()
1428 clear_bit(ICE_TESTING, pf->state); in ice_self_test()
1435 pf->int_name, status); in ice_self_test()
1444 eth_test->flags |= ETH_TEST_FL_FAILED; in ice_self_test()
1482 if (vsi->type != ICE_VSI_PF) in __ice_get_strings()
1513 __ice_get_strings(netdev, stringset, data, np->vsi); in ice_get_strings()
1530 return -EINVAL; in ice_set_phys_id()
1533 if (ice_aq_set_port_id_led(np->vsi->port_info, !led_active, NULL)) in ice_set_phys_id()
1534 return -EIO; in ice_set_phys_id()
1540 * ice_set_fec_cfg - Set link FEC options
1548 struct ice_vsi *vsi = np->vsi; in ice_set_fec_cfg()
1551 pi = vsi->port_info; in ice_set_fec_cfg()
1553 return -EOPNOTSUPP; in ice_set_fec_cfg()
1556 if (vsi->type != ICE_VSI_PF) { in ice_set_fec_cfg()
1558 return -EOPNOTSUPP; in ice_set_fec_cfg()
1562 if (pi->phy.curr_user_fec_req == req_fec) in ice_set_fec_cfg()
1569 memcpy(&config, &pi->phy.curr_user_phy_cfg, sizeof(config)); in ice_set_fec_cfg()
1574 if (ice_aq_set_phy_cfg(pi->hw, pi, &config, NULL)) in ice_set_fec_cfg()
1575 return -EAGAIN; in ice_set_fec_cfg()
1578 pi->phy.curr_user_fec_req = req_fec; in ice_set_fec_cfg()
1584 * ice_set_fecparam - Set FEC link options
1592 struct ice_vsi *vsi = np->vsi; in ice_set_fecparam()
1595 switch (fecparam->fec) { in ice_set_fecparam()
1610 dev_warn(ice_pf_to_dev(vsi->back), "Unsupported FEC mode: %d\n", in ice_set_fecparam()
1611 fecparam->fec); in ice_set_fecparam()
1612 return -EINVAL; in ice_set_fecparam()
1619 * ice_get_fecparam - Get link FEC options
1629 struct ice_vsi *vsi = np->vsi; in ice_get_fecparam()
1633 pi = vsi->port_info; in ice_get_fecparam()
1636 return -EOPNOTSUPP; in ice_get_fecparam()
1637 link_info = &pi->phy.link_info; in ice_get_fecparam()
1640 switch (link_info->fec_info) { in ice_get_fecparam()
1642 fecparam->active_fec = ETHTOOL_FEC_BASER; in ice_get_fecparam()
1646 fecparam->active_fec = ETHTOOL_FEC_RS; in ice_get_fecparam()
1649 fecparam->active_fec = ETHTOOL_FEC_OFF; in ice_get_fecparam()
1655 return -ENOMEM; in ice_get_fecparam()
1663 if (caps->caps & ICE_AQC_PHY_EN_AUTO_FEC) in ice_get_fecparam()
1664 fecparam->fec |= ETHTOOL_FEC_AUTO; in ice_get_fecparam()
1665 if (caps->link_fec_options & ICE_AQC_PHY_FEC_10G_KR_40G_KR4_EN || in ice_get_fecparam()
1666 caps->link_fec_options & ICE_AQC_PHY_FEC_10G_KR_40G_KR4_REQ || in ice_get_fecparam()
1667 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_KR_CLAUSE74_EN || in ice_get_fecparam()
1668 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_KR_REQ) in ice_get_fecparam()
1669 fecparam->fec |= ETHTOOL_FEC_BASER; in ice_get_fecparam()
1670 if (caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_528_REQ || in ice_get_fecparam()
1671 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_544_REQ || in ice_get_fecparam()
1672 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_CLAUSE91_EN) in ice_get_fecparam()
1673 fecparam->fec |= ETHTOOL_FEC_RS; in ice_get_fecparam()
1674 if (caps->link_fec_options == 0) in ice_get_fecparam()
1675 fecparam->fec |= ETHTOOL_FEC_OFF; in ice_get_fecparam()
1683 * ice_nway_reset - restart autonegotiation
1689 struct ice_vsi *vsi = np->vsi; in ice_nway_reset()
1693 if (!test_bit(ICE_DOWN, vsi->back->state)) in ice_nway_reset()
1702 * ice_get_priv_flags - report device private flags
1714 struct ice_vsi *vsi = np->vsi; in ice_get_priv_flags()
1715 struct ice_pf *pf = vsi->back; in ice_get_priv_flags()
1723 if (test_bit(priv_flag->bitno, pf->flags)) in ice_get_priv_flags()
1731 * ice_set_priv_flags - set private flags
1740 struct ice_vsi *vsi = np->vsi; in ice_set_priv_flags()
1741 struct ice_pf *pf = vsi->back; in ice_set_priv_flags()
1747 return -EINVAL; in ice_set_priv_flags()
1750 set_bit(ICE_FLAG_ETHTOOL_CTXT, pf->flags); in ice_set_priv_flags()
1752 bitmap_copy(orig_flags, pf->flags, ICE_PF_FLAGS_NBITS); in ice_set_priv_flags()
1759 set_bit(priv_flag->bitno, pf->flags); in ice_set_priv_flags()
1761 clear_bit(priv_flag->bitno, pf->flags); in ice_set_priv_flags()
1764 bitmap_xor(change_flags, pf->flags, orig_flags, ICE_PF_FLAGS_NBITS); in ice_set_priv_flags()
1766 /* Do not allow change to link-down-on-close when Total Port Shutdown in ice_set_priv_flags()
1770 test_bit(ICE_FLAG_TOTAL_PORT_SHUTDOWN_ENA, pf->flags)) { in ice_set_priv_flags()
1771 dev_err(dev, "Setting link-down-on-close not supported on this port\n"); in ice_set_priv_flags()
1772 set_bit(ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA, pf->flags); in ice_set_priv_flags()
1773 ret = -EINVAL; in ice_set_priv_flags()
1778 if (!test_bit(ICE_FLAG_FW_LLDP_AGENT, pf->flags)) { in ice_set_priv_flags()
1782 status = ice_cfg_lldp_mib_change(&pf->hw, false); in ice_set_priv_flags()
1794 status = ice_aq_stop_lldp(&pf->hw, true, true, NULL); in ice_set_priv_flags()
1805 pf->dcbx_cap &= ~DCB_CAP_DCBX_LLD_MANAGED; in ice_set_priv_flags()
1806 pf->dcbx_cap |= DCB_CAP_DCBX_HOST; in ice_set_priv_flags()
1812 clear_bit(ICE_FLAG_FW_LLDP_AGENT, pf->flags); in ice_set_priv_flags()
1814 ret = -EOPNOTSUPP; in ice_set_priv_flags()
1826 status = ice_aq_start_lldp(&pf->hw, true, NULL); in ice_set_priv_flags()
1833 status = ice_aq_start_stop_dcbx(&pf->hw, true, in ice_set_priv_flags()
1852 status = ice_cfg_lldp_mib_change(&pf->hw, true); in ice_set_priv_flags()
1856 pf->dcbx_cap &= ~DCB_CAP_DCBX_HOST; in ice_set_priv_flags()
1857 pf->dcbx_cap |= DCB_CAP_DCBX_LLD_MANAGED; in ice_set_priv_flags()
1871 …dev_err(dev, "Changing vf-true-promisc-support flag while VF(s) are in promiscuous mode not suppor… in ice_set_priv_flags()
1873 change_bit(ICE_FLAG_VF_TRUE_PROMISC_ENA, pf->flags); in ice_set_priv_flags()
1874 ret = -EAGAIN; in ice_set_priv_flags()
1879 dev_err(dev, "vf-vlan-pruning: VLAN pruning cannot be changed while VFs are active.\n"); in ice_set_priv_flags()
1881 change_bit(ICE_FLAG_VF_VLAN_PRUNING, pf->flags); in ice_set_priv_flags()
1882 ret = -EOPNOTSUPP; in ice_set_priv_flags()
1885 clear_bit(ICE_FLAG_ETHTOOL_CTXT, pf->flags); in ice_set_priv_flags()
1904 * undefined memory access or incorrect string<->value in ice_get_sset_count()
1917 return -EOPNOTSUPP; in ice_get_sset_count()
1926 struct ice_pf *pf = vsi->back; in __ice_get_ethtool_stats()
1949 tx_ring = READ_ONCE(vsi->tx_rings[j]); in __ice_get_ethtool_stats()
1950 if (tx_ring && tx_ring->ring_stats) { in __ice_get_ethtool_stats()
1951 data[i++] = tx_ring->ring_stats->stats.pkts; in __ice_get_ethtool_stats()
1952 data[i++] = tx_ring->ring_stats->stats.bytes; in __ice_get_ethtool_stats()
1960 rx_ring = READ_ONCE(vsi->rx_rings[j]); in __ice_get_ethtool_stats()
1961 if (rx_ring && rx_ring->ring_stats) { in __ice_get_ethtool_stats()
1962 data[i++] = rx_ring->ring_stats->stats.pkts; in __ice_get_ethtool_stats()
1963 data[i++] = rx_ring->ring_stats->stats.bytes; in __ice_get_ethtool_stats()
1972 if (vsi->type != ICE_VSI_PF) in __ice_get_ethtool_stats()
1982 data[i++] = pf->stats.priority_xon_tx[j]; in __ice_get_ethtool_stats()
1983 data[i++] = pf->stats.priority_xoff_tx[j]; in __ice_get_ethtool_stats()
1987 data[i++] = pf->stats.priority_xon_rx[j]; in __ice_get_ethtool_stats()
1988 data[i++] = pf->stats.priority_xoff_rx[j]; in __ice_get_ethtool_stats()
1998 __ice_get_ethtool_stats(netdev, stats, data, np->vsi); in ice_get_ethtool_stats()
2075 * ice_linkmode_set_bit - set link mode bit
2087 linkmode_set_bit(phy_to_ethtool->link_mode, ks->link_modes.supported); in ice_linkmode_set_bit()
2089 if (req_speeds & phy_to_ethtool->aq_link_speed || in ice_linkmode_set_bit()
2091 linkmode_set_bit(phy_to_ethtool->link_mode, in ice_linkmode_set_bit()
2092 ks->link_modes.advertising); in ice_linkmode_set_bit()
2096 * ice_phy_type_to_ethtool - convert the phy_types to ethtool link modes
2105 struct ice_vsi *vsi = np->vsi; in ice_phy_type_to_ethtool()
2106 struct ice_pf *pf = vsi->back; in ice_phy_type_to_ethtool()
2114 req_speeds = vsi->port_info->phy.link_info.req_speeds; in ice_phy_type_to_ethtool()
2119 * media. The Advertising link mode is either 1. the user requested in ice_phy_type_to_ethtool()
2123 * and Advertising link modes are the media PHY type or the speed in ice_phy_type_to_ethtool()
2126 if (test_bit(ICE_FLAG_LINK_LENIENT_MODE_ENA, pf->flags)) { in ice_phy_type_to_ethtool()
2127 phy_types_low = le64_to_cpu(pf->nvm_phy_type_lo); in ice_phy_type_to_ethtool()
2128 phy_types_high = le64_to_cpu(pf->nvm_phy_type_hi); in ice_phy_type_to_ethtool()
2130 ice_mask_min_supported_speeds(&pf->hw, phy_types_high, in ice_phy_type_to_ethtool()
2136 if (ice_fw_supports_link_override(&pf->hw) && in ice_phy_type_to_ethtool()
2137 !ice_fw_supports_report_dflt_cfg(&pf->hw)) { in ice_phy_type_to_ethtool()
2140 ldo = &pf->link_dflt_override; in ice_phy_type_to_ethtool()
2142 * Advertising link mode is the intersection of the PHY in ice_phy_type_to_ethtool()
2145 if (ldo->options & ICE_LINK_OVERRIDE_EN && in ice_phy_type_to_ethtool()
2146 (ldo->phy_type_low || ldo->phy_type_high)) { in ice_phy_type_to_ethtool()
2148 le64_to_cpu(pf->nvm_phy_type_lo) & in ice_phy_type_to_ethtool()
2149 ldo->phy_type_low; in ice_phy_type_to_ethtool()
2151 le64_to_cpu(pf->nvm_phy_type_hi) & in ice_phy_type_to_ethtool()
2152 ldo->phy_type_high; in ice_phy_type_to_ethtool()
2157 phy_types_low = vsi->port_info->phy.phy_type_low; in ice_phy_type_to_ethtool()
2158 phy_types_high = vsi->port_info->phy.phy_type_high; in ice_phy_type_to_ethtool()
2161 /* If Advertising link mode PHY type is not using override PHY type, in ice_phy_type_to_ethtool()
2165 advert_phy_type_lo = vsi->port_info->phy.phy_type_low; in ice_phy_type_to_ethtool()
2166 advert_phy_type_hi = vsi->port_info->phy.phy_type_high; in ice_phy_type_to_ethtool()
2169 linkmode_zero(ks->link_modes.supported); in ice_phy_type_to_ethtool()
2170 linkmode_zero(ks->link_modes.advertising); in ice_phy_type_to_ethtool()
2192 * ice_get_settings_link_up - Get Link settings for when link is up
2201 struct ice_port_info *pi = np->vsi->port_info; in ice_get_settings_link_up()
2203 struct ice_vsi *vsi = np->vsi; in ice_get_settings_link_up()
2205 link_info = &vsi->port_info->phy.link_info; in ice_get_settings_link_up()
2210 switch (link_info->link_speed) { in ice_get_settings_link_up()
2212 ks->base.speed = SPEED_200000; in ice_get_settings_link_up()
2215 ks->base.speed = SPEED_100000; in ice_get_settings_link_up()
2218 ks->base.speed = SPEED_50000; in ice_get_settings_link_up()
2221 ks->base.speed = SPEED_40000; in ice_get_settings_link_up()
2224 ks->base.speed = SPEED_25000; in ice_get_settings_link_up()
2227 ks->base.speed = SPEED_20000; in ice_get_settings_link_up()
2230 ks->base.speed = SPEED_10000; in ice_get_settings_link_up()
2233 ks->base.speed = SPEED_5000; in ice_get_settings_link_up()
2236 ks->base.speed = SPEED_2500; in ice_get_settings_link_up()
2239 ks->base.speed = SPEED_1000; in ice_get_settings_link_up()
2242 ks->base.speed = SPEED_100; in ice_get_settings_link_up()
2246 link_info->link_speed); in ice_get_settings_link_up()
2249 ks->base.duplex = DUPLEX_FULL; in ice_get_settings_link_up()
2251 if (link_info->an_info & ICE_AQ_AN_COMPLETED) in ice_get_settings_link_up()
2256 switch (pi->fc.current_mode) { in ice_get_settings_link_up()
2279 * ice_get_settings_link_down - Get the Link settings when link is down
2295 ks->base.speed = SPEED_UNKNOWN; in ice_get_settings_link_down()
2296 ks->base.duplex = DUPLEX_UNKNOWN; in ice_get_settings_link_down()
2300 * ice_get_link_ksettings - Get Link Speed and Duplex settings
2313 struct ice_vsi *vsi = np->vsi; in ice_get_link_ksettings()
2317 ethtool_link_ksettings_zero_link_mode(ks, advertising); in ice_get_link_ksettings()
2319 hw_link_info = &vsi->port_info->phy.link_info; in ice_get_link_ksettings()
2322 if (hw_link_info->link_info & ICE_AQ_LINK_UP) in ice_get_link_ksettings()
2328 ks->base.autoneg = (hw_link_info->an_info & ICE_AQ_AN_COMPLETED) ? in ice_get_link_ksettings()
2332 switch (vsi->port_info->phy.media_type) { in ice_get_link_ksettings()
2335 ks->base.port = PORT_FIBRE; in ice_get_link_ksettings()
2339 ethtool_link_ksettings_add_link_mode(ks, advertising, TP); in ice_get_link_ksettings()
2340 ks->base.port = PORT_TP; in ice_get_link_ksettings()
2344 ethtool_link_ksettings_add_link_mode(ks, advertising, in ice_get_link_ksettings()
2346 ks->base.port = PORT_NONE; in ice_get_link_ksettings()
2350 ethtool_link_ksettings_add_link_mode(ks, advertising, FIBRE); in ice_get_link_ksettings()
2351 ks->base.port = PORT_DA; in ice_get_link_ksettings()
2354 ks->base.port = PORT_OTHER; in ice_get_link_ksettings()
2363 return -ENOMEM; in ice_get_link_ksettings()
2365 err = ice_aq_get_phy_caps(vsi->port_info, false, in ice_get_link_ksettings()
2371 if ((caps->caps & ICE_AQC_PHY_EN_TX_LINK_PAUSE) && in ice_get_link_ksettings()
2372 (caps->caps & ICE_AQC_PHY_EN_RX_LINK_PAUSE)) { in ice_get_link_ksettings()
2373 ethtool_link_ksettings_add_link_mode(ks, advertising, Pause); in ice_get_link_ksettings()
2374 ethtool_link_ksettings_add_link_mode(ks, advertising, in ice_get_link_ksettings()
2376 } else if (caps->caps & ICE_AQC_PHY_EN_TX_LINK_PAUSE) { in ice_get_link_ksettings()
2377 ethtool_link_ksettings_add_link_mode(ks, advertising, in ice_get_link_ksettings()
2379 } else if (caps->caps & ICE_AQC_PHY_EN_RX_LINK_PAUSE) { in ice_get_link_ksettings()
2380 ethtool_link_ksettings_add_link_mode(ks, advertising, Pause); in ice_get_link_ksettings()
2381 ethtool_link_ksettings_add_link_mode(ks, advertising, in ice_get_link_ksettings()
2384 ethtool_link_ksettings_del_link_mode(ks, advertising, Pause); in ice_get_link_ksettings()
2385 ethtool_link_ksettings_del_link_mode(ks, advertising, in ice_get_link_ksettings()
2390 ethtool_link_ksettings_add_link_mode(ks, advertising, FEC_NONE); in ice_get_link_ksettings()
2392 if (caps->link_fec_options & ICE_AQC_PHY_FEC_10G_KR_40G_KR4_REQ || in ice_get_link_ksettings()
2393 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_KR_REQ) in ice_get_link_ksettings()
2394 ethtool_link_ksettings_add_link_mode(ks, advertising, in ice_get_link_ksettings()
2396 if (caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_528_REQ || in ice_get_link_ksettings()
2397 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_544_REQ) in ice_get_link_ksettings()
2398 ethtool_link_ksettings_add_link_mode(ks, advertising, FEC_RS); in ice_get_link_ksettings()
2400 err = ice_aq_get_phy_caps(vsi->port_info, false, in ice_get_link_ksettings()
2408 if (caps->link_fec_options & ICE_AQC_PHY_FEC_10G_KR_40G_KR4_EN || in ice_get_link_ksettings()
2409 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_KR_CLAUSE74_EN) in ice_get_link_ksettings()
2411 if (caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_CLAUSE91_EN) in ice_get_link_ksettings()
2417 ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg); in ice_get_link_ksettings()
2426 * ice_speed_to_aq_link - Get AQ link speed by Ethtool forced speed
2475 * ice_ksettings_find_adv_link_speed - Find advertising link speed
2486 if (linkmode_intersects(ks->link_modes.advertising, map->caps)) in ice_ksettings_find_adv_link_speed()
2487 adv_link_speed |= ice_speed_to_aq_link(map->speed); in ice_ksettings_find_adv_link_speed()
2517 if (!(p->phy.link_info.an_info & ICE_AQ_AN_COMPLETED)) { in ice_setup_autoneg()
2523 err = -EINVAL; in ice_setup_autoneg()
2526 config->caps |= ICE_AQ_PHY_ENA_AUTO_LINK_UPDT; in ice_setup_autoneg()
2532 if (p->phy.link_info.an_info & ICE_AQ_AN_COMPLETED) { in ice_setup_autoneg()
2540 err = -EINVAL; in ice_setup_autoneg()
2543 config->caps &= ~ICE_AQ_PHY_ENA_AUTO_LINK_UPDT; in ice_setup_autoneg()
2553 * ice_set_phy_type_from_speed - set phy_types based on speeds
2571 if (ethtool_link_ksettings_test_link_mode(ks, advertising, in ice_set_phy_type_from_speed()
2576 if (ethtool_link_ksettings_test_link_mode(ks, advertising, in ice_set_phy_type_from_speed()
2580 if (ethtool_link_ksettings_test_link_mode(ks, advertising, in ice_set_phy_type_from_speed()
2589 * ice_set_link_ksettings - Set Speed and Duplex
2606 struct ice_pf *pf = np->vsi->back; in ice_set_link_ksettings()
2614 pi = np->vsi->port_info; in ice_set_link_ksettings()
2617 return -EIO; in ice_set_link_ksettings()
2619 if (pi->phy.media_type != ICE_MEDIA_BASET && in ice_set_link_ksettings()
2620 pi->phy.media_type != ICE_MEDIA_FIBER && in ice_set_link_ksettings()
2621 pi->phy.media_type != ICE_MEDIA_BACKPLANE && in ice_set_link_ksettings()
2622 pi->phy.media_type != ICE_MEDIA_DA && in ice_set_link_ksettings()
2623 pi->phy.link_info.link_info & ICE_AQ_LINK_UP) in ice_set_link_ksettings()
2624 return -EOPNOTSUPP; in ice_set_link_ksettings()
2628 return -ENOMEM; in ice_set_link_ksettings()
2631 if (ice_fw_supports_report_dflt_cfg(pi->hw)) in ice_set_link_ksettings()
2649 if (!bitmap_subset(copy_ks.link_modes.advertising, in ice_set_link_ksettings()
2652 if (!test_bit(ICE_FLAG_LINK_LENIENT_MODE_ENA, pf->flags)) in ice_set_link_ksettings()
2654 err = -EOPNOTSUPP; in ice_set_link_ksettings()
2674 err = -EOPNOTSUPP; in ice_set_link_ksettings()
2678 while (test_and_set_bit(ICE_CFG_BUSY, pf->state)) { in ice_set_link_ksettings()
2679 timeout--; in ice_set_link_ksettings()
2681 err = -EBUSY; in ice_set_link_ksettings()
2691 config = pi->phy.curr_user_phy_cfg; in ice_set_link_ksettings()
2703 pi->phy.get_link_info = true; in ice_set_link_ksettings()
2708 curr_link_speed = pi->phy.curr_user_speed_req; in ice_set_link_ksettings()
2728 pi->phy.link_info.req_speeds = adv_link_speed; in ice_set_link_ksettings()
2736 err = -EOPNOTSUPP; in ice_set_link_ksettings()
2744 phy_caps->phy_type_high; in ice_set_link_ksettings()
2746 phy_caps->phy_type_low; in ice_set_link_ksettings()
2753 if (test_bit(ICE_FLAG_LINK_LENIENT_MODE_ENA, pf->flags)) { in ice_set_link_ksettings()
2755 pf->nvm_phy_type_hi; in ice_set_link_ksettings()
2757 pf->nvm_phy_type_lo; in ice_set_link_ksettings()
2760 err = -EOPNOTSUPP; in ice_set_link_ksettings()
2766 if (pi->phy.link_info.link_info & ICE_AQ_LINK_UP) { in ice_set_link_ksettings()
2770 ice_print_link_msg(np->vsi, false); in ice_set_link_ksettings()
2776 err = ice_aq_set_phy_cfg(&pf->hw, pi, &config, NULL); in ice_set_link_ksettings()
2783 pi->phy.curr_user_speed_req = adv_link_speed; in ice_set_link_ksettings()
2786 clear_bit(ICE_CFG_BUSY, pf->state); in ice_set_link_ksettings()
2792 * ice_parse_hdrs - parses headers from RSS hash input
2802 switch (nfc->flow_type) { in ice_parse_hdrs()
2864 * ice_parse_hash_flds - parses hash fields from RSS hash input
2875 if (nfc->data & RXH_IP_SRC || nfc->data & RXH_IP_DST) { in ice_parse_hash_flds()
2876 switch (nfc->flow_type) { in ice_parse_hash_flds()
2886 if (nfc->data & RXH_IP_SRC) in ice_parse_hash_flds()
2888 if (nfc->data & RXH_IP_DST) in ice_parse_hash_flds()
2900 if (nfc->data & RXH_IP_SRC) in ice_parse_hash_flds()
2902 if (nfc->data & RXH_IP_DST) in ice_parse_hash_flds()
2910 if (nfc->data & RXH_L4_B_0_1 || nfc->data & RXH_L4_B_2_3) { in ice_parse_hash_flds()
2911 switch (nfc->flow_type) { in ice_parse_hash_flds()
2914 if (nfc->data & RXH_L4_B_0_1) in ice_parse_hash_flds()
2916 if (nfc->data & RXH_L4_B_2_3) in ice_parse_hash_flds()
2921 if (nfc->data & RXH_L4_B_0_1) in ice_parse_hash_flds()
2923 if (nfc->data & RXH_L4_B_2_3) in ice_parse_hash_flds()
2928 if (nfc->data & RXH_L4_B_0_1) in ice_parse_hash_flds()
2930 if (nfc->data & RXH_L4_B_2_3) in ice_parse_hash_flds()
2938 if (nfc->data & RXH_GTP_TEID) { in ice_parse_hash_flds()
2939 switch (nfc->flow_type) { in ice_parse_hash_flds()
2969 * ice_set_rss_hash_opt - Enable/Disable flow types for RSS hash
2978 struct ice_pf *pf = vsi->back; in ice_set_rss_hash_opt()
2989 vsi->vsi_num); in ice_set_rss_hash_opt()
2990 return -EINVAL; in ice_set_rss_hash_opt()
2993 symm = !!(vsi->rss_hfunc == ICE_AQ_VSI_Q_OPT_RSS_HASH_SYM_TPLZ); in ice_set_rss_hash_opt()
2997 vsi->vsi_num); in ice_set_rss_hash_opt()
2998 return -EINVAL; in ice_set_rss_hash_opt()
3004 vsi->vsi_num); in ice_set_rss_hash_opt()
3005 return -EINVAL; in ice_set_rss_hash_opt()
3013 status = ice_add_rss_cfg(&pf->hw, vsi, &cfg); in ice_set_rss_hash_opt()
3016 vsi->vsi_num, status); in ice_set_rss_hash_opt()
3024 * ice_get_rss_hash_opt - Retrieve hash fields for a given flow-type
3031 struct ice_pf *pf = vsi->back; in ice_get_rss_hash_opt()
3039 nfc->data = 0; in ice_get_rss_hash_opt()
3042 vsi->vsi_num); in ice_get_rss_hash_opt()
3049 vsi->vsi_num); in ice_get_rss_hash_opt()
3053 hash_flds = ice_get_rss_cfg(&pf->hw, vsi->idx, hdrs, &symm); in ice_get_rss_hash_opt()
3056 vsi->vsi_num); in ice_get_rss_hash_opt()
3062 nfc->data |= (u64)RXH_IP_SRC; in ice_get_rss_hash_opt()
3066 nfc->data |= (u64)RXH_IP_DST; in ice_get_rss_hash_opt()
3071 nfc->data |= (u64)RXH_L4_B_0_1; in ice_get_rss_hash_opt()
3076 nfc->data |= (u64)RXH_L4_B_2_3; in ice_get_rss_hash_opt()
3083 nfc->data |= (u64)RXH_GTP_TEID; in ice_get_rss_hash_opt()
3087 * ice_set_rxnfc - command to set Rx flow rules.
3096 struct ice_vsi *vsi = np->vsi; in ice_set_rxnfc()
3098 switch (cmd->cmd) { in ice_set_rxnfc()
3108 return -EOPNOTSUPP; in ice_set_rxnfc()
3112 * ice_get_rxnfc - command to get Rx flow classification rules
3124 struct ice_vsi *vsi = np->vsi; in ice_get_rxnfc()
3125 int ret = -EOPNOTSUPP; in ice_get_rxnfc()
3128 hw = &vsi->back->hw; in ice_get_rxnfc()
3130 switch (cmd->cmd) { in ice_get_rxnfc()
3132 cmd->data = vsi->rss_size; in ice_get_rxnfc()
3136 cmd->rule_cnt = hw->fdir_active_fltr; in ice_get_rxnfc()
3138 cmd->data = ice_get_fdir_cnt_all(hw); in ice_get_rxnfc()
3164 struct ice_vsi *vsi = np->vsi; in ice_get_ringparam()
3166 ring->rx_max_pending = ICE_MAX_NUM_DESC; in ice_get_ringparam()
3167 ring->tx_max_pending = ICE_MAX_NUM_DESC; in ice_get_ringparam()
3168 if (vsi->tx_rings && vsi->rx_rings) { in ice_get_ringparam()
3169 ring->rx_pending = vsi->rx_rings[0]->count; in ice_get_ringparam()
3170 ring->tx_pending = vsi->tx_rings[0]->count; in ice_get_ringparam()
3172 ring->rx_pending = 0; in ice_get_ringparam()
3173 ring->tx_pending = 0; in ice_get_ringparam()
3177 ring->rx_mini_max_pending = 0; in ice_get_ringparam()
3178 ring->rx_jumbo_max_pending = 0; in ice_get_ringparam()
3179 ring->rx_mini_pending = 0; in ice_get_ringparam()
3180 ring->rx_jumbo_pending = 0; in ice_get_ringparam()
3192 struct ice_vsi *vsi = np->vsi; in ice_set_ringparam()
3193 struct ice_pf *pf = vsi->back; in ice_set_ringparam()
3197 if (ring->tx_pending > ICE_MAX_NUM_DESC || in ice_set_ringparam()
3198 ring->tx_pending < ICE_MIN_NUM_DESC || in ice_set_ringparam()
3199 ring->rx_pending > ICE_MAX_NUM_DESC || in ice_set_ringparam()
3200 ring->rx_pending < ICE_MIN_NUM_DESC) { in ice_set_ringparam()
3201 …netdev_err(netdev, "Descriptors requested (Tx: %d / Rx: %d) out of range [%d-%d] (increment %d)\n", in ice_set_ringparam()
3202 ring->tx_pending, ring->rx_pending, in ice_set_ringparam()
3205 return -EINVAL; in ice_set_ringparam()
3209 if (!vsi->tx_rings || !vsi->rx_rings) in ice_set_ringparam()
3210 return -EBUSY; in ice_set_ringparam()
3212 new_tx_cnt = ALIGN(ring->tx_pending, ICE_REQ_DESC_MULTIPLE); in ice_set_ringparam()
3213 if (new_tx_cnt != ring->tx_pending) in ice_set_ringparam()
3216 new_rx_cnt = ALIGN(ring->rx_pending, ICE_REQ_DESC_MULTIPLE); in ice_set_ringparam()
3217 if (new_rx_cnt != ring->rx_pending) in ice_set_ringparam()
3222 if (new_tx_cnt == vsi->tx_rings[0]->count && in ice_set_ringparam()
3223 new_rx_cnt == vsi->rx_rings[0]->count) { in ice_set_ringparam()
3229 * disallow changing the number of descriptors -- regardless in ice_set_ringparam()
3233 return -EBUSY; in ice_set_ringparam()
3235 while (test_and_set_bit(ICE_CFG_BUSY, pf->state)) { in ice_set_ringparam()
3236 timeout--; in ice_set_ringparam()
3238 return -EBUSY; in ice_set_ringparam()
3243 if (!netif_running(vsi->netdev)) { in ice_set_ringparam()
3245 vsi->tx_rings[i]->count = new_tx_cnt; in ice_set_ringparam()
3247 vsi->rx_rings[i]->count = new_rx_cnt; in ice_set_ringparam()
3250 vsi->xdp_rings[i]->count = new_tx_cnt; in ice_set_ringparam()
3251 vsi->num_tx_desc = (u16)new_tx_cnt; in ice_set_ringparam()
3252 vsi->num_rx_desc = (u16)new_rx_cnt; in ice_set_ringparam()
3257 if (new_tx_cnt == vsi->tx_rings[0]->count) in ice_set_ringparam()
3262 vsi->tx_rings[0]->count, new_tx_cnt); in ice_set_ringparam()
3264 tx_rings = kcalloc(vsi->num_txq, sizeof(*tx_rings), GFP_KERNEL); in ice_set_ringparam()
3266 err = -ENOMEM; in ice_set_ringparam()
3272 tx_rings[i] = *vsi->tx_rings[i]; in ice_set_ringparam()
3276 tx_rings[i].tx_tstamps = &pf->ptp.port.tx; in ice_set_ringparam()
3279 while (i--) in ice_set_ringparam()
3291 vsi->xdp_rings[0]->count, new_tx_cnt); in ice_set_ringparam()
3293 xdp_rings = kcalloc(vsi->num_xdp_txq, sizeof(*xdp_rings), GFP_KERNEL); in ice_set_ringparam()
3295 err = -ENOMEM; in ice_set_ringparam()
3301 xdp_rings[i] = *vsi->xdp_rings[i]; in ice_set_ringparam()
3307 while (i--) in ice_set_ringparam()
3316 if (new_rx_cnt == vsi->rx_rings[0]->count) in ice_set_ringparam()
3321 vsi->rx_rings[0]->count, new_rx_cnt); in ice_set_ringparam()
3323 rx_rings = kcalloc(vsi->num_rxq, sizeof(*rx_rings), GFP_KERNEL); in ice_set_ringparam()
3325 err = -ENOMEM; in ice_set_ringparam()
3331 rx_rings[i] = *vsi->rx_rings[i]; in ice_set_ringparam()
3333 rx_rings[i].cached_phctime = pf->ptp.cached_phc_time; in ice_set_ringparam()
3339 rx_rings[i].tail = vsi->back->hw.hw_addr + PRTGEN_STATUS; in ice_set_ringparam()
3351 i--; in ice_set_ringparam()
3355 err = -ENOMEM; in ice_set_ringparam()
3364 if (!test_and_set_bit(ICE_VSI_DOWN, vsi->state)) { in ice_set_ringparam()
3369 ice_free_tx_ring(vsi->tx_rings[i]); in ice_set_ringparam()
3370 *vsi->tx_rings[i] = tx_rings[i]; in ice_set_ringparam()
3377 ice_free_rx_ring(vsi->rx_rings[i]); in ice_set_ringparam()
3379 rx_rings[i].tail = vsi->rx_rings[i]->tail; in ice_set_ringparam()
3382 * but the recycling logic will let us re-use in ice_set_ringparam()
3388 *vsi->rx_rings[i] = rx_rings[i]; in ice_set_ringparam()
3395 ice_free_tx_ring(vsi->xdp_rings[i]); in ice_set_ringparam()
3396 *vsi->xdp_rings[i] = xdp_rings[i]; in ice_set_ringparam()
3401 vsi->num_tx_desc = new_tx_cnt; in ice_set_ringparam()
3402 vsi->num_rx_desc = new_rx_cnt; in ice_set_ringparam()
3416 clear_bit(ICE_CFG_BUSY, pf->state); in ice_set_ringparam()
3421 * ice_get_pauseparam - Get Flow Control status
3434 struct ice_port_info *pi = np->vsi->port_info; in ice_get_pauseparam()
3440 pause->rx_pause = 0; in ice_get_pauseparam()
3441 pause->tx_pause = 0; in ice_get_pauseparam()
3443 dcbx_cfg = &pi->qos_cfg.local_dcbx_cfg; in ice_get_pauseparam()
3455 pause->autoneg = ice_is_phy_caps_an_enabled(pcaps) ? AUTONEG_ENABLE : in ice_get_pauseparam()
3458 if (dcbx_cfg->pfc.pfcena) in ice_get_pauseparam()
3462 if (pcaps->caps & ICE_AQC_PHY_EN_TX_LINK_PAUSE) in ice_get_pauseparam()
3463 pause->tx_pause = 1; in ice_get_pauseparam()
3464 if (pcaps->caps & ICE_AQC_PHY_EN_RX_LINK_PAUSE) in ice_get_pauseparam()
3465 pause->rx_pause = 1; in ice_get_pauseparam()
3472 * ice_set_pauseparam - Set Flow Control parameter
3482 struct ice_pf *pf = np->vsi->back; in ice_set_pauseparam()
3484 struct ice_vsi *vsi = np->vsi; in ice_set_pauseparam()
3485 struct ice_hw *hw = &pf->hw; in ice_set_pauseparam()
3492 pi = vsi->port_info; in ice_set_pauseparam()
3493 hw_link_info = &pi->phy.link_info; in ice_set_pauseparam()
3494 dcbx_cfg = &pi->qos_cfg.local_dcbx_cfg; in ice_set_pauseparam()
3495 link_up = hw_link_info->link_info & ICE_AQ_LINK_UP; in ice_set_pauseparam()
3500 if (vsi->type != ICE_VSI_PF) { in ice_set_pauseparam()
3502 return -EOPNOTSUPP; in ice_set_pauseparam()
3507 * defined get pause param pause->autoneg reports SW configured setting, in ice_set_pauseparam()
3508 * so compare pause->autoneg with SW configured to prevent the user from in ice_set_pauseparam()
3513 return -ENOMEM; in ice_set_pauseparam()
3528 if (pause->autoneg != is_an) { in ice_set_pauseparam()
3529 netdev_info(netdev, "To change autoneg please use: ethtool -s <dev> autoneg <on|off>\n"); in ice_set_pauseparam()
3530 return -EOPNOTSUPP; in ice_set_pauseparam()
3534 if (!test_bit(ICE_DOWN, pf->state) && in ice_set_pauseparam()
3535 !(hw_link_info->an_info & ICE_AQ_AN_COMPLETED)) { in ice_set_pauseparam()
3540 if (dcbx_cfg->pfc.pfcena) { in ice_set_pauseparam()
3542 return -EOPNOTSUPP; in ice_set_pauseparam()
3544 if (pause->rx_pause && pause->tx_pause) in ice_set_pauseparam()
3545 pi->fc.req_mode = ICE_FC_FULL; in ice_set_pauseparam()
3546 else if (pause->rx_pause && !pause->tx_pause) in ice_set_pauseparam()
3547 pi->fc.req_mode = ICE_FC_RX_PAUSE; in ice_set_pauseparam()
3548 else if (!pause->rx_pause && pause->tx_pause) in ice_set_pauseparam()
3549 pi->fc.req_mode = ICE_FC_TX_PAUSE; in ice_set_pauseparam()
3550 else if (!pause->rx_pause && !pause->tx_pause) in ice_set_pauseparam()
3551 pi->fc.req_mode = ICE_FC_NONE; in ice_set_pauseparam()
3553 return -EINVAL; in ice_set_pauseparam()
3560 err, ice_aq_str(hw->adminq.sq_last_status)); in ice_set_pauseparam()
3561 err = -EAGAIN; in ice_set_pauseparam()
3564 err, ice_aq_str(hw->adminq.sq_last_status)); in ice_set_pauseparam()
3565 err = -EAGAIN; in ice_set_pauseparam()
3568 err, ice_aq_str(hw->adminq.sq_last_status)); in ice_set_pauseparam()
3569 err = -EAGAIN; in ice_set_pauseparam()
3576 * ice_get_rxfh_key_size - get the RSS hash key size
3587 * ice_get_rxfh_indir_size - get the Rx flow hash indirection table size
3596 return np->vsi->rss_table_size; in ice_get_rxfh_indir_size()
3600 * ice_get_rxfh - get the Rx flow hash indirection table
3610 u32 rss_context = rxfh->rss_context; in ice_get_rxfh()
3611 struct ice_vsi *vsi = np->vsi; in ice_get_rxfh()
3612 struct ice_pf *pf = vsi->back; in ice_get_rxfh()
3617 if (!test_bit(ICE_FLAG_RSS_ENA, pf->flags)) { in ice_get_rxfh()
3619 return -EOPNOTSUPP; in ice_get_rxfh()
3623 netdev_err(netdev, "RSS context cannot be non-zero when ADQ is not configured.\n"); in ice_get_rxfh()
3624 return -EINVAL; in ice_get_rxfh()
3627 qcount = vsi->mqprio_qopt.qopt.count[rss_context]; in ice_get_rxfh()
3628 offset = vsi->mqprio_qopt.qopt.offset[rss_context]; in ice_get_rxfh()
3631 num_tc = vsi->mqprio_qopt.qopt.num_tc; in ice_get_rxfh()
3635 return -EINVAL; in ice_get_rxfh()
3638 vsi = vsi->tc_map_vsi[rss_context]; in ice_get_rxfh()
3641 rxfh->hfunc = ETH_RSS_HASH_TOP; in ice_get_rxfh()
3642 if (vsi->rss_hfunc == ICE_AQ_VSI_Q_OPT_RSS_HASH_SYM_TPLZ) in ice_get_rxfh()
3643 rxfh->input_xfrm |= RXH_XFRM_SYM_XOR; in ice_get_rxfh()
3645 if (!rxfh->indir) in ice_get_rxfh()
3648 lut = kzalloc(vsi->rss_table_size, GFP_KERNEL); in ice_get_rxfh()
3650 return -ENOMEM; in ice_get_rxfh()
3652 err = ice_get_rss_key(vsi, rxfh->key); in ice_get_rxfh()
3656 err = ice_get_rss_lut(vsi, lut, vsi->rss_table_size); in ice_get_rxfh()
3661 for (i = 0; i < vsi->rss_table_size; i++) in ice_get_rxfh()
3662 rxfh->indir[i] = offset + lut[i] % qcount; in ice_get_rxfh()
3666 for (i = 0; i < vsi->rss_table_size; i++) in ice_get_rxfh()
3667 rxfh->indir[i] = lut[i]; in ice_get_rxfh()
3675 * ice_set_rxfh - set the Rx flow hash indirection table
3680 * Returns -EINVAL if the table specifies an invalid queue ID, otherwise
3689 struct ice_vsi *vsi = np->vsi; in ice_set_rxfh()
3690 struct ice_pf *pf = vsi->back; in ice_set_rxfh()
3695 if (rxfh->hfunc != ETH_RSS_HASH_NO_CHANGE && in ice_set_rxfh()
3696 rxfh->hfunc != ETH_RSS_HASH_TOP) in ice_set_rxfh()
3697 return -EOPNOTSUPP; in ice_set_rxfh()
3699 if (rxfh->rss_context) in ice_set_rxfh()
3700 return -EOPNOTSUPP; in ice_set_rxfh()
3702 if (!test_bit(ICE_FLAG_RSS_ENA, pf->flags)) { in ice_set_rxfh()
3705 return -EIO; in ice_set_rxfh()
3710 return -EOPNOTSUPP; in ice_set_rxfh()
3714 if (rxfh->input_xfrm & RXH_XFRM_SYM_XOR) in ice_set_rxfh()
3721 if (rxfh->key) { in ice_set_rxfh()
3722 if (!vsi->rss_hkey_user) { in ice_set_rxfh()
3723 vsi->rss_hkey_user = in ice_set_rxfh()
3726 if (!vsi->rss_hkey_user) in ice_set_rxfh()
3727 return -ENOMEM; in ice_set_rxfh()
3729 memcpy(vsi->rss_hkey_user, rxfh->key, in ice_set_rxfh()
3732 err = ice_set_rss_key(vsi, vsi->rss_hkey_user); in ice_set_rxfh()
3737 if (!vsi->rss_lut_user) { in ice_set_rxfh()
3738 vsi->rss_lut_user = devm_kzalloc(dev, vsi->rss_table_size, in ice_set_rxfh()
3740 if (!vsi->rss_lut_user) in ice_set_rxfh()
3741 return -ENOMEM; in ice_set_rxfh()
3745 if (rxfh->indir) { in ice_set_rxfh()
3748 for (i = 0; i < vsi->rss_table_size; i++) in ice_set_rxfh()
3749 vsi->rss_lut_user[i] = (u8)(rxfh->indir[i]); in ice_set_rxfh()
3751 ice_fill_rss_lut(vsi->rss_lut_user, vsi->rss_table_size, in ice_set_rxfh()
3752 vsi->rss_size); in ice_set_rxfh()
3755 err = ice_set_rss_lut(vsi, vsi->rss_lut_user, vsi->rss_table_size); in ice_set_rxfh()
3768 if (pf->ptp.state != ICE_PTP_READY) in ice_get_ts_info()
3771 info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE | in ice_get_ts_info()
3776 info->phc_index = ice_ptp_clock_index(pf); in ice_get_ts_info()
3778 info->tx_types = BIT(HWTSTAMP_TX_OFF) | BIT(HWTSTAMP_TX_ON); in ice_get_ts_info()
3780 info->rx_filters = BIT(HWTSTAMP_FILTER_NONE) | BIT(HWTSTAMP_FILTER_ALL); in ice_get_ts_info()
3786 * ice_get_max_txq - return the maximum number of Tx queues for in a PF
3791 return min3(pf->num_lan_msix, (u16)num_online_cpus(), in ice_get_max_txq()
3792 (u16)pf->hw.func_caps.common_cap.num_txq); in ice_get_max_txq()
3796 * ice_get_max_rxq - return the maximum number of Rx queues for in a PF
3801 return min3(pf->num_lan_msix, (u16)num_online_cpus(), in ice_get_max_rxq()
3802 (u16)pf->hw.func_caps.common_cap.num_rxq); in ice_get_max_rxq()
3806 * ice_get_combined_cnt - return the current number of combined channels
3818 struct ice_q_vector *q_vector = vsi->q_vectors[q_idx]; in ice_get_combined_cnt()
3820 if (q_vector->rx.rx_ring && q_vector->tx.tx_ring) in ice_get_combined_cnt()
3828 * ice_get_channels - get the current and max supported channels
3836 struct ice_vsi *vsi = np->vsi; in ice_get_channels()
3837 struct ice_pf *pf = vsi->back; in ice_get_channels()
3840 ch->max_rx = ice_get_max_rxq(pf); in ice_get_channels()
3841 ch->max_tx = ice_get_max_txq(pf); in ice_get_channels()
3842 ch->max_combined = min_t(int, ch->max_rx, ch->max_tx); in ice_get_channels()
3845 ch->combined_count = ice_get_combined_cnt(vsi); in ice_get_channels()
3846 ch->rx_count = vsi->num_rxq - ch->combined_count; in ice_get_channels()
3847 ch->tx_count = vsi->num_txq - ch->combined_count; in ice_get_channels()
3850 ch->other_count = test_bit(ICE_FLAG_FD_ENA, pf->flags) ? 1 : 0; in ice_get_channels()
3851 ch->max_other = ch->other_count; in ice_get_channels()
3855 * ice_get_valid_rss_size - return valid number of RSS queues
3861 struct ice_hw_common_caps *caps = &hw->func_caps.common_cap; in ice_get_valid_rss_size()
3863 return min_t(int, new_size, BIT(caps->rss_table_entry_width)); in ice_get_valid_rss_size()
3867 * ice_vsi_set_dflt_rss_lut - set default RSS LUT with requested RSS size
3875 struct ice_pf *pf = vsi->back; in ice_vsi_set_dflt_rss_lut()
3882 hw = &pf->hw; in ice_vsi_set_dflt_rss_lut()
3885 return -EINVAL; in ice_vsi_set_dflt_rss_lut()
3887 lut = kzalloc(vsi->rss_table_size, GFP_KERNEL); in ice_vsi_set_dflt_rss_lut()
3889 return -ENOMEM; in ice_vsi_set_dflt_rss_lut()
3892 if (!test_bit(ICE_FLAG_RSS_ENA, pf->flags)) in ice_vsi_set_dflt_rss_lut()
3893 vsi->rss_size = 1; in ice_vsi_set_dflt_rss_lut()
3895 vsi->rss_size = ice_get_valid_rss_size(hw, req_rss_size); in ice_vsi_set_dflt_rss_lut()
3898 ice_fill_rss_lut(lut, vsi->rss_table_size, vsi->rss_size); in ice_vsi_set_dflt_rss_lut()
3899 err = ice_set_rss_lut(vsi, lut, vsi->rss_table_size); in ice_vsi_set_dflt_rss_lut()
3902 ice_aq_str(hw->adminq.sq_last_status)); in ice_vsi_set_dflt_rss_lut()
3909 * ice_set_channels - set the number channels
3916 struct ice_vsi *vsi = np->vsi; in ice_set_channels()
3917 struct ice_pf *pf = vsi->back; in ice_set_channels()
3925 return -EOPNOTSUPP; in ice_set_channels()
3928 if (ch->other_count != (test_bit(ICE_FLAG_FD_ENA, pf->flags) ? 1U : 0U)) in ice_set_channels()
3929 return -EINVAL; in ice_set_channels()
3933 return -EOPNOTSUPP; in ice_set_channels()
3936 if (test_bit(ICE_FLAG_FD_ENA, pf->flags) && pf->hw.fdir_active_fltr) { in ice_set_channels()
3938 return -EOPNOTSUPP; in ice_set_channels()
3941 if (ch->rx_count && ch->tx_count) { in ice_set_channels()
3943 return -EINVAL; in ice_set_channels()
3946 new_rx = ch->combined_count + ch->rx_count; in ice_set_channels()
3947 new_tx = ch->combined_count + ch->tx_count; in ice_set_channels()
3949 if (new_rx < vsi->tc_cfg.numtc) { in ice_set_channels()
3951 vsi->tc_cfg.numtc); in ice_set_channels()
3952 return -EINVAL; in ice_set_channels()
3954 if (new_tx < vsi->tc_cfg.numtc) { in ice_set_channels()
3956 vsi->tc_cfg.numtc); in ice_set_channels()
3957 return -EINVAL; in ice_set_channels()
3962 return -EINVAL; in ice_set_channels()
3967 return -EINVAL; in ice_set_channels()
3970 if (pf->adev) { in ice_set_channels()
3971 mutex_lock(&pf->adev_mutex); in ice_set_channels()
3972 device_lock(&pf->adev->dev); in ice_set_channels()
3974 if (pf->adev->dev.driver) { in ice_set_channels()
3976 ret = -EBUSY; in ice_set_channels()
3989 vsi->rss_size = ice_get_valid_rss_size(&pf->hw, new_rx); in ice_set_channels()
3993 device_unlock(&pf->adev->dev); in ice_set_channels()
3994 mutex_unlock(&pf->adev_mutex); in ice_set_channels()
4000 * ice_get_wol - get current Wake on LAN configuration
4007 struct ice_pf *pf = np->vsi->back; in ice_get_wol()
4009 if (np->vsi->type != ICE_VSI_PF) in ice_get_wol()
4013 if (ice_is_wol_supported(&pf->hw)) { in ice_get_wol()
4014 wol->supported = WAKE_MAGIC; in ice_get_wol()
4015 wol->wolopts = pf->wol_ena ? WAKE_MAGIC : 0; in ice_get_wol()
4017 wol->supported = 0; in ice_get_wol()
4018 wol->wolopts = 0; in ice_get_wol()
4023 * ice_set_wol - set Wake on LAN on supported device
4030 struct ice_vsi *vsi = np->vsi; in ice_set_wol()
4031 struct ice_pf *pf = vsi->back; in ice_set_wol()
4033 if (vsi->type != ICE_VSI_PF || !ice_is_wol_supported(&pf->hw)) in ice_set_wol()
4034 return -EOPNOTSUPP; in ice_set_wol()
4037 if (wol->wolopts && wol->wolopts != WAKE_MAGIC) in ice_set_wol()
4038 return -EOPNOTSUPP; in ice_set_wol()
4041 if (pf->wol_ena != !!wol->wolopts) { in ice_set_wol()
4042 pf->wol_ena = !!wol->wolopts; in ice_set_wol()
4043 device_set_wakeup_enable(ice_pf_to_dev(pf), pf->wol_ena); in ice_set_wol()
4045 pf->wol_ena ? "en" : "dis"); in ice_set_wol()
4052 * ice_get_rc_coalesce - get ITR values for specific ring container
4065 if (!rc->rx_ring) in ice_get_rc_coalesce()
4066 return -EINVAL; in ice_get_rc_coalesce()
4068 switch (rc->type) { in ice_get_rc_coalesce()
4070 ec->use_adaptive_rx_coalesce = ITR_IS_DYNAMIC(rc); in ice_get_rc_coalesce()
4071 ec->rx_coalesce_usecs = rc->itr_setting; in ice_get_rc_coalesce()
4072 ec->rx_coalesce_usecs_high = rc->rx_ring->q_vector->intrl; in ice_get_rc_coalesce()
4075 ec->use_adaptive_tx_coalesce = ITR_IS_DYNAMIC(rc); in ice_get_rc_coalesce()
4076 ec->tx_coalesce_usecs = rc->itr_setting; in ice_get_rc_coalesce()
4079 dev_dbg(ice_pf_to_dev(rc->rx_ring->vsi->back), "Invalid c_type %d\n", rc->type); in ice_get_rc_coalesce()
4080 return -EINVAL; in ice_get_rc_coalesce()
4087 * ice_get_q_coalesce - get a queue's ITR/INTRL (coalesce) settings
4099 if (q_num < vsi->num_rxq && q_num < vsi->num_txq) { in ice_get_q_coalesce()
4101 &vsi->rx_rings[q_num]->q_vector->rx)) in ice_get_q_coalesce()
4102 return -EINVAL; in ice_get_q_coalesce()
4104 &vsi->tx_rings[q_num]->q_vector->tx)) in ice_get_q_coalesce()
4105 return -EINVAL; in ice_get_q_coalesce()
4106 } else if (q_num < vsi->num_rxq) { in ice_get_q_coalesce()
4108 &vsi->rx_rings[q_num]->q_vector->rx)) in ice_get_q_coalesce()
4109 return -EINVAL; in ice_get_q_coalesce()
4110 } else if (q_num < vsi->num_txq) { in ice_get_q_coalesce()
4112 &vsi->tx_rings[q_num]->q_vector->tx)) in ice_get_q_coalesce()
4113 return -EINVAL; in ice_get_q_coalesce()
4115 return -EINVAL; in ice_get_q_coalesce()
4122 * __ice_get_coalesce - get ITR/INTRL values for the device
4135 struct ice_vsi *vsi = np->vsi; in __ice_get_coalesce()
4141 return -EINVAL; in __ice_get_coalesce()
4151 return __ice_get_coalesce(netdev, ec, -1); in ice_get_coalesce()
4162 * ice_set_rc_coalesce - set ITR values for specific ring container
4177 const char *c_type_str = (rc->type == ICE_RX_CONTAINER) ? "rx" : "tx"; in ice_set_rc_coalesce()
4179 struct ice_pf *pf = vsi->back; in ice_set_rc_coalesce()
4182 if (!rc->rx_ring) in ice_set_rc_coalesce()
4183 return -EINVAL; in ice_set_rc_coalesce()
4185 switch (rc->type) { in ice_set_rc_coalesce()
4188 struct ice_q_vector *q_vector = rc->rx_ring->q_vector; in ice_set_rc_coalesce()
4190 if (ec->rx_coalesce_usecs_high > ICE_MAX_INTRL || in ice_set_rc_coalesce()
4191 (ec->rx_coalesce_usecs_high && in ice_set_rc_coalesce()
4192 ec->rx_coalesce_usecs_high < pf->hw.intrl_gran)) { in ice_set_rc_coalesce()
4193 netdev_info(vsi->netdev, "Invalid value, %s-usecs-high valid values are 0 (disabled), %d-%d\n", in ice_set_rc_coalesce()
4194 c_type_str, pf->hw.intrl_gran, in ice_set_rc_coalesce()
4196 return -EINVAL; in ice_set_rc_coalesce()
4198 if (ec->rx_coalesce_usecs_high != q_vector->intrl && in ice_set_rc_coalesce()
4199 (ec->use_adaptive_rx_coalesce || ec->use_adaptive_tx_coalesce)) { in ice_set_rc_coalesce()
4200 …netdev_info(vsi->netdev, "Invalid value, %s-usecs-high cannot be changed if adaptive-tx or adaptiv… in ice_set_rc_coalesce()
4202 return -EINVAL; in ice_set_rc_coalesce()
4204 if (ec->rx_coalesce_usecs_high != q_vector->intrl) in ice_set_rc_coalesce()
4205 q_vector->intrl = ec->rx_coalesce_usecs_high; in ice_set_rc_coalesce()
4207 use_adaptive_coalesce = ec->use_adaptive_rx_coalesce; in ice_set_rc_coalesce()
4208 coalesce_usecs = ec->rx_coalesce_usecs; in ice_set_rc_coalesce()
4213 use_adaptive_coalesce = ec->use_adaptive_tx_coalesce; in ice_set_rc_coalesce()
4214 coalesce_usecs = ec->tx_coalesce_usecs; in ice_set_rc_coalesce()
4219 rc->type); in ice_set_rc_coalesce()
4220 return -EINVAL; in ice_set_rc_coalesce()
4223 itr_setting = rc->itr_setting; in ice_set_rc_coalesce()
4225 netdev_info(vsi->netdev, "%s interrupt throttling cannot be changed if adaptive-%s is enabled\n", in ice_set_rc_coalesce()
4227 return -EINVAL; in ice_set_rc_coalesce()
4231 netdev_info(vsi->netdev, "Invalid value, %s-usecs range is 0-%d\n", in ice_set_rc_coalesce()
4233 return -EINVAL; in ice_set_rc_coalesce()
4237 rc->itr_mode = ITR_DYNAMIC; in ice_set_rc_coalesce()
4239 rc->itr_mode = ITR_STATIC; in ice_set_rc_coalesce()
4241 rc->itr_setting = coalesce_usecs; in ice_set_rc_coalesce()
4248 ice_flush(&pf->hw); in ice_set_rc_coalesce()
4255 * ice_set_q_coalesce - set a queue's ITR/INTRL (coalesce) settings
4267 if (q_num < vsi->num_rxq && q_num < vsi->num_txq) { in ice_set_q_coalesce()
4269 &vsi->rx_rings[q_num]->q_vector->rx, in ice_set_q_coalesce()
4271 return -EINVAL; in ice_set_q_coalesce()
4274 &vsi->tx_rings[q_num]->q_vector->tx, in ice_set_q_coalesce()
4276 return -EINVAL; in ice_set_q_coalesce()
4277 } else if (q_num < vsi->num_rxq) { in ice_set_q_coalesce()
4279 &vsi->rx_rings[q_num]->q_vector->rx, in ice_set_q_coalesce()
4281 return -EINVAL; in ice_set_q_coalesce()
4282 } else if (q_num < vsi->num_txq) { in ice_set_q_coalesce()
4284 &vsi->tx_rings[q_num]->q_vector->tx, in ice_set_q_coalesce()
4286 return -EINVAL; in ice_set_q_coalesce()
4288 return -EINVAL; in ice_set_q_coalesce()
4295 * ice_print_if_odd_usecs - print message if user tries to set odd [tx|rx]-usecs
4299 * @coalesce_usecs: requested value of [tx|rx]-usecs
4300 * @c_type_str: either "rx" or "tx" to match user set field of [tx|rx]-usecs
4311 …netdev_info(netdev, "User set %s-usecs to %d, device only supports even values. Rounding down and … in ice_print_if_odd_usecs()
4317 * __ice_set_coalesce - set ITR/INTRL values for the device
4330 struct ice_vsi *vsi = np->vsi; in __ice_set_coalesce()
4333 struct ice_q_vector *q_vector = vsi->q_vectors[0]; in __ice_set_coalesce()
4337 ice_print_if_odd_usecs(netdev, q_vector->rx.itr_setting, in __ice_set_coalesce()
4338 ec->use_adaptive_rx_coalesce, in __ice_set_coalesce()
4339 ec->rx_coalesce_usecs, "rx"); in __ice_set_coalesce()
4341 ice_print_if_odd_usecs(netdev, q_vector->tx.itr_setting, in __ice_set_coalesce()
4342 ec->use_adaptive_tx_coalesce, in __ice_set_coalesce()
4343 ec->tx_coalesce_usecs, "tx"); in __ice_set_coalesce()
4348 * can be less than vsi->num_q_vectors. This check in __ice_set_coalesce()
4351 if (v_idx >= vsi->num_rxq && v_idx >= vsi->num_txq) in __ice_set_coalesce()
4355 return -EINVAL; in __ice_set_coalesce()
4357 ice_set_q_vector_intrl(vsi->q_vectors[v_idx]); in __ice_set_coalesce()
4363 return -EINVAL; in __ice_set_coalesce()
4365 ice_set_q_vector_intrl(vsi->q_vectors[q_num]); in __ice_set_coalesce()
4376 return __ice_set_coalesce(netdev, ec, -1); in ice_set_coalesce()
4392 if (repr->ops.ready(repr)) in ice_repr_get_drvinfo()
4395 __ice_get_drvinfo(netdev, drvinfo, repr->src_vsi); in ice_repr_get_drvinfo()
4404 if (repr->ops.ready(repr) || stringset != ETH_SS_STATS) in ice_repr_get_strings()
4407 __ice_get_strings(netdev, stringset, data, repr->src_vsi); in ice_repr_get_strings()
4417 if (repr->ops.ready(repr)) in ice_repr_get_ethtool_stats()
4420 __ice_get_ethtool_stats(netdev, stats, data, repr->src_vsi); in ice_repr_get_ethtool_stats()
4429 return -EOPNOTSUPP; in ice_repr_get_sset_count()
4446 * ice_get_module_info - get SFF module type and revision information
4455 struct ice_vsi *vsi = np->vsi; in ice_get_module_info()
4456 struct ice_pf *pf = vsi->back; in ice_get_module_info()
4457 struct ice_hw *hw = &pf->hw; in ice_get_module_info()
4483 modinfo->type = ETH_MODULE_SFF_8079; in ice_get_module_info()
4484 modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN; in ice_get_module_info()
4487 modinfo->type = ETH_MODULE_SFF_8472; in ice_get_module_info()
4488 modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN; in ice_get_module_info()
4490 modinfo->type = ETH_MODULE_SFF_8079; in ice_get_module_info()
4491 modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN; in ice_get_module_info()
4503 /* Module is SFF-8636 compliant */ in ice_get_module_info()
4504 modinfo->type = ETH_MODULE_SFF_8636; in ice_get_module_info()
4505 modinfo->eeprom_len = ICE_MODULE_QSFP_MAX_LEN; in ice_get_module_info()
4507 modinfo->type = ETH_MODULE_SFF_8436; in ice_get_module_info()
4508 modinfo->eeprom_len = ICE_MODULE_QSFP_MAX_LEN; in ice_get_module_info()
4513 return -EINVAL; in ice_get_module_info()
4519 * ice_get_module_eeprom - fill buffer with SFF EEPROM contents
4532 struct ice_vsi *vsi = np->vsi; in ice_get_module_eeprom()
4533 struct ice_pf *pf = vsi->back; in ice_get_module_eeprom()
4534 struct ice_hw *hw = &pf->hw; in ice_get_module_eeprom()
4541 if (!ee || !ee->len || !data) in ice_get_module_eeprom()
4542 return -EINVAL; in ice_get_module_eeprom()
4552 memset(data, 0, ee->len); in ice_get_module_eeprom()
4553 for (i = 0; i < ee->len; i += SFF_READ_BLOCK_SIZE) { in ice_get_module_eeprom()
4554 offset = i + ee->offset; in ice_get_module_eeprom()
4560 offset -= ETH_MODULE_SFF_8079_LEN; in ice_get_module_eeprom()
4566 offset -= ETH_MODULE_SFF_8436_LEN / 2; in ice_get_module_eeprom()
4601 copy_len = min_t(u32, SFF_READ_BLOCK_SIZE, ee->len - i); in ice_get_module_eeprom()
4609 * ice_get_port_fec_stats - returns FEC correctable, uncorrectable stats per
4626 return -EINVAL; in ice_get_port_fec_stats()
4650 fec_stats->corrected_blocks.total = (fec_corr_high_val << 16) + in ice_get_port_fec_stats()
4652 fec_stats->uncorrectable_blocks.total = (fec_uncorr_high_val << 16) + in ice_get_port_fec_stats()
4658 * ice_get_fec_stats - returns FEC correctable, uncorrectable stats per netdev
4673 pf = np->vsi->back; in ice_get_fec_stats()
4674 hw = &pf->hw; in ice_get_fec_stats()
4675 pi = np->vsi->port_info; in ice_get_fec_stats()
4678 if (np->vsi->type != ICE_VSI_PF || !pi) in ice_get_fec_stats()
4681 err = ice_get_port_topology(hw, pi->lport, &port_topology); in ice_get_fec_stats()
4684 pi->lport); in ice_get_fec_stats()
4693 pi->lport, err); in ice_get_fec_stats()
4709 * ice_ethtool_reset - triggers a given type of reset
4713 * Return: 0 on success, -EOPNOTSUPP when using unsupported set of flags.
4718 struct ice_pf *pf = np->vsi->back; in ice_ethtool_reset()
4733 return -EOPNOTSUPP; in ice_ethtool_reset()
4744 * ice_repr_ethtool_reset - triggers a VF reset
4749 * -EOPNOTSUPP when using unsupported set of flags
4750 * -EBUSY when VF is not ready for reset.
4757 if (repr->type != ICE_REPR_TYPE_VF || in ice_repr_ethtool_reset()
4759 return -EOPNOTSUPP; in ice_repr_ethtool_reset()
4761 vf = repr->vf; in ice_repr_ethtool_reset()
4764 return -EBUSY; in ice_repr_ethtool_reset()
4846 * ice_set_ethtool_safe_mode_ops - setup safe mode ethtool ops
4851 netdev->ethtool_ops = &ice_ethtool_safe_mode_ops; in ice_set_ethtool_safe_mode_ops()
4864 * ice_set_ethtool_repr_ops - setup VF's port representor ethtool ops
4869 netdev->ethtool_ops = &ice_ethtool_repr_ops; in ice_set_ethtool_repr_ops()
4873 * ice_set_ethtool_ops - setup netdev ethtool ops
4880 netdev->ethtool_ops = &ice_ethtool_ops; in ice_set_ethtool_ops()