Lines Matching +full:supported +full:- +full:hw

1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2013 - 2018 Intel Corporation. */
13 * struct i40e_stats - definition for an ethtool statistic
14 * @stat_string: statistic name to display in ethtool -S output
62 I40E_QUEUE_STAT("%s-%u.packets", stats.packets),
63 I40E_QUEUE_STAT("%s-%u.bytes", stats.bytes),
67 * i40e_add_one_ethtool_stat - copy the stat into the supplied buffer
90 p = (char *)pointer + stat->stat_offset; in i40e_add_one_ethtool_stat()
91 switch (stat->sizeof_stat) { in i40e_add_one_ethtool_stat()
106 stat->stat_string); in i40e_add_one_ethtool_stat()
112 * __i40e_add_ethtool_stats - copy stats into the ethtool supplied buffer
136 * i40e_add_ethtool_stats - copy stats into ethtool supplied buffer
152 * i40e_add_queue_stats - copy queue statistics into supplied buffer
176 * non-null before attempting to access its syncp. in i40e_add_queue_stats()
179 start = !ring ? 0 : u64_stats_fetch_begin_irq(&ring->syncp); in i40e_add_queue_stats()
184 } while (ring && u64_stats_fetch_retry_irq(&ring->syncp, start)); in i40e_add_queue_stats()
191 * __i40e_add_stat_strings - copy stat strings into ethtool buffer
215 * i40e_add_stat_strings - copy stat strings into ethtool buffer
307 * The PF_STATs are appended to the netdev stats only when ethtool -S
440 I40E_PRIV_FLAG("total-port-shutdown",
443 I40E_PRIV_FLAG("flow-director-atr", I40E_FLAG_FD_ATR_ENABLED, 0),
444 I40E_PRIV_FLAG("veb-stats", I40E_FLAG_VEB_STATS_ENABLED, 0),
445 I40E_PRIV_FLAG("hw-atr-eviction", I40E_FLAG_HW_ATR_EVICT_ENABLED, 0),
446 I40E_PRIV_FLAG("link-down-on-close",
448 I40E_PRIV_FLAG("legacy-rx", I40E_FLAG_LEGACY_RX, 0),
449 I40E_PRIV_FLAG("disable-source-pruning",
451 I40E_PRIV_FLAG("disable-fw-lldp", I40E_FLAG_DISABLE_FW_LLDP, 0),
452 I40E_PRIV_FLAG("rs-fec", I40E_FLAG_RS_FEC, 0),
453 I40E_PRIV_FLAG("base-r-fec", I40E_FLAG_BASE_R_FEC, 0),
460 I40E_PRIV_FLAG("vf-true-promisc-support",
467 * i40e_partition_setting_complaint - generic complaint for MFP restriction
472 dev_info(&pf->pdev->dev, in i40e_partition_setting_complaint()
477 * i40e_phy_type_to_ethtool - convert the phy_types to ethtool link modes
485 struct i40e_link_status *hw_link_info = &pf->hw.phy.link_info; in i40e_phy_type_to_ethtool()
486 u64 phy_types = pf->hw.phy.phy_types; in i40e_phy_type_to_ethtool()
488 ethtool_link_ksettings_zero_link_mode(ks, supported); in i40e_phy_type_to_ethtool()
492 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
494 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB) in i40e_phy_type_to_ethtool()
497 if (pf->hw_features & I40E_HW_100M_SGMII_CAPABLE) { in i40e_phy_type_to_ethtool()
498 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
509 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
511 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_phy_type_to_ethtool()
516 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
518 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_phy_type_to_ethtool()
523 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
525 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_2_5GB) in i40e_phy_type_to_ethtool()
530 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
532 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_5GB) in i40e_phy_type_to_ethtool()
539 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
543 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
545 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_40GB) in i40e_phy_type_to_ethtool()
550 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
552 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_100MB) in i40e_phy_type_to_ethtool()
557 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
559 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB) in i40e_phy_type_to_ethtool()
564 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
570 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
576 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
582 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
584 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_20GB) in i40e_phy_type_to_ethtool()
589 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
591 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_phy_type_to_ethtool()
596 !(pf->hw_features & I40E_HW_HAVE_CRT_RETIMER)) { in i40e_phy_type_to_ethtool()
597 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
599 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_phy_type_to_ethtool()
604 !(pf->hw_features & I40E_HW_HAVE_CRT_RETIMER)) { in i40e_phy_type_to_ethtool()
605 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
607 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB) in i40e_phy_type_to_ethtool()
613 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
615 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_25GB) in i40e_phy_type_to_ethtool()
620 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
622 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_25GB) in i40e_phy_type_to_ethtool()
628 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
630 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_25GB) in i40e_phy_type_to_ethtool()
636 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
638 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_25GB) in i40e_phy_type_to_ethtool()
648 ethtool_link_ksettings_add_link_mode(ks, supported, FEC_NONE); in i40e_phy_type_to_ethtool()
649 ethtool_link_ksettings_add_link_mode(ks, supported, FEC_RS); in i40e_phy_type_to_ethtool()
650 ethtool_link_ksettings_add_link_mode(ks, supported, FEC_BASER); in i40e_phy_type_to_ethtool()
651 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_25GB) { in i40e_phy_type_to_ethtool()
663 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
665 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_phy_type_to_ethtool()
670 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
672 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_phy_type_to_ethtool()
677 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
679 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_phy_type_to_ethtool()
686 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
688 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB) in i40e_phy_type_to_ethtool()
717 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
725 * i40e_get_settings_link_up_fec - Get the FEC mode encoding from mask
732 ethtool_link_ksettings_add_link_mode(ks, supported, FEC_NONE); in i40e_get_settings_link_up_fec()
733 ethtool_link_ksettings_add_link_mode(ks, supported, FEC_RS); in i40e_get_settings_link_up_fec()
734 ethtool_link_ksettings_add_link_mode(ks, supported, FEC_BASER); in i40e_get_settings_link_up_fec()
755 * i40e_get_settings_link_up - Get the Link settings for when link is up
756 * @hw: hw structure
761 static void i40e_get_settings_link_up(struct i40e_hw *hw, in i40e_get_settings_link_up() argument
766 struct i40e_link_status *hw_link_info = &hw->phy.link_info; in i40e_get_settings_link_up()
768 u32 link_speed = hw_link_info->link_speed; in i40e_get_settings_link_up()
770 /* Initialize supported and advertised settings based on phy settings */ in i40e_get_settings_link_up()
771 switch (hw_link_info->phy_type) { in i40e_get_settings_link_up()
774 ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); in i40e_get_settings_link_up()
775 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
784 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
790 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
796 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
807 ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); in i40e_get_settings_link_up()
809 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
813 i40e_get_settings_link_up_fec(hw_link_info->req_fec_info, ks); in i40e_get_settings_link_up()
814 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
818 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
822 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
826 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
828 if (hw_link_info->module_type[2] & in i40e_get_settings_link_up()
830 hw_link_info->module_type[2] & in i40e_get_settings_link_up()
832 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
834 if (hw_link_info->requested_speeds & in i40e_get_settings_link_up()
839 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_get_settings_link_up()
848 ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); in i40e_get_settings_link_up()
849 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
851 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
853 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
855 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
857 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
860 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_get_settings_link_up()
863 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_5GB) in i40e_get_settings_link_up()
866 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_2_5GB) in i40e_get_settings_link_up()
869 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB) in i40e_get_settings_link_up()
872 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_100MB) in i40e_get_settings_link_up()
877 ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); in i40e_get_settings_link_up()
878 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
886 ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); in i40e_get_settings_link_up()
887 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
898 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
900 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_get_settings_link_up()
903 i40e_get_settings_link_up_fec(hw_link_info->req_fec_info, ks); in i40e_get_settings_link_up()
906 ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); in i40e_get_settings_link_up()
907 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
909 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB) in i40e_get_settings_link_up()
912 if (pf->hw_features & I40E_HW_100M_SGMII_CAPABLE) { in i40e_get_settings_link_up()
913 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
915 if (hw_link_info->requested_speeds & in i40e_get_settings_link_up()
927 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
929 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
931 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
933 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
935 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
937 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
939 ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); in i40e_get_settings_link_up()
944 i40e_get_settings_link_up_fec(hw_link_info->req_fec_info, ks); in i40e_get_settings_link_up()
956 ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); in i40e_get_settings_link_up()
958 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
962 i40e_get_settings_link_up_fec(hw_link_info->req_fec_info, ks); in i40e_get_settings_link_up()
967 ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); in i40e_get_settings_link_up()
969 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
973 i40e_get_settings_link_up_fec(hw_link_info->req_fec_info, ks); in i40e_get_settings_link_up()
975 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
984 hw_link_info->phy_type); in i40e_get_settings_link_up()
987 /* Now that we've worked out everything that could be supported by the in i40e_get_settings_link_up()
988 * current PHY type, get what is supported by the NVM and intersect in i40e_get_settings_link_up()
989 * them to get what is truly supported in i40e_get_settings_link_up()
998 ks->base.speed = SPEED_40000; in i40e_get_settings_link_up()
1001 ks->base.speed = SPEED_25000; in i40e_get_settings_link_up()
1004 ks->base.speed = SPEED_20000; in i40e_get_settings_link_up()
1007 ks->base.speed = SPEED_10000; in i40e_get_settings_link_up()
1010 ks->base.speed = SPEED_5000; in i40e_get_settings_link_up()
1013 ks->base.speed = SPEED_2500; in i40e_get_settings_link_up()
1016 ks->base.speed = SPEED_1000; in i40e_get_settings_link_up()
1019 ks->base.speed = SPEED_100; in i40e_get_settings_link_up()
1022 ks->base.speed = SPEED_UNKNOWN; in i40e_get_settings_link_up()
1025 ks->base.duplex = DUPLEX_FULL; in i40e_get_settings_link_up()
1029 * i40e_get_settings_link_down - Get the Link settings for when link is down
1030 * @hw: hw structure
1036 static void i40e_get_settings_link_down(struct i40e_hw *hw, in i40e_get_settings_link_down() argument
1041 * supported phy types to figure out what info to display in i40e_get_settings_link_down()
1046 ks->base.speed = SPEED_UNKNOWN; in i40e_get_settings_link_down()
1047 ks->base.duplex = DUPLEX_UNKNOWN; in i40e_get_settings_link_down()
1051 * i40e_get_link_ksettings - Get Link Speed and Duplex settings
1061 struct i40e_pf *pf = np->vsi->back; in i40e_get_link_ksettings()
1062 struct i40e_hw *hw = &pf->hw; in i40e_get_link_ksettings() local
1063 struct i40e_link_status *hw_link_info = &hw->phy.link_info; in i40e_get_link_ksettings()
1064 bool link_up = hw_link_info->link_info & I40E_AQ_LINK_UP; in i40e_get_link_ksettings()
1066 ethtool_link_ksettings_zero_link_mode(ks, supported); in i40e_get_link_ksettings()
1070 i40e_get_settings_link_up(hw, ks, netdev, pf); in i40e_get_link_ksettings()
1072 i40e_get_settings_link_down(hw, ks, pf); in i40e_get_link_ksettings()
1076 ks->base.autoneg = ((hw_link_info->an_info & I40E_AQ_AN_COMPLETED) ? in i40e_get_link_ksettings()
1080 switch (hw->phy.media_type) { in i40e_get_link_ksettings()
1082 ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); in i40e_get_link_ksettings()
1083 ethtool_link_ksettings_add_link_mode(ks, supported, Backplane); in i40e_get_link_ksettings()
1087 ks->base.port = PORT_NONE; in i40e_get_link_ksettings()
1090 ethtool_link_ksettings_add_link_mode(ks, supported, TP); in i40e_get_link_ksettings()
1092 ks->base.port = PORT_TP; in i40e_get_link_ksettings()
1096 ethtool_link_ksettings_add_link_mode(ks, supported, FIBRE); in i40e_get_link_ksettings()
1098 ks->base.port = PORT_DA; in i40e_get_link_ksettings()
1101 ethtool_link_ksettings_add_link_mode(ks, supported, FIBRE); in i40e_get_link_ksettings()
1103 ks->base.port = PORT_FIBRE; in i40e_get_link_ksettings()
1107 ks->base.port = PORT_OTHER; in i40e_get_link_ksettings()
1112 ethtool_link_ksettings_add_link_mode(ks, supported, Pause); in i40e_get_link_ksettings()
1113 ethtool_link_ksettings_add_link_mode(ks, supported, Asym_Pause); in i40e_get_link_ksettings()
1115 switch (hw->fc.requested_mode) { in i40e_get_link_ksettings()
1139 * i40e_set_link_ksettings - Set Speed and Duplex
1153 struct i40e_pf *pf = np->vsi->back; in i40e_set_link_ksettings()
1154 struct i40e_vsi *vsi = np->vsi; in i40e_set_link_ksettings()
1155 struct i40e_hw *hw = &pf->hw; in i40e_set_link_ksettings() local
1162 /* Changing port settings is not supported if this isn't the in i40e_set_link_ksettings()
1165 if (hw->partition_id != 1) { in i40e_set_link_ksettings()
1167 return -EOPNOTSUPP; in i40e_set_link_ksettings()
1169 if (vsi != pf->vsi[pf->lan_vsi]) in i40e_set_link_ksettings()
1170 return -EOPNOTSUPP; in i40e_set_link_ksettings()
1171 if (hw->phy.media_type != I40E_MEDIA_TYPE_BASET && in i40e_set_link_ksettings()
1172 hw->phy.media_type != I40E_MEDIA_TYPE_FIBER && in i40e_set_link_ksettings()
1173 hw->phy.media_type != I40E_MEDIA_TYPE_BACKPLANE && in i40e_set_link_ksettings()
1174 hw->phy.media_type != I40E_MEDIA_TYPE_DA && in i40e_set_link_ksettings()
1175 hw->phy.link_info.link_info & I40E_AQ_LINK_UP) in i40e_set_link_ksettings()
1176 return -EOPNOTSUPP; in i40e_set_link_ksettings()
1177 if (hw->device_id == I40E_DEV_ID_KX_B || in i40e_set_link_ksettings()
1178 hw->device_id == I40E_DEV_ID_KX_C || in i40e_set_link_ksettings()
1179 hw->device_id == I40E_DEV_ID_20G_KR2 || in i40e_set_link_ksettings()
1180 hw->device_id == I40E_DEV_ID_20G_KR2_A || in i40e_set_link_ksettings()
1181 hw->device_id == I40E_DEV_ID_25G_B || in i40e_set_link_ksettings()
1182 hw->device_id == I40E_DEV_ID_KX_X722) { in i40e_set_link_ksettings()
1183 netdev_info(netdev, "Changing settings is not supported on backplane.\n"); in i40e_set_link_ksettings()
1184 return -EOPNOTSUPP; in i40e_set_link_ksettings()
1200 /* Get link modes supported by hardware and check against modes in i40e_set_link_ksettings()
1204 safe_ks.link_modes.supported, in i40e_set_link_ksettings()
1206 return -EINVAL; in i40e_set_link_ksettings()
1216 return -EOPNOTSUPP; in i40e_set_link_ksettings()
1218 while (test_and_set_bit(__I40E_CONFIG_BUSY, pf->state)) { in i40e_set_link_ksettings()
1219 timeout--; in i40e_set_link_ksettings()
1221 return -EBUSY; in i40e_set_link_ksettings()
1226 status = i40e_aq_get_phy_capabilities(hw, false, false, &abilities, in i40e_set_link_ksettings()
1229 err = -EAGAIN; in i40e_set_link_ksettings()
1242 if (!(hw->phy.link_info.an_info & I40E_AQ_AN_COMPLETED)) { in i40e_set_link_ksettings()
1243 /* If autoneg is not supported, return error */ in i40e_set_link_ksettings()
1245 supported, in i40e_set_link_ksettings()
1247 netdev_info(netdev, "Autoneg not supported on this phy\n"); in i40e_set_link_ksettings()
1248 err = -EINVAL; in i40e_set_link_ksettings()
1258 if (hw->phy.link_info.an_info & I40E_AQ_AN_COMPLETED) { in i40e_set_link_ksettings()
1259 /* If autoneg is supported 10GBASE_T is the only PHY in i40e_set_link_ksettings()
1263 supported, in i40e_set_link_ksettings()
1265 hw->phy.media_type != I40E_MEDIA_TYPE_BASET) { in i40e_set_link_ksettings()
1267 err = -EINVAL; in i40e_set_link_ksettings()
1343 hw->phy.link_info.requested_speeds = config.link_speed; in i40e_set_link_ksettings()
1347 if (hw->phy.link_info.link_info & I40E_AQ_LINK_UP) { in i40e_set_link_ksettings()
1357 status = i40e_aq_set_phy_config(hw, &config, NULL); in i40e_set_link_ksettings()
1361 i40e_stat_str(hw, status), in i40e_set_link_ksettings()
1362 i40e_aq_str(hw, hw->aq.asq_last_status)); in i40e_set_link_ksettings()
1363 err = -EAGAIN; in i40e_set_link_ksettings()
1367 status = i40e_update_link_info(hw); in i40e_set_link_ksettings()
1371 i40e_stat_str(hw, status), in i40e_set_link_ksettings()
1372 i40e_aq_str(hw, hw->aq.asq_last_status)); in i40e_set_link_ksettings()
1379 clear_bit(__I40E_CONFIG_BUSY, pf->state); in i40e_set_link_ksettings()
1388 struct i40e_pf *pf = np->vsi->back; in i40e_set_fec_cfg()
1389 struct i40e_hw *hw = &pf->hw; in i40e_set_fec_cfg() local
1394 flags = READ_ONCE(pf->flags); in i40e_set_fec_cfg()
1399 status = i40e_aq_get_phy_capabilities(hw, false, false, &abilities, in i40e_set_fec_cfg()
1402 err = -EAGAIN; in i40e_set_fec_cfg()
1419 status = i40e_aq_set_phy_config(hw, &config, NULL); in i40e_set_fec_cfg()
1423 i40e_stat_str(hw, status), in i40e_set_fec_cfg()
1424 i40e_aq_str(hw, hw->aq.asq_last_status)); in i40e_set_fec_cfg()
1425 err = -EAGAIN; in i40e_set_fec_cfg()
1428 pf->flags = flags; in i40e_set_fec_cfg()
1429 status = i40e_update_link_info(hw); in i40e_set_fec_cfg()
1437 i40e_stat_str(hw, status), in i40e_set_fec_cfg()
1438 i40e_aq_str(hw, hw->aq.asq_last_status)); in i40e_set_fec_cfg()
1450 struct i40e_pf *pf = np->vsi->back; in i40e_get_fec_param()
1451 struct i40e_hw *hw = &pf->hw; in i40e_get_fec_param() local
1458 status = i40e_aq_get_phy_capabilities(hw, false, false, &abilities, in i40e_get_fec_param()
1461 err = -EAGAIN; in i40e_get_fec_param()
1465 fecparam->fec = 0; in i40e_get_fec_param()
1468 fecparam->fec |= ETHTOOL_FEC_AUTO; in i40e_get_fec_param()
1471 fecparam->fec |= ETHTOOL_FEC_RS; in i40e_get_fec_param()
1474 fecparam->fec |= ETHTOOL_FEC_BASER; in i40e_get_fec_param()
1476 fecparam->fec |= ETHTOOL_FEC_OFF; in i40e_get_fec_param()
1478 if (hw->phy.link_info.fec_info & I40E_AQ_CONFIG_FEC_KR_ENA) in i40e_get_fec_param()
1479 fecparam->active_fec = ETHTOOL_FEC_BASER; in i40e_get_fec_param()
1480 else if (hw->phy.link_info.fec_info & I40E_AQ_CONFIG_FEC_RS_ENA) in i40e_get_fec_param()
1481 fecparam->active_fec = ETHTOOL_FEC_RS; in i40e_get_fec_param()
1483 fecparam->active_fec = ETHTOOL_FEC_OFF; in i40e_get_fec_param()
1492 struct i40e_pf *pf = np->vsi->back; in i40e_set_fec_param()
1493 struct i40e_hw *hw = &pf->hw; in i40e_set_fec_param() local
1496 if (hw->device_id != I40E_DEV_ID_25G_SFP28 && in i40e_set_fec_param()
1497 hw->device_id != I40E_DEV_ID_25G_B && in i40e_set_fec_param()
1498 hw->device_id != I40E_DEV_ID_KX_X722) in i40e_set_fec_param()
1499 return -EPERM; in i40e_set_fec_param()
1501 if (hw->mac.type == I40E_MAC_X722 && in i40e_set_fec_param()
1502 !(hw->flags & I40E_HW_FLAG_X722_FEC_REQUEST_CAPABLE)) { in i40e_set_fec_param()
1503 …netdev_err(netdev, "Setting FEC encoding not supported by firmware. Please update the NVM image.\n… in i40e_set_fec_param()
1504 return -EOPNOTSUPP; in i40e_set_fec_param()
1507 switch (fecparam->fec) { in i40e_set_fec_param()
1524 dev_warn(&pf->pdev->dev, "Unsupported FEC mode: %d", in i40e_set_fec_param()
1525 fecparam->fec); in i40e_set_fec_param()
1526 return -EINVAL; in i40e_set_fec_param()
1536 struct i40e_pf *pf = np->vsi->back; in i40e_nway_reset()
1537 struct i40e_hw *hw = &pf->hw; in i40e_nway_reset() local
1538 bool link_up = hw->phy.link_info.link_info & I40E_AQ_LINK_UP; in i40e_nway_reset()
1541 ret = i40e_aq_set_link_restart_an(hw, link_up, NULL); in i40e_nway_reset()
1544 i40e_stat_str(hw, ret), in i40e_nway_reset()
1545 i40e_aq_str(hw, hw->aq.asq_last_status)); in i40e_nway_reset()
1546 return -EIO; in i40e_nway_reset()
1553 * i40e_get_pauseparam - Get Flow Control status
1557 * Return tx/rx-pause status
1563 struct i40e_pf *pf = np->vsi->back; in i40e_get_pauseparam()
1564 struct i40e_hw *hw = &pf->hw; in i40e_get_pauseparam() local
1565 struct i40e_link_status *hw_link_info = &hw->phy.link_info; in i40e_get_pauseparam()
1566 struct i40e_dcbx_config *dcbx_cfg = &hw->local_dcbx_config; in i40e_get_pauseparam()
1568 pause->autoneg = in i40e_get_pauseparam()
1569 ((hw_link_info->an_info & I40E_AQ_AN_COMPLETED) ? in i40e_get_pauseparam()
1573 if (dcbx_cfg->pfc.pfcenable) { in i40e_get_pauseparam()
1574 pause->rx_pause = 0; in i40e_get_pauseparam()
1575 pause->tx_pause = 0; in i40e_get_pauseparam()
1579 if (hw->fc.current_mode == I40E_FC_RX_PAUSE) { in i40e_get_pauseparam()
1580 pause->rx_pause = 1; in i40e_get_pauseparam()
1581 } else if (hw->fc.current_mode == I40E_FC_TX_PAUSE) { in i40e_get_pauseparam()
1582 pause->tx_pause = 1; in i40e_get_pauseparam()
1583 } else if (hw->fc.current_mode == I40E_FC_FULL) { in i40e_get_pauseparam()
1584 pause->rx_pause = 1; in i40e_get_pauseparam()
1585 pause->tx_pause = 1; in i40e_get_pauseparam()
1590 * i40e_set_pauseparam - Set Flow Control parameter
1598 struct i40e_pf *pf = np->vsi->back; in i40e_set_pauseparam()
1599 struct i40e_vsi *vsi = np->vsi; in i40e_set_pauseparam()
1600 struct i40e_hw *hw = &pf->hw; in i40e_set_pauseparam() local
1601 struct i40e_link_status *hw_link_info = &hw->phy.link_info; in i40e_set_pauseparam()
1602 struct i40e_dcbx_config *dcbx_cfg = &hw->local_dcbx_config; in i40e_set_pauseparam()
1603 bool link_up = hw_link_info->link_info & I40E_AQ_LINK_UP; in i40e_set_pauseparam()
1609 /* Changing the port's flow control is not supported if this isn't the in i40e_set_pauseparam()
1612 if (hw->partition_id != 1) { in i40e_set_pauseparam()
1614 return -EOPNOTSUPP; in i40e_set_pauseparam()
1617 if (vsi != pf->vsi[pf->lan_vsi]) in i40e_set_pauseparam()
1618 return -EOPNOTSUPP; in i40e_set_pauseparam()
1620 is_an = hw_link_info->an_info & I40E_AQ_AN_COMPLETED; in i40e_set_pauseparam()
1621 if (pause->autoneg != is_an) { in i40e_set_pauseparam()
1622 netdev_info(netdev, "To change autoneg please use: ethtool -s <dev> autoneg <on|off>\n"); in i40e_set_pauseparam()
1623 return -EOPNOTSUPP; in i40e_set_pauseparam()
1627 if (!test_bit(__I40E_DOWN, pf->state) && !is_an) { in i40e_set_pauseparam()
1632 if (dcbx_cfg->pfc.pfcenable) { in i40e_set_pauseparam()
1635 return -EOPNOTSUPP; in i40e_set_pauseparam()
1638 if (pause->rx_pause && pause->tx_pause) in i40e_set_pauseparam()
1639 hw->fc.requested_mode = I40E_FC_FULL; in i40e_set_pauseparam()
1640 else if (pause->rx_pause && !pause->tx_pause) in i40e_set_pauseparam()
1641 hw->fc.requested_mode = I40E_FC_RX_PAUSE; in i40e_set_pauseparam()
1642 else if (!pause->rx_pause && pause->tx_pause) in i40e_set_pauseparam()
1643 hw->fc.requested_mode = I40E_FC_TX_PAUSE; in i40e_set_pauseparam()
1644 else if (!pause->rx_pause && !pause->tx_pause) in i40e_set_pauseparam()
1645 hw->fc.requested_mode = I40E_FC_NONE; in i40e_set_pauseparam()
1647 return -EINVAL; in i40e_set_pauseparam()
1657 status = i40e_set_fc(hw, &aq_failures, link_up); in i40e_set_pauseparam()
1661 i40e_stat_str(hw, status), in i40e_set_pauseparam()
1662 i40e_aq_str(hw, hw->aq.asq_last_status)); in i40e_set_pauseparam()
1663 err = -EAGAIN; in i40e_set_pauseparam()
1667 i40e_stat_str(hw, status), in i40e_set_pauseparam()
1668 i40e_aq_str(hw, hw->aq.asq_last_status)); in i40e_set_pauseparam()
1669 err = -EAGAIN; in i40e_set_pauseparam()
1673 i40e_stat_str(hw, status), in i40e_set_pauseparam()
1674 i40e_aq_str(hw, hw->aq.asq_last_status)); in i40e_set_pauseparam()
1675 err = -EAGAIN; in i40e_set_pauseparam()
1678 if (!test_bit(__I40E_DOWN, pf->state) && is_an) { in i40e_set_pauseparam()
1681 if (!test_bit(__I40E_DOWN, pf->state)) in i40e_set_pauseparam()
1691 struct i40e_pf *pf = np->vsi->back; in i40e_get_msglevel()
1692 u32 debug_mask = pf->hw.debug_mask; in i40e_get_msglevel()
1697 return pf->msg_enable; in i40e_get_msglevel()
1703 struct i40e_pf *pf = np->vsi->back; in i40e_set_msglevel()
1706 pf->hw.debug_mask = data; in i40e_set_msglevel()
1708 pf->msg_enable = data; in i40e_set_msglevel()
1726 struct i40e_pf *pf = np->vsi->back; in i40e_get_regs()
1727 struct i40e_hw *hw = &pf->hw; in i40e_get_regs() local
1732 /* Tell ethtool which driver-version-specific regs output we have. in i40e_get_regs()
1739 regs->version = 1; in i40e_get_regs()
1747 reg_buf[ri++] = rd32(hw, reg); in i40e_get_regs()
1757 struct i40e_hw *hw = &np->vsi->back->hw; in i40e_get_eeprom() local
1758 struct i40e_pf *pf = np->vsi->back; in i40e_get_eeprom()
1766 if (eeprom->len == 0) in i40e_get_eeprom()
1767 return -EINVAL; in i40e_get_eeprom()
1770 magic = hw->vendor_id | (hw->device_id << 16); in i40e_get_eeprom()
1771 if (eeprom->magic && eeprom->magic != magic) { in i40e_get_eeprom()
1776 if ((eeprom->magic >> 16) != hw->device_id) in i40e_get_eeprom()
1777 errno = -EINVAL; in i40e_get_eeprom()
1778 else if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) || in i40e_get_eeprom()
1779 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) in i40e_get_eeprom()
1780 errno = -EBUSY; in i40e_get_eeprom()
1782 ret_val = i40e_nvmupd_command(hw, cmd, bytes, &errno); in i40e_get_eeprom()
1784 if ((errno || ret_val) && (hw->debug_mask & I40E_DEBUG_NVM)) in i40e_get_eeprom()
1785 dev_info(&pf->pdev->dev, in i40e_get_eeprom()
1787 ret_val, hw->aq.asq_last_status, errno, in i40e_get_eeprom()
1788 (u8)(cmd->config & I40E_NVM_MOD_PNT_MASK), in i40e_get_eeprom()
1789 cmd->offset, cmd->data_size); in i40e_get_eeprom()
1795 eeprom->magic = hw->vendor_id | (hw->device_id << 16); in i40e_get_eeprom()
1797 eeprom_buff = kzalloc(eeprom->len, GFP_KERNEL); in i40e_get_eeprom()
1799 return -ENOMEM; in i40e_get_eeprom()
1801 ret_val = i40e_acquire_nvm(hw, I40E_RESOURCE_READ); in i40e_get_eeprom()
1803 dev_info(&pf->pdev->dev, in i40e_get_eeprom()
1805 ret_val, hw->aq.asq_last_status); in i40e_get_eeprom()
1809 sectors = eeprom->len / I40E_NVM_SECTOR_SIZE; in i40e_get_eeprom()
1810 sectors += (eeprom->len % I40E_NVM_SECTOR_SIZE) ? 1 : 0; in i40e_get_eeprom()
1814 if (i == (sectors - 1)) { in i40e_get_eeprom()
1815 len = eeprom->len - (I40E_NVM_SECTOR_SIZE * i); in i40e_get_eeprom()
1818 offset = eeprom->offset + (I40E_NVM_SECTOR_SIZE * i), in i40e_get_eeprom()
1819 ret_val = i40e_aq_read_nvm(hw, 0x0, offset, len, in i40e_get_eeprom()
1822 if (ret_val && hw->aq.asq_last_status == I40E_AQ_RC_EPERM) { in i40e_get_eeprom()
1823 dev_info(&pf->pdev->dev, in i40e_get_eeprom()
1828 hw->aq.asq_last_status == I40E_AQ_RC_EACCES) { in i40e_get_eeprom()
1829 dev_info(&pf->pdev->dev, in i40e_get_eeprom()
1834 dev_info(&pf->pdev->dev, in i40e_get_eeprom()
1836 offset, ret_val, hw->aq.asq_last_status); in i40e_get_eeprom()
1841 i40e_release_nvm(hw); in i40e_get_eeprom()
1842 memcpy(bytes, (u8 *)eeprom_buff, eeprom->len); in i40e_get_eeprom()
1851 struct i40e_hw *hw = &np->vsi->back->hw; in i40e_get_eeprom_len() local
1855 if (hw->mac.type == I40E_MAC_X722) { in i40e_get_eeprom_len()
1859 val = (rd32(hw, I40E_GLPCI_LBARCTRL) in i40e_get_eeprom_len()
1871 struct i40e_hw *hw = &np->vsi->back->hw; in i40e_set_eeprom() local
1872 struct i40e_pf *pf = np->vsi->back; in i40e_set_eeprom()
1878 /* normal ethtool set_eeprom is not supported */ in i40e_set_eeprom()
1879 magic = hw->vendor_id | (hw->device_id << 16); in i40e_set_eeprom()
1880 if (eeprom->magic == magic) in i40e_set_eeprom()
1881 errno = -EOPNOTSUPP; in i40e_set_eeprom()
1883 else if (!eeprom->magic || (eeprom->magic >> 16) != hw->device_id) in i40e_set_eeprom()
1884 errno = -EINVAL; in i40e_set_eeprom()
1885 else if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) || in i40e_set_eeprom()
1886 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) in i40e_set_eeprom()
1887 errno = -EBUSY; in i40e_set_eeprom()
1889 ret_val = i40e_nvmupd_command(hw, cmd, bytes, &errno); in i40e_set_eeprom()
1891 if ((errno || ret_val) && (hw->debug_mask & I40E_DEBUG_NVM)) in i40e_set_eeprom()
1892 dev_info(&pf->pdev->dev, in i40e_set_eeprom()
1894 ret_val, hw->aq.asq_last_status, errno, in i40e_set_eeprom()
1895 (u8)(cmd->config & I40E_NVM_MOD_PNT_MASK), in i40e_set_eeprom()
1896 cmd->offset, cmd->data_size); in i40e_set_eeprom()
1905 struct i40e_vsi *vsi = np->vsi; in i40e_get_drvinfo()
1906 struct i40e_pf *pf = vsi->back; in i40e_get_drvinfo()
1908 strlcpy(drvinfo->driver, i40e_driver_name, sizeof(drvinfo->driver)); in i40e_get_drvinfo()
1909 strlcpy(drvinfo->fw_version, i40e_nvm_version_str(&pf->hw), in i40e_get_drvinfo()
1910 sizeof(drvinfo->fw_version)); in i40e_get_drvinfo()
1911 strlcpy(drvinfo->bus_info, pci_name(pf->pdev), in i40e_get_drvinfo()
1912 sizeof(drvinfo->bus_info)); in i40e_get_drvinfo()
1913 drvinfo->n_priv_flags = I40E_PRIV_FLAGS_STR_LEN; in i40e_get_drvinfo()
1914 if (pf->hw.pf_id == 0) in i40e_get_drvinfo()
1915 drvinfo->n_priv_flags += I40E_GL_PRIV_FLAGS_STR_LEN; in i40e_get_drvinfo()
1922 struct i40e_pf *pf = np->vsi->back; in i40e_get_ringparam()
1923 struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi]; in i40e_get_ringparam()
1925 ring->rx_max_pending = I40E_MAX_NUM_DESCRIPTORS; in i40e_get_ringparam()
1926 ring->tx_max_pending = I40E_MAX_NUM_DESCRIPTORS; in i40e_get_ringparam()
1927 ring->rx_mini_max_pending = 0; in i40e_get_ringparam()
1928 ring->rx_jumbo_max_pending = 0; in i40e_get_ringparam()
1929 ring->rx_pending = vsi->rx_rings[0]->count; in i40e_get_ringparam()
1930 ring->tx_pending = vsi->tx_rings[0]->count; in i40e_get_ringparam()
1931 ring->rx_mini_pending = 0; in i40e_get_ringparam()
1932 ring->rx_jumbo_pending = 0; in i40e_get_ringparam()
1938 return index < vsi->num_queue_pairs || in i40e_active_tx_ring_index()
1939 (index >= vsi->alloc_queue_pairs && in i40e_active_tx_ring_index()
1940 index < vsi->alloc_queue_pairs + vsi->num_queue_pairs); in i40e_active_tx_ring_index()
1943 return index < vsi->num_queue_pairs; in i40e_active_tx_ring_index()
1951 struct i40e_hw *hw = &np->vsi->back->hw; in i40e_set_ringparam() local
1952 struct i40e_vsi *vsi = np->vsi; in i40e_set_ringparam()
1953 struct i40e_pf *pf = vsi->back; in i40e_set_ringparam()
1959 if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending)) in i40e_set_ringparam()
1960 return -EINVAL; in i40e_set_ringparam()
1962 if (ring->tx_pending > I40E_MAX_NUM_DESCRIPTORS || in i40e_set_ringparam()
1963 ring->tx_pending < I40E_MIN_NUM_DESCRIPTORS || in i40e_set_ringparam()
1964 ring->rx_pending > I40E_MAX_NUM_DESCRIPTORS || in i40e_set_ringparam()
1965 ring->rx_pending < I40E_MIN_NUM_DESCRIPTORS) { in i40e_set_ringparam()
1967 "Descriptors requested (Tx: %d / Rx: %d) out of range [%d-%d]\n", in i40e_set_ringparam()
1968 ring->tx_pending, ring->rx_pending, in i40e_set_ringparam()
1970 return -EINVAL; in i40e_set_ringparam()
1973 new_tx_count = ALIGN(ring->tx_pending, I40E_REQ_DESCRIPTOR_MULTIPLE); in i40e_set_ringparam()
1974 new_rx_count = ALIGN(ring->rx_pending, I40E_REQ_DESCRIPTOR_MULTIPLE); in i40e_set_ringparam()
1977 if ((new_tx_count == vsi->tx_rings[0]->count) && in i40e_set_ringparam()
1978 (new_rx_count == vsi->rx_rings[0]->count)) in i40e_set_ringparam()
1982 * disallow changing the number of descriptors -- regardless in i40e_set_ringparam()
1986 return -EBUSY; in i40e_set_ringparam()
1988 while (test_and_set_bit(__I40E_CONFIG_BUSY, pf->state)) { in i40e_set_ringparam()
1989 timeout--; in i40e_set_ringparam()
1991 return -EBUSY; in i40e_set_ringparam()
1995 if (!netif_running(vsi->netdev)) { in i40e_set_ringparam()
1996 /* simple case - set for the next time the netdev is started */ in i40e_set_ringparam()
1997 for (i = 0; i < vsi->num_queue_pairs; i++) { in i40e_set_ringparam()
1998 vsi->tx_rings[i]->count = new_tx_count; in i40e_set_ringparam()
1999 vsi->rx_rings[i]->count = new_rx_count; in i40e_set_ringparam()
2001 vsi->xdp_rings[i]->count = new_tx_count; in i40e_set_ringparam()
2003 vsi->num_tx_desc = new_tx_count; in i40e_set_ringparam()
2004 vsi->num_rx_desc = new_rx_count; in i40e_set_ringparam()
2009 * because the ISRs in MSI-X mode get passed pointers in i40e_set_ringparam()
2014 tx_alloc_queue_pairs = vsi->alloc_queue_pairs * in i40e_set_ringparam()
2016 if (new_tx_count != vsi->tx_rings[0]->count) { in i40e_set_ringparam()
2019 vsi->tx_rings[0]->count, new_tx_count); in i40e_set_ringparam()
2023 err = -ENOMEM; in i40e_set_ringparam()
2031 tx_rings[i] = *vsi->tx_rings[i]; in i40e_set_ringparam()
2041 i--; in i40e_set_ringparam()
2055 if (new_rx_count != vsi->rx_rings[0]->count) { in i40e_set_ringparam()
2058 vsi->rx_rings[0]->count, new_rx_count); in i40e_set_ringparam()
2059 rx_rings = kcalloc(vsi->alloc_queue_pairs, in i40e_set_ringparam()
2062 err = -ENOMEM; in i40e_set_ringparam()
2066 for (i = 0; i < vsi->num_queue_pairs; i++) { in i40e_set_ringparam()
2070 rx_rings[i] = *vsi->rx_rings[i]; in i40e_set_ringparam()
2077 /* Clear cloned XDP RX-queue info before setup call */ in i40e_set_ringparam()
2082 rx_rings[i].tail = hw->hw_addr + I40E_PRTGEN_STATUS; in i40e_set_ringparam()
2099 } while (i--); in i40e_set_ringparam()
2116 i40e_free_tx_resources(vsi->tx_rings[i]); in i40e_set_ringparam()
2117 *vsi->tx_rings[i] = tx_rings[i]; in i40e_set_ringparam()
2125 for (i = 0; i < vsi->num_queue_pairs; i++) { in i40e_set_ringparam()
2126 i40e_free_rx_resources(vsi->rx_rings[i]); in i40e_set_ringparam()
2128 rx_rings[i].tail = vsi->rx_rings[i]->tail; in i40e_set_ringparam()
2131 * but the recycling logic will let us re-use in i40e_set_ringparam()
2138 *vsi->rx_rings[i] = rx_rings[i]; in i40e_set_ringparam()
2144 vsi->num_tx_desc = new_tx_count; in i40e_set_ringparam()
2145 vsi->num_rx_desc = new_rx_count; in i40e_set_ringparam()
2153 i40e_free_tx_resources(vsi->tx_rings[i]); in i40e_set_ringparam()
2160 clear_bit(__I40E_CONFIG_BUSY, pf->state); in i40e_set_ringparam()
2166 * i40e_get_stats_count - return the stats count for a device
2173 * obtaining stats is *not* safe against changes based on non-static
2182 struct i40e_vsi *vsi = np->vsi; in i40e_get_stats_count()
2183 struct i40e_pf *pf = vsi->back; in i40e_get_stats_count()
2186 if (vsi == pf->vsi[pf->lan_vsi] && pf->hw.partition_id == 1) in i40e_get_stats_count()
2201 * queues in pairs, we'll just use netdev->num_tx_queues * 2. This in i40e_get_stats_count()
2205 stats_len += I40E_QUEUE_STATS_LEN * 2 * netdev->num_tx_queues; in i40e_get_stats_count()
2213 struct i40e_vsi *vsi = np->vsi; in i40e_get_sset_count()
2214 struct i40e_pf *pf = vsi->back; in i40e_get_sset_count()
2223 (pf->hw.pf_id == 0 ? I40E_GL_PRIV_FLAGS_STR_LEN : 0); in i40e_get_sset_count()
2225 return -EOPNOTSUPP; in i40e_get_sset_count()
2230 * i40e_get_veb_tc_stats - copy VEB TC statistics to formatted structure
2231 * @tc: the TC statistics in VEB structure (veb->tc_stats)
2232 * @i: the index of traffic class in (veb->tc_stats) structure to copy
2234 * Copy VEB TC statistics from structure of arrays (veb->tc_stats) to
2243 .tc_rx_packets = tc->tc_rx_packets[i], in i40e_get_veb_tc_stats()
2244 .tc_rx_bytes = tc->tc_rx_bytes[i], in i40e_get_veb_tc_stats()
2245 .tc_tx_packets = tc->tc_tx_packets[i], in i40e_get_veb_tc_stats()
2246 .tc_tx_bytes = tc->tc_tx_bytes[i], in i40e_get_veb_tc_stats()
2253 * i40e_get_pfc_stats - copy HW PFC statistics to formatted structure
2257 * The PFC stats are found as arrays in pf->stats, which is not easy to pass
2265 .stat = pf->stats.stat[priority] in i40e_get_pfc_stats()
2278 * i40e_get_ethtool_stats - copy stat values into supplied buffer
2284 * pre-allocated to the size returned by i40e_get_stats_count.. Note that all
2295 struct i40e_vsi *vsi = np->vsi; in i40e_get_ethtool_stats()
2296 struct i40e_pf *pf = vsi->back; in i40e_get_ethtool_stats()
2310 for (i = 0; i < netdev->num_tx_queues; i++) { in i40e_get_ethtool_stats()
2311 i40e_add_queue_stats(&data, READ_ONCE(vsi->tx_rings[i])); in i40e_get_ethtool_stats()
2312 i40e_add_queue_stats(&data, READ_ONCE(vsi->rx_rings[i])); in i40e_get_ethtool_stats()
2316 if (vsi != pf->vsi[pf->lan_vsi] || pf->hw.partition_id != 1) in i40e_get_ethtool_stats()
2319 veb_stats = ((pf->lan_veb != I40E_NO_VEB) && in i40e_get_ethtool_stats()
2320 (pf->lan_veb < I40E_MAX_VEB) && in i40e_get_ethtool_stats()
2321 (pf->flags & I40E_FLAG_VEB_STATS_ENABLED)); in i40e_get_ethtool_stats()
2324 veb = pf->veb[pf->lan_veb]; in i40e_get_ethtool_stats()
2338 i40e_get_veb_tc_stats(&veb->tc_stats, i); in i40e_get_ethtool_stats()
2356 WARN_ONCE(data - p != i40e_get_stats_count(netdev), in i40e_get_ethtool_stats()
2361 * i40e_get_stat_strings - copy stat strings into supplied buffer
2366 * pre-allocated with the size reported by i40e_get_stats_count. Note that the
2373 struct i40e_vsi *vsi = np->vsi; in i40e_get_stat_strings()
2374 struct i40e_pf *pf = vsi->back; in i40e_get_stat_strings()
2382 for (i = 0; i < netdev->num_tx_queues; i++) { in i40e_get_stat_strings()
2389 if (vsi != pf->vsi[pf->lan_vsi] || pf->hw.partition_id != 1) in i40e_get_stat_strings()
2403 WARN_ONCE(data - p != i40e_get_stats_count(netdev) * ETH_GSTRING_LEN, in i40e_get_stat_strings()
2410 struct i40e_vsi *vsi = np->vsi; in i40e_get_priv_flag_strings()
2411 struct i40e_pf *pf = vsi->back; in i40e_get_priv_flag_strings()
2417 if (pf->hw.pf_id != 0) in i40e_get_priv_flag_strings()
2447 /* only report HW timestamping if PTP is enabled */ in i40e_get_ts_info()
2448 if (!(pf->flags & I40E_FLAG_PTP)) in i40e_get_ts_info()
2451 info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE | in i40e_get_ts_info()
2458 if (pf->ptp_clock) in i40e_get_ts_info()
2459 info->phc_index = ptp_clock_index(pf->ptp_clock); in i40e_get_ts_info()
2461 info->phc_index = -1; in i40e_get_ts_info()
2463 info->tx_types = BIT(HWTSTAMP_TX_OFF) | BIT(HWTSTAMP_TX_ON); in i40e_get_ts_info()
2465 info->rx_filters = BIT(HWTSTAMP_FILTER_NONE) | in i40e_get_ts_info()
2470 if (pf->hw_features & I40E_HW_PTP_L4_CAPABLE) in i40e_get_ts_info()
2471 info->rx_filters |= BIT(HWTSTAMP_FILTER_PTP_V1_L4_SYNC) | in i40e_get_ts_info()
2486 struct i40e_pf *pf = np->vsi->back; in i40e_link_test()
2490 netif_info(pf, hw, netdev, "link test\n"); in i40e_link_test()
2491 status = i40e_get_link_status(&pf->hw, &link_up); in i40e_link_test()
2509 struct i40e_pf *pf = np->vsi->back; in i40e_reg_test()
2511 netif_info(pf, hw, netdev, "register test\n"); in i40e_reg_test()
2512 *data = i40e_diag_reg_test(&pf->hw); in i40e_reg_test()
2520 struct i40e_pf *pf = np->vsi->back; in i40e_eeprom_test()
2522 netif_info(pf, hw, netdev, "eeprom test\n"); in i40e_eeprom_test()
2523 *data = i40e_diag_eeprom_test(&pf->hw); in i40e_eeprom_test()
2526 pf->hw.nvmupd_state = I40E_NVMUPD_STATE_INIT; in i40e_eeprom_test()
2534 struct i40e_pf *pf = np->vsi->back; in i40e_intr_test()
2535 u16 swc_old = pf->sw_int_count; in i40e_intr_test()
2537 netif_info(pf, hw, netdev, "interrupt test\n"); in i40e_intr_test()
2538 wr32(&pf->hw, I40E_PFINT_DYN_CTL0, in i40e_intr_test()
2545 *data = (swc_old == pf->sw_int_count); in i40e_intr_test()
2552 struct i40e_vf *vfs = pf->vf; in i40e_active_vfs()
2555 for (i = 0; i < pf->num_alloc_vfs; i++) in i40e_active_vfs()
2571 struct i40e_pf *pf = np->vsi->back; in i40e_diag_test()
2573 if (eth_test->flags == ETH_TEST_FL_OFFLINE) { in i40e_diag_test()
2577 set_bit(__I40E_TESTING, pf->state); in i40e_diag_test()
2580 dev_warn(&pf->pdev->dev, in i40e_diag_test()
2586 eth_test->flags |= ETH_TEST_FL_FAILED; in i40e_diag_test()
2587 clear_bit(__I40E_TESTING, pf->state); in i40e_diag_test()
2596 /* This reset does not affect link - if it is in i40e_diag_test()
2604 eth_test->flags |= ETH_TEST_FL_FAILED; in i40e_diag_test()
2607 eth_test->flags |= ETH_TEST_FL_FAILED; in i40e_diag_test()
2610 eth_test->flags |= ETH_TEST_FL_FAILED; in i40e_diag_test()
2614 eth_test->flags |= ETH_TEST_FL_FAILED; in i40e_diag_test()
2616 clear_bit(__I40E_TESTING, pf->state); in i40e_diag_test()
2626 eth_test->flags |= ETH_TEST_FL_FAILED; in i40e_diag_test()
2643 struct i40e_pf *pf = np->vsi->back; in i40e_get_wol()
2644 struct i40e_hw *hw = &pf->hw; in i40e_get_wol() local
2648 i40e_read_nvm_word(hw, I40E_SR_NVM_WAKE_ON_LAN, &wol_nvm_bits); in i40e_get_wol()
2649 if ((BIT(hw->port) & wol_nvm_bits) || (hw->partition_id != 1)) { in i40e_get_wol()
2650 wol->supported = 0; in i40e_get_wol()
2651 wol->wolopts = 0; in i40e_get_wol()
2653 wol->supported = WAKE_MAGIC; in i40e_get_wol()
2654 wol->wolopts = (pf->wol_en ? WAKE_MAGIC : 0); in i40e_get_wol()
2659 * i40e_set_wol - set the WakeOnLAN configuration
2666 struct i40e_pf *pf = np->vsi->back; in i40e_set_wol()
2667 struct i40e_vsi *vsi = np->vsi; in i40e_set_wol()
2668 struct i40e_hw *hw = &pf->hw; in i40e_set_wol() local
2671 /* WoL not supported if this isn't the controlling PF on the port */ in i40e_set_wol()
2672 if (hw->partition_id != 1) { in i40e_set_wol()
2674 return -EOPNOTSUPP; in i40e_set_wol()
2677 if (vsi != pf->vsi[pf->lan_vsi]) in i40e_set_wol()
2678 return -EOPNOTSUPP; in i40e_set_wol()
2681 i40e_read_nvm_word(hw, I40E_SR_NVM_WAKE_ON_LAN, &wol_nvm_bits); in i40e_set_wol()
2682 if (BIT(hw->port) & wol_nvm_bits) in i40e_set_wol()
2683 return -EOPNOTSUPP; in i40e_set_wol()
2685 /* only magic packet is supported */ in i40e_set_wol()
2686 if (wol->wolopts & ~WAKE_MAGIC) in i40e_set_wol()
2687 return -EOPNOTSUPP; in i40e_set_wol()
2690 if (pf->wol_en != !!wol->wolopts) { in i40e_set_wol()
2691 pf->wol_en = !!wol->wolopts; in i40e_set_wol()
2692 device_set_wakeup_enable(&pf->pdev->dev, pf->wol_en); in i40e_set_wol()
2703 struct i40e_pf *pf = np->vsi->back; in i40e_set_phys_id()
2704 struct i40e_hw *hw = &pf->hw; in i40e_set_phys_id() local
2710 if (!(pf->hw_features & I40E_HW_PHY_CONTROLS_LEDS)) { in i40e_set_phys_id()
2711 pf->led_status = i40e_led_get(hw); in i40e_set_phys_id()
2713 if (!(hw->flags & I40E_HW_FLAG_AQ_PHY_ACCESS_CAPABLE)) in i40e_set_phys_id()
2714 i40e_aq_set_phy_debug(hw, I40E_PHY_DEBUG_ALL, in i40e_set_phys_id()
2716 ret = i40e_led_get_phy(hw, &temp_status, in i40e_set_phys_id()
2717 &pf->phy_led_val); in i40e_set_phys_id()
2718 pf->led_status = temp_status; in i40e_set_phys_id()
2722 if (!(pf->hw_features & I40E_HW_PHY_CONTROLS_LEDS)) in i40e_set_phys_id()
2723 i40e_led_set(hw, 0xf, false); in i40e_set_phys_id()
2725 ret = i40e_led_set_phy(hw, true, pf->led_status, 0); in i40e_set_phys_id()
2728 if (!(pf->hw_features & I40E_HW_PHY_CONTROLS_LEDS)) in i40e_set_phys_id()
2729 i40e_led_set(hw, 0x0, false); in i40e_set_phys_id()
2731 ret = i40e_led_set_phy(hw, false, pf->led_status, 0); in i40e_set_phys_id()
2734 if (!(pf->hw_features & I40E_HW_PHY_CONTROLS_LEDS)) { in i40e_set_phys_id()
2735 i40e_led_set(hw, pf->led_status, false); in i40e_set_phys_id()
2737 ret = i40e_led_set_phy(hw, false, pf->led_status, in i40e_set_phys_id()
2738 (pf->phy_led_val | in i40e_set_phys_id()
2740 if (!(hw->flags & I40E_HW_FLAG_AQ_PHY_ACCESS_CAPABLE)) in i40e_set_phys_id()
2741 i40e_aq_set_phy_debug(hw, 0, NULL); in i40e_set_phys_id()
2748 return -ENOENT; in i40e_set_phys_id()
2759 * __i40e_get_coalesce - get per-queue coalesce settings
2764 * Gets the per-queue settings for coalescence. Specifically Rx and Tx usecs
2774 struct i40e_vsi *vsi = np->vsi; in __i40e_get_coalesce()
2776 ec->tx_max_coalesced_frames_irq = vsi->work_limit; in __i40e_get_coalesce()
2777 ec->rx_max_coalesced_frames_irq = vsi->work_limit; in __i40e_get_coalesce()
2784 else if (queue >= vsi->num_queue_pairs) in __i40e_get_coalesce()
2785 return -EINVAL; in __i40e_get_coalesce()
2787 rx_ring = vsi->rx_rings[queue]; in __i40e_get_coalesce()
2788 tx_ring = vsi->tx_rings[queue]; in __i40e_get_coalesce()
2790 if (ITR_IS_DYNAMIC(rx_ring->itr_setting)) in __i40e_get_coalesce()
2791 ec->use_adaptive_rx_coalesce = 1; in __i40e_get_coalesce()
2793 if (ITR_IS_DYNAMIC(tx_ring->itr_setting)) in __i40e_get_coalesce()
2794 ec->use_adaptive_tx_coalesce = 1; in __i40e_get_coalesce()
2796 ec->rx_coalesce_usecs = rx_ring->itr_setting & ~I40E_ITR_DYNAMIC; in __i40e_get_coalesce()
2797 ec->tx_coalesce_usecs = tx_ring->itr_setting & ~I40E_ITR_DYNAMIC; in __i40e_get_coalesce()
2805 ec->rx_coalesce_usecs_high = vsi->int_rate_limit; in __i40e_get_coalesce()
2806 ec->tx_coalesce_usecs_high = vsi->int_rate_limit; in __i40e_get_coalesce()
2812 * i40e_get_coalesce - get a netdev's coalesce settings
2819 * modified per-queue settings, this only guarantees to represent queue 0. See
2827 return __i40e_get_coalesce(netdev, ec, -1); in i40e_get_coalesce()
2831 * i40e_get_per_queue_coalesce - gets coalesce settings for particular queue
2845 * i40e_set_itr_per_queue - set ITR values for specific queue
2856 struct i40e_ring *rx_ring = vsi->rx_rings[queue]; in i40e_set_itr_per_queue()
2857 struct i40e_ring *tx_ring = vsi->tx_rings[queue]; in i40e_set_itr_per_queue()
2858 struct i40e_pf *pf = vsi->back; in i40e_set_itr_per_queue()
2859 struct i40e_hw *hw = &pf->hw; in i40e_set_itr_per_queue() local
2863 intrl = i40e_intrl_usec_to_reg(vsi->int_rate_limit); in i40e_set_itr_per_queue()
2865 rx_ring->itr_setting = ITR_REG_ALIGN(ec->rx_coalesce_usecs); in i40e_set_itr_per_queue()
2866 tx_ring->itr_setting = ITR_REG_ALIGN(ec->tx_coalesce_usecs); in i40e_set_itr_per_queue()
2868 if (ec->use_adaptive_rx_coalesce) in i40e_set_itr_per_queue()
2869 rx_ring->itr_setting |= I40E_ITR_DYNAMIC; in i40e_set_itr_per_queue()
2871 rx_ring->itr_setting &= ~I40E_ITR_DYNAMIC; in i40e_set_itr_per_queue()
2873 if (ec->use_adaptive_tx_coalesce) in i40e_set_itr_per_queue()
2874 tx_ring->itr_setting |= I40E_ITR_DYNAMIC; in i40e_set_itr_per_queue()
2876 tx_ring->itr_setting &= ~I40E_ITR_DYNAMIC; in i40e_set_itr_per_queue()
2878 q_vector = rx_ring->q_vector; in i40e_set_itr_per_queue()
2879 q_vector->rx.target_itr = ITR_TO_REG(rx_ring->itr_setting); in i40e_set_itr_per_queue()
2881 q_vector = tx_ring->q_vector; in i40e_set_itr_per_queue()
2882 q_vector->tx.target_itr = ITR_TO_REG(tx_ring->itr_setting); in i40e_set_itr_per_queue()
2889 wr32(hw, I40E_PFINT_RATEN(q_vector->reg_idx), intrl); in i40e_set_itr_per_queue()
2890 i40e_flush(hw); in i40e_set_itr_per_queue()
2894 * __i40e_set_coalesce - set coalesce settings for particular queue
2907 struct i40e_vsi *vsi = np->vsi; in __i40e_set_coalesce()
2908 struct i40e_pf *pf = vsi->back; in __i40e_set_coalesce()
2911 if (ec->tx_max_coalesced_frames_irq || ec->rx_max_coalesced_frames_irq) in __i40e_set_coalesce()
2912 vsi->work_limit = ec->tx_max_coalesced_frames_irq; in __i40e_set_coalesce()
2915 cur_rx_itr = vsi->rx_rings[0]->itr_setting; in __i40e_set_coalesce()
2916 cur_tx_itr = vsi->tx_rings[0]->itr_setting; in __i40e_set_coalesce()
2917 } else if (queue < vsi->num_queue_pairs) { in __i40e_set_coalesce()
2918 cur_rx_itr = vsi->rx_rings[queue]->itr_setting; in __i40e_set_coalesce()
2919 cur_tx_itr = vsi->tx_rings[queue]->itr_setting; in __i40e_set_coalesce()
2921 netif_info(pf, drv, netdev, "Invalid queue value, queue range is 0 - %d\n", in __i40e_set_coalesce()
2922 vsi->num_queue_pairs - 1); in __i40e_set_coalesce()
2923 return -EINVAL; in __i40e_set_coalesce()
2929 /* tx_coalesce_usecs_high is ignored, use rx-usecs-high instead */ in __i40e_set_coalesce()
2930 if (ec->tx_coalesce_usecs_high != vsi->int_rate_limit) { in __i40e_set_coalesce()
2931 netif_info(pf, drv, netdev, "tx-usecs-high is not used, please program rx-usecs-high\n"); in __i40e_set_coalesce()
2932 return -EINVAL; in __i40e_set_coalesce()
2935 if (ec->rx_coalesce_usecs_high > INTRL_REG_TO_USEC(I40E_MAX_INTRL)) { in __i40e_set_coalesce()
2936 netif_info(pf, drv, netdev, "Invalid value, rx-usecs-high range is 0-%lu\n", in __i40e_set_coalesce()
2938 return -EINVAL; in __i40e_set_coalesce()
2941 if (ec->rx_coalesce_usecs != cur_rx_itr && in __i40e_set_coalesce()
2942 ec->use_adaptive_rx_coalesce) { in __i40e_set_coalesce()
2943 …netif_info(pf, drv, netdev, "RX interrupt moderation cannot be changed if adaptive-rx is enabled.\… in __i40e_set_coalesce()
2944 return -EINVAL; in __i40e_set_coalesce()
2947 if (ec->rx_coalesce_usecs > I40E_MAX_ITR) { in __i40e_set_coalesce()
2948 netif_info(pf, drv, netdev, "Invalid value, rx-usecs range is 0-8160\n"); in __i40e_set_coalesce()
2949 return -EINVAL; in __i40e_set_coalesce()
2952 if (ec->tx_coalesce_usecs != cur_tx_itr && in __i40e_set_coalesce()
2953 ec->use_adaptive_tx_coalesce) { in __i40e_set_coalesce()
2954 …netif_info(pf, drv, netdev, "TX interrupt moderation cannot be changed if adaptive-tx is enabled.\… in __i40e_set_coalesce()
2955 return -EINVAL; in __i40e_set_coalesce()
2958 if (ec->tx_coalesce_usecs > I40E_MAX_ITR) { in __i40e_set_coalesce()
2959 netif_info(pf, drv, netdev, "Invalid value, tx-usecs range is 0-8160\n"); in __i40e_set_coalesce()
2960 return -EINVAL; in __i40e_set_coalesce()
2963 if (ec->use_adaptive_rx_coalesce && !cur_rx_itr) in __i40e_set_coalesce()
2964 ec->rx_coalesce_usecs = I40E_MIN_ITR; in __i40e_set_coalesce()
2966 if (ec->use_adaptive_tx_coalesce && !cur_tx_itr) in __i40e_set_coalesce()
2967 ec->tx_coalesce_usecs = I40E_MIN_ITR; in __i40e_set_coalesce()
2969 intrl_reg = i40e_intrl_usec_to_reg(ec->rx_coalesce_usecs_high); in __i40e_set_coalesce()
2970 vsi->int_rate_limit = INTRL_REG_TO_USEC(intrl_reg); in __i40e_set_coalesce()
2971 if (vsi->int_rate_limit != ec->rx_coalesce_usecs_high) { in __i40e_set_coalesce()
2973 vsi->int_rate_limit); in __i40e_set_coalesce()
2980 for (i = 0; i < vsi->num_queue_pairs; i++) in __i40e_set_coalesce()
2990 * i40e_set_coalesce - set coalesce settings for every queue on the netdev
3003 return __i40e_set_coalesce(netdev, ec, -1); in i40e_set_coalesce()
3007 * i40e_set_per_queue_coalesce - set specific queue's coalesce settings
3021 * i40e_get_rss_hash_opts - Get RSS hash Input Set for each flow type
3025 * Returns Success if the flow is supported, else Invalid Input.
3029 struct i40e_hw *hw = &pf->hw; in i40e_get_rss_hash_opts() local
3033 cmd->data = 0; in i40e_get_rss_hash_opts()
3035 switch (cmd->flow_type) { in i40e_get_rss_hash_opts()
3059 cmd->data |= RXH_IP_SRC | RXH_IP_DST; in i40e_get_rss_hash_opts()
3062 return -EINVAL; in i40e_get_rss_hash_opts()
3067 i_set = (u64)i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(0, in i40e_get_rss_hash_opts()
3069 ((u64)i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(1, in i40e_get_rss_hash_opts()
3076 cmd->data |= RXH_L4_B_0_1; in i40e_get_rss_hash_opts()
3078 cmd->data |= RXH_L4_B_2_3; in i40e_get_rss_hash_opts()
3080 if (cmd->flow_type == TCP_V4_FLOW || in i40e_get_rss_hash_opts()
3081 cmd->flow_type == UDP_V4_FLOW) { in i40e_get_rss_hash_opts()
3083 cmd->data |= RXH_IP_SRC; in i40e_get_rss_hash_opts()
3085 cmd->data |= RXH_IP_DST; in i40e_get_rss_hash_opts()
3086 } else if (cmd->flow_type == TCP_V6_FLOW || in i40e_get_rss_hash_opts()
3087 cmd->flow_type == UDP_V6_FLOW) { in i40e_get_rss_hash_opts()
3089 cmd->data |= RXH_IP_SRC; in i40e_get_rss_hash_opts()
3091 cmd->data |= RXH_IP_DST; in i40e_get_rss_hash_opts()
3099 * i40e_check_mask - Check whether a mask field is set
3115 return -1; in i40e_check_mask()
3119 * i40e_parse_rx_flow_user_data - Deconstruct user-defined data
3123 * Read the user-defined data and deconstruct the value into a structure. No
3124 * other code should read the user-defined data, so as to ensure that every
3127 * The user-defined field is a 64bit Big Endian format value, which we
3132 * Returns 0 if the data is valid, and non-zero if the userdef data is invalid
3146 if (!(fsp->flow_type & FLOW_EXT)) in i40e_parse_rx_flow_user_data()
3149 value = be64_to_cpu(*((__be64 *)fsp->h_ext.data)); in i40e_parse_rx_flow_user_data()
3150 mask = be64_to_cpu(*((__be64 *)fsp->m_ext.data)); in i40e_parse_rx_flow_user_data()
3158 return -EINVAL; in i40e_parse_rx_flow_user_data()
3160 data->flex_word = value & I40E_USERDEF_FLEX_WORD; in i40e_parse_rx_flow_user_data()
3161 data->flex_offset = in i40e_parse_rx_flow_user_data()
3163 data->flex_filter = true; in i40e_parse_rx_flow_user_data()
3170 * i40e_fill_rx_flow_user_data - Fill in user-defined data field
3182 if (data->flex_filter) { in i40e_fill_rx_flow_user_data()
3183 value |= data->flex_word; in i40e_fill_rx_flow_user_data()
3184 value |= (u64)data->flex_offset << 16; in i40e_fill_rx_flow_user_data()
3189 fsp->flow_type |= FLOW_EXT; in i40e_fill_rx_flow_user_data()
3191 *((__be64 *)fsp->h_ext.data) = cpu_to_be64(value); in i40e_fill_rx_flow_user_data()
3192 *((__be64 *)fsp->m_ext.data) = cpu_to_be64(mask); in i40e_fill_rx_flow_user_data()
3196 * i40e_get_ethtool_fdir_all - Populates the rule count of a command
3204 * Returns 0 on success or -EMSGSIZE if entry not found
3215 cmd->data = i40e_get_fd_cnt_all(pf); in i40e_get_ethtool_fdir_all()
3218 &pf->fdir_filter_list, fdir_node) { in i40e_get_ethtool_fdir_all()
3219 if (cnt == cmd->rule_cnt) in i40e_get_ethtool_fdir_all()
3220 return -EMSGSIZE; in i40e_get_ethtool_fdir_all()
3222 rule_locs[cnt] = rule->fd_id; in i40e_get_ethtool_fdir_all()
3226 cmd->rule_cnt = cnt; in i40e_get_ethtool_fdir_all()
3232 * i40e_get_ethtool_fdir_entry - Look up a filter based on Rx flow
3239 * Returns 0 on success or -EINVAL if filter not found
3245 (struct ethtool_rx_flow_spec *)&cmd->fs; in i40e_get_ethtool_fdir_entry()
3253 &pf->fdir_filter_list, fdir_node) { in i40e_get_ethtool_fdir_entry()
3254 if (fsp->location <= rule->fd_id) in i40e_get_ethtool_fdir_entry()
3258 if (!rule || fsp->location != rule->fd_id) in i40e_get_ethtool_fdir_entry()
3259 return -EINVAL; in i40e_get_ethtool_fdir_entry()
3261 fsp->flow_type = rule->flow_type; in i40e_get_ethtool_fdir_entry()
3262 if (fsp->flow_type == IP_USER_FLOW) { in i40e_get_ethtool_fdir_entry()
3263 fsp->h_u.usr_ip4_spec.ip_ver = ETH_RX_NFC_IP4; in i40e_get_ethtool_fdir_entry()
3264 fsp->h_u.usr_ip4_spec.proto = 0; in i40e_get_ethtool_fdir_entry()
3265 fsp->m_u.usr_ip4_spec.proto = 0; in i40e_get_ethtool_fdir_entry()
3268 if (fsp->flow_type == IPV6_USER_FLOW || in i40e_get_ethtool_fdir_entry()
3269 fsp->flow_type == UDP_V6_FLOW || in i40e_get_ethtool_fdir_entry()
3270 fsp->flow_type == TCP_V6_FLOW || in i40e_get_ethtool_fdir_entry()
3271 fsp->flow_type == SCTP_V6_FLOW) { in i40e_get_ethtool_fdir_entry()
3272 /* Reverse the src and dest notion, since the HW views them in i40e_get_ethtool_fdir_entry()
3276 fsp->h_u.tcp_ip6_spec.psrc = rule->dst_port; in i40e_get_ethtool_fdir_entry()
3277 fsp->h_u.tcp_ip6_spec.pdst = rule->src_port; in i40e_get_ethtool_fdir_entry()
3278 memcpy(fsp->h_u.tcp_ip6_spec.ip6dst, rule->src_ip6, in i40e_get_ethtool_fdir_entry()
3280 memcpy(fsp->h_u.tcp_ip6_spec.ip6src, rule->dst_ip6, in i40e_get_ethtool_fdir_entry()
3283 /* Reverse the src and dest notion, since the HW views them in i40e_get_ethtool_fdir_entry()
3287 fsp->h_u.tcp_ip4_spec.psrc = rule->dst_port; in i40e_get_ethtool_fdir_entry()
3288 fsp->h_u.tcp_ip4_spec.pdst = rule->src_port; in i40e_get_ethtool_fdir_entry()
3289 fsp->h_u.tcp_ip4_spec.ip4src = rule->dst_ip; in i40e_get_ethtool_fdir_entry()
3290 fsp->h_u.tcp_ip4_spec.ip4dst = rule->src_ip; in i40e_get_ethtool_fdir_entry()
3293 switch (rule->flow_type) { in i40e_get_ethtool_fdir_entry()
3325 rule->flow_type); in i40e_get_ethtool_fdir_entry()
3334 fsp->m_u.tcp_ip6_spec.ip6src[0] = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3335 fsp->m_u.tcp_ip6_spec.ip6src[1] = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3336 fsp->m_u.tcp_ip6_spec.ip6src[2] = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3337 fsp->m_u.tcp_ip6_spec.ip6src[3] = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3341 fsp->m_u.tcp_ip6_spec.ip6dst[0] = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3342 fsp->m_u.tcp_ip6_spec.ip6dst[1] = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3343 fsp->m_u.tcp_ip6_spec.ip6dst[2] = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3344 fsp->m_u.tcp_ip6_spec.ip6dst[3] = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3348 fsp->m_u.tcp_ip4_spec.ip4src = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3351 fsp->m_u.tcp_ip4_spec.ip4dst = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3354 fsp->m_u.tcp_ip4_spec.psrc = htons(0xFFFF); in i40e_get_ethtool_fdir_entry()
3357 fsp->m_u.tcp_ip4_spec.pdst = htons(0xFFFF); in i40e_get_ethtool_fdir_entry()
3359 if (rule->dest_ctl == I40E_FILTER_PROGRAM_DESC_DEST_DROP_PACKET) in i40e_get_ethtool_fdir_entry()
3360 fsp->ring_cookie = RX_CLS_FLOW_DISC; in i40e_get_ethtool_fdir_entry()
3362 fsp->ring_cookie = rule->q_index; in i40e_get_ethtool_fdir_entry()
3364 if (rule->vlan_tag) { in i40e_get_ethtool_fdir_entry()
3365 fsp->h_ext.vlan_etype = rule->vlan_etype; in i40e_get_ethtool_fdir_entry()
3366 fsp->m_ext.vlan_etype = htons(0xFFFF); in i40e_get_ethtool_fdir_entry()
3367 fsp->h_ext.vlan_tci = rule->vlan_tag; in i40e_get_ethtool_fdir_entry()
3368 fsp->m_ext.vlan_tci = htons(0xFFFF); in i40e_get_ethtool_fdir_entry()
3369 fsp->flow_type |= FLOW_EXT; in i40e_get_ethtool_fdir_entry()
3372 if (rule->dest_vsi != pf->vsi[pf->lan_vsi]->id) { in i40e_get_ethtool_fdir_entry()
3375 vsi = i40e_find_vsi_from_id(pf, rule->dest_vsi); in i40e_get_ethtool_fdir_entry()
3376 if (vsi && vsi->type == I40E_VSI_SRIOV) { in i40e_get_ethtool_fdir_entry()
3377 /* VFs are zero-indexed by the driver, but ethtool in i40e_get_ethtool_fdir_entry()
3378 * expects them to be one-indexed, so add one here in i40e_get_ethtool_fdir_entry()
3380 u64 ring_vf = vsi->vf_id + 1; in i40e_get_ethtool_fdir_entry()
3383 fsp->ring_cookie |= ring_vf; in i40e_get_ethtool_fdir_entry()
3387 if (rule->flex_filter) { in i40e_get_ethtool_fdir_entry()
3389 userdef.flex_word = be16_to_cpu(rule->flex_word); in i40e_get_ethtool_fdir_entry()
3390 userdef.flex_offset = rule->flex_offset; in i40e_get_ethtool_fdir_entry()
3399 * i40e_get_rxnfc - command to get RX flow classification rules
3404 * Returns Success if the command is supported.
3410 struct i40e_vsi *vsi = np->vsi; in i40e_get_rxnfc()
3411 struct i40e_pf *pf = vsi->back; in i40e_get_rxnfc()
3412 int ret = -EOPNOTSUPP; in i40e_get_rxnfc()
3414 switch (cmd->cmd) { in i40e_get_rxnfc()
3416 cmd->data = vsi->rss_size; in i40e_get_rxnfc()
3423 cmd->rule_cnt = pf->fdir_pf_active_filters; in i40e_get_rxnfc()
3425 cmd->data = i40e_get_fd_cnt_all(pf); in i40e_get_rxnfc()
3442 * i40e_get_rss_hash_bits - Read RSS Hash bits from register
3453 if (nfc->data & RXH_L4_B_0_1) in i40e_get_rss_hash_bits()
3457 if (nfc->data & RXH_L4_B_2_3) in i40e_get_rss_hash_bits()
3462 if (nfc->flow_type == TCP_V6_FLOW || nfc->flow_type == UDP_V6_FLOW) { in i40e_get_rss_hash_bits()
3465 } else if (nfc->flow_type == TCP_V4_FLOW || in i40e_get_rss_hash_bits()
3466 nfc->flow_type == UDP_V4_FLOW) { in i40e_get_rss_hash_bits()
3470 /* Any other flow type are not supported here */ in i40e_get_rss_hash_bits()
3474 if (nfc->data & RXH_IP_SRC) in i40e_get_rss_hash_bits()
3478 if (nfc->data & RXH_IP_DST) in i40e_get_rss_hash_bits()
3487 * i40e_set_rss_hash_opt - Enable/Disable flow types for RSS hash
3491 * Returns Success if the flow input set is supported.
3495 struct i40e_hw *hw = &pf->hw; in i40e_set_rss_hash_opt() local
3496 u64 hena = (u64)i40e_read_rx_ctl(hw, I40E_PFQF_HENA(0)) | in i40e_set_rss_hash_opt()
3497 ((u64)i40e_read_rx_ctl(hw, I40E_PFQF_HENA(1)) << 32); in i40e_set_rss_hash_opt()
3501 if (pf->flags & I40E_FLAG_MFP_ENABLED) { in i40e_set_rss_hash_opt()
3502 dev_err(&pf->pdev->dev, in i40e_set_rss_hash_opt()
3503 "Change of RSS hash input set is not supported when MFP mode is enabled\n"); in i40e_set_rss_hash_opt()
3504 return -EOPNOTSUPP; in i40e_set_rss_hash_opt()
3510 if (nfc->data & ~(RXH_IP_SRC | RXH_IP_DST | in i40e_set_rss_hash_opt()
3512 return -EINVAL; in i40e_set_rss_hash_opt()
3514 switch (nfc->flow_type) { in i40e_set_rss_hash_opt()
3517 if (pf->hw_features & I40E_HW_MULTIPLE_TCP_UDP_RSS_PCTYPE) in i40e_set_rss_hash_opt()
3523 if (pf->hw_features & I40E_HW_MULTIPLE_TCP_UDP_RSS_PCTYPE) in i40e_set_rss_hash_opt()
3526 if (pf->hw_features & I40E_HW_MULTIPLE_TCP_UDP_RSS_PCTYPE) in i40e_set_rss_hash_opt()
3532 if (pf->hw_features & I40E_HW_MULTIPLE_TCP_UDP_RSS_PCTYPE) in i40e_set_rss_hash_opt()
3541 if (pf->hw_features & I40E_HW_MULTIPLE_TCP_UDP_RSS_PCTYPE) in i40e_set_rss_hash_opt()
3552 if ((nfc->data & RXH_L4_B_0_1) || in i40e_set_rss_hash_opt()
3553 (nfc->data & RXH_L4_B_2_3)) in i40e_set_rss_hash_opt()
3554 return -EINVAL; in i40e_set_rss_hash_opt()
3561 if ((nfc->data & RXH_L4_B_0_1) || in i40e_set_rss_hash_opt()
3562 (nfc->data & RXH_L4_B_2_3)) in i40e_set_rss_hash_opt()
3563 return -EINVAL; in i40e_set_rss_hash_opt()
3575 return -EINVAL; in i40e_set_rss_hash_opt()
3579 i_setc = (u64)i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(0, in i40e_set_rss_hash_opt()
3581 ((u64)i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(1, in i40e_set_rss_hash_opt()
3584 i40e_write_rx_ctl(hw, I40E_GLQF_HASH_INSET(0, flow_pctype), in i40e_set_rss_hash_opt()
3586 i40e_write_rx_ctl(hw, I40E_GLQF_HASH_INSET(1, flow_pctype), in i40e_set_rss_hash_opt()
3591 i40e_write_rx_ctl(hw, I40E_PFQF_HENA(0), (u32)hena); in i40e_set_rss_hash_opt()
3592 i40e_write_rx_ctl(hw, I40E_PFQF_HENA(1), (u32)(hena >> 32)); in i40e_set_rss_hash_opt()
3593 i40e_flush(hw); in i40e_set_rss_hash_opt()
3599 * i40e_update_ethtool_fdir_entry - Updates the fdir filter entry
3616 struct i40e_pf *pf = vsi->back; in i40e_update_ethtool_fdir_entry()
3618 int err = -EINVAL; in i40e_update_ethtool_fdir_entry()
3624 &pf->fdir_filter_list, fdir_node) { in i40e_update_ethtool_fdir_entry()
3626 if (rule->fd_id >= sw_idx) in i40e_update_ethtool_fdir_entry()
3632 if (rule && (rule->fd_id == sw_idx)) { in i40e_update_ethtool_fdir_entry()
3637 hlist_del(&rule->fdir_node); in i40e_update_ethtool_fdir_entry()
3639 pf->fdir_pf_active_filters--; in i40e_update_ethtool_fdir_entry()
3649 INIT_HLIST_NODE(&input->fdir_node); in i40e_update_ethtool_fdir_entry()
3653 hlist_add_behind(&input->fdir_node, &parent->fdir_node); in i40e_update_ethtool_fdir_entry()
3655 hlist_add_head(&input->fdir_node, in i40e_update_ethtool_fdir_entry()
3656 &pf->fdir_filter_list); in i40e_update_ethtool_fdir_entry()
3659 pf->fdir_pf_active_filters++; in i40e_update_ethtool_fdir_entry()
3665 * i40e_prune_flex_pit_list - Cleanup unused entries in FLX_PIT table
3678 list_for_each_entry_safe(entry, tmp, &pf->l3_flex_pit_list, list) { in i40e_prune_flex_pit_list()
3681 hlist_for_each_entry(rule, &pf->fdir_filter_list, fdir_node) { in i40e_prune_flex_pit_list()
3682 if (rule->flow_type != IP_USER_FLOW) in i40e_prune_flex_pit_list()
3684 if (rule->flex_filter && in i40e_prune_flex_pit_list()
3685 rule->flex_offset == entry->src_offset) { in i40e_prune_flex_pit_list()
3695 list_del(&entry->list); in i40e_prune_flex_pit_list()
3701 list_for_each_entry_safe(entry, tmp, &pf->l4_flex_pit_list, list) { in i40e_prune_flex_pit_list()
3704 hlist_for_each_entry(rule, &pf->fdir_filter_list, fdir_node) { in i40e_prune_flex_pit_list()
3708 if (rule->flow_type == IP_USER_FLOW) in i40e_prune_flex_pit_list()
3710 if (rule->flex_filter && in i40e_prune_flex_pit_list()
3711 rule->flex_offset == entry->src_offset) { in i40e_prune_flex_pit_list()
3721 list_del(&entry->list); in i40e_prune_flex_pit_list()
3728 * i40e_del_fdir_entry - Deletes a Flow Director filter entry
3741 (struct ethtool_rx_flow_spec *)&cmd->fs; in i40e_del_fdir_entry()
3742 struct i40e_pf *pf = vsi->back; in i40e_del_fdir_entry()
3745 if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) || in i40e_del_fdir_entry()
3746 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) in i40e_del_fdir_entry()
3747 return -EBUSY; in i40e_del_fdir_entry()
3749 if (test_bit(__I40E_FD_FLUSH_REQUESTED, pf->state)) in i40e_del_fdir_entry()
3750 return -EBUSY; in i40e_del_fdir_entry()
3752 ret = i40e_update_ethtool_fdir_entry(vsi, NULL, fsp->location, cmd); in i40e_del_fdir_entry()
3761 * i40e_unused_pit_index - Find an unused PIT index for given list
3779 list_for_each_entry(entry, &pf->l4_flex_pit_list, list) in i40e_unused_pit_index()
3780 clear_bit(entry->pit_index, &available_index); in i40e_unused_pit_index()
3782 list_for_each_entry(entry, &pf->l3_flex_pit_list, list) in i40e_unused_pit_index()
3783 clear_bit(entry->pit_index, &available_index); in i40e_unused_pit_index()
3789 * i40e_find_flex_offset - Find an existing flex src_offset
3805 * already programmed, we can simply re-use it. in i40e_find_flex_offset()
3809 if (entry->src_offset == src_offset) in i40e_find_flex_offset()
3819 return ERR_PTR(-ENOSPC); in i40e_find_flex_offset()
3825 * i40e_add_flex_offset - Add src_offset to flex PIT table list
3845 return -ENOMEM; in i40e_add_flex_offset()
3847 new_pit->src_offset = src_offset; in i40e_add_flex_offset()
3848 new_pit->pit_index = pit_index; in i40e_add_flex_offset()
3854 if (new_pit->src_offset < entry->src_offset) { in i40e_add_flex_offset()
3855 list_add_tail(&new_pit->list, &entry->list); in i40e_add_flex_offset()
3863 if (new_pit->src_offset == entry->src_offset) { in i40e_add_flex_offset()
3866 /* If the PIT index is not the same we can't re-use in i40e_add_flex_offset()
3869 if (new_pit->pit_index != entry->pit_index) in i40e_add_flex_offset()
3870 err = -EINVAL; in i40e_add_flex_offset()
3880 list_add_tail(&new_pit->list, flex_pit_list); in i40e_add_flex_offset()
3885 * __i40e_reprogram_flex_pit - Re-program specific FLX_PIT table
3898 * This function will reprogram the FLX_PIT register from a book-keeping
3932 u16 offset = entry->src_offset + j; in __i40e_reprogram_flex_pit()
3936 offset - 3); in __i40e_reprogram_flex_pit()
3939 i40e_write_rx_ctl(&pf->hw, in __i40e_reprogram_flex_pit()
3947 i40e_write_rx_ctl(&pf->hw, in __i40e_reprogram_flex_pit()
3949 I40E_FLEX_PREP_VAL(entry->pit_index + 50, in __i40e_reprogram_flex_pit()
3951 entry->src_offset)); in __i40e_reprogram_flex_pit()
3962 last_offset = list_prev_entry(entry, list)->src_offset + 1; in __i40e_reprogram_flex_pit()
3965 i40e_write_rx_ctl(&pf->hw, in __i40e_reprogram_flex_pit()
3974 * i40e_reprogram_flex_pit - Reprogram all FLX_PIT tables after input set change
3982 __i40e_reprogram_flex_pit(pf, &pf->l3_flex_pit_list, in i40e_reprogram_flex_pit()
3985 __i40e_reprogram_flex_pit(pf, &pf->l4_flex_pit_list, in i40e_reprogram_flex_pit()
3989 i40e_write_rx_ctl(&pf->hw, in i40e_reprogram_flex_pit()
3994 i40e_write_rx_ctl(&pf->hw, in i40e_reprogram_flex_pit()
4001 * i40e_flow_str - Converts a flow_type into a human readable string
4009 switch (fsp->flow_type & ~FLOW_EXT) { in i40e_flow_str()
4032 * i40e_pit_index_to_mask - Return the FLEX mask for a given PIT index
4063 * i40e_print_input_set - Show changes between two input sets
4074 struct i40e_pf *pf = vsi->back; in i40e_print_input_set()
4081 netif_info(pf, drv, vsi->netdev, "L3 source address: %s -> %s\n", in i40e_print_input_set()
4088 netif_info(pf, drv, vsi->netdev, "L3 destination address: %s -> %s\n", in i40e_print_input_set()
4095 netif_info(pf, drv, vsi->netdev, "L4 source port: %s -> %s\n", in i40e_print_input_set()
4102 netif_info(pf, drv, vsi->netdev, "L4 destination port: %s -> %s\n", in i40e_print_input_set()
4109 netif_info(pf, drv, vsi->netdev, "SCTP verification tag: %s -> %s\n", in i40e_print_input_set()
4120 netif_info(pf, drv, vsi->netdev, "FLEX index %d: %s -> %s\n", in i40e_print_input_set()
4126 netif_info(pf, drv, vsi->netdev, " Current input set: %0llx\n", in i40e_print_input_set()
4128 netif_info(pf, drv, vsi->netdev, "Requested input set: %0llx\n", in i40e_print_input_set()
4133 * i40e_check_fdir_input_set - Check that a given rx_flow_spec mask is valid
4151 * as supported, we print a diagnostic message displaying how the input set
4168 struct i40e_pf *pf = vsi->back; in i40e_check_fdir_input_set()
4177 switch (fsp->flow_type & ~FLOW_EXT) { in i40e_check_fdir_input_set()
4180 fdir_filter_count = &pf->fd_sctp4_filter_cnt; in i40e_check_fdir_input_set()
4184 fdir_filter_count = &pf->fd_tcp4_filter_cnt; in i40e_check_fdir_input_set()
4188 fdir_filter_count = &pf->fd_udp4_filter_cnt; in i40e_check_fdir_input_set()
4192 fdir_filter_count = &pf->fd_sctp6_filter_cnt; in i40e_check_fdir_input_set()
4196 fdir_filter_count = &pf->fd_tcp6_filter_cnt; in i40e_check_fdir_input_set()
4200 fdir_filter_count = &pf->fd_udp6_filter_cnt; in i40e_check_fdir_input_set()
4204 fdir_filter_count = &pf->fd_ip4_filter_cnt; in i40e_check_fdir_input_set()
4209 fdir_filter_count = &pf->fd_ip6_filter_cnt; in i40e_check_fdir_input_set()
4213 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4229 switch (fsp->flow_type & ~FLOW_EXT) { in i40e_check_fdir_input_set()
4235 tcp_ip4_spec = &fsp->m_u.tcp_ip4_spec; in i40e_check_fdir_input_set()
4238 if (tcp_ip4_spec->ip4src == htonl(0xFFFFFFFF)) in i40e_check_fdir_input_set()
4240 else if (!tcp_ip4_spec->ip4src) in i40e_check_fdir_input_set()
4243 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4246 if (tcp_ip4_spec->ip4dst == htonl(0xFFFFFFFF)) in i40e_check_fdir_input_set()
4248 else if (!tcp_ip4_spec->ip4dst) in i40e_check_fdir_input_set()
4251 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4254 if (tcp_ip4_spec->psrc == htons(0xFFFF)) in i40e_check_fdir_input_set()
4256 else if (!tcp_ip4_spec->psrc) in i40e_check_fdir_input_set()
4259 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4262 if (tcp_ip4_spec->pdst == htons(0xFFFF)) in i40e_check_fdir_input_set()
4264 else if (!tcp_ip4_spec->pdst) in i40e_check_fdir_input_set()
4267 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4269 /* Filtering on Type of Service is not supported. */ in i40e_check_fdir_input_set()
4270 if (tcp_ip4_spec->tos) in i40e_check_fdir_input_set()
4271 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4279 tcp_ip6_spec = &fsp->m_u.tcp_ip6_spec; in i40e_check_fdir_input_set()
4282 if (ipv6_addr_equal((struct in6_addr *)&tcp_ip6_spec->ip6src, in i40e_check_fdir_input_set()
4286 &tcp_ip6_spec->ip6src)) in i40e_check_fdir_input_set()
4289 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4292 if (ipv6_addr_equal((struct in6_addr *)&tcp_ip6_spec->ip6dst, in i40e_check_fdir_input_set()
4296 &tcp_ip6_spec->ip6dst)) in i40e_check_fdir_input_set()
4299 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4302 if (tcp_ip6_spec->psrc == htons(0xFFFF)) in i40e_check_fdir_input_set()
4304 else if (!tcp_ip6_spec->psrc) in i40e_check_fdir_input_set()
4307 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4310 if (tcp_ip6_spec->pdst == htons(0xFFFF)) in i40e_check_fdir_input_set()
4312 else if (!tcp_ip6_spec->pdst) in i40e_check_fdir_input_set()
4315 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4317 /* Filtering on Traffic Classes is not supported. */ in i40e_check_fdir_input_set()
4318 if (tcp_ip6_spec->tclass) in i40e_check_fdir_input_set()
4319 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4322 usr_ip4_spec = &fsp->m_u.usr_ip4_spec; in i40e_check_fdir_input_set()
4325 if (usr_ip4_spec->ip4src == htonl(0xFFFFFFFF)) in i40e_check_fdir_input_set()
4327 else if (!usr_ip4_spec->ip4src) in i40e_check_fdir_input_set()
4330 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4333 if (usr_ip4_spec->ip4dst == htonl(0xFFFFFFFF)) in i40e_check_fdir_input_set()
4335 else if (!usr_ip4_spec->ip4dst) in i40e_check_fdir_input_set()
4338 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4341 if (usr_ip4_spec->l4_4_bytes == htonl(0xFFFFFFFF)) in i40e_check_fdir_input_set()
4343 else if (!usr_ip4_spec->l4_4_bytes) in i40e_check_fdir_input_set()
4346 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4348 /* Filtering on Type of Service is not supported. */ in i40e_check_fdir_input_set()
4349 if (usr_ip4_spec->tos) in i40e_check_fdir_input_set()
4350 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4352 /* Filtering on IP version is not supported */ in i40e_check_fdir_input_set()
4353 if (usr_ip4_spec->ip_ver) in i40e_check_fdir_input_set()
4354 return -EINVAL; in i40e_check_fdir_input_set()
4356 /* Filtering on L4 protocol is not supported */ in i40e_check_fdir_input_set()
4357 if (usr_ip4_spec->proto) in i40e_check_fdir_input_set()
4358 return -EINVAL; in i40e_check_fdir_input_set()
4362 usr_ip6_spec = &fsp->m_u.usr_ip6_spec; in i40e_check_fdir_input_set()
4365 if (ipv6_addr_equal((struct in6_addr *)&usr_ip6_spec->ip6src, in i40e_check_fdir_input_set()
4369 &usr_ip6_spec->ip6src)) in i40e_check_fdir_input_set()
4372 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4375 if (ipv6_addr_equal((struct in6_addr *)&usr_ip6_spec->ip6dst, in i40e_check_fdir_input_set()
4379 &usr_ip6_spec->ip6src)) in i40e_check_fdir_input_set()
4382 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4384 if (usr_ip6_spec->l4_4_bytes == htonl(0xFFFFFFFF)) in i40e_check_fdir_input_set()
4386 else if (!usr_ip6_spec->l4_4_bytes) in i40e_check_fdir_input_set()
4389 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4391 /* Filtering on Traffic class is not supported. */ in i40e_check_fdir_input_set()
4392 if (usr_ip6_spec->tclass) in i40e_check_fdir_input_set()
4393 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4395 /* Filtering on L4 protocol is not supported */ in i40e_check_fdir_input_set()
4396 if (usr_ip6_spec->l4_proto) in i40e_check_fdir_input_set()
4397 return -EINVAL; in i40e_check_fdir_input_set()
4401 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4404 if (fsp->flow_type & FLOW_EXT) { in i40e_check_fdir_input_set()
4408 if (fsp->h_ext.vlan_etype != htons(ETH_P_8021Q) && in i40e_check_fdir_input_set()
4409 fsp->h_ext.vlan_etype != 0) in i40e_check_fdir_input_set()
4410 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4411 if (fsp->m_ext.vlan_tci == htons(0xFFFF)) in i40e_check_fdir_input_set()
4425 if (userdef->flex_filter) { in i40e_check_fdir_input_set()
4429 * must be aligned on 2-byte boundary. in i40e_check_fdir_input_set()
4431 if (userdef->flex_offset & 0x1) { in i40e_check_fdir_input_set()
4432 dev_warn(&pf->pdev->dev, in i40e_check_fdir_input_set()
4433 "Flexible data offset must be 2-byte aligned\n"); in i40e_check_fdir_input_set()
4434 return -EINVAL; in i40e_check_fdir_input_set()
4437 src_offset = userdef->flex_offset >> 1; in i40e_check_fdir_input_set()
4441 dev_warn(&pf->pdev->dev, in i40e_check_fdir_input_set()
4443 return -EINVAL; in i40e_check_fdir_input_set()
4451 flex_pit = i40e_find_flex_offset(&pf->l4_flex_pit_list, in i40e_check_fdir_input_set()
4465 i40e_find_flex_offset(&pf->l3_flex_pit_list, in i40e_check_fdir_input_set()
4476 if (l3_flex_pit->pit_index != in i40e_check_fdir_input_set()
4477 flex_pit->pit_index) { in i40e_check_fdir_input_set()
4478 return -EINVAL; in i40e_check_fdir_input_set()
4497 pit_index = flex_pit->pit_index; in i40e_check_fdir_input_set()
4511 netif_info(pf, drv, vsi->netdev, "Input set change requested for %s flows:\n", in i40e_check_fdir_input_set()
4515 netif_info(pf, drv, vsi->netdev, "FLEX index %d: Offset -> %d", in i40e_check_fdir_input_set()
4523 if (pf->flags & I40E_FLAG_MFP_ENABLED) { in i40e_check_fdir_input_set()
4524 netif_err(pf, drv, vsi->netdev, "Cannot change Flow Director input sets while MFP is enabled\n"); in i40e_check_fdir_input_set()
4525 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4538 …netif_err(pf, drv, vsi->netdev, "Cannot change input set for %s flows until %d preexisting filters… in i40e_check_fdir_input_set()
4541 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4558 err = i40e_add_flex_offset(&pf->l4_flex_pit_list, src_offset, in i40e_check_fdir_input_set()
4564 err = i40e_add_flex_offset(&pf->l3_flex_pit_list, in i40e_check_fdir_input_set()
4578 * i40e_match_fdir_filter - Return true of two filters match
4584 * check any input-set since all filters of the same flow type must use the
4591 if (a->dst_ip != b->dst_ip || in i40e_match_fdir_filter()
4592 a->src_ip != b->src_ip || in i40e_match_fdir_filter()
4593 a->dst_port != b->dst_port || in i40e_match_fdir_filter()
4594 a->src_port != b->src_port || in i40e_match_fdir_filter()
4595 a->flow_type != b->flow_type || in i40e_match_fdir_filter()
4596 a->ipl4_proto != b->ipl4_proto || in i40e_match_fdir_filter()
4597 a->vlan_tag != b->vlan_tag || in i40e_match_fdir_filter()
4598 a->vlan_etype != b->vlan_etype) in i40e_match_fdir_filter()
4605 * i40e_disallow_matching_filters - Check that new filters differ
4632 struct i40e_pf *pf = vsi->back; in i40e_disallow_matching_filters()
4638 &pf->fdir_filter_list, fdir_node) { in i40e_disallow_matching_filters()
4643 if (rule->fd_id == input->fd_id) in i40e_disallow_matching_filters()
4650 dev_warn(&pf->pdev->dev, in i40e_disallow_matching_filters()
4652 rule->fd_id); in i40e_disallow_matching_filters()
4653 return -EINVAL; in i40e_disallow_matching_filters()
4661 * i40e_add_fdir_ethtool - Add/Remove Flow Director filters
4676 int ret = -EINVAL; in i40e_add_fdir_ethtool()
4680 return -EINVAL; in i40e_add_fdir_ethtool()
4681 pf = vsi->back; in i40e_add_fdir_ethtool()
4683 if (!(pf->flags & I40E_FLAG_FD_SB_ENABLED)) in i40e_add_fdir_ethtool()
4684 return -EOPNOTSUPP; in i40e_add_fdir_ethtool()
4686 if (test_bit(__I40E_FD_SB_AUTO_DISABLED, pf->state)) in i40e_add_fdir_ethtool()
4687 return -ENOSPC; in i40e_add_fdir_ethtool()
4689 if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) || in i40e_add_fdir_ethtool()
4690 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) in i40e_add_fdir_ethtool()
4691 return -EBUSY; in i40e_add_fdir_ethtool()
4693 if (test_bit(__I40E_FD_FLUSH_REQUESTED, pf->state)) in i40e_add_fdir_ethtool()
4694 return -EBUSY; in i40e_add_fdir_ethtool()
4696 fsp = (struct ethtool_rx_flow_spec *)&cmd->fs; in i40e_add_fdir_ethtool()
4698 /* Parse the user-defined field */ in i40e_add_fdir_ethtool()
4700 return -EINVAL; in i40e_add_fdir_ethtool()
4702 /* Extended MAC field is not supported */ in i40e_add_fdir_ethtool()
4703 if (fsp->flow_type & FLOW_MAC_EXT) in i40e_add_fdir_ethtool()
4704 return -EINVAL; in i40e_add_fdir_ethtool()
4710 if (fsp->location >= (pf->hw.func_caps.fd_filters_best_effort + in i40e_add_fdir_ethtool()
4711 pf->hw.func_caps.fd_filters_guaranteed)) { in i40e_add_fdir_ethtool()
4712 return -EINVAL; in i40e_add_fdir_ethtool()
4718 if (fsp->ring_cookie == RX_CLS_FLOW_DISC) { in i40e_add_fdir_ethtool()
4721 u32 ring = ethtool_get_flow_spec_ring(fsp->ring_cookie); in i40e_add_fdir_ethtool()
4722 u8 vf = ethtool_get_flow_spec_ring_vf(fsp->ring_cookie); in i40e_add_fdir_ethtool()
4725 if (ring >= vsi->num_queue_pairs) in i40e_add_fdir_ethtool()
4726 return -EINVAL; in i40e_add_fdir_ethtool()
4727 dest_vsi = vsi->id; in i40e_add_fdir_ethtool()
4729 /* VFs are zero-indexed, so we subtract one here */ in i40e_add_fdir_ethtool()
4730 vf--; in i40e_add_fdir_ethtool()
4732 if (vf >= pf->num_alloc_vfs) in i40e_add_fdir_ethtool()
4733 return -EINVAL; in i40e_add_fdir_ethtool()
4734 if (ring >= pf->vf[vf].num_queue_pairs) in i40e_add_fdir_ethtool()
4735 return -EINVAL; in i40e_add_fdir_ethtool()
4736 dest_vsi = pf->vf[vf].lan_vsi_id; in i40e_add_fdir_ethtool()
4745 return -ENOMEM; in i40e_add_fdir_ethtool()
4747 input->fd_id = fsp->location; in i40e_add_fdir_ethtool()
4748 input->q_index = q_index; in i40e_add_fdir_ethtool()
4749 input->dest_vsi = dest_vsi; in i40e_add_fdir_ethtool()
4750 input->dest_ctl = dest_ctl; in i40e_add_fdir_ethtool()
4751 input->fd_status = I40E_FILTER_PROGRAM_DESC_FD_STATUS_FD_ID; in i40e_add_fdir_ethtool()
4752 input->cnt_index = I40E_FD_SB_STAT_IDX(pf->hw.pf_id); in i40e_add_fdir_ethtool()
4753 input->dst_ip = fsp->h_u.tcp_ip4_spec.ip4src; in i40e_add_fdir_ethtool()
4754 input->src_ip = fsp->h_u.tcp_ip4_spec.ip4dst; in i40e_add_fdir_ethtool()
4755 input->flow_type = fsp->flow_type & ~FLOW_EXT; in i40e_add_fdir_ethtool()
4757 input->vlan_etype = fsp->h_ext.vlan_etype; in i40e_add_fdir_ethtool()
4758 if (!fsp->m_ext.vlan_etype && fsp->h_ext.vlan_tci) in i40e_add_fdir_ethtool()
4759 input->vlan_etype = cpu_to_be16(ETH_P_8021Q); in i40e_add_fdir_ethtool()
4760 if (fsp->m_ext.vlan_tci && input->vlan_etype) in i40e_add_fdir_ethtool()
4761 input->vlan_tag = fsp->h_ext.vlan_tci; in i40e_add_fdir_ethtool()
4762 if (input->flow_type == IPV6_USER_FLOW || in i40e_add_fdir_ethtool()
4763 input->flow_type == UDP_V6_FLOW || in i40e_add_fdir_ethtool()
4764 input->flow_type == TCP_V6_FLOW || in i40e_add_fdir_ethtool()
4765 input->flow_type == SCTP_V6_FLOW) { in i40e_add_fdir_ethtool()
4766 /* Reverse the src and dest notion, since the HW expects them in i40e_add_fdir_ethtool()
4770 input->ipl4_proto = fsp->h_u.usr_ip6_spec.l4_proto; in i40e_add_fdir_ethtool()
4771 input->dst_port = fsp->h_u.tcp_ip6_spec.psrc; in i40e_add_fdir_ethtool()
4772 input->src_port = fsp->h_u.tcp_ip6_spec.pdst; in i40e_add_fdir_ethtool()
4773 memcpy(input->dst_ip6, fsp->h_u.ah_ip6_spec.ip6src, in i40e_add_fdir_ethtool()
4775 memcpy(input->src_ip6, fsp->h_u.ah_ip6_spec.ip6dst, in i40e_add_fdir_ethtool()
4778 /* Reverse the src and dest notion, since the HW expects them in i40e_add_fdir_ethtool()
4782 input->ipl4_proto = fsp->h_u.usr_ip4_spec.proto; in i40e_add_fdir_ethtool()
4783 input->dst_port = fsp->h_u.tcp_ip4_spec.psrc; in i40e_add_fdir_ethtool()
4784 input->src_port = fsp->h_u.tcp_ip4_spec.pdst; in i40e_add_fdir_ethtool()
4785 input->dst_ip = fsp->h_u.tcp_ip4_spec.ip4src; in i40e_add_fdir_ethtool()
4786 input->src_ip = fsp->h_u.tcp_ip4_spec.ip4dst; in i40e_add_fdir_ethtool()
4790 input->flex_filter = true; in i40e_add_fdir_ethtool()
4791 input->flex_word = cpu_to_be16(userdef.flex_word); in i40e_add_fdir_ethtool()
4792 input->flex_offset = userdef.flex_offset; in i40e_add_fdir_ethtool()
4802 * to the list as this would cause a use-after-free bug. in i40e_add_fdir_ethtool()
4804 i40e_update_ethtool_fdir_entry(vsi, input, fsp->location, NULL); in i40e_add_fdir_ethtool()
4811 hlist_del(&input->fdir_node); in i40e_add_fdir_ethtool()
4812 pf->fdir_pf_active_filters--; in i40e_add_fdir_ethtool()
4819 * i40e_set_rxnfc - command to set RX flow classification rules
4823 * Returns Success if the command is supported.
4828 struct i40e_vsi *vsi = np->vsi; in i40e_set_rxnfc()
4829 struct i40e_pf *pf = vsi->back; in i40e_set_rxnfc()
4830 int ret = -EOPNOTSUPP; in i40e_set_rxnfc()
4832 switch (cmd->cmd) { in i40e_set_rxnfc()
4850 * i40e_max_channels - get Max number of combined channels supported
4856 return vsi->alloc_queue_pairs; in i40e_max_channels()
4860 * i40e_get_channels - Get the current channels enabled and max supported etc.
4873 struct i40e_vsi *vsi = np->vsi; in i40e_get_channels()
4874 struct i40e_pf *pf = vsi->back; in i40e_get_channels()
4877 ch->max_combined = i40e_max_channels(vsi); in i40e_get_channels()
4880 ch->other_count = (pf->flags & I40E_FLAG_FD_SB_ENABLED) ? 1 : 0; in i40e_get_channels()
4881 ch->max_other = ch->other_count; in i40e_get_channels()
4884 ch->combined_count = vsi->num_queue_pairs; in i40e_get_channels()
4888 * i40e_set_channels - Set the new channels count.
4900 unsigned int count = ch->combined_count; in i40e_set_channels()
4901 struct i40e_vsi *vsi = np->vsi; in i40e_set_channels()
4902 struct i40e_pf *pf = vsi->back; in i40e_set_channels()
4909 if (vsi->type != I40E_VSI_MAIN) in i40e_set_channels()
4910 return -EINVAL; in i40e_set_channels()
4915 if (pf->flags & I40E_FLAG_TC_MQPRIO) in i40e_set_channels()
4916 return -EINVAL; in i40e_set_channels()
4919 if (!count || ch->rx_count || ch->tx_count) in i40e_set_channels()
4920 return -EINVAL; in i40e_set_channels()
4923 if (ch->other_count != ((pf->flags & I40E_FLAG_FD_SB_ENABLED) ? 1 : 0)) in i40e_set_channels()
4924 return -EINVAL; in i40e_set_channels()
4928 return -EINVAL; in i40e_set_channels()
4934 &pf->fdir_filter_list, fdir_node) { in i40e_set_channels()
4935 if (rule->dest_ctl != drop && count <= rule->q_index) { in i40e_set_channels()
4936 dev_warn(&pf->pdev->dev, in i40e_set_channels()
4938 rule->fd_id, rule->q_index); in i40e_set_channels()
4939 err = -EINVAL; in i40e_set_channels()
4944 dev_err(&pf->pdev->dev, in i40e_set_channels()
4950 /* update feature limits from largest to smallest supported values */ in i40e_set_channels()
4960 return -EINVAL; in i40e_set_channels()
4964 * i40e_get_rxfh_key_size - get the RSS hash key size
4975 * i40e_get_rxfh_indir_size - get the rx flow hash indirection table size
4986 * i40e_get_rxfh - get the rx flow hash indirection table
4999 struct i40e_vsi *vsi = np->vsi; in i40e_get_rxfh()
5013 return -ENOMEM; in i40e_get_rxfh()
5027 * i40e_set_rxfh - set the rx flow hash indirection table
5033 * Returns -EINVAL if the table specifies an invalid queue id, otherwise
5040 struct i40e_vsi *vsi = np->vsi; in i40e_set_rxfh()
5041 struct i40e_pf *pf = vsi->back; in i40e_set_rxfh()
5046 return -EOPNOTSUPP; in i40e_set_rxfh()
5049 if (!vsi->rss_hkey_user) { in i40e_set_rxfh()
5050 vsi->rss_hkey_user = kzalloc(I40E_HKEY_ARRAY_SIZE, in i40e_set_rxfh()
5052 if (!vsi->rss_hkey_user) in i40e_set_rxfh()
5053 return -ENOMEM; in i40e_set_rxfh()
5055 memcpy(vsi->rss_hkey_user, key, I40E_HKEY_ARRAY_SIZE); in i40e_set_rxfh()
5056 seed = vsi->rss_hkey_user; in i40e_set_rxfh()
5058 if (!vsi->rss_lut_user) { in i40e_set_rxfh()
5059 vsi->rss_lut_user = kzalloc(I40E_HLUT_ARRAY_SIZE, GFP_KERNEL); in i40e_set_rxfh()
5060 if (!vsi->rss_lut_user) in i40e_set_rxfh()
5061 return -ENOMEM; in i40e_set_rxfh()
5067 vsi->rss_lut_user[i] = (u8)(indir[i]); in i40e_set_rxfh()
5069 i40e_fill_rss_lut(pf, vsi->rss_lut_user, I40E_HLUT_ARRAY_SIZE, in i40e_set_rxfh()
5070 vsi->rss_size); in i40e_set_rxfh()
5072 return i40e_config_rss(vsi, seed, vsi->rss_lut_user, in i40e_set_rxfh()
5077 * i40e_get_priv_flags - report device private flags
5089 struct i40e_vsi *vsi = np->vsi; in i40e_get_priv_flags()
5090 struct i40e_pf *pf = vsi->back; in i40e_get_priv_flags()
5098 if (priv_flags->flag & pf->flags) in i40e_get_priv_flags()
5102 if (pf->hw.pf_id != 0) in i40e_get_priv_flags()
5110 if (priv_flags->flag & pf->flags) in i40e_get_priv_flags()
5118 * i40e_set_priv_flags - set private flags
5127 struct i40e_vsi *vsi = np->vsi; in i40e_set_priv_flags()
5128 struct i40e_pf *pf = vsi->back; in i40e_set_priv_flags()
5133 orig_flags = READ_ONCE(pf->flags); in i40e_set_priv_flags()
5142 new_flags |= priv_flags->flag; in i40e_set_priv_flags()
5144 new_flags &= ~(priv_flags->flag); in i40e_set_priv_flags()
5146 /* If this is a read-only flag, it can't be changed */ in i40e_set_priv_flags()
5147 if (priv_flags->read_only && in i40e_set_priv_flags()
5149 return -EOPNOTSUPP; in i40e_set_priv_flags()
5152 if (pf->hw.pf_id != 0) in i40e_set_priv_flags()
5161 new_flags |= priv_flags->flag; in i40e_set_priv_flags()
5163 new_flags &= ~(priv_flags->flag); in i40e_set_priv_flags()
5165 /* If this is a read-only flag, it can't be changed */ in i40e_set_priv_flags()
5166 if (priv_flags->read_only && in i40e_set_priv_flags()
5168 return -EOPNOTSUPP; in i40e_set_priv_flags()
5181 * checks to ensure that the changes are supported and safe. in i40e_set_priv_flags()
5184 /* ATR eviction is not supported on all devices */ in i40e_set_priv_flags()
5186 !(pf->hw_features & I40E_HW_ATR_EVICT_CAPABLE)) in i40e_set_priv_flags()
5187 return -EOPNOTSUPP; in i40e_set_priv_flags()
5191 * - on XL710 if NPAR is enabled or FW API version < 1.7 in i40e_set_priv_flags()
5192 * - on X722 with FW API version < 1.6 in i40e_set_priv_flags()
5198 if (!(pf->hw.flags & I40E_HW_FLAG_FW_LLDP_STOPPABLE)) { in i40e_set_priv_flags()
5199 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5201 return -EOPNOTSUPP; in i40e_set_priv_flags()
5206 pf->hw.device_id != I40E_DEV_ID_25G_SFP28 && in i40e_set_priv_flags()
5207 pf->hw.device_id != I40E_DEV_ID_25G_B) { in i40e_set_priv_flags()
5208 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5210 return -EOPNOTSUPP; in i40e_set_priv_flags()
5214 pf->hw.device_id != I40E_DEV_ID_25G_SFP28 && in i40e_set_priv_flags()
5215 pf->hw.device_id != I40E_DEV_ID_25G_B && in i40e_set_priv_flags()
5216 pf->hw.device_id != I40E_DEV_ID_KX_X722) { in i40e_set_priv_flags()
5217 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5219 return -EOPNOTSUPP; in i40e_set_priv_flags()
5230 set_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state); in i40e_set_priv_flags()
5231 set_bit(__I40E_FD_FLUSH_REQUESTED, pf->state); in i40e_set_priv_flags()
5241 ret = i40e_aq_set_switch_config(&pf->hw, sw_flags, valid_flags, in i40e_set_priv_flags()
5243 if (ret && pf->hw.aq.asq_last_status != I40E_AQ_RC_ESRCH) { in i40e_set_priv_flags()
5244 dev_info(&pf->pdev->dev, in i40e_set_priv_flags()
5246 i40e_stat_str(&pf->hw, ret), in i40e_set_priv_flags()
5247 i40e_aq_str(&pf->hw, in i40e_set_priv_flags()
5248 pf->hw.aq.asq_last_status)); in i40e_set_priv_flags()
5268 dev_warn(&pf->pdev->dev, "Cannot change FEC config\n"); in i40e_set_priv_flags()
5273 dev_err(&pf->pdev->dev, in i40e_set_priv_flags()
5274 …"Setting link-down-on-close not supported on this port (because total-port-shutdown is enabled)\n"… in i40e_set_priv_flags()
5275 return -EOPNOTSUPP; in i40e_set_priv_flags()
5281 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5282 "Turning on link-down-on-close flag may affect other partitions\n"); in i40e_set_priv_flags()
5289 i40e_aq_cfg_lldp_mib_change_event(&pf->hw, false, NULL); in i40e_set_priv_flags()
5290 i40e_aq_stop_lldp(&pf->hw, true, false, NULL); in i40e_set_priv_flags()
5292 status = i40e_aq_start_lldp(&pf->hw, false, NULL); in i40e_set_priv_flags()
5294 adq_err = pf->hw.aq.asq_last_status; in i40e_set_priv_flags()
5297 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5302 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5304 return -EINVAL; in i40e_set_priv_flags()
5306 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5308 return -EBUSY; in i40e_set_priv_flags()
5310 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5312 i40e_stat_str(&pf->hw, in i40e_set_priv_flags()
5314 i40e_aq_str(&pf->hw, in i40e_set_priv_flags()
5316 return -EINVAL; in i40e_set_priv_flags()
5327 pf->flags = new_flags; in i40e_set_priv_flags()
5339 * i40e_get_module_info - get (Q)SFP+ module type info
5347 struct i40e_vsi *vsi = np->vsi; in i40e_get_module_info()
5348 struct i40e_pf *pf = vsi->back; in i40e_get_module_info()
5349 struct i40e_hw *hw = &pf->hw; in i40e_get_module_info() local
5357 if (!(hw->flags & I40E_HW_FLAG_AQ_PHY_ACCESS_CAPABLE)) { in i40e_get_module_info()
5358 …netdev_err(vsi->netdev, "Module EEPROM memory read not supported. Please update the NVM image.\n"); in i40e_get_module_info()
5359 return -EINVAL; in i40e_get_module_info()
5362 status = i40e_update_link_info(hw); in i40e_get_module_info()
5364 return -EIO; in i40e_get_module_info()
5366 if (hw->phy.link_info.phy_type == I40E_PHY_TYPE_EMPTY) { in i40e_get_module_info()
5367 netdev_err(vsi->netdev, "Cannot read module EEPROM memory. No module connected.\n"); in i40e_get_module_info()
5368 return -EINVAL; in i40e_get_module_info()
5371 type = hw->phy.link_info.module_type[0]; in i40e_get_module_info()
5375 status = i40e_aq_get_phy_register(hw, in i40e_get_module_info()
5381 return -EIO; in i40e_get_module_info()
5383 status = i40e_aq_get_phy_register(hw, in i40e_get_module_info()
5389 return -EIO; in i40e_get_module_info()
5395 netdev_warn(vsi->netdev, "Module address swap to access page 0xA2 is not supported.\n"); in i40e_get_module_info()
5396 modinfo->type = ETH_MODULE_SFF_8079; in i40e_get_module_info()
5397 modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN; in i40e_get_module_info()
5399 /* Module is not SFF-8472 compliant */ in i40e_get_module_info()
5400 modinfo->type = ETH_MODULE_SFF_8079; in i40e_get_module_info()
5401 modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN; in i40e_get_module_info()
5403 /* Module is SFF-8472 compliant but doesn't implement in i40e_get_module_info()
5406 modinfo->type = ETH_MODULE_SFF_8079; in i40e_get_module_info()
5407 modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN; in i40e_get_module_info()
5409 modinfo->type = ETH_MODULE_SFF_8472; in i40e_get_module_info()
5410 modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN; in i40e_get_module_info()
5415 status = i40e_aq_get_phy_register(hw, in i40e_get_module_info()
5421 return -EIO; in i40e_get_module_info()
5424 /* Module is SFF-8636 compliant */ in i40e_get_module_info()
5425 modinfo->type = ETH_MODULE_SFF_8636; in i40e_get_module_info()
5426 modinfo->eeprom_len = I40E_MODULE_QSFP_MAX_LEN; in i40e_get_module_info()
5428 modinfo->type = ETH_MODULE_SFF_8436; in i40e_get_module_info()
5429 modinfo->eeprom_len = I40E_MODULE_QSFP_MAX_LEN; in i40e_get_module_info()
5433 modinfo->type = ETH_MODULE_SFF_8636; in i40e_get_module_info()
5434 modinfo->eeprom_len = I40E_MODULE_QSFP_MAX_LEN; in i40e_get_module_info()
5437 netdev_err(vsi->netdev, "Module type unrecognized\n"); in i40e_get_module_info()
5438 return -EINVAL; in i40e_get_module_info()
5444 * i40e_get_module_eeprom - fills buffer with (Q)SFP+ module memory contents
5454 struct i40e_vsi *vsi = np->vsi; in i40e_get_module_eeprom()
5455 struct i40e_pf *pf = vsi->back; in i40e_get_module_eeprom()
5456 struct i40e_hw *hw = &pf->hw; in i40e_get_module_eeprom() local
5462 if (!ee || !ee->len || !data) in i40e_get_module_eeprom()
5463 return -EINVAL; in i40e_get_module_eeprom()
5465 if (hw->phy.link_info.module_type[0] == I40E_MODULE_TYPE_SFP) in i40e_get_module_eeprom()
5468 for (i = 0; i < ee->len; i++) { in i40e_get_module_eeprom()
5469 u32 offset = i + ee->offset; in i40e_get_module_eeprom()
5475 offset -= ETH_MODULE_SFF_8079_LEN; in i40e_get_module_eeprom()
5481 offset -= ETH_MODULE_SFF_8436_LEN / 2; in i40e_get_module_eeprom()
5486 status = i40e_aq_get_phy_register(hw, in i40e_get_module_eeprom()
5490 return -EIO; in i40e_get_module_eeprom()
5501 struct i40e_vsi *vsi = np->vsi; in i40e_get_eee()
5502 struct i40e_pf *pf = vsi->back; in i40e_get_eee()
5503 struct i40e_hw *hw = &pf->hw; in i40e_get_eee() local
5506 status = i40e_aq_get_phy_capabilities(hw, false, true, &phy_cfg, NULL); in i40e_get_eee()
5508 return -EAGAIN; in i40e_get_eee()
5514 return -EOPNOTSUPP; in i40e_get_eee()
5516 edata->supported = SUPPORTED_Autoneg; in i40e_get_eee()
5517 edata->lp_advertised = edata->supported; in i40e_get_eee()
5520 status = i40e_aq_get_phy_capabilities(hw, false, false, &phy_cfg, NULL); in i40e_get_eee()
5522 return -EAGAIN; in i40e_get_eee()
5524 edata->advertised = phy_cfg.eee_capability ? SUPPORTED_Autoneg : 0U; in i40e_get_eee()
5525 edata->eee_enabled = !!edata->advertised; in i40e_get_eee()
5526 edata->tx_lpi_enabled = pf->stats.tx_lpi_status; in i40e_get_eee()
5528 edata->eee_active = pf->stats.tx_lpi_status && pf->stats.rx_lpi_status; in i40e_get_eee()
5537 struct i40e_vsi *vsi = np->vsi; in i40e_is_eee_param_supported()
5538 struct i40e_pf *pf = vsi->back; in i40e_is_eee_param_supported()
5543 {edata->advertised & ~SUPPORTED_Autoneg, "advertise"}, in i40e_is_eee_param_supported()
5544 {edata->tx_lpi_timer, "tx-timer"}, in i40e_is_eee_param_supported()
5545 {edata->tx_lpi_enabled != pf->stats.tx_lpi_status, "tx-lpi"} in i40e_is_eee_param_supported()
5552 "EEE setting %s not supported\n", in i40e_is_eee_param_supported()
5554 return -EOPNOTSUPP; in i40e_is_eee_param_supported()
5567 struct i40e_vsi *vsi = np->vsi; in i40e_set_eee()
5568 struct i40e_pf *pf = vsi->back; in i40e_set_eee()
5569 struct i40e_hw *hw = &pf->hw; in i40e_set_eee() local
5574 return -EOPNOTSUPP; in i40e_set_eee()
5577 status = i40e_aq_get_phy_capabilities(hw, false, true, &abilities, in i40e_set_eee()
5580 return -EAGAIN; in i40e_set_eee()
5586 return -EOPNOTSUPP; in i40e_set_eee()
5592 status = i40e_aq_get_phy_capabilities(hw, false, false, &abilities, in i40e_set_eee()
5595 return -EAGAIN; in i40e_set_eee()
5609 if (edata->eee_enabled) { in i40e_set_eee()
5618 status = i40e_aq_set_phy_config(hw, &config, NULL); in i40e_set_eee()
5620 return -EAGAIN; in i40e_set_eee()
5688 struct i40e_pf *pf = np->vsi->back; in i40e_set_ethtool_ops()
5690 if (!test_bit(__I40E_RECOVERY_MODE, pf->state)) in i40e_set_ethtool_ops()
5691 netdev->ethtool_ops = &i40e_ethtool_ops; in i40e_set_ethtool_ops()
5693 netdev->ethtool_ops = &i40e_ethtool_recovery_mode_ops; in i40e_set_ethtool_ops()