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

1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2013 - 2018 Intel Corporation. */
14 * struct i40e_stats - definition for an ethtool statistic
15 * @stat_string: statistic name to display in ethtool -S output
63 I40E_QUEUE_STAT("%s-%u.packets", stats.packets),
64 I40E_QUEUE_STAT("%s-%u.bytes", stats.bytes),
68 * i40e_add_one_ethtool_stat - copy the stat into the supplied buffer
91 p = (char *)pointer + stat->stat_offset; in i40e_add_one_ethtool_stat()
92 switch (stat->sizeof_stat) { in i40e_add_one_ethtool_stat()
107 stat->stat_string); in i40e_add_one_ethtool_stat()
113 * __i40e_add_ethtool_stats - copy stats into the ethtool supplied buffer
137 * i40e_add_ethtool_stats - copy stats into ethtool supplied buffer
153 * i40e_add_queue_stats - copy queue statistics into supplied buffer
177 * non-null before attempting to access its syncp. in i40e_add_queue_stats()
180 start = !ring ? 0 : u64_stats_fetch_begin(&ring->syncp); in i40e_add_queue_stats()
185 } while (ring && u64_stats_fetch_retry(&ring->syncp, start)); in i40e_add_queue_stats()
192 * __i40e_add_stat_strings - copy stat strings into ethtool buffer
216 * i40e_add_stat_strings - copy stat strings into ethtool buffer
313 * The PF_STATs are appended to the netdev stats only when ethtool -S
446 I40E_PRIV_FLAG("total-port-shutdown",
449 I40E_PRIV_FLAG("flow-director-atr", I40E_FLAG_FD_ATR_ENA, 0),
450 I40E_PRIV_FLAG("veb-stats", I40E_FLAG_VEB_STATS_ENA, 0),
451 I40E_PRIV_FLAG("hw-atr-eviction", I40E_FLAG_HW_ATR_EVICT_ENA, 0),
452 I40E_PRIV_FLAG("link-down-on-close",
454 I40E_PRIV_FLAG("legacy-rx", I40E_FLAG_LEGACY_RX_ENA, 0),
455 I40E_PRIV_FLAG("disable-source-pruning",
457 I40E_PRIV_FLAG("disable-fw-lldp", I40E_FLAG_FW_LLDP_DIS, 0),
458 I40E_PRIV_FLAG("rs-fec", I40E_FLAG_RS_FEC, 0),
459 I40E_PRIV_FLAG("base-r-fec", I40E_FLAG_BASE_R_FEC, 0),
460 I40E_PRIV_FLAG("vf-vlan-pruning",
468 I40E_PRIV_FLAG("vf-true-promisc-support",
475 * i40e_partition_setting_complaint - generic complaint for MFP restriction
480 dev_info(&pf->pdev->dev, in i40e_partition_setting_complaint()
485 * i40e_phy_type_to_ethtool - convert the phy_types to ethtool link modes
493 struct i40e_link_status *hw_link_info = &pf->hw.phy.link_info; in i40e_phy_type_to_ethtool()
494 u64 phy_types = pf->hw.phy.phy_types; in i40e_phy_type_to_ethtool()
496 ethtool_link_ksettings_zero_link_mode(ks, supported); in i40e_phy_type_to_ethtool()
500 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
502 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB) in i40e_phy_type_to_ethtool()
505 if (test_bit(I40E_HW_CAP_100M_SGMII, pf->hw.caps)) { in i40e_phy_type_to_ethtool()
506 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
517 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
519 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_phy_type_to_ethtool()
524 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
526 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_phy_type_to_ethtool()
531 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
533 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_2_5GB) in i40e_phy_type_to_ethtool()
538 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
540 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_5GB) in i40e_phy_type_to_ethtool()
547 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
551 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
553 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_40GB) in i40e_phy_type_to_ethtool()
558 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
560 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_100MB) in i40e_phy_type_to_ethtool()
565 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
567 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB) in i40e_phy_type_to_ethtool()
572 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
578 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
584 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
590 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
592 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_20GB) 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 !test_bit(I40E_HW_CAP_CRT_RETIMER, pf->hw.caps)) { 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_10GB) in i40e_phy_type_to_ethtool()
612 !test_bit(I40E_HW_CAP_CRT_RETIMER, pf->hw.caps)) { 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_1GB) in i40e_phy_type_to_ethtool()
621 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
623 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()
644 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
646 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_25GB) in i40e_phy_type_to_ethtool()
656 ethtool_link_ksettings_add_link_mode(ks, supported, FEC_NONE); in i40e_phy_type_to_ethtool()
657 ethtool_link_ksettings_add_link_mode(ks, supported, FEC_RS); in i40e_phy_type_to_ethtool()
658 ethtool_link_ksettings_add_link_mode(ks, supported, FEC_BASER); in i40e_phy_type_to_ethtool()
659 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_25GB) { in i40e_phy_type_to_ethtool()
671 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
673 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_phy_type_to_ethtool()
678 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
680 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_phy_type_to_ethtool()
685 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
687 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_phy_type_to_ethtool()
694 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
696 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB) in i40e_phy_type_to_ethtool()
725 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
733 * i40e_get_settings_link_up_fec - Get the FEC mode encoding from mask
740 ethtool_link_ksettings_add_link_mode(ks, supported, FEC_NONE); in i40e_get_settings_link_up_fec()
741 ethtool_link_ksettings_add_link_mode(ks, supported, FEC_RS); in i40e_get_settings_link_up_fec()
742 ethtool_link_ksettings_add_link_mode(ks, supported, FEC_BASER); in i40e_get_settings_link_up_fec()
763 * i40e_get_settings_link_up - Get the Link settings for when link is up
764 * @hw: hw structure
769 static void i40e_get_settings_link_up(struct i40e_hw *hw, in i40e_get_settings_link_up() argument
774 struct i40e_link_status *hw_link_info = &hw->phy.link_info; in i40e_get_settings_link_up()
776 u32 link_speed = hw_link_info->link_speed; in i40e_get_settings_link_up()
778 /* Initialize supported and advertised settings based on phy settings */ in i40e_get_settings_link_up()
779 switch (hw_link_info->phy_type) { in i40e_get_settings_link_up()
782 ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); in i40e_get_settings_link_up()
783 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
792 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
798 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
804 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
815 ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); in i40e_get_settings_link_up()
817 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
821 i40e_get_settings_link_up_fec(hw_link_info->req_fec_info, ks); 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()
830 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
834 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
836 if (hw_link_info->module_type[2] & in i40e_get_settings_link_up()
838 hw_link_info->module_type[2] & in i40e_get_settings_link_up()
840 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
842 if (hw_link_info->requested_speeds & in i40e_get_settings_link_up()
847 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_get_settings_link_up()
856 ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); in i40e_get_settings_link_up()
857 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
859 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
861 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
863 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
865 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
868 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_get_settings_link_up()
871 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_5GB) in i40e_get_settings_link_up()
874 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_2_5GB) in i40e_get_settings_link_up()
877 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB) in i40e_get_settings_link_up()
880 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_100MB) in i40e_get_settings_link_up()
885 ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); in i40e_get_settings_link_up()
886 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
894 ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); in i40e_get_settings_link_up()
895 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
906 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
908 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_get_settings_link_up()
911 i40e_get_settings_link_up_fec(hw_link_info->req_fec_info, ks); in i40e_get_settings_link_up()
914 ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); in i40e_get_settings_link_up()
915 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
917 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB) in i40e_get_settings_link_up()
920 if (test_bit(I40E_HW_CAP_100M_SGMII, pf->hw.caps)) { in i40e_get_settings_link_up()
921 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
923 if (hw_link_info->requested_speeds & 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, in i40e_get_settings_link_up()
941 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
943 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
945 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
947 ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); in i40e_get_settings_link_up()
952 i40e_get_settings_link_up_fec(hw_link_info->req_fec_info, ks); in i40e_get_settings_link_up()
964 ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); in i40e_get_settings_link_up()
966 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
970 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, Autoneg); in i40e_get_settings_link_up()
977 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
981 i40e_get_settings_link_up_fec(hw_link_info->req_fec_info, ks); in i40e_get_settings_link_up()
983 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
992 hw_link_info->phy_type); in i40e_get_settings_link_up()
995 /* Now that we've worked out everything that could be supported by the in i40e_get_settings_link_up()
996 * current PHY type, get what is supported by the NVM and intersect in i40e_get_settings_link_up()
997 * them to get what is truly supported in i40e_get_settings_link_up()
1006 ks->base.speed = SPEED_40000; in i40e_get_settings_link_up()
1009 ks->base.speed = SPEED_25000; in i40e_get_settings_link_up()
1012 ks->base.speed = SPEED_20000; in i40e_get_settings_link_up()
1015 ks->base.speed = SPEED_10000; in i40e_get_settings_link_up()
1018 ks->base.speed = SPEED_5000; in i40e_get_settings_link_up()
1021 ks->base.speed = SPEED_2500; in i40e_get_settings_link_up()
1024 ks->base.speed = SPEED_1000; in i40e_get_settings_link_up()
1027 ks->base.speed = SPEED_100; in i40e_get_settings_link_up()
1030 ks->base.speed = SPEED_UNKNOWN; in i40e_get_settings_link_up()
1033 ks->base.duplex = DUPLEX_FULL; in i40e_get_settings_link_up()
1037 * i40e_get_settings_link_down - Get the Link settings for when link is down
1038 * @hw: hw structure
1044 static void i40e_get_settings_link_down(struct i40e_hw *hw, in i40e_get_settings_link_down() argument
1049 * supported phy types to figure out what info to display in i40e_get_settings_link_down()
1054 ks->base.speed = SPEED_UNKNOWN; in i40e_get_settings_link_down()
1055 ks->base.duplex = DUPLEX_UNKNOWN; in i40e_get_settings_link_down()
1059 * i40e_get_link_ksettings - Get Link Speed and Duplex settings
1069 struct i40e_pf *pf = np->vsi->back; in i40e_get_link_ksettings()
1070 struct i40e_hw *hw = &pf->hw; in i40e_get_link_ksettings() local
1071 struct i40e_link_status *hw_link_info = &hw->phy.link_info; in i40e_get_link_ksettings()
1072 bool link_up = hw_link_info->link_info & I40E_AQ_LINK_UP; in i40e_get_link_ksettings()
1074 ethtool_link_ksettings_zero_link_mode(ks, supported); in i40e_get_link_ksettings()
1078 i40e_get_settings_link_up(hw, ks, netdev, pf); in i40e_get_link_ksettings()
1080 i40e_get_settings_link_down(hw, ks, pf); in i40e_get_link_ksettings()
1084 ks->base.autoneg = ((hw_link_info->an_info & I40E_AQ_AN_COMPLETED) ? in i40e_get_link_ksettings()
1088 switch (hw->phy.media_type) { in i40e_get_link_ksettings()
1090 ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); in i40e_get_link_ksettings()
1091 ethtool_link_ksettings_add_link_mode(ks, supported, Backplane); in i40e_get_link_ksettings()
1095 ks->base.port = PORT_NONE; in i40e_get_link_ksettings()
1098 ethtool_link_ksettings_add_link_mode(ks, supported, TP); in i40e_get_link_ksettings()
1100 ks->base.port = PORT_TP; in i40e_get_link_ksettings()
1104 ethtool_link_ksettings_add_link_mode(ks, supported, FIBRE); in i40e_get_link_ksettings()
1106 ks->base.port = PORT_DA; in i40e_get_link_ksettings()
1109 ethtool_link_ksettings_add_link_mode(ks, supported, FIBRE); in i40e_get_link_ksettings()
1111 ks->base.port = PORT_FIBRE; in i40e_get_link_ksettings()
1115 ks->base.port = PORT_OTHER; in i40e_get_link_ksettings()
1120 ethtool_link_ksettings_add_link_mode(ks, supported, Pause); in i40e_get_link_ksettings()
1121 ethtool_link_ksettings_add_link_mode(ks, supported, Asym_Pause); in i40e_get_link_ksettings()
1123 switch (hw->fc.requested_mode) { in i40e_get_link_ksettings()
1148 * i40e_speed_to_link_speed - Translate decimal speed to i40e_aq_link_speed
1193 ks->link_modes.supported)) { in i40e_speed_to_link_speed()
1212 * i40e_set_link_ksettings - Set Speed and Duplex
1226 struct i40e_pf *pf = np->vsi->back; in i40e_set_link_ksettings()
1228 struct i40e_vsi *vsi = np->vsi; in i40e_set_link_ksettings()
1229 struct i40e_hw *hw = &pf->hw; in i40e_set_link_ksettings() local
1237 /* Changing port settings is not supported if this isn't the in i40e_set_link_ksettings()
1240 if (hw->partition_id != 1) { in i40e_set_link_ksettings()
1242 return -EOPNOTSUPP; in i40e_set_link_ksettings()
1244 if (vsi->type != I40E_VSI_MAIN) in i40e_set_link_ksettings()
1245 return -EOPNOTSUPP; in i40e_set_link_ksettings()
1246 if (hw->phy.media_type != I40E_MEDIA_TYPE_BASET && in i40e_set_link_ksettings()
1247 hw->phy.media_type != I40E_MEDIA_TYPE_FIBER && in i40e_set_link_ksettings()
1248 hw->phy.media_type != I40E_MEDIA_TYPE_BACKPLANE && in i40e_set_link_ksettings()
1249 hw->phy.media_type != I40E_MEDIA_TYPE_DA && in i40e_set_link_ksettings()
1250 hw->phy.link_info.link_info & I40E_AQ_LINK_UP) in i40e_set_link_ksettings()
1251 return -EOPNOTSUPP; in i40e_set_link_ksettings()
1252 if (hw->device_id == I40E_DEV_ID_KX_B || in i40e_set_link_ksettings()
1253 hw->device_id == I40E_DEV_ID_KX_C || in i40e_set_link_ksettings()
1254 hw->device_id == I40E_DEV_ID_20G_KR2 || in i40e_set_link_ksettings()
1255 hw->device_id == I40E_DEV_ID_20G_KR2_A || in i40e_set_link_ksettings()
1256 hw->device_id == I40E_DEV_ID_25G_B || in i40e_set_link_ksettings()
1257 hw->device_id == I40E_DEV_ID_KX_X722) { in i40e_set_link_ksettings()
1258 netdev_info(netdev, "Changing settings is not supported on backplane.\n"); in i40e_set_link_ksettings()
1259 return -EOPNOTSUPP; in i40e_set_link_ksettings()
1276 /* Get link modes supported by hardware and check against modes in i40e_set_link_ksettings()
1280 safe_ks.link_modes.supported, in i40e_set_link_ksettings()
1282 return -EINVAL; in i40e_set_link_ksettings()
1293 netdev_err(netdev, "Only speed and autoneg are supported.\n"); in i40e_set_link_ksettings()
1294 return -EOPNOTSUPP; in i40e_set_link_ksettings()
1297 while (test_and_set_bit(__I40E_CONFIG_BUSY, pf->state)) { in i40e_set_link_ksettings()
1298 timeout--; in i40e_set_link_ksettings()
1300 return -EBUSY; in i40e_set_link_ksettings()
1305 status = i40e_aq_get_phy_capabilities(hw, false, false, &abilities, in i40e_set_link_ksettings()
1308 err = -EAGAIN; in i40e_set_link_ksettings()
1321 if (!(hw->phy.link_info.an_info & I40E_AQ_AN_COMPLETED)) { in i40e_set_link_ksettings()
1322 /* If autoneg is not supported, return error */ in i40e_set_link_ksettings()
1324 supported, in i40e_set_link_ksettings()
1326 netdev_info(netdev, "Autoneg not supported on this phy\n"); in i40e_set_link_ksettings()
1327 err = -EINVAL; in i40e_set_link_ksettings()
1337 if (hw->phy.link_info.an_info & I40E_AQ_AN_COMPLETED) { in i40e_set_link_ksettings()
1338 /* If autoneg is supported 10GBASE_T is the only PHY in i40e_set_link_ksettings()
1342 supported, in i40e_set_link_ksettings()
1344 hw->phy.media_type != I40E_MEDIA_TYPE_BASET) { in i40e_set_link_ksettings()
1346 err = -EINVAL; in i40e_set_link_ksettings()
1411 netdev_info(netdev, "Given speed is not supported\n"); in i40e_set_link_ksettings()
1412 err = -EOPNOTSUPP; in i40e_set_link_ksettings()
1421 err = -EOPNOTSUPP; in i40e_set_link_ksettings()
1443 hw->phy.link_info.requested_speeds = config.link_speed; in i40e_set_link_ksettings()
1447 if (hw->phy.link_info.link_info & I40E_AQ_LINK_UP) { in i40e_set_link_ksettings()
1457 status = i40e_aq_set_phy_config(hw, &config, NULL); in i40e_set_link_ksettings()
1462 i40e_aq_str(hw, hw->aq.asq_last_status)); in i40e_set_link_ksettings()
1463 err = -EAGAIN; in i40e_set_link_ksettings()
1467 status = i40e_update_link_info(hw); in i40e_set_link_ksettings()
1472 i40e_aq_str(hw, hw->aq.asq_last_status)); in i40e_set_link_ksettings()
1479 clear_bit(__I40E_CONFIG_BUSY, pf->state); in i40e_set_link_ksettings()
1488 struct i40e_pf *pf = np->vsi->back; in i40e_set_fec_cfg()
1489 struct i40e_hw *hw = &pf->hw; in i40e_set_fec_cfg() local
1495 status = i40e_aq_get_phy_capabilities(hw, false, false, &abilities, in i40e_set_fec_cfg()
1498 err = -EAGAIN; in i40e_set_fec_cfg()
1515 status = i40e_aq_set_phy_config(hw, &config, NULL); in i40e_set_fec_cfg()
1520 i40e_aq_str(hw, hw->aq.asq_last_status)); in i40e_set_fec_cfg()
1521 err = -EAGAIN; in i40e_set_fec_cfg()
1524 i40e_set_fec_in_flags(fec_cfg, pf->flags); in i40e_set_fec_cfg()
1525 status = i40e_update_link_info(hw); in i40e_set_fec_cfg()
1534 i40e_aq_str(hw, hw->aq.asq_last_status)); in i40e_set_fec_cfg()
1546 struct i40e_pf *pf = np->vsi->back; in i40e_get_fec_param()
1547 struct i40e_hw *hw = &pf->hw; in i40e_get_fec_param() local
1554 status = i40e_aq_get_phy_capabilities(hw, false, false, &abilities, in i40e_get_fec_param()
1557 err = -EAGAIN; in i40e_get_fec_param()
1561 fecparam->fec = 0; in i40e_get_fec_param()
1564 fecparam->fec |= ETHTOOL_FEC_AUTO; in i40e_get_fec_param()
1567 fecparam->fec |= ETHTOOL_FEC_RS; in i40e_get_fec_param()
1570 fecparam->fec |= ETHTOOL_FEC_BASER; in i40e_get_fec_param()
1572 fecparam->fec |= ETHTOOL_FEC_OFF; in i40e_get_fec_param()
1574 if (hw->phy.link_info.fec_info & I40E_AQ_CONFIG_FEC_KR_ENA) in i40e_get_fec_param()
1575 fecparam->active_fec = ETHTOOL_FEC_BASER; in i40e_get_fec_param()
1576 else if (hw->phy.link_info.fec_info & I40E_AQ_CONFIG_FEC_RS_ENA) in i40e_get_fec_param()
1577 fecparam->active_fec = ETHTOOL_FEC_RS; in i40e_get_fec_param()
1579 fecparam->active_fec = ETHTOOL_FEC_OFF; in i40e_get_fec_param()
1588 struct i40e_pf *pf = np->vsi->back; in i40e_set_fec_param()
1589 struct i40e_hw *hw = &pf->hw; in i40e_set_fec_param() local
1592 if (hw->device_id != I40E_DEV_ID_25G_SFP28 && in i40e_set_fec_param()
1593 hw->device_id != I40E_DEV_ID_25G_B && in i40e_set_fec_param()
1594 hw->device_id != I40E_DEV_ID_KX_X722) in i40e_set_fec_param()
1595 return -EPERM; in i40e_set_fec_param()
1597 if (hw->mac.type == I40E_MAC_X722 && in i40e_set_fec_param()
1598 !test_bit(I40E_HW_CAP_X722_FEC_REQUEST, hw->caps)) { in i40e_set_fec_param()
1599 …netdev_err(netdev, "Setting FEC encoding not supported by firmware. Please update the NVM image.\n… in i40e_set_fec_param()
1600 return -EOPNOTSUPP; in i40e_set_fec_param()
1603 switch (fecparam->fec) { in i40e_set_fec_param()
1620 dev_warn(&pf->pdev->dev, "Unsupported FEC mode: %d", in i40e_set_fec_param()
1621 fecparam->fec); in i40e_set_fec_param()
1622 return -EINVAL; in i40e_set_fec_param()
1632 struct i40e_pf *pf = np->vsi->back; in i40e_nway_reset()
1633 struct i40e_hw *hw = &pf->hw; in i40e_nway_reset() local
1634 bool link_up = hw->phy.link_info.link_info & I40E_AQ_LINK_UP; in i40e_nway_reset()
1637 ret = i40e_aq_set_link_restart_an(hw, link_up, NULL); in i40e_nway_reset()
1641 i40e_aq_str(hw, hw->aq.asq_last_status)); in i40e_nway_reset()
1642 return -EIO; in i40e_nway_reset()
1649 * i40e_get_pauseparam - Get Flow Control status
1653 * Return tx/rx-pause status
1659 struct i40e_pf *pf = np->vsi->back; in i40e_get_pauseparam()
1660 struct i40e_hw *hw = &pf->hw; in i40e_get_pauseparam() local
1661 struct i40e_link_status *hw_link_info = &hw->phy.link_info; in i40e_get_pauseparam()
1662 struct i40e_dcbx_config *dcbx_cfg = &hw->local_dcbx_config; in i40e_get_pauseparam()
1664 pause->autoneg = in i40e_get_pauseparam()
1665 ((hw_link_info->an_info & I40E_AQ_AN_COMPLETED) ? in i40e_get_pauseparam()
1669 if (dcbx_cfg->pfc.pfcenable) { in i40e_get_pauseparam()
1670 pause->rx_pause = 0; in i40e_get_pauseparam()
1671 pause->tx_pause = 0; in i40e_get_pauseparam()
1675 if (hw->fc.current_mode == I40E_FC_RX_PAUSE) { in i40e_get_pauseparam()
1676 pause->rx_pause = 1; in i40e_get_pauseparam()
1677 } else if (hw->fc.current_mode == I40E_FC_TX_PAUSE) { in i40e_get_pauseparam()
1678 pause->tx_pause = 1; in i40e_get_pauseparam()
1679 } else if (hw->fc.current_mode == I40E_FC_FULL) { in i40e_get_pauseparam()
1680 pause->rx_pause = 1; in i40e_get_pauseparam()
1681 pause->tx_pause = 1; in i40e_get_pauseparam()
1686 * i40e_set_pauseparam - Set Flow Control parameter
1694 struct i40e_pf *pf = np->vsi->back; in i40e_set_pauseparam()
1695 struct i40e_vsi *vsi = np->vsi; in i40e_set_pauseparam()
1696 struct i40e_hw *hw = &pf->hw; in i40e_set_pauseparam() local
1697 struct i40e_link_status *hw_link_info = &hw->phy.link_info; in i40e_set_pauseparam()
1698 struct i40e_dcbx_config *dcbx_cfg = &hw->local_dcbx_config; in i40e_set_pauseparam()
1699 bool link_up = hw_link_info->link_info & I40E_AQ_LINK_UP; in i40e_set_pauseparam()
1705 /* Changing the port's flow control is not supported if this isn't the in i40e_set_pauseparam()
1708 if (hw->partition_id != 1) { in i40e_set_pauseparam()
1710 return -EOPNOTSUPP; in i40e_set_pauseparam()
1713 if (vsi->type != I40E_VSI_MAIN) in i40e_set_pauseparam()
1714 return -EOPNOTSUPP; in i40e_set_pauseparam()
1716 is_an = hw_link_info->an_info & I40E_AQ_AN_COMPLETED; in i40e_set_pauseparam()
1717 if (pause->autoneg != is_an) { in i40e_set_pauseparam()
1718 netdev_info(netdev, "To change autoneg please use: ethtool -s <dev> autoneg <on|off>\n"); in i40e_set_pauseparam()
1719 return -EOPNOTSUPP; in i40e_set_pauseparam()
1723 if (!test_bit(__I40E_DOWN, pf->state) && !is_an) { in i40e_set_pauseparam()
1728 if (dcbx_cfg->pfc.pfcenable) { in i40e_set_pauseparam()
1731 return -EOPNOTSUPP; in i40e_set_pauseparam()
1734 if (pause->rx_pause && pause->tx_pause) in i40e_set_pauseparam()
1735 hw->fc.requested_mode = I40E_FC_FULL; in i40e_set_pauseparam()
1736 else if (pause->rx_pause && !pause->tx_pause) in i40e_set_pauseparam()
1737 hw->fc.requested_mode = I40E_FC_RX_PAUSE; in i40e_set_pauseparam()
1738 else if (!pause->rx_pause && pause->tx_pause) in i40e_set_pauseparam()
1739 hw->fc.requested_mode = I40E_FC_TX_PAUSE; in i40e_set_pauseparam()
1740 else if (!pause->rx_pause && !pause->tx_pause) in i40e_set_pauseparam()
1741 hw->fc.requested_mode = I40E_FC_NONE; in i40e_set_pauseparam()
1743 return -EINVAL; in i40e_set_pauseparam()
1753 status = i40e_set_fc(hw, &aq_failures, link_up); in i40e_set_pauseparam()
1758 i40e_aq_str(hw, hw->aq.asq_last_status)); in i40e_set_pauseparam()
1759 err = -EAGAIN; in i40e_set_pauseparam()
1764 i40e_aq_str(hw, hw->aq.asq_last_status)); in i40e_set_pauseparam()
1765 err = -EAGAIN; in i40e_set_pauseparam()
1770 i40e_aq_str(hw, hw->aq.asq_last_status)); in i40e_set_pauseparam()
1771 err = -EAGAIN; in i40e_set_pauseparam()
1774 if (!test_bit(__I40E_DOWN, pf->state) && is_an) { in i40e_set_pauseparam()
1777 if (!test_bit(__I40E_DOWN, pf->state)) in i40e_set_pauseparam()
1787 struct i40e_pf *pf = np->vsi->back; in i40e_get_msglevel()
1788 u32 debug_mask = pf->hw.debug_mask; in i40e_get_msglevel()
1793 return pf->msg_enable; in i40e_get_msglevel()
1799 struct i40e_pf *pf = np->vsi->back; in i40e_set_msglevel()
1802 pf->hw.debug_mask = data; in i40e_set_msglevel()
1804 pf->msg_enable = data; in i40e_set_msglevel()
1822 struct i40e_pf *pf = np->vsi->back; in i40e_get_regs()
1823 struct i40e_hw *hw = &pf->hw; in i40e_get_regs() local
1828 /* Tell ethtool which driver-version-specific regs output we have. in i40e_get_regs()
1835 regs->version = 1; in i40e_get_regs()
1843 reg_buf[ri++] = rd32(hw, reg); in i40e_get_regs()
1853 struct i40e_hw *hw = &np->vsi->back->hw; in i40e_get_eeprom() local
1854 struct i40e_pf *pf = np->vsi->back; in i40e_get_eeprom()
1862 if (eeprom->len == 0) in i40e_get_eeprom()
1863 return -EINVAL; in i40e_get_eeprom()
1866 magic = hw->vendor_id | (hw->device_id << 16); in i40e_get_eeprom()
1867 if (eeprom->magic && eeprom->magic != magic) { in i40e_get_eeprom()
1872 if ((eeprom->magic >> 16) != hw->device_id) in i40e_get_eeprom()
1873 errno = -EINVAL; in i40e_get_eeprom()
1874 else if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) || in i40e_get_eeprom()
1875 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) in i40e_get_eeprom()
1876 errno = -EBUSY; in i40e_get_eeprom()
1878 ret_val = i40e_nvmupd_command(hw, cmd, bytes, &errno); in i40e_get_eeprom()
1880 if ((errno || ret_val) && (hw->debug_mask & I40E_DEBUG_NVM)) in i40e_get_eeprom()
1881 dev_info(&pf->pdev->dev, in i40e_get_eeprom()
1883 ret_val, hw->aq.asq_last_status, errno, in i40e_get_eeprom()
1884 (u8)(cmd->config & I40E_NVM_MOD_PNT_MASK), in i40e_get_eeprom()
1885 cmd->offset, cmd->data_size); in i40e_get_eeprom()
1891 eeprom->magic = hw->vendor_id | (hw->device_id << 16); in i40e_get_eeprom()
1893 eeprom_buff = kzalloc(eeprom->len, GFP_KERNEL); in i40e_get_eeprom()
1895 return -ENOMEM; in i40e_get_eeprom()
1897 ret_val = i40e_acquire_nvm(hw, I40E_RESOURCE_READ); in i40e_get_eeprom()
1899 dev_info(&pf->pdev->dev, in i40e_get_eeprom()
1901 ret_val, hw->aq.asq_last_status); in i40e_get_eeprom()
1905 sectors = eeprom->len / I40E_NVM_SECTOR_SIZE; in i40e_get_eeprom()
1906 sectors += (eeprom->len % I40E_NVM_SECTOR_SIZE) ? 1 : 0; in i40e_get_eeprom()
1910 if (i == (sectors - 1)) { in i40e_get_eeprom()
1911 len = eeprom->len - (I40E_NVM_SECTOR_SIZE * i); in i40e_get_eeprom()
1914 offset = eeprom->offset + (I40E_NVM_SECTOR_SIZE * i); in i40e_get_eeprom()
1915 ret_val = i40e_aq_read_nvm(hw, 0x0, offset, len, in i40e_get_eeprom()
1918 if (ret_val && hw->aq.asq_last_status == I40E_AQ_RC_EPERM) { in i40e_get_eeprom()
1919 dev_info(&pf->pdev->dev, in i40e_get_eeprom()
1924 hw->aq.asq_last_status == I40E_AQ_RC_EACCES) { in i40e_get_eeprom()
1925 dev_info(&pf->pdev->dev, in i40e_get_eeprom()
1930 dev_info(&pf->pdev->dev, in i40e_get_eeprom()
1932 offset, ret_val, hw->aq.asq_last_status); in i40e_get_eeprom()
1937 i40e_release_nvm(hw); in i40e_get_eeprom()
1938 memcpy(bytes, (u8 *)eeprom_buff, eeprom->len); in i40e_get_eeprom()
1947 struct i40e_hw *hw = &np->vsi->back->hw; in i40e_get_eeprom_len() local
1951 if (hw->mac.type == I40E_MAC_X722) { in i40e_get_eeprom_len()
1956 rd32(hw, I40E_GLPCI_LBARCTRL)); in i40e_get_eeprom_len()
1966 struct i40e_hw *hw = &np->vsi->back->hw; in i40e_set_eeprom() local
1967 struct i40e_pf *pf = np->vsi->back; in i40e_set_eeprom()
1973 /* normal ethtool set_eeprom is not supported */ in i40e_set_eeprom()
1974 magic = hw->vendor_id | (hw->device_id << 16); in i40e_set_eeprom()
1975 if (eeprom->magic == magic) in i40e_set_eeprom()
1976 errno = -EOPNOTSUPP; in i40e_set_eeprom()
1978 else if (!eeprom->magic || (eeprom->magic >> 16) != hw->device_id) in i40e_set_eeprom()
1979 errno = -EINVAL; in i40e_set_eeprom()
1980 else if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) || in i40e_set_eeprom()
1981 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) in i40e_set_eeprom()
1982 errno = -EBUSY; in i40e_set_eeprom()
1984 ret_val = i40e_nvmupd_command(hw, cmd, bytes, &errno); in i40e_set_eeprom()
1986 if ((errno || ret_val) && (hw->debug_mask & I40E_DEBUG_NVM)) in i40e_set_eeprom()
1987 dev_info(&pf->pdev->dev, in i40e_set_eeprom()
1989 ret_val, hw->aq.asq_last_status, errno, in i40e_set_eeprom()
1990 (u8)(cmd->config & I40E_NVM_MOD_PNT_MASK), in i40e_set_eeprom()
1991 cmd->offset, cmd->data_size); in i40e_set_eeprom()
2000 struct i40e_vsi *vsi = np->vsi; in i40e_get_drvinfo()
2001 struct i40e_pf *pf = vsi->back; in i40e_get_drvinfo()
2003 strscpy(drvinfo->driver, i40e_driver_name, sizeof(drvinfo->driver)); in i40e_get_drvinfo()
2004 i40e_nvm_version_str(&pf->hw, drvinfo->fw_version, in i40e_get_drvinfo()
2005 sizeof(drvinfo->fw_version)); in i40e_get_drvinfo()
2006 strscpy(drvinfo->bus_info, pci_name(pf->pdev), in i40e_get_drvinfo()
2007 sizeof(drvinfo->bus_info)); in i40e_get_drvinfo()
2008 drvinfo->n_priv_flags = I40E_PRIV_FLAGS_STR_LEN; in i40e_get_drvinfo()
2009 if (pf->hw.pf_id == 0) in i40e_get_drvinfo()
2010 drvinfo->n_priv_flags += I40E_GL_PRIV_FLAGS_STR_LEN; in i40e_get_drvinfo()
2015 struct i40e_hw *hw = &pf->hw; in i40e_get_max_num_descriptors() local
2017 switch (hw->mac.type) { in i40e_get_max_num_descriptors()
2031 struct i40e_pf *pf = np->vsi->back; in i40e_get_ringparam()
2034 ring->rx_max_pending = i40e_get_max_num_descriptors(pf); in i40e_get_ringparam()
2035 ring->tx_max_pending = i40e_get_max_num_descriptors(pf); in i40e_get_ringparam()
2036 ring->rx_mini_max_pending = 0; in i40e_get_ringparam()
2037 ring->rx_jumbo_max_pending = 0; in i40e_get_ringparam()
2038 ring->rx_pending = vsi->rx_rings[0]->count; in i40e_get_ringparam()
2039 ring->tx_pending = vsi->tx_rings[0]->count; in i40e_get_ringparam()
2040 ring->rx_mini_pending = 0; in i40e_get_ringparam()
2041 ring->rx_jumbo_pending = 0; in i40e_get_ringparam()
2047 return index < vsi->num_queue_pairs || in i40e_active_tx_ring_index()
2048 (index >= vsi->alloc_queue_pairs && in i40e_active_tx_ring_index()
2049 index < vsi->alloc_queue_pairs + vsi->num_queue_pairs); in i40e_active_tx_ring_index()
2052 return index < vsi->num_queue_pairs; in i40e_active_tx_ring_index()
2063 struct i40e_hw *hw = &np->vsi->back->hw; in i40e_set_ringparam() local
2064 struct i40e_vsi *vsi = np->vsi; in i40e_set_ringparam()
2065 struct i40e_pf *pf = vsi->back; in i40e_set_ringparam()
2070 if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending)) in i40e_set_ringparam()
2071 return -EINVAL; in i40e_set_ringparam()
2074 if (ring->tx_pending > max_num_descriptors || in i40e_set_ringparam()
2075 ring->tx_pending < I40E_MIN_NUM_DESCRIPTORS || in i40e_set_ringparam()
2076 ring->rx_pending > max_num_descriptors || in i40e_set_ringparam()
2077 ring->rx_pending < I40E_MIN_NUM_DESCRIPTORS) { in i40e_set_ringparam()
2079 "Descriptors requested (Tx: %d / Rx: %d) out of range [%d-%d]\n", in i40e_set_ringparam()
2080 ring->tx_pending, ring->rx_pending, in i40e_set_ringparam()
2082 return -EINVAL; in i40e_set_ringparam()
2085 new_tx_count = ALIGN(ring->tx_pending, I40E_REQ_DESCRIPTOR_MULTIPLE); in i40e_set_ringparam()
2086 new_rx_count = ALIGN(ring->rx_pending, I40E_REQ_DESCRIPTOR_MULTIPLE); in i40e_set_ringparam()
2089 if ((new_tx_count == vsi->tx_rings[0]->count) && in i40e_set_ringparam()
2090 (new_rx_count == vsi->rx_rings[0]->count)) in i40e_set_ringparam()
2094 * disallow changing the number of descriptors -- regardless in i40e_set_ringparam()
2098 return -EBUSY; in i40e_set_ringparam()
2100 while (test_and_set_bit(__I40E_CONFIG_BUSY, pf->state)) { in i40e_set_ringparam()
2101 timeout--; in i40e_set_ringparam()
2103 return -EBUSY; in i40e_set_ringparam()
2107 if (!netif_running(vsi->netdev)) { in i40e_set_ringparam()
2108 /* simple case - set for the next time the netdev is started */ in i40e_set_ringparam()
2109 for (i = 0; i < vsi->num_queue_pairs; i++) { in i40e_set_ringparam()
2110 vsi->tx_rings[i]->count = new_tx_count; in i40e_set_ringparam()
2111 vsi->rx_rings[i]->count = new_rx_count; in i40e_set_ringparam()
2113 vsi->xdp_rings[i]->count = new_tx_count; in i40e_set_ringparam()
2115 vsi->num_tx_desc = new_tx_count; in i40e_set_ringparam()
2116 vsi->num_rx_desc = new_rx_count; in i40e_set_ringparam()
2121 * because the ISRs in MSI-X mode get passed pointers in i40e_set_ringparam()
2126 tx_alloc_queue_pairs = vsi->alloc_queue_pairs * in i40e_set_ringparam()
2128 if (new_tx_count != vsi->tx_rings[0]->count) { in i40e_set_ringparam()
2131 vsi->tx_rings[0]->count, new_tx_count); in i40e_set_ringparam()
2135 err = -ENOMEM; in i40e_set_ringparam()
2143 tx_rings[i] = *vsi->tx_rings[i]; in i40e_set_ringparam()
2153 i--; in i40e_set_ringparam()
2167 if (new_rx_count != vsi->rx_rings[0]->count) { in i40e_set_ringparam()
2170 vsi->rx_rings[0]->count, new_rx_count); in i40e_set_ringparam()
2171 rx_rings = kcalloc(vsi->alloc_queue_pairs, in i40e_set_ringparam()
2174 err = -ENOMEM; in i40e_set_ringparam()
2178 for (i = 0; i < vsi->num_queue_pairs; i++) { in i40e_set_ringparam()
2182 rx_rings[i] = *vsi->rx_rings[i]; in i40e_set_ringparam()
2189 /* Clear cloned XDP RX-queue info before setup call */ in i40e_set_ringparam()
2194 rx_rings[i].tail = hw->hw_addr + I40E_PRTGEN_STATUS; in i40e_set_ringparam()
2208 } while (i--); in i40e_set_ringparam()
2225 i40e_free_tx_resources(vsi->tx_rings[i]); in i40e_set_ringparam()
2226 *vsi->tx_rings[i] = tx_rings[i]; in i40e_set_ringparam()
2234 for (i = 0; i < vsi->num_queue_pairs; i++) { in i40e_set_ringparam()
2235 i40e_free_rx_resources(vsi->rx_rings[i]); in i40e_set_ringparam()
2237 rx_rings[i].tail = vsi->rx_rings[i]->tail; in i40e_set_ringparam()
2240 * but the recycling logic will let us re-use in i40e_set_ringparam()
2247 *vsi->rx_rings[i] = rx_rings[i]; in i40e_set_ringparam()
2253 vsi->num_tx_desc = new_tx_count; in i40e_set_ringparam()
2254 vsi->num_rx_desc = new_rx_count; in i40e_set_ringparam()
2262 i40e_free_tx_resources(vsi->tx_rings[i]); in i40e_set_ringparam()
2269 clear_bit(__I40E_CONFIG_BUSY, pf->state); in i40e_set_ringparam()
2275 * i40e_get_stats_count - return the stats count for a device
2282 * obtaining stats is *not* safe against changes based on non-static
2291 struct i40e_vsi *vsi = np->vsi; in i40e_get_stats_count()
2292 struct i40e_pf *pf = vsi->back; in i40e_get_stats_count()
2295 if (vsi->type == I40E_VSI_MAIN && pf->hw.partition_id == 1) in i40e_get_stats_count()
2310 * queues in pairs, we'll just use netdev->num_tx_queues * 2. This in i40e_get_stats_count()
2314 stats_len += I40E_QUEUE_STATS_LEN * 2 * netdev->num_tx_queues; in i40e_get_stats_count()
2322 struct i40e_vsi *vsi = np->vsi; in i40e_get_sset_count()
2323 struct i40e_pf *pf = vsi->back; in i40e_get_sset_count()
2332 (pf->hw.pf_id == 0 ? I40E_GL_PRIV_FLAGS_STR_LEN : 0); in i40e_get_sset_count()
2334 return -EOPNOTSUPP; in i40e_get_sset_count()
2339 * i40e_get_veb_tc_stats - copy VEB TC statistics to formatted structure
2340 * @tc: the TC statistics in VEB structure (veb->tc_stats)
2341 * @i: the index of traffic class in (veb->tc_stats) structure to copy
2343 * Copy VEB TC statistics from structure of arrays (veb->tc_stats) to
2352 .tc_rx_packets = tc->tc_rx_packets[i], in i40e_get_veb_tc_stats()
2353 .tc_rx_bytes = tc->tc_rx_bytes[i], in i40e_get_veb_tc_stats()
2354 .tc_tx_packets = tc->tc_tx_packets[i], in i40e_get_veb_tc_stats()
2355 .tc_tx_bytes = tc->tc_tx_bytes[i], in i40e_get_veb_tc_stats()
2362 * i40e_get_pfc_stats - copy HW PFC statistics to formatted structure
2366 * The PFC stats are found as arrays in pf->stats, which is not easy to pass
2374 .stat = pf->stats.stat[priority] in i40e_get_pfc_stats()
2387 * i40e_get_ethtool_stats - copy stat values into supplied buffer
2393 * pre-allocated to the size returned by i40e_get_stats_count.. Note that all
2404 struct i40e_vsi *vsi = np->vsi; in i40e_get_ethtool_stats()
2405 struct i40e_pf *pf = vsi->back; in i40e_get_ethtool_stats()
2419 for (i = 0; i < netdev->num_tx_queues; i++) { in i40e_get_ethtool_stats()
2420 i40e_add_queue_stats(&data, READ_ONCE(vsi->tx_rings[i])); in i40e_get_ethtool_stats()
2421 i40e_add_queue_stats(&data, READ_ONCE(vsi->rx_rings[i])); in i40e_get_ethtool_stats()
2425 if (vsi->type != I40E_VSI_MAIN || pf->hw.partition_id != 1) in i40e_get_ethtool_stats()
2429 veb_stats = veb && test_bit(I40E_FLAG_VEB_STATS_ENA, pf->flags); in i40e_get_ethtool_stats()
2444 i40e_get_veb_tc_stats(&veb->tc_stats, i); in i40e_get_ethtool_stats()
2462 WARN_ONCE(data - p != i40e_get_stats_count(netdev), in i40e_get_ethtool_stats()
2467 * i40e_get_stat_strings - copy stat strings into supplied buffer
2472 * pre-allocated with the size reported by i40e_get_stats_count. Note that the
2479 struct i40e_vsi *vsi = np->vsi; in i40e_get_stat_strings()
2480 struct i40e_pf *pf = vsi->back; in i40e_get_stat_strings()
2488 for (i = 0; i < netdev->num_tx_queues; i++) { in i40e_get_stat_strings()
2495 if (vsi->type != I40E_VSI_MAIN || pf->hw.partition_id != 1) in i40e_get_stat_strings()
2509 WARN_ONCE(data - p != i40e_get_stats_count(netdev) * ETH_GSTRING_LEN, in i40e_get_stat_strings()
2516 struct i40e_vsi *vsi = np->vsi; in i40e_get_priv_flag_strings()
2517 struct i40e_pf *pf = vsi->back; in i40e_get_priv_flag_strings()
2523 if (pf->hw.pf_id != 0) in i40e_get_priv_flag_strings()
2553 /* only report HW timestamping if PTP is enabled */ in i40e_get_ts_info()
2554 if (!test_bit(I40E_FLAG_PTP_ENA, pf->flags)) in i40e_get_ts_info()
2557 info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE | in i40e_get_ts_info()
2562 if (pf->ptp_clock) in i40e_get_ts_info()
2563 info->phc_index = ptp_clock_index(pf->ptp_clock); in i40e_get_ts_info()
2565 info->tx_types = BIT(HWTSTAMP_TX_OFF) | BIT(HWTSTAMP_TX_ON); in i40e_get_ts_info()
2567 info->rx_filters = BIT(HWTSTAMP_FILTER_NONE) | in i40e_get_ts_info()
2572 if (test_bit(I40E_HW_CAP_PTP_L4, pf->hw.caps)) in i40e_get_ts_info()
2573 info->rx_filters |= BIT(HWTSTAMP_FILTER_PTP_V1_L4_SYNC) | in i40e_get_ts_info()
2588 struct i40e_pf *pf = np->vsi->back; in i40e_link_test()
2592 netif_info(pf, hw, netdev, "link test\n"); in i40e_link_test()
2593 status = i40e_get_link_status(&pf->hw, &link_up); in i40e_link_test()
2611 struct i40e_pf *pf = np->vsi->back; in i40e_reg_test()
2613 netif_info(pf, hw, netdev, "register test\n"); in i40e_reg_test()
2614 *data = i40e_diag_reg_test(&pf->hw); in i40e_reg_test()
2622 struct i40e_pf *pf = np->vsi->back; in i40e_eeprom_test()
2624 netif_info(pf, hw, netdev, "eeprom test\n"); in i40e_eeprom_test()
2625 *data = i40e_diag_eeprom_test(&pf->hw); in i40e_eeprom_test()
2628 pf->hw.nvmupd_state = I40E_NVMUPD_STATE_INIT; in i40e_eeprom_test()
2636 struct i40e_pf *pf = np->vsi->back; in i40e_intr_test()
2637 u16 swc_old = pf->sw_int_count; in i40e_intr_test()
2639 netif_info(pf, hw, netdev, "interrupt test\n"); in i40e_intr_test()
2640 wr32(&pf->hw, I40E_PFINT_DYN_CTL0, in i40e_intr_test()
2647 *data = (swc_old == pf->sw_int_count); in i40e_intr_test()
2654 struct i40e_vf *vfs = pf->vf; in i40e_active_vfs()
2657 for (i = 0; i < pf->num_alloc_vfs; i++) in i40e_active_vfs()
2673 struct i40e_pf *pf = np->vsi->back; in i40e_diag_test()
2675 if (eth_test->flags == ETH_TEST_FL_OFFLINE) { in i40e_diag_test()
2679 set_bit(__I40E_TESTING, pf->state); in i40e_diag_test()
2681 if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) || in i40e_diag_test()
2682 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) { in i40e_diag_test()
2683 dev_warn(&pf->pdev->dev, in i40e_diag_test()
2689 dev_warn(&pf->pdev->dev, in i40e_diag_test()
2699 /* This reset does not affect link - if it is in i40e_diag_test()
2707 eth_test->flags |= ETH_TEST_FL_FAILED; in i40e_diag_test()
2710 eth_test->flags |= ETH_TEST_FL_FAILED; in i40e_diag_test()
2713 eth_test->flags |= ETH_TEST_FL_FAILED; in i40e_diag_test()
2717 eth_test->flags |= ETH_TEST_FL_FAILED; in i40e_diag_test()
2719 clear_bit(__I40E_TESTING, pf->state); in i40e_diag_test()
2729 eth_test->flags |= ETH_TEST_FL_FAILED; in i40e_diag_test()
2745 eth_test->flags |= ETH_TEST_FL_FAILED; in i40e_diag_test()
2746 clear_bit(__I40E_TESTING, pf->state); in i40e_diag_test()
2754 struct i40e_pf *pf = np->vsi->back; in i40e_get_wol()
2755 struct i40e_hw *hw = &pf->hw; in i40e_get_wol() local
2759 i40e_read_nvm_word(hw, I40E_SR_NVM_WAKE_ON_LAN, &wol_nvm_bits); in i40e_get_wol()
2760 if ((BIT(hw->port) & wol_nvm_bits) || (hw->partition_id != 1)) { in i40e_get_wol()
2761 wol->supported = 0; in i40e_get_wol()
2762 wol->wolopts = 0; in i40e_get_wol()
2764 wol->supported = WAKE_MAGIC; in i40e_get_wol()
2765 wol->wolopts = (pf->wol_en ? WAKE_MAGIC : 0); in i40e_get_wol()
2770 * i40e_set_wol - set the WakeOnLAN configuration
2777 struct i40e_pf *pf = np->vsi->back; in i40e_set_wol()
2778 struct i40e_vsi *vsi = np->vsi; in i40e_set_wol()
2779 struct i40e_hw *hw = &pf->hw; in i40e_set_wol() local
2782 /* WoL not supported if this isn't the controlling PF on the port */ in i40e_set_wol()
2783 if (hw->partition_id != 1) { in i40e_set_wol()
2785 return -EOPNOTSUPP; in i40e_set_wol()
2788 if (vsi->type != I40E_VSI_MAIN) in i40e_set_wol()
2789 return -EOPNOTSUPP; in i40e_set_wol()
2792 i40e_read_nvm_word(hw, I40E_SR_NVM_WAKE_ON_LAN, &wol_nvm_bits); in i40e_set_wol()
2793 if (BIT(hw->port) & wol_nvm_bits) in i40e_set_wol()
2794 return -EOPNOTSUPP; in i40e_set_wol()
2796 /* only magic packet is supported */ in i40e_set_wol()
2797 if (wol->wolopts & ~WAKE_MAGIC) in i40e_set_wol()
2798 return -EOPNOTSUPP; in i40e_set_wol()
2801 if (pf->wol_en != !!wol->wolopts) { in i40e_set_wol()
2802 pf->wol_en = !!wol->wolopts; in i40e_set_wol()
2803 device_set_wakeup_enable(&pf->pdev->dev, pf->wol_en); in i40e_set_wol()
2813 struct i40e_pf *pf = np->vsi->back; in i40e_set_phys_id()
2814 struct i40e_hw *hw = &pf->hw; in i40e_set_phys_id() local
2821 if (!test_bit(I40E_HW_CAP_PHY_CONTROLS_LEDS, pf->hw.caps)) { in i40e_set_phys_id()
2822 pf->led_status = i40e_led_get(hw); in i40e_set_phys_id()
2824 if (!test_bit(I40E_HW_CAP_AQ_PHY_ACCESS, hw->caps)) in i40e_set_phys_id()
2825 i40e_aq_set_phy_debug(hw, I40E_PHY_DEBUG_ALL, in i40e_set_phys_id()
2827 ret = i40e_led_get_phy(hw, &temp_status, in i40e_set_phys_id()
2828 &pf->phy_led_val); in i40e_set_phys_id()
2829 pf->led_status = temp_status; in i40e_set_phys_id()
2833 if (!test_bit(I40E_HW_CAP_PHY_CONTROLS_LEDS, pf->hw.caps)) in i40e_set_phys_id()
2834 i40e_led_set(hw, 0xf, false); in i40e_set_phys_id()
2836 ret = i40e_led_set_phy(hw, true, pf->led_status, 0); in i40e_set_phys_id()
2839 if (!test_bit(I40E_HW_CAP_PHY_CONTROLS_LEDS, pf->hw.caps)) in i40e_set_phys_id()
2840 i40e_led_set(hw, 0x0, false); in i40e_set_phys_id()
2842 ret = i40e_led_set_phy(hw, false, pf->led_status, 0); in i40e_set_phys_id()
2845 if (!test_bit(I40E_HW_CAP_PHY_CONTROLS_LEDS, pf->hw.caps)) { in i40e_set_phys_id()
2846 i40e_led_set(hw, pf->led_status, false); in i40e_set_phys_id()
2848 ret = i40e_led_set_phy(hw, false, pf->led_status, in i40e_set_phys_id()
2849 (pf->phy_led_val | in i40e_set_phys_id()
2851 if (!test_bit(I40E_HW_CAP_AQ_PHY_ACCESS, hw->caps)) in i40e_set_phys_id()
2852 i40e_aq_set_phy_debug(hw, 0, NULL); in i40e_set_phys_id()
2859 return -ENOENT; in i40e_set_phys_id()
2870 * __i40e_get_coalesce - get per-queue coalesce settings
2875 * Gets the per-queue settings for coalescence. Specifically Rx and Tx usecs
2885 struct i40e_vsi *vsi = np->vsi; in __i40e_get_coalesce()
2887 ec->tx_max_coalesced_frames_irq = vsi->work_limit; in __i40e_get_coalesce()
2894 else if (queue >= vsi->num_queue_pairs) in __i40e_get_coalesce()
2895 return -EINVAL; in __i40e_get_coalesce()
2897 rx_ring = vsi->rx_rings[queue]; in __i40e_get_coalesce()
2898 tx_ring = vsi->tx_rings[queue]; in __i40e_get_coalesce()
2900 if (ITR_IS_DYNAMIC(rx_ring->itr_setting)) in __i40e_get_coalesce()
2901 ec->use_adaptive_rx_coalesce = 1; in __i40e_get_coalesce()
2903 if (ITR_IS_DYNAMIC(tx_ring->itr_setting)) in __i40e_get_coalesce()
2904 ec->use_adaptive_tx_coalesce = 1; in __i40e_get_coalesce()
2906 ec->rx_coalesce_usecs = rx_ring->itr_setting & ~I40E_ITR_DYNAMIC; in __i40e_get_coalesce()
2907 ec->tx_coalesce_usecs = tx_ring->itr_setting & ~I40E_ITR_DYNAMIC; in __i40e_get_coalesce()
2915 ec->rx_coalesce_usecs_high = vsi->int_rate_limit; in __i40e_get_coalesce()
2916 ec->tx_coalesce_usecs_high = vsi->int_rate_limit; in __i40e_get_coalesce()
2922 * i40e_get_coalesce - get a netdev's coalesce settings
2929 * modified per-queue settings, this only guarantees to represent queue 0. See
2937 return __i40e_get_coalesce(netdev, ec, -1); in i40e_get_coalesce()
2941 * i40e_get_per_queue_coalesce - gets coalesce settings for particular queue
2955 * i40e_set_itr_per_queue - set ITR values for specific queue
2966 struct i40e_ring *rx_ring = vsi->rx_rings[queue]; in i40e_set_itr_per_queue()
2967 struct i40e_ring *tx_ring = vsi->tx_rings[queue]; in i40e_set_itr_per_queue()
2968 struct i40e_pf *pf = vsi->back; in i40e_set_itr_per_queue()
2969 struct i40e_hw *hw = &pf->hw; in i40e_set_itr_per_queue() local
2973 intrl = i40e_intrl_usec_to_reg(vsi->int_rate_limit); in i40e_set_itr_per_queue()
2975 rx_ring->itr_setting = ITR_REG_ALIGN(ec->rx_coalesce_usecs); in i40e_set_itr_per_queue()
2976 tx_ring->itr_setting = ITR_REG_ALIGN(ec->tx_coalesce_usecs); in i40e_set_itr_per_queue()
2978 if (ec->use_adaptive_rx_coalesce) in i40e_set_itr_per_queue()
2979 rx_ring->itr_setting |= I40E_ITR_DYNAMIC; in i40e_set_itr_per_queue()
2981 rx_ring->itr_setting &= ~I40E_ITR_DYNAMIC; in i40e_set_itr_per_queue()
2983 if (ec->use_adaptive_tx_coalesce) in i40e_set_itr_per_queue()
2984 tx_ring->itr_setting |= I40E_ITR_DYNAMIC; in i40e_set_itr_per_queue()
2986 tx_ring->itr_setting &= ~I40E_ITR_DYNAMIC; in i40e_set_itr_per_queue()
2988 q_vector = rx_ring->q_vector; in i40e_set_itr_per_queue()
2989 q_vector->rx.target_itr = ITR_TO_REG(rx_ring->itr_setting); in i40e_set_itr_per_queue()
2991 q_vector = tx_ring->q_vector; in i40e_set_itr_per_queue()
2992 q_vector->tx.target_itr = ITR_TO_REG(tx_ring->itr_setting); in i40e_set_itr_per_queue()
2999 wr32(hw, I40E_PFINT_RATEN(q_vector->reg_idx), intrl); in i40e_set_itr_per_queue()
3000 i40e_flush(hw); in i40e_set_itr_per_queue()
3004 * __i40e_set_coalesce - set coalesce settings for particular queue
3017 struct i40e_vsi *vsi = np->vsi; in __i40e_set_coalesce()
3018 struct i40e_pf *pf = vsi->back; in __i40e_set_coalesce()
3021 if (ec->tx_max_coalesced_frames_irq) in __i40e_set_coalesce()
3022 vsi->work_limit = ec->tx_max_coalesced_frames_irq; in __i40e_set_coalesce()
3025 cur_rx_itr = vsi->rx_rings[0]->itr_setting; in __i40e_set_coalesce()
3026 cur_tx_itr = vsi->tx_rings[0]->itr_setting; in __i40e_set_coalesce()
3027 } else if (queue < vsi->num_queue_pairs) { in __i40e_set_coalesce()
3028 cur_rx_itr = vsi->rx_rings[queue]->itr_setting; in __i40e_set_coalesce()
3029 cur_tx_itr = vsi->tx_rings[queue]->itr_setting; in __i40e_set_coalesce()
3031 netif_info(pf, drv, netdev, "Invalid queue value, queue range is 0 - %d\n", in __i40e_set_coalesce()
3032 vsi->num_queue_pairs - 1); in __i40e_set_coalesce()
3033 return -EINVAL; in __i40e_set_coalesce()
3039 /* tx_coalesce_usecs_high is ignored, use rx-usecs-high instead */ in __i40e_set_coalesce()
3040 if (ec->tx_coalesce_usecs_high != vsi->int_rate_limit) { in __i40e_set_coalesce()
3041 netif_info(pf, drv, netdev, "tx-usecs-high is not used, please program rx-usecs-high\n"); in __i40e_set_coalesce()
3042 return -EINVAL; in __i40e_set_coalesce()
3045 if (ec->rx_coalesce_usecs_high > INTRL_REG_TO_USEC(I40E_MAX_INTRL)) { in __i40e_set_coalesce()
3046 netif_info(pf, drv, netdev, "Invalid value, rx-usecs-high range is 0-%lu\n", in __i40e_set_coalesce()
3048 return -EINVAL; in __i40e_set_coalesce()
3051 if (ec->rx_coalesce_usecs != cur_rx_itr && in __i40e_set_coalesce()
3052 ec->use_adaptive_rx_coalesce) { in __i40e_set_coalesce()
3053 …netif_info(pf, drv, netdev, "RX interrupt moderation cannot be changed if adaptive-rx is enabled.\… in __i40e_set_coalesce()
3054 return -EINVAL; in __i40e_set_coalesce()
3057 if (ec->rx_coalesce_usecs > I40E_MAX_ITR) { in __i40e_set_coalesce()
3058 netif_info(pf, drv, netdev, "Invalid value, rx-usecs range is 0-8160\n"); in __i40e_set_coalesce()
3059 return -EINVAL; in __i40e_set_coalesce()
3062 if (ec->tx_coalesce_usecs != cur_tx_itr && in __i40e_set_coalesce()
3063 ec->use_adaptive_tx_coalesce) { in __i40e_set_coalesce()
3064 …netif_info(pf, drv, netdev, "TX interrupt moderation cannot be changed if adaptive-tx is enabled.\… in __i40e_set_coalesce()
3065 return -EINVAL; in __i40e_set_coalesce()
3068 if (ec->tx_coalesce_usecs > I40E_MAX_ITR) { in __i40e_set_coalesce()
3069 netif_info(pf, drv, netdev, "Invalid value, tx-usecs range is 0-8160\n"); in __i40e_set_coalesce()
3070 return -EINVAL; in __i40e_set_coalesce()
3073 if (ec->use_adaptive_rx_coalesce && !cur_rx_itr) in __i40e_set_coalesce()
3074 ec->rx_coalesce_usecs = I40E_MIN_ITR; in __i40e_set_coalesce()
3076 if (ec->use_adaptive_tx_coalesce && !cur_tx_itr) in __i40e_set_coalesce()
3077 ec->tx_coalesce_usecs = I40E_MIN_ITR; in __i40e_set_coalesce()
3079 intrl_reg = i40e_intrl_usec_to_reg(ec->rx_coalesce_usecs_high); in __i40e_set_coalesce()
3080 vsi->int_rate_limit = INTRL_REG_TO_USEC(intrl_reg); in __i40e_set_coalesce()
3081 if (vsi->int_rate_limit != ec->rx_coalesce_usecs_high) { in __i40e_set_coalesce()
3083 vsi->int_rate_limit); in __i40e_set_coalesce()
3090 for (i = 0; i < vsi->num_queue_pairs; i++) in __i40e_set_coalesce()
3100 * i40e_set_coalesce - set coalesce settings for every queue on the netdev
3113 return __i40e_set_coalesce(netdev, ec, -1); in i40e_set_coalesce()
3117 * i40e_set_per_queue_coalesce - set specific queue's coalesce settings
3131 * i40e_get_rss_hash_opts - Get RSS hash Input Set for each flow type
3135 * Returns Success if the flow is supported, else Invalid Input.
3139 struct i40e_hw *hw = &pf->hw; in i40e_get_rss_hash_opts() local
3143 cmd->data = 0; in i40e_get_rss_hash_opts()
3145 switch (cmd->flow_type) { in i40e_get_rss_hash_opts()
3169 cmd->data |= RXH_IP_SRC | RXH_IP_DST; in i40e_get_rss_hash_opts()
3172 return -EINVAL; in i40e_get_rss_hash_opts()
3177 i_set = (u64)i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(0, in i40e_get_rss_hash_opts()
3179 ((u64)i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(1, in i40e_get_rss_hash_opts()
3186 cmd->data |= RXH_L4_B_0_1; in i40e_get_rss_hash_opts()
3188 cmd->data |= RXH_L4_B_2_3; in i40e_get_rss_hash_opts()
3190 if (cmd->flow_type == TCP_V4_FLOW || in i40e_get_rss_hash_opts()
3191 cmd->flow_type == UDP_V4_FLOW) { in i40e_get_rss_hash_opts()
3192 if (hw->mac.type == I40E_MAC_X722) { in i40e_get_rss_hash_opts()
3194 cmd->data |= RXH_IP_SRC; in i40e_get_rss_hash_opts()
3196 cmd->data |= RXH_IP_DST; in i40e_get_rss_hash_opts()
3199 cmd->data |= RXH_IP_SRC; in i40e_get_rss_hash_opts()
3201 cmd->data |= RXH_IP_DST; in i40e_get_rss_hash_opts()
3203 } else if (cmd->flow_type == TCP_V6_FLOW || in i40e_get_rss_hash_opts()
3204 cmd->flow_type == UDP_V6_FLOW) { in i40e_get_rss_hash_opts()
3206 cmd->data |= RXH_IP_SRC; in i40e_get_rss_hash_opts()
3208 cmd->data |= RXH_IP_DST; in i40e_get_rss_hash_opts()
3216 * i40e_check_mask - Check whether a mask field is set
3232 return -1; in i40e_check_mask()
3236 * i40e_parse_rx_flow_user_data - Deconstruct user-defined data
3240 * Read the user-defined data and deconstruct the value into a structure. No
3241 * other code should read the user-defined data, so as to ensure that every
3244 * The user-defined field is a 64bit Big Endian format value, which we
3249 * Returns 0 if the data is valid, and non-zero if the userdef data is invalid
3263 if (!(fsp->flow_type & FLOW_EXT)) in i40e_parse_rx_flow_user_data()
3266 value = be64_to_cpu(*((__be64 *)fsp->h_ext.data)); in i40e_parse_rx_flow_user_data()
3267 mask = be64_to_cpu(*((__be64 *)fsp->m_ext.data)); in i40e_parse_rx_flow_user_data()
3275 return -EINVAL; in i40e_parse_rx_flow_user_data()
3277 data->flex_word = value & I40E_USERDEF_FLEX_WORD; in i40e_parse_rx_flow_user_data()
3278 data->flex_offset = in i40e_parse_rx_flow_user_data()
3280 data->flex_filter = true; in i40e_parse_rx_flow_user_data()
3287 * i40e_fill_rx_flow_user_data - Fill in user-defined data field
3299 if (data->flex_filter) { in i40e_fill_rx_flow_user_data()
3300 value |= data->flex_word; in i40e_fill_rx_flow_user_data()
3301 value |= (u64)data->flex_offset << 16; in i40e_fill_rx_flow_user_data()
3306 fsp->flow_type |= FLOW_EXT; in i40e_fill_rx_flow_user_data()
3308 *((__be64 *)fsp->h_ext.data) = cpu_to_be64(value); in i40e_fill_rx_flow_user_data()
3309 *((__be64 *)fsp->m_ext.data) = cpu_to_be64(mask); in i40e_fill_rx_flow_user_data()
3313 * i40e_get_ethtool_fdir_all - Populates the rule count of a command
3321 * Returns 0 on success or -EMSGSIZE if entry not found
3332 cmd->data = i40e_get_fd_cnt_all(pf); in i40e_get_ethtool_fdir_all()
3335 &pf->fdir_filter_list, fdir_node) { in i40e_get_ethtool_fdir_all()
3336 if (cnt == cmd->rule_cnt) in i40e_get_ethtool_fdir_all()
3337 return -EMSGSIZE; in i40e_get_ethtool_fdir_all()
3339 rule_locs[cnt] = rule->fd_id; in i40e_get_ethtool_fdir_all()
3343 cmd->rule_cnt = cnt; in i40e_get_ethtool_fdir_all()
3349 * i40e_get_ethtool_fdir_entry - Look up a filter based on Rx flow
3356 * Returns 0 on success or -EINVAL if filter not found
3362 (struct ethtool_rx_flow_spec *)&cmd->fs; in i40e_get_ethtool_fdir_entry()
3371 &pf->fdir_filter_list, fdir_node) { in i40e_get_ethtool_fdir_entry()
3372 if (fsp->location <= rule->fd_id) in i40e_get_ethtool_fdir_entry()
3376 if (!rule || fsp->location != rule->fd_id) in i40e_get_ethtool_fdir_entry()
3377 return -EINVAL; in i40e_get_ethtool_fdir_entry()
3379 fsp->flow_type = rule->flow_type; in i40e_get_ethtool_fdir_entry()
3380 if (fsp->flow_type == IP_USER_FLOW) { in i40e_get_ethtool_fdir_entry()
3381 fsp->h_u.usr_ip4_spec.ip_ver = ETH_RX_NFC_IP4; in i40e_get_ethtool_fdir_entry()
3382 fsp->h_u.usr_ip4_spec.proto = 0; in i40e_get_ethtool_fdir_entry()
3383 fsp->m_u.usr_ip4_spec.proto = 0; in i40e_get_ethtool_fdir_entry()
3386 if (fsp->flow_type == IPV6_USER_FLOW || in i40e_get_ethtool_fdir_entry()
3387 fsp->flow_type == UDP_V6_FLOW || in i40e_get_ethtool_fdir_entry()
3388 fsp->flow_type == TCP_V6_FLOW || in i40e_get_ethtool_fdir_entry()
3389 fsp->flow_type == SCTP_V6_FLOW) { in i40e_get_ethtool_fdir_entry()
3390 /* Reverse the src and dest notion, since the HW views them in i40e_get_ethtool_fdir_entry()
3394 fsp->h_u.tcp_ip6_spec.psrc = rule->dst_port; in i40e_get_ethtool_fdir_entry()
3395 fsp->h_u.tcp_ip6_spec.pdst = rule->src_port; in i40e_get_ethtool_fdir_entry()
3396 memcpy(fsp->h_u.tcp_ip6_spec.ip6dst, rule->src_ip6, in i40e_get_ethtool_fdir_entry()
3398 memcpy(fsp->h_u.tcp_ip6_spec.ip6src, rule->dst_ip6, in i40e_get_ethtool_fdir_entry()
3401 /* Reverse the src and dest notion, since the HW views them in i40e_get_ethtool_fdir_entry()
3405 fsp->h_u.tcp_ip4_spec.psrc = rule->dst_port; in i40e_get_ethtool_fdir_entry()
3406 fsp->h_u.tcp_ip4_spec.pdst = rule->src_port; in i40e_get_ethtool_fdir_entry()
3407 fsp->h_u.tcp_ip4_spec.ip4src = rule->dst_ip; in i40e_get_ethtool_fdir_entry()
3408 fsp->h_u.tcp_ip4_spec.ip4dst = rule->src_ip; in i40e_get_ethtool_fdir_entry()
3411 switch (rule->flow_type) { in i40e_get_ethtool_fdir_entry()
3443 rule->flow_type); in i40e_get_ethtool_fdir_entry()
3452 fsp->m_u.tcp_ip6_spec.ip6src[0] = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3453 fsp->m_u.tcp_ip6_spec.ip6src[1] = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3454 fsp->m_u.tcp_ip6_spec.ip6src[2] = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3455 fsp->m_u.tcp_ip6_spec.ip6src[3] = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3459 fsp->m_u.tcp_ip6_spec.ip6dst[0] = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3460 fsp->m_u.tcp_ip6_spec.ip6dst[1] = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3461 fsp->m_u.tcp_ip6_spec.ip6dst[2] = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3462 fsp->m_u.tcp_ip6_spec.ip6dst[3] = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3466 fsp->m_u.tcp_ip4_spec.ip4src = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3469 fsp->m_u.tcp_ip4_spec.ip4dst = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3472 fsp->m_u.tcp_ip4_spec.psrc = htons(0xFFFF); in i40e_get_ethtool_fdir_entry()
3475 fsp->m_u.tcp_ip4_spec.pdst = htons(0xFFFF); in i40e_get_ethtool_fdir_entry()
3477 if (rule->dest_ctl == I40E_FILTER_PROGRAM_DESC_DEST_DROP_PACKET) in i40e_get_ethtool_fdir_entry()
3478 fsp->ring_cookie = RX_CLS_FLOW_DISC; in i40e_get_ethtool_fdir_entry()
3480 fsp->ring_cookie = rule->q_index; in i40e_get_ethtool_fdir_entry()
3482 if (rule->vlan_tag) { in i40e_get_ethtool_fdir_entry()
3483 fsp->h_ext.vlan_etype = rule->vlan_etype; in i40e_get_ethtool_fdir_entry()
3484 fsp->m_ext.vlan_etype = htons(0xFFFF); in i40e_get_ethtool_fdir_entry()
3485 fsp->h_ext.vlan_tci = rule->vlan_tag; in i40e_get_ethtool_fdir_entry()
3486 fsp->m_ext.vlan_tci = htons(0xFFFF); in i40e_get_ethtool_fdir_entry()
3487 fsp->flow_type |= FLOW_EXT; in i40e_get_ethtool_fdir_entry()
3491 if (rule->dest_vsi != vsi->id) { in i40e_get_ethtool_fdir_entry()
3492 vsi = i40e_find_vsi_from_id(pf, rule->dest_vsi); in i40e_get_ethtool_fdir_entry()
3493 if (vsi && vsi->type == I40E_VSI_SRIOV) { in i40e_get_ethtool_fdir_entry()
3494 /* VFs are zero-indexed by the driver, but ethtool in i40e_get_ethtool_fdir_entry()
3495 * expects them to be one-indexed, so add one here in i40e_get_ethtool_fdir_entry()
3497 u64 ring_vf = vsi->vf_id + 1; in i40e_get_ethtool_fdir_entry()
3500 fsp->ring_cookie |= ring_vf; in i40e_get_ethtool_fdir_entry()
3504 if (rule->flex_filter) { in i40e_get_ethtool_fdir_entry()
3506 userdef.flex_word = be16_to_cpu(rule->flex_word); in i40e_get_ethtool_fdir_entry()
3507 userdef.flex_offset = rule->flex_offset; in i40e_get_ethtool_fdir_entry()
3516 * i40e_get_rxnfc - command to get RX flow classification rules
3521 * Returns Success if the command is supported.
3527 struct i40e_vsi *vsi = np->vsi; in i40e_get_rxnfc()
3528 struct i40e_pf *pf = vsi->back; in i40e_get_rxnfc()
3529 int ret = -EOPNOTSUPP; in i40e_get_rxnfc()
3531 switch (cmd->cmd) { in i40e_get_rxnfc()
3533 cmd->data = vsi->rss_size; in i40e_get_rxnfc()
3540 cmd->rule_cnt = pf->fdir_pf_active_filters; in i40e_get_rxnfc()
3542 cmd->data = i40e_get_fd_cnt_all(pf); in i40e_get_rxnfc()
3559 * i40e_get_rss_hash_bits - Read RSS Hash bits from register
3560 * @hw: hw structure
3566 static u64 i40e_get_rss_hash_bits(struct i40e_hw *hw, in i40e_get_rss_hash_bits() argument
3573 if (nfc->data & RXH_L4_B_0_1) in i40e_get_rss_hash_bits()
3577 if (nfc->data & RXH_L4_B_2_3) in i40e_get_rss_hash_bits()
3582 if (nfc->flow_type == TCP_V6_FLOW || nfc->flow_type == UDP_V6_FLOW) { in i40e_get_rss_hash_bits()
3585 } else if (nfc->flow_type == TCP_V4_FLOW || in i40e_get_rss_hash_bits()
3586 nfc->flow_type == UDP_V4_FLOW) { in i40e_get_rss_hash_bits()
3587 if (hw->mac.type == I40E_MAC_X722) { in i40e_get_rss_hash_bits()
3595 /* Any other flow type are not supported here */ in i40e_get_rss_hash_bits()
3599 if (nfc->data & RXH_IP_SRC) in i40e_get_rss_hash_bits()
3603 if (nfc->data & RXH_IP_DST) in i40e_get_rss_hash_bits()
3613 * i40e_set_rss_hash_opt - Enable/Disable flow types for RSS hash
3617 * Returns Success if the flow input set is supported.
3621 struct i40e_hw *hw = &pf->hw; in i40e_set_rss_hash_opt() local
3622 u64 hena = (u64)i40e_read_rx_ctl(hw, I40E_PFQF_HENA(0)) | in i40e_set_rss_hash_opt()
3623 ((u64)i40e_read_rx_ctl(hw, I40E_PFQF_HENA(1)) << 32); in i40e_set_rss_hash_opt()
3629 if (test_bit(I40E_FLAG_MFP_ENA, pf->flags)) { in i40e_set_rss_hash_opt()
3630 dev_err(&pf->pdev->dev, in i40e_set_rss_hash_opt()
3631 "Change of RSS hash input set is not supported when MFP mode is enabled\n"); in i40e_set_rss_hash_opt()
3632 return -EOPNOTSUPP; in i40e_set_rss_hash_opt()
3638 if (nfc->data & ~(RXH_IP_SRC | RXH_IP_DST | in i40e_set_rss_hash_opt()
3640 return -EINVAL; in i40e_set_rss_hash_opt()
3642 switch (nfc->flow_type) { in i40e_set_rss_hash_opt()
3646 pf->hw.caps)) in i40e_set_rss_hash_opt()
3653 pf->hw.caps)) in i40e_set_rss_hash_opt()
3660 pf->hw.caps)) { in i40e_set_rss_hash_opt()
3671 pf->hw.caps)) { in i40e_set_rss_hash_opt()
3683 if ((nfc->data & RXH_L4_B_0_1) || in i40e_set_rss_hash_opt()
3684 (nfc->data & RXH_L4_B_2_3)) in i40e_set_rss_hash_opt()
3685 return -EINVAL; in i40e_set_rss_hash_opt()
3692 if ((nfc->data & RXH_L4_B_0_1) || in i40e_set_rss_hash_opt()
3693 (nfc->data & RXH_L4_B_2_3)) in i40e_set_rss_hash_opt()
3694 return -EINVAL; in i40e_set_rss_hash_opt()
3706 return -EINVAL; in i40e_set_rss_hash_opt()
3713 i_setc = (u64)i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(0, flow_id)) | in i40e_set_rss_hash_opt()
3714 ((u64)i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(1, flow_id)) << 32); in i40e_set_rss_hash_opt()
3715 i_set = i40e_get_rss_hash_bits(&pf->hw, nfc, i_setc); in i40e_set_rss_hash_opt()
3717 i40e_write_rx_ctl(hw, I40E_GLQF_HASH_INSET(0, flow_id), in i40e_set_rss_hash_opt()
3719 i40e_write_rx_ctl(hw, I40E_GLQF_HASH_INSET(1, flow_id), in i40e_set_rss_hash_opt()
3725 i40e_write_rx_ctl(hw, I40E_PFQF_HENA(0), (u32)hena); in i40e_set_rss_hash_opt()
3726 i40e_write_rx_ctl(hw, I40E_PFQF_HENA(1), (u32)(hena >> 32)); in i40e_set_rss_hash_opt()
3727 i40e_flush(hw); in i40e_set_rss_hash_opt()
3733 * i40e_update_ethtool_fdir_entry - Updates the fdir filter entry
3750 struct i40e_pf *pf = vsi->back; in i40e_update_ethtool_fdir_entry()
3752 int err = -EINVAL; in i40e_update_ethtool_fdir_entry()
3758 &pf->fdir_filter_list, fdir_node) { in i40e_update_ethtool_fdir_entry()
3760 if (rule->fd_id >= sw_idx) in i40e_update_ethtool_fdir_entry()
3766 if (rule && (rule->fd_id == sw_idx)) { in i40e_update_ethtool_fdir_entry()
3771 hlist_del(&rule->fdir_node); in i40e_update_ethtool_fdir_entry()
3773 pf->fdir_pf_active_filters--; in i40e_update_ethtool_fdir_entry()
3783 INIT_HLIST_NODE(&input->fdir_node); in i40e_update_ethtool_fdir_entry()
3787 hlist_add_behind(&input->fdir_node, &parent->fdir_node); in i40e_update_ethtool_fdir_entry()
3789 hlist_add_head(&input->fdir_node, in i40e_update_ethtool_fdir_entry()
3790 &pf->fdir_filter_list); in i40e_update_ethtool_fdir_entry()
3793 pf->fdir_pf_active_filters++; in i40e_update_ethtool_fdir_entry()
3799 * i40e_prune_flex_pit_list - Cleanup unused entries in FLX_PIT table
3812 list_for_each_entry_safe(entry, tmp, &pf->l3_flex_pit_list, list) { in i40e_prune_flex_pit_list()
3815 hlist_for_each_entry(rule, &pf->fdir_filter_list, fdir_node) { in i40e_prune_flex_pit_list()
3816 if (rule->flow_type != IP_USER_FLOW) in i40e_prune_flex_pit_list()
3818 if (rule->flex_filter && in i40e_prune_flex_pit_list()
3819 rule->flex_offset == entry->src_offset) { in i40e_prune_flex_pit_list()
3829 list_del(&entry->list); in i40e_prune_flex_pit_list()
3835 list_for_each_entry_safe(entry, tmp, &pf->l4_flex_pit_list, list) { in i40e_prune_flex_pit_list()
3838 hlist_for_each_entry(rule, &pf->fdir_filter_list, fdir_node) { in i40e_prune_flex_pit_list()
3842 if (rule->flow_type == IP_USER_FLOW) in i40e_prune_flex_pit_list()
3844 if (rule->flex_filter && in i40e_prune_flex_pit_list()
3845 rule->flex_offset == entry->src_offset) { in i40e_prune_flex_pit_list()
3855 list_del(&entry->list); in i40e_prune_flex_pit_list()
3862 * i40e_del_fdir_entry - Deletes a Flow Director filter entry
3875 (struct ethtool_rx_flow_spec *)&cmd->fs; in i40e_del_fdir_entry()
3876 struct i40e_pf *pf = vsi->back; in i40e_del_fdir_entry()
3879 if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) || in i40e_del_fdir_entry()
3880 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) in i40e_del_fdir_entry()
3881 return -EBUSY; in i40e_del_fdir_entry()
3883 if (test_bit(__I40E_FD_FLUSH_REQUESTED, pf->state)) in i40e_del_fdir_entry()
3884 return -EBUSY; in i40e_del_fdir_entry()
3886 ret = i40e_update_ethtool_fdir_entry(vsi, NULL, fsp->location, cmd); in i40e_del_fdir_entry()
3895 * i40e_unused_pit_index - Find an unused PIT index for given list
3913 list_for_each_entry(entry, &pf->l4_flex_pit_list, list) in i40e_unused_pit_index()
3914 clear_bit(entry->pit_index, &available_index); in i40e_unused_pit_index()
3916 list_for_each_entry(entry, &pf->l3_flex_pit_list, list) in i40e_unused_pit_index()
3917 clear_bit(entry->pit_index, &available_index); in i40e_unused_pit_index()
3923 * i40e_find_flex_offset - Find an existing flex src_offset
3939 * already programmed, we can simply re-use it. in i40e_find_flex_offset()
3943 if (entry->src_offset == src_offset) in i40e_find_flex_offset()
3953 return ERR_PTR(-ENOSPC); in i40e_find_flex_offset()
3959 * i40e_add_flex_offset - Add src_offset to flex PIT table list
3979 return -ENOMEM; in i40e_add_flex_offset()
3981 new_pit->src_offset = src_offset; in i40e_add_flex_offset()
3982 new_pit->pit_index = pit_index; in i40e_add_flex_offset()
3988 if (new_pit->src_offset < entry->src_offset) { in i40e_add_flex_offset()
3989 list_add_tail(&new_pit->list, &entry->list); in i40e_add_flex_offset()
3997 if (new_pit->src_offset == entry->src_offset) { in i40e_add_flex_offset()
4000 /* If the PIT index is not the same we can't re-use in i40e_add_flex_offset()
4003 if (new_pit->pit_index != entry->pit_index) in i40e_add_flex_offset()
4004 err = -EINVAL; in i40e_add_flex_offset()
4014 list_add_tail(&new_pit->list, flex_pit_list); in i40e_add_flex_offset()
4019 * __i40e_reprogram_flex_pit - Re-program specific FLX_PIT table
4032 * This function will reprogram the FLX_PIT register from a book-keeping
4066 u16 offset = entry->src_offset + j; in __i40e_reprogram_flex_pit()
4070 offset - 3); in __i40e_reprogram_flex_pit()
4073 i40e_write_rx_ctl(&pf->hw, in __i40e_reprogram_flex_pit()
4081 i40e_write_rx_ctl(&pf->hw, in __i40e_reprogram_flex_pit()
4083 I40E_FLEX_PREP_VAL(entry->pit_index + 50, in __i40e_reprogram_flex_pit()
4085 entry->src_offset)); in __i40e_reprogram_flex_pit()
4096 last_offset = list_prev_entry(entry, list)->src_offset + 1; in __i40e_reprogram_flex_pit()
4099 i40e_write_rx_ctl(&pf->hw, in __i40e_reprogram_flex_pit()
4108 * i40e_reprogram_flex_pit - Reprogram all FLX_PIT tables after input set change
4116 __i40e_reprogram_flex_pit(pf, &pf->l3_flex_pit_list, in i40e_reprogram_flex_pit()
4119 __i40e_reprogram_flex_pit(pf, &pf->l4_flex_pit_list, in i40e_reprogram_flex_pit()
4123 i40e_write_rx_ctl(&pf->hw, in i40e_reprogram_flex_pit()
4128 i40e_write_rx_ctl(&pf->hw, in i40e_reprogram_flex_pit()
4135 * i40e_flow_str - Converts a flow_type into a human readable string
4143 switch (fsp->flow_type & ~FLOW_EXT) { in i40e_flow_str()
4166 * i40e_pit_index_to_mask - Return the FLEX mask for a given PIT index
4197 * i40e_print_input_set - Show changes between two input sets
4208 struct i40e_pf *pf = vsi->back; in i40e_print_input_set()
4215 netif_info(pf, drv, vsi->netdev, "L3 source address: %s -> %s\n", in i40e_print_input_set()
4222 netif_info(pf, drv, vsi->netdev, "L3 destination address: %s -> %s\n", in i40e_print_input_set()
4229 netif_info(pf, drv, vsi->netdev, "L4 source port: %s -> %s\n", in i40e_print_input_set()
4236 netif_info(pf, drv, vsi->netdev, "L4 destination port: %s -> %s\n", in i40e_print_input_set()
4243 netif_info(pf, drv, vsi->netdev, "SCTP verification tag: %s -> %s\n", in i40e_print_input_set()
4254 netif_info(pf, drv, vsi->netdev, "FLEX index %d: %s -> %s\n", in i40e_print_input_set()
4260 netif_info(pf, drv, vsi->netdev, " Current input set: %0llx\n", in i40e_print_input_set()
4262 netif_info(pf, drv, vsi->netdev, "Requested input set: %0llx\n", in i40e_print_input_set()
4267 * i40e_check_fdir_input_set - Check that a given rx_flow_spec mask is valid
4285 * as supported, we print a diagnostic message displaying how the input set
4302 struct i40e_pf *pf = vsi->back; in i40e_check_fdir_input_set()
4311 switch (fsp->flow_type & ~FLOW_EXT) { in i40e_check_fdir_input_set()
4314 fdir_filter_count = &pf->fd_sctp4_filter_cnt; in i40e_check_fdir_input_set()
4318 fdir_filter_count = &pf->fd_tcp4_filter_cnt; in i40e_check_fdir_input_set()
4322 fdir_filter_count = &pf->fd_udp4_filter_cnt; in i40e_check_fdir_input_set()
4326 fdir_filter_count = &pf->fd_sctp6_filter_cnt; in i40e_check_fdir_input_set()
4330 fdir_filter_count = &pf->fd_tcp6_filter_cnt; in i40e_check_fdir_input_set()
4334 fdir_filter_count = &pf->fd_udp6_filter_cnt; in i40e_check_fdir_input_set()
4338 fdir_filter_count = &pf->fd_ip4_filter_cnt; in i40e_check_fdir_input_set()
4343 fdir_filter_count = &pf->fd_ip6_filter_cnt; in i40e_check_fdir_input_set()
4347 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4363 switch (fsp->flow_type & ~FLOW_EXT) { in i40e_check_fdir_input_set()
4369 tcp_ip4_spec = &fsp->m_u.tcp_ip4_spec; in i40e_check_fdir_input_set()
4372 if (tcp_ip4_spec->ip4src == htonl(0xFFFFFFFF)) in i40e_check_fdir_input_set()
4374 else if (!tcp_ip4_spec->ip4src) in i40e_check_fdir_input_set()
4377 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4380 if (tcp_ip4_spec->ip4dst == htonl(0xFFFFFFFF)) in i40e_check_fdir_input_set()
4382 else if (!tcp_ip4_spec->ip4dst) in i40e_check_fdir_input_set()
4385 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4388 if (tcp_ip4_spec->psrc == htons(0xFFFF)) in i40e_check_fdir_input_set()
4390 else if (!tcp_ip4_spec->psrc) in i40e_check_fdir_input_set()
4393 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4396 if (tcp_ip4_spec->pdst == htons(0xFFFF)) in i40e_check_fdir_input_set()
4398 else if (!tcp_ip4_spec->pdst) in i40e_check_fdir_input_set()
4401 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4403 /* Filtering on Type of Service is not supported. */ in i40e_check_fdir_input_set()
4404 if (tcp_ip4_spec->tos) in i40e_check_fdir_input_set()
4405 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4413 tcp_ip6_spec = &fsp->m_u.tcp_ip6_spec; in i40e_check_fdir_input_set()
4416 if (ipv6_addr_equal((struct in6_addr *)&tcp_ip6_spec->ip6src, in i40e_check_fdir_input_set()
4420 &tcp_ip6_spec->ip6src)) in i40e_check_fdir_input_set()
4423 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4426 if (ipv6_addr_equal((struct in6_addr *)&tcp_ip6_spec->ip6dst, in i40e_check_fdir_input_set()
4430 &tcp_ip6_spec->ip6dst)) in i40e_check_fdir_input_set()
4433 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4436 if (tcp_ip6_spec->psrc == htons(0xFFFF)) in i40e_check_fdir_input_set()
4438 else if (!tcp_ip6_spec->psrc) in i40e_check_fdir_input_set()
4441 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4444 if (tcp_ip6_spec->pdst == htons(0xFFFF)) in i40e_check_fdir_input_set()
4446 else if (!tcp_ip6_spec->pdst) in i40e_check_fdir_input_set()
4449 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4451 /* Filtering on Traffic Classes is not supported. */ in i40e_check_fdir_input_set()
4452 if (tcp_ip6_spec->tclass) in i40e_check_fdir_input_set()
4453 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4456 usr_ip4_spec = &fsp->m_u.usr_ip4_spec; in i40e_check_fdir_input_set()
4459 if (usr_ip4_spec->ip4src == htonl(0xFFFFFFFF)) in i40e_check_fdir_input_set()
4461 else if (!usr_ip4_spec->ip4src) in i40e_check_fdir_input_set()
4464 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4467 if (usr_ip4_spec->ip4dst == htonl(0xFFFFFFFF)) in i40e_check_fdir_input_set()
4469 else if (!usr_ip4_spec->ip4dst) in i40e_check_fdir_input_set()
4472 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4475 if (usr_ip4_spec->l4_4_bytes) in i40e_check_fdir_input_set()
4476 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4478 /* Filtering on Type of Service is not supported. */ in i40e_check_fdir_input_set()
4479 if (usr_ip4_spec->tos) in i40e_check_fdir_input_set()
4480 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4482 /* Filtering on IP version is not supported */ in i40e_check_fdir_input_set()
4483 if (usr_ip4_spec->ip_ver) in i40e_check_fdir_input_set()
4484 return -EINVAL; in i40e_check_fdir_input_set()
4486 /* Filtering on L4 protocol is not supported */ in i40e_check_fdir_input_set()
4487 if (usr_ip4_spec->proto) in i40e_check_fdir_input_set()
4488 return -EINVAL; in i40e_check_fdir_input_set()
4492 usr_ip6_spec = &fsp->m_u.usr_ip6_spec; in i40e_check_fdir_input_set()
4495 if (ipv6_addr_equal((struct in6_addr *)&usr_ip6_spec->ip6src, in i40e_check_fdir_input_set()
4499 &usr_ip6_spec->ip6src)) in i40e_check_fdir_input_set()
4502 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4505 if (ipv6_addr_equal((struct in6_addr *)&usr_ip6_spec->ip6dst, in i40e_check_fdir_input_set()
4509 &usr_ip6_spec->ip6dst)) in i40e_check_fdir_input_set()
4512 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4514 if (usr_ip6_spec->l4_4_bytes) in i40e_check_fdir_input_set()
4515 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4517 /* Filtering on Traffic class is not supported. */ in i40e_check_fdir_input_set()
4518 if (usr_ip6_spec->tclass) in i40e_check_fdir_input_set()
4519 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4521 /* Filtering on L4 protocol is not supported */ in i40e_check_fdir_input_set()
4522 if (usr_ip6_spec->l4_proto) in i40e_check_fdir_input_set()
4523 return -EINVAL; in i40e_check_fdir_input_set()
4527 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4530 if (fsp->flow_type & FLOW_EXT) { in i40e_check_fdir_input_set()
4534 if (fsp->h_ext.vlan_etype != htons(ETH_P_8021Q) && in i40e_check_fdir_input_set()
4535 fsp->h_ext.vlan_etype != 0) in i40e_check_fdir_input_set()
4536 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4537 if (fsp->m_ext.vlan_tci == htons(0xFFFF)) in i40e_check_fdir_input_set()
4551 if (userdef->flex_filter) { in i40e_check_fdir_input_set()
4555 * must be aligned on 2-byte boundary. in i40e_check_fdir_input_set()
4557 if (userdef->flex_offset & 0x1) { in i40e_check_fdir_input_set()
4558 dev_warn(&pf->pdev->dev, in i40e_check_fdir_input_set()
4559 "Flexible data offset must be 2-byte aligned\n"); in i40e_check_fdir_input_set()
4560 return -EINVAL; in i40e_check_fdir_input_set()
4563 src_offset = userdef->flex_offset >> 1; in i40e_check_fdir_input_set()
4567 dev_warn(&pf->pdev->dev, in i40e_check_fdir_input_set()
4569 return -EINVAL; in i40e_check_fdir_input_set()
4577 flex_pit = i40e_find_flex_offset(&pf->l4_flex_pit_list, in i40e_check_fdir_input_set()
4591 i40e_find_flex_offset(&pf->l3_flex_pit_list, in i40e_check_fdir_input_set()
4602 if (l3_flex_pit->pit_index != in i40e_check_fdir_input_set()
4603 flex_pit->pit_index) { in i40e_check_fdir_input_set()
4604 return -EINVAL; in i40e_check_fdir_input_set()
4623 pit_index = flex_pit->pit_index; in i40e_check_fdir_input_set()
4637 netif_info(pf, drv, vsi->netdev, "Input set change requested for %s flows:\n", in i40e_check_fdir_input_set()
4641 netif_info(pf, drv, vsi->netdev, "FLEX index %d: Offset -> %d", in i40e_check_fdir_input_set()
4649 if (test_bit(I40E_FLAG_MFP_ENA, pf->flags)) { in i40e_check_fdir_input_set()
4650 netif_err(pf, drv, vsi->netdev, "Cannot change Flow Director input sets while MFP is enabled\n"); in i40e_check_fdir_input_set()
4651 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4664 …netif_err(pf, drv, vsi->netdev, "Cannot change input set for %s flows until %d preexisting filters… in i40e_check_fdir_input_set()
4667 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4684 err = i40e_add_flex_offset(&pf->l4_flex_pit_list, src_offset, in i40e_check_fdir_input_set()
4690 err = i40e_add_flex_offset(&pf->l3_flex_pit_list, in i40e_check_fdir_input_set()
4704 * i40e_match_fdir_filter - Return true of two filters match
4710 * check any input-set since all filters of the same flow type must use the
4717 if (a->dst_ip != b->dst_ip || in i40e_match_fdir_filter()
4718 a->src_ip != b->src_ip || in i40e_match_fdir_filter()
4719 a->dst_port != b->dst_port || in i40e_match_fdir_filter()
4720 a->src_port != b->src_port || in i40e_match_fdir_filter()
4721 a->flow_type != b->flow_type || in i40e_match_fdir_filter()
4722 a->ipl4_proto != b->ipl4_proto || in i40e_match_fdir_filter()
4723 a->vlan_tag != b->vlan_tag || in i40e_match_fdir_filter()
4724 a->vlan_etype != b->vlan_etype) in i40e_match_fdir_filter()
4731 * i40e_disallow_matching_filters - Check that new filters differ
4758 struct i40e_pf *pf = vsi->back; in i40e_disallow_matching_filters()
4764 &pf->fdir_filter_list, fdir_node) { in i40e_disallow_matching_filters()
4769 if (rule->fd_id == input->fd_id) in i40e_disallow_matching_filters()
4776 dev_warn(&pf->pdev->dev, in i40e_disallow_matching_filters()
4778 rule->fd_id); in i40e_disallow_matching_filters()
4779 return -EINVAL; in i40e_disallow_matching_filters()
4787 * i40e_add_fdir_ethtool - Add/Remove Flow Director filters
4802 int ret = -EINVAL; in i40e_add_fdir_ethtool()
4806 return -EINVAL; in i40e_add_fdir_ethtool()
4807 pf = vsi->back; in i40e_add_fdir_ethtool()
4809 if (!test_bit(I40E_FLAG_FD_SB_ENA, pf->flags)) in i40e_add_fdir_ethtool()
4810 return -EOPNOTSUPP; in i40e_add_fdir_ethtool()
4812 if (test_bit(__I40E_FD_SB_AUTO_DISABLED, pf->state)) in i40e_add_fdir_ethtool()
4813 return -ENOSPC; in i40e_add_fdir_ethtool()
4815 if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) || in i40e_add_fdir_ethtool()
4816 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) in i40e_add_fdir_ethtool()
4817 return -EBUSY; in i40e_add_fdir_ethtool()
4819 if (test_bit(__I40E_FD_FLUSH_REQUESTED, pf->state)) in i40e_add_fdir_ethtool()
4820 return -EBUSY; in i40e_add_fdir_ethtool()
4822 fsp = (struct ethtool_rx_flow_spec *)&cmd->fs; in i40e_add_fdir_ethtool()
4824 /* Parse the user-defined field */ in i40e_add_fdir_ethtool()
4826 return -EINVAL; in i40e_add_fdir_ethtool()
4828 /* Extended MAC field is not supported */ in i40e_add_fdir_ethtool()
4829 if (fsp->flow_type & FLOW_MAC_EXT) in i40e_add_fdir_ethtool()
4830 return -EINVAL; in i40e_add_fdir_ethtool()
4836 if (fsp->location >= (pf->hw.func_caps.fd_filters_best_effort + in i40e_add_fdir_ethtool()
4837 pf->hw.func_caps.fd_filters_guaranteed)) { in i40e_add_fdir_ethtool()
4838 return -EINVAL; in i40e_add_fdir_ethtool()
4844 if (fsp->ring_cookie == RX_CLS_FLOW_DISC) { in i40e_add_fdir_ethtool()
4847 u32 ring = ethtool_get_flow_spec_ring(fsp->ring_cookie); in i40e_add_fdir_ethtool()
4848 u8 vf = ethtool_get_flow_spec_ring_vf(fsp->ring_cookie); in i40e_add_fdir_ethtool()
4851 if (ring >= vsi->num_queue_pairs) in i40e_add_fdir_ethtool()
4852 return -EINVAL; in i40e_add_fdir_ethtool()
4853 dest_vsi = vsi->id; in i40e_add_fdir_ethtool()
4855 /* VFs are zero-indexed, so we subtract one here */ in i40e_add_fdir_ethtool()
4856 vf--; in i40e_add_fdir_ethtool()
4858 if (vf >= pf->num_alloc_vfs) in i40e_add_fdir_ethtool()
4859 return -EINVAL; in i40e_add_fdir_ethtool()
4860 if (ring >= pf->vf[vf].num_queue_pairs) in i40e_add_fdir_ethtool()
4861 return -EINVAL; in i40e_add_fdir_ethtool()
4862 dest_vsi = pf->vf[vf].lan_vsi_id; in i40e_add_fdir_ethtool()
4871 return -ENOMEM; in i40e_add_fdir_ethtool()
4873 input->fd_id = fsp->location; in i40e_add_fdir_ethtool()
4874 input->q_index = q_index; in i40e_add_fdir_ethtool()
4875 input->dest_vsi = dest_vsi; in i40e_add_fdir_ethtool()
4876 input->dest_ctl = dest_ctl; in i40e_add_fdir_ethtool()
4877 input->fd_status = I40E_FILTER_PROGRAM_DESC_FD_STATUS_FD_ID; in i40e_add_fdir_ethtool()
4878 input->cnt_index = I40E_FD_SB_STAT_IDX(pf->hw.pf_id); in i40e_add_fdir_ethtool()
4879 input->dst_ip = fsp->h_u.tcp_ip4_spec.ip4src; in i40e_add_fdir_ethtool()
4880 input->src_ip = fsp->h_u.tcp_ip4_spec.ip4dst; in i40e_add_fdir_ethtool()
4881 input->flow_type = fsp->flow_type & ~FLOW_EXT; in i40e_add_fdir_ethtool()
4883 input->vlan_etype = fsp->h_ext.vlan_etype; in i40e_add_fdir_ethtool()
4884 if (!fsp->m_ext.vlan_etype && fsp->h_ext.vlan_tci) in i40e_add_fdir_ethtool()
4885 input->vlan_etype = cpu_to_be16(ETH_P_8021Q); in i40e_add_fdir_ethtool()
4886 if (fsp->m_ext.vlan_tci && input->vlan_etype) in i40e_add_fdir_ethtool()
4887 input->vlan_tag = fsp->h_ext.vlan_tci; in i40e_add_fdir_ethtool()
4888 if (input->flow_type == IPV6_USER_FLOW || in i40e_add_fdir_ethtool()
4889 input->flow_type == UDP_V6_FLOW || in i40e_add_fdir_ethtool()
4890 input->flow_type == TCP_V6_FLOW || in i40e_add_fdir_ethtool()
4891 input->flow_type == SCTP_V6_FLOW) { in i40e_add_fdir_ethtool()
4892 /* Reverse the src and dest notion, since the HW expects them in i40e_add_fdir_ethtool()
4896 input->ipl4_proto = fsp->h_u.usr_ip6_spec.l4_proto; in i40e_add_fdir_ethtool()
4897 input->dst_port = fsp->h_u.tcp_ip6_spec.psrc; in i40e_add_fdir_ethtool()
4898 input->src_port = fsp->h_u.tcp_ip6_spec.pdst; in i40e_add_fdir_ethtool()
4899 memcpy(input->dst_ip6, fsp->h_u.ah_ip6_spec.ip6src, in i40e_add_fdir_ethtool()
4901 memcpy(input->src_ip6, fsp->h_u.ah_ip6_spec.ip6dst, in i40e_add_fdir_ethtool()
4904 /* Reverse the src and dest notion, since the HW expects them in i40e_add_fdir_ethtool()
4908 input->ipl4_proto = fsp->h_u.usr_ip4_spec.proto; in i40e_add_fdir_ethtool()
4909 input->dst_port = fsp->h_u.tcp_ip4_spec.psrc; in i40e_add_fdir_ethtool()
4910 input->src_port = fsp->h_u.tcp_ip4_spec.pdst; in i40e_add_fdir_ethtool()
4911 input->dst_ip = fsp->h_u.tcp_ip4_spec.ip4src; in i40e_add_fdir_ethtool()
4912 input->src_ip = fsp->h_u.tcp_ip4_spec.ip4dst; in i40e_add_fdir_ethtool()
4916 input->flex_filter = true; in i40e_add_fdir_ethtool()
4917 input->flex_word = cpu_to_be16(userdef.flex_word); in i40e_add_fdir_ethtool()
4918 input->flex_offset = userdef.flex_offset; in i40e_add_fdir_ethtool()
4928 * to the list as this would cause a use-after-free bug. in i40e_add_fdir_ethtool()
4930 i40e_update_ethtool_fdir_entry(vsi, input, fsp->location, NULL); in i40e_add_fdir_ethtool()
4937 hlist_del(&input->fdir_node); in i40e_add_fdir_ethtool()
4938 pf->fdir_pf_active_filters--; in i40e_add_fdir_ethtool()
4945 * i40e_set_rxnfc - command to set RX flow classification rules
4949 * Returns Success if the command is supported.
4954 struct i40e_vsi *vsi = np->vsi; in i40e_set_rxnfc()
4955 struct i40e_pf *pf = vsi->back; in i40e_set_rxnfc()
4956 int ret = -EOPNOTSUPP; in i40e_set_rxnfc()
4958 switch (cmd->cmd) { in i40e_set_rxnfc()
4976 * i40e_max_channels - get Max number of combined channels supported
4982 return vsi->alloc_queue_pairs; in i40e_max_channels()
4986 * i40e_get_channels - Get the current channels enabled and max supported etc.
4999 struct i40e_vsi *vsi = np->vsi; in i40e_get_channels()
5000 struct i40e_pf *pf = vsi->back; in i40e_get_channels()
5003 ch->max_combined = i40e_max_channels(vsi); in i40e_get_channels()
5006 ch->other_count = test_bit(I40E_FLAG_FD_SB_ENA, pf->flags) ? 1 : 0; in i40e_get_channels()
5007 ch->max_other = ch->other_count; in i40e_get_channels()
5010 ch->combined_count = vsi->num_queue_pairs; in i40e_get_channels()
5014 * i40e_set_channels - Set the new channels count.
5026 unsigned int count = ch->combined_count; in i40e_set_channels()
5027 struct i40e_vsi *vsi = np->vsi; in i40e_set_channels()
5028 struct i40e_pf *pf = vsi->back; in i40e_set_channels()
5035 if (vsi->type != I40E_VSI_MAIN) in i40e_set_channels()
5036 return -EINVAL; in i40e_set_channels()
5042 return -EINVAL; in i40e_set_channels()
5045 if (!count || ch->rx_count || ch->tx_count) in i40e_set_channels()
5046 return -EINVAL; in i40e_set_channels()
5049 if (ch->other_count != (test_bit(I40E_FLAG_FD_SB_ENA, pf->flags) ? 1 : 0)) in i40e_set_channels()
5050 return -EINVAL; in i40e_set_channels()
5054 return -EINVAL; in i40e_set_channels()
5060 &pf->fdir_filter_list, fdir_node) { in i40e_set_channels()
5061 if (rule->dest_ctl != drop && count <= rule->q_index) { in i40e_set_channels()
5062 dev_warn(&pf->pdev->dev, in i40e_set_channels()
5064 rule->fd_id, rule->q_index); in i40e_set_channels()
5065 err = -EINVAL; in i40e_set_channels()
5070 dev_err(&pf->pdev->dev, in i40e_set_channels()
5076 /* update feature limits from largest to smallest supported values */ in i40e_set_channels()
5086 return -EINVAL; in i40e_set_channels()
5090 * i40e_get_rxfh_key_size - get the RSS hash key size
5101 * i40e_get_rxfh_indir_size - get the rx flow hash indirection table size
5112 * i40e_get_rxfh - get the rx flow hash indirection table
5123 struct i40e_vsi *vsi = np->vsi; in i40e_get_rxfh()
5128 rxfh->hfunc = ETH_RSS_HASH_TOP; in i40e_get_rxfh()
5130 if (!rxfh->indir) in i40e_get_rxfh()
5133 seed = rxfh->key; in i40e_get_rxfh()
5136 return -ENOMEM; in i40e_get_rxfh()
5141 rxfh->indir[i] = (u32)(lut[i]); in i40e_get_rxfh()
5150 * i40e_set_rxfh - set the rx flow hash indirection table
5155 * Returns -EINVAL if the table specifies an invalid queue id, otherwise
5163 struct i40e_vsi *vsi = np->vsi; in i40e_set_rxfh()
5164 struct i40e_pf *pf = vsi->back; in i40e_set_rxfh()
5168 if (rxfh->hfunc != ETH_RSS_HASH_NO_CHANGE && in i40e_set_rxfh()
5169 rxfh->hfunc != ETH_RSS_HASH_TOP) in i40e_set_rxfh()
5170 return -EOPNOTSUPP; in i40e_set_rxfh()
5172 if (rxfh->key) { in i40e_set_rxfh()
5173 if (!vsi->rss_hkey_user) { in i40e_set_rxfh()
5174 vsi->rss_hkey_user = kzalloc(I40E_HKEY_ARRAY_SIZE, in i40e_set_rxfh()
5176 if (!vsi->rss_hkey_user) in i40e_set_rxfh()
5177 return -ENOMEM; in i40e_set_rxfh()
5179 memcpy(vsi->rss_hkey_user, rxfh->key, I40E_HKEY_ARRAY_SIZE); in i40e_set_rxfh()
5180 seed = vsi->rss_hkey_user; in i40e_set_rxfh()
5182 if (!vsi->rss_lut_user) { in i40e_set_rxfh()
5183 vsi->rss_lut_user = kzalloc(I40E_HLUT_ARRAY_SIZE, GFP_KERNEL); in i40e_set_rxfh()
5184 if (!vsi->rss_lut_user) in i40e_set_rxfh()
5185 return -ENOMEM; in i40e_set_rxfh()
5189 if (rxfh->indir) in i40e_set_rxfh()
5191 vsi->rss_lut_user[i] = (u8)(rxfh->indir[i]); in i40e_set_rxfh()
5193 i40e_fill_rss_lut(pf, vsi->rss_lut_user, I40E_HLUT_ARRAY_SIZE, in i40e_set_rxfh()
5194 vsi->rss_size); in i40e_set_rxfh()
5196 return i40e_config_rss(vsi, seed, vsi->rss_lut_user, in i40e_set_rxfh()
5201 * i40e_get_priv_flags - report device private flags
5213 struct i40e_vsi *vsi = np->vsi; in i40e_get_priv_flags()
5214 struct i40e_pf *pf = vsi->back; in i40e_get_priv_flags()
5222 if (test_bit(priv_flag->bitno, pf->flags)) in i40e_get_priv_flags()
5226 if (pf->hw.pf_id != 0) in i40e_get_priv_flags()
5234 if (test_bit(priv_flag->bitno, pf->flags)) in i40e_get_priv_flags()
5242 * i40e_set_priv_flags - set private flags
5253 struct i40e_vsi *vsi = np->vsi; in i40e_set_priv_flags()
5254 struct i40e_pf *pf = vsi->back; in i40e_set_priv_flags()
5259 bitmap_copy(orig_flags, pf->flags, I40E_PF_FLAGS_NBITS); in i40e_set_priv_flags()
5260 bitmap_copy(new_flags, pf->flags, I40E_PF_FLAGS_NBITS); in i40e_set_priv_flags()
5269 /* If this is a read-only flag, it can't be changed */ in i40e_set_priv_flags()
5270 if (priv_flag->read_only && in i40e_set_priv_flags()
5271 test_bit(priv_flag->bitno, orig_flags) != new_val) in i40e_set_priv_flags()
5272 return -EOPNOTSUPP; in i40e_set_priv_flags()
5275 set_bit(priv_flag->bitno, new_flags); in i40e_set_priv_flags()
5277 clear_bit(priv_flag->bitno, new_flags); in i40e_set_priv_flags()
5280 if (pf->hw.pf_id != 0) in i40e_set_priv_flags()
5290 /* If this is a read-only flag, it can't be changed */ in i40e_set_priv_flags()
5291 if (priv_flag->read_only && in i40e_set_priv_flags()
5292 test_bit(priv_flag->bitno, orig_flags) != new_val) in i40e_set_priv_flags()
5293 return -EOPNOTSUPP; in i40e_set_priv_flags()
5296 set_bit(priv_flag->bitno, new_flags); in i40e_set_priv_flags()
5298 clear_bit(priv_flag->bitno, new_flags); in i40e_set_priv_flags()
5302 bitmap_xor(changed_flags, pf->flags, orig_flags, I40E_PF_FLAGS_NBITS); in i40e_set_priv_flags()
5313 * checks to ensure that the changes are supported and safe. in i40e_set_priv_flags()
5316 /* ATR eviction is not supported on all devices */ in i40e_set_priv_flags()
5318 !test_bit(I40E_HW_CAP_ATR_EVICT, pf->hw.caps)) in i40e_set_priv_flags()
5319 return -EOPNOTSUPP; in i40e_set_priv_flags()
5323 * - on XL710 if NPAR is enabled or FW API version < 1.7 in i40e_set_priv_flags()
5324 * - on X722 with FW API version < 1.6 in i40e_set_priv_flags()
5330 !test_bit(I40E_HW_CAP_FW_LLDP_STOPPABLE, pf->hw.caps)) { in i40e_set_priv_flags()
5331 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5333 return -EOPNOTSUPP; in i40e_set_priv_flags()
5337 pf->hw.device_id != I40E_DEV_ID_25G_SFP28 && in i40e_set_priv_flags()
5338 pf->hw.device_id != I40E_DEV_ID_25G_B) { in i40e_set_priv_flags()
5339 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5341 return -EOPNOTSUPP; in i40e_set_priv_flags()
5345 pf->hw.device_id != I40E_DEV_ID_25G_SFP28 && in i40e_set_priv_flags()
5346 pf->hw.device_id != I40E_DEV_ID_25G_B && in i40e_set_priv_flags()
5347 pf->hw.device_id != I40E_DEV_ID_KX_X722) { in i40e_set_priv_flags()
5348 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5350 return -EOPNOTSUPP; in i40e_set_priv_flags()
5361 set_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state); in i40e_set_priv_flags()
5362 set_bit(__I40E_FD_FLUSH_REQUESTED, pf->state); in i40e_set_priv_flags()
5372 ret = i40e_aq_set_switch_config(&pf->hw, sw_flags, valid_flags, in i40e_set_priv_flags()
5374 if (ret && pf->hw.aq.asq_last_status != I40E_AQ_RC_ESRCH) { in i40e_set_priv_flags()
5375 dev_info(&pf->pdev->dev, in i40e_set_priv_flags()
5378 i40e_aq_str(&pf->hw, in i40e_set_priv_flags()
5379 pf->hw.aq.asq_last_status)); in i40e_set_priv_flags()
5399 dev_warn(&pf->pdev->dev, "Cannot change FEC config\n"); in i40e_set_priv_flags()
5404 dev_err(&pf->pdev->dev, in i40e_set_priv_flags()
5405 …"Setting link-down-on-close not supported on this port (because total-port-shutdown is enabled)\n"… in i40e_set_priv_flags()
5406 return -EOPNOTSUPP; in i40e_set_priv_flags()
5410 pf->num_alloc_vfs) { in i40e_set_priv_flags()
5411 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5412 "Changing vf-vlan-pruning flag while VF(s) are active is not supported\n"); in i40e_set_priv_flags()
5413 return -EOPNOTSUPP; in i40e_set_priv_flags()
5418 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5420 return -EOPNOTSUPP; in i40e_set_priv_flags()
5426 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5427 "Turning on link-down-on-close flag may affect other partitions\n"); in i40e_set_priv_flags()
5434 i40e_aq_cfg_lldp_mib_change_event(&pf->hw, false, NULL); in i40e_set_priv_flags()
5435 i40e_aq_stop_lldp(&pf->hw, true, false, NULL); in i40e_set_priv_flags()
5437 status = i40e_aq_start_lldp(&pf->hw, false, NULL); in i40e_set_priv_flags()
5439 adq_err = pf->hw.aq.asq_last_status; in i40e_set_priv_flags()
5442 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5447 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5449 return -EINVAL; in i40e_set_priv_flags()
5451 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5453 return -EBUSY; in i40e_set_priv_flags()
5455 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5458 i40e_aq_str(&pf->hw, in i40e_set_priv_flags()
5460 return -EINVAL; in i40e_set_priv_flags()
5471 bitmap_copy(pf->flags, new_flags, I40E_PF_FLAGS_NBITS); in i40e_set_priv_flags()
5483 * i40e_get_module_info - get (Q)SFP+ module type info
5491 struct i40e_vsi *vsi = np->vsi; in i40e_get_module_info()
5492 struct i40e_pf *pf = vsi->back; in i40e_get_module_info()
5493 struct i40e_hw *hw = &pf->hw; in i40e_get_module_info() local
5501 if (!test_bit(I40E_HW_CAP_AQ_PHY_ACCESS, hw->caps)) { in i40e_get_module_info()
5502 …netdev_err(vsi->netdev, "Module EEPROM memory read not supported. Please update the NVM image.\n"); in i40e_get_module_info()
5503 return -EINVAL; in i40e_get_module_info()
5506 status = i40e_update_link_info(hw); in i40e_get_module_info()
5508 return -EIO; in i40e_get_module_info()
5510 if (hw->phy.link_info.phy_type == I40E_PHY_TYPE_EMPTY) { in i40e_get_module_info()
5511 netdev_err(vsi->netdev, "Cannot read module EEPROM memory. No module connected.\n"); in i40e_get_module_info()
5512 return -EINVAL; in i40e_get_module_info()
5515 type = hw->phy.link_info.module_type[0]; in i40e_get_module_info()
5519 status = i40e_aq_get_phy_register(hw, in i40e_get_module_info()
5525 return -EIO; in i40e_get_module_info()
5527 status = i40e_aq_get_phy_register(hw, in i40e_get_module_info()
5533 return -EIO; in i40e_get_module_info()
5539 netdev_warn(vsi->netdev, "Module address swap to access page 0xA2 is not supported.\n"); in i40e_get_module_info()
5540 modinfo->type = ETH_MODULE_SFF_8079; in i40e_get_module_info()
5541 modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN; in i40e_get_module_info()
5543 /* Module is not SFF-8472 compliant */ in i40e_get_module_info()
5544 modinfo->type = ETH_MODULE_SFF_8079; in i40e_get_module_info()
5545 modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN; in i40e_get_module_info()
5547 /* Module is SFF-8472 compliant but doesn't implement in i40e_get_module_info()
5550 modinfo->type = ETH_MODULE_SFF_8079; in i40e_get_module_info()
5551 modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN; in i40e_get_module_info()
5553 modinfo->type = ETH_MODULE_SFF_8472; in i40e_get_module_info()
5554 modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN; in i40e_get_module_info()
5559 status = i40e_aq_get_phy_register(hw, in i40e_get_module_info()
5565 return -EIO; in i40e_get_module_info()
5568 /* Module is SFF-8636 compliant */ in i40e_get_module_info()
5569 modinfo->type = ETH_MODULE_SFF_8636; in i40e_get_module_info()
5570 modinfo->eeprom_len = I40E_MODULE_QSFP_MAX_LEN; in i40e_get_module_info()
5572 modinfo->type = ETH_MODULE_SFF_8436; in i40e_get_module_info()
5573 modinfo->eeprom_len = I40E_MODULE_QSFP_MAX_LEN; in i40e_get_module_info()
5577 modinfo->type = ETH_MODULE_SFF_8636; in i40e_get_module_info()
5578 modinfo->eeprom_len = I40E_MODULE_QSFP_MAX_LEN; in i40e_get_module_info()
5581 netdev_dbg(vsi->netdev, "SFP module type unrecognized or no SFP connector used.\n"); in i40e_get_module_info()
5582 return -EOPNOTSUPP; in i40e_get_module_info()
5588 * i40e_get_module_eeprom - fills buffer with (Q)SFP+ module memory contents
5598 struct i40e_vsi *vsi = np->vsi; in i40e_get_module_eeprom()
5599 struct i40e_pf *pf = vsi->back; in i40e_get_module_eeprom()
5600 struct i40e_hw *hw = &pf->hw; in i40e_get_module_eeprom() local
5606 if (!ee || !ee->len || !data) in i40e_get_module_eeprom()
5607 return -EINVAL; in i40e_get_module_eeprom()
5609 if (hw->phy.link_info.module_type[0] == I40E_MODULE_TYPE_SFP) in i40e_get_module_eeprom()
5612 for (i = 0; i < ee->len; i++) { in i40e_get_module_eeprom()
5613 u32 offset = i + ee->offset; in i40e_get_module_eeprom()
5619 offset -= ETH_MODULE_SFF_8079_LEN; in i40e_get_module_eeprom()
5625 offset -= ETH_MODULE_SFF_8436_LEN / 2; in i40e_get_module_eeprom()
5630 status = i40e_aq_get_phy_register(hw, in i40e_get_module_eeprom()
5634 return -EIO; in i40e_get_module_eeprom()
5641 unsigned long *supported) in i40e_eee_capability_to_kedata_supported() argument
5654 linkmode_zero(supported); in i40e_eee_capability_to_kedata_supported()
5655 for (unsigned int i = ARRAY_SIZE(lut); i--; ) in i40e_eee_capability_to_kedata_supported()
5657 linkmode_set_bit(lut[i], supported); in i40e_eee_capability_to_kedata_supported()
5664 struct i40e_vsi *vsi = np->vsi; in i40e_get_eee()
5665 struct i40e_pf *pf = vsi->back; in i40e_get_eee()
5666 struct i40e_hw *hw = &pf->hw; in i40e_get_eee() local
5670 status = i40e_aq_get_phy_capabilities(hw, false, true, &phy_cfg, NULL); in i40e_get_eee()
5672 return -EAGAIN; in i40e_get_eee()
5678 return -EOPNOTSUPP; in i40e_get_eee()
5681 edata->supported); in i40e_get_eee()
5682 linkmode_copy(edata->lp_advertised, edata->supported); in i40e_get_eee()
5685 status = i40e_aq_get_phy_capabilities(hw, false, false, &phy_cfg, NULL); in i40e_get_eee()
5687 return -EAGAIN; in i40e_get_eee()
5689 linkmode_zero(edata->advertised); in i40e_get_eee()
5691 linkmode_copy(edata->advertised, edata->supported); in i40e_get_eee()
5692 edata->eee_enabled = !!phy_cfg.eee_capability; in i40e_get_eee()
5693 edata->tx_lpi_enabled = pf->stats.tx_lpi_status; in i40e_get_eee()
5695 edata->eee_active = pf->stats.tx_lpi_status && pf->stats.rx_lpi_status; in i40e_get_eee()
5704 struct i40e_vsi *vsi = np->vsi; in i40e_is_eee_param_supported()
5705 struct i40e_pf *pf = vsi->back; in i40e_is_eee_param_supported()
5710 {!!(edata->advertised[0] & ~edata->supported[0]), "advertise"}, in i40e_is_eee_param_supported()
5711 {!!edata->tx_lpi_timer, "tx-timer"}, in i40e_is_eee_param_supported()
5712 {edata->tx_lpi_enabled != pf->stats.tx_lpi_status, "tx-lpi"} in i40e_is_eee_param_supported()
5719 "EEE setting %s not supported\n", in i40e_is_eee_param_supported()
5721 return -EOPNOTSUPP; in i40e_is_eee_param_supported()
5733 struct i40e_vsi *vsi = np->vsi; in i40e_set_eee()
5734 struct i40e_pf *pf = vsi->back; in i40e_set_eee()
5735 struct i40e_hw *hw = &pf->hw; in i40e_set_eee() local
5741 return -EOPNOTSUPP; in i40e_set_eee()
5744 status = i40e_aq_get_phy_capabilities(hw, false, true, &abilities, in i40e_set_eee()
5747 return -EAGAIN; in i40e_set_eee()
5753 return -EOPNOTSUPP; in i40e_set_eee()
5759 status = i40e_aq_get_phy_capabilities(hw, false, false, &abilities, in i40e_set_eee()
5762 return -EAGAIN; in i40e_set_eee()
5776 if (edata->eee_enabled) { in i40e_set_eee()
5785 status = i40e_aq_set_phy_config(hw, &config, NULL); in i40e_set_eee()
5787 return -EAGAIN; in i40e_set_eee()
5855 struct i40e_pf *pf = np->vsi->back; in i40e_set_ethtool_ops()
5857 if (!test_bit(__I40E_RECOVERY_MODE, pf->state)) in i40e_set_ethtool_ops()
5858 netdev->ethtool_ops = &i40e_ethtool_ops; in i40e_set_ethtool_ops()
5860 netdev->ethtool_ops = &i40e_ethtool_recovery_mode_ops; in i40e_set_ethtool_ops()