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
312 * The PF_STATs are appended to the netdev stats only when ethtool -S
445 I40E_PRIV_FLAG("total-port-shutdown",
448 I40E_PRIV_FLAG("flow-director-atr", I40E_FLAG_FD_ATR_ENABLED, 0),
449 I40E_PRIV_FLAG("veb-stats", I40E_FLAG_VEB_STATS_ENABLED, 0),
450 I40E_PRIV_FLAG("hw-atr-eviction", I40E_FLAG_HW_ATR_EVICT_ENABLED, 0),
451 I40E_PRIV_FLAG("link-down-on-close",
453 I40E_PRIV_FLAG("legacy-rx", I40E_FLAG_LEGACY_RX, 0),
454 I40E_PRIV_FLAG("disable-source-pruning",
456 I40E_PRIV_FLAG("disable-fw-lldp", I40E_FLAG_DISABLE_FW_LLDP, 0),
457 I40E_PRIV_FLAG("rs-fec", I40E_FLAG_RS_FEC, 0),
458 I40E_PRIV_FLAG("base-r-fec", I40E_FLAG_BASE_R_FEC, 0),
459 I40E_PRIV_FLAG("vf-vlan-pruning",
467 I40E_PRIV_FLAG("vf-true-promisc-support",
474 * i40e_partition_setting_complaint - generic complaint for MFP restriction
479 dev_info(&pf->pdev->dev, in i40e_partition_setting_complaint()
484 * i40e_phy_type_to_ethtool - convert the phy_types to ethtool link modes
492 struct i40e_link_status *hw_link_info = &pf->hw.phy.link_info; in i40e_phy_type_to_ethtool()
493 u64 phy_types = pf->hw.phy.phy_types; in i40e_phy_type_to_ethtool()
495 ethtool_link_ksettings_zero_link_mode(ks, supported); in i40e_phy_type_to_ethtool()
499 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
501 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB) in i40e_phy_type_to_ethtool()
504 if (pf->hw_features & I40E_HW_100M_SGMII_CAPABLE) { in i40e_phy_type_to_ethtool()
505 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
516 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
518 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_phy_type_to_ethtool()
523 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
525 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_phy_type_to_ethtool()
530 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
532 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_2_5GB) in i40e_phy_type_to_ethtool()
537 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
539 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_5GB) in i40e_phy_type_to_ethtool()
546 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
550 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
552 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_40GB) in i40e_phy_type_to_ethtool()
557 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
559 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_100MB) in i40e_phy_type_to_ethtool()
564 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
566 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB) in i40e_phy_type_to_ethtool()
571 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
577 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
583 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
589 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
591 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_20GB) in i40e_phy_type_to_ethtool()
596 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
598 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_phy_type_to_ethtool()
603 !(pf->hw_features & I40E_HW_HAVE_CRT_RETIMER)) { in i40e_phy_type_to_ethtool()
604 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
606 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_phy_type_to_ethtool()
611 !(pf->hw_features & I40E_HW_HAVE_CRT_RETIMER)) { in i40e_phy_type_to_ethtool()
612 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
614 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB) in i40e_phy_type_to_ethtool()
620 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
622 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_25GB) in i40e_phy_type_to_ethtool()
627 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
629 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_25GB) in i40e_phy_type_to_ethtool()
635 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
637 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_25GB) in i40e_phy_type_to_ethtool()
643 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
645 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_25GB) in i40e_phy_type_to_ethtool()
655 ethtool_link_ksettings_add_link_mode(ks, supported, FEC_NONE); in i40e_phy_type_to_ethtool()
656 ethtool_link_ksettings_add_link_mode(ks, supported, FEC_RS); in i40e_phy_type_to_ethtool()
657 ethtool_link_ksettings_add_link_mode(ks, supported, FEC_BASER); in i40e_phy_type_to_ethtool()
658 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_25GB) { in i40e_phy_type_to_ethtool()
670 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
672 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_phy_type_to_ethtool()
677 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
679 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_phy_type_to_ethtool()
684 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
686 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_phy_type_to_ethtool()
693 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
695 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB) in i40e_phy_type_to_ethtool()
724 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_phy_type_to_ethtool()
732 * i40e_get_settings_link_up_fec - Get the FEC mode encoding from mask
739 ethtool_link_ksettings_add_link_mode(ks, supported, FEC_NONE); in i40e_get_settings_link_up_fec()
740 ethtool_link_ksettings_add_link_mode(ks, supported, FEC_RS); in i40e_get_settings_link_up_fec()
741 ethtool_link_ksettings_add_link_mode(ks, supported, FEC_BASER); in i40e_get_settings_link_up_fec()
762 * i40e_get_settings_link_up - Get the Link settings for when link is up
763 * @hw: hw structure
768 static void i40e_get_settings_link_up(struct i40e_hw *hw, in i40e_get_settings_link_up() argument
773 struct i40e_link_status *hw_link_info = &hw->phy.link_info; in i40e_get_settings_link_up()
775 u32 link_speed = hw_link_info->link_speed; in i40e_get_settings_link_up()
777 /* Initialize supported and advertised settings based on phy settings */ in i40e_get_settings_link_up()
778 switch (hw_link_info->phy_type) { in i40e_get_settings_link_up()
781 ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); in i40e_get_settings_link_up()
782 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
791 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
797 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
803 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
814 ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); in i40e_get_settings_link_up()
816 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
820 i40e_get_settings_link_up_fec(hw_link_info->req_fec_info, ks); in i40e_get_settings_link_up()
821 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
825 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
829 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
833 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
835 if (hw_link_info->module_type[2] & in i40e_get_settings_link_up()
837 hw_link_info->module_type[2] & in i40e_get_settings_link_up()
839 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
841 if (hw_link_info->requested_speeds & in i40e_get_settings_link_up()
846 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_get_settings_link_up()
855 ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); in i40e_get_settings_link_up()
856 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
858 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
860 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
862 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
864 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
867 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_get_settings_link_up()
870 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_5GB) in i40e_get_settings_link_up()
873 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_2_5GB) in i40e_get_settings_link_up()
876 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB) in i40e_get_settings_link_up()
879 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_100MB) in i40e_get_settings_link_up()
884 ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); in i40e_get_settings_link_up()
885 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
893 ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); in i40e_get_settings_link_up()
894 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
905 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
907 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_get_settings_link_up()
910 i40e_get_settings_link_up_fec(hw_link_info->req_fec_info, ks); in i40e_get_settings_link_up()
913 ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); in i40e_get_settings_link_up()
914 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
916 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB) in i40e_get_settings_link_up()
919 if (pf->hw_features & I40E_HW_100M_SGMII_CAPABLE) { in i40e_get_settings_link_up()
920 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
922 if (hw_link_info->requested_speeds & in i40e_get_settings_link_up()
934 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
936 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
938 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
940 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
942 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
944 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
946 ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); in i40e_get_settings_link_up()
951 i40e_get_settings_link_up_fec(hw_link_info->req_fec_info, ks); in i40e_get_settings_link_up()
963 ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); in i40e_get_settings_link_up()
965 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
969 i40e_get_settings_link_up_fec(hw_link_info->req_fec_info, ks); in i40e_get_settings_link_up()
974 ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); in i40e_get_settings_link_up()
976 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
980 i40e_get_settings_link_up_fec(hw_link_info->req_fec_info, ks); in i40e_get_settings_link_up()
982 ethtool_link_ksettings_add_link_mode(ks, supported, in i40e_get_settings_link_up()
991 hw_link_info->phy_type); in i40e_get_settings_link_up()
994 /* Now that we've worked out everything that could be supported by the in i40e_get_settings_link_up()
995 * current PHY type, get what is supported by the NVM and intersect in i40e_get_settings_link_up()
996 * them to get what is truly supported in i40e_get_settings_link_up()
1005 ks->base.speed = SPEED_40000; in i40e_get_settings_link_up()
1008 ks->base.speed = SPEED_25000; in i40e_get_settings_link_up()
1011 ks->base.speed = SPEED_20000; in i40e_get_settings_link_up()
1014 ks->base.speed = SPEED_10000; in i40e_get_settings_link_up()
1017 ks->base.speed = SPEED_5000; in i40e_get_settings_link_up()
1020 ks->base.speed = SPEED_2500; in i40e_get_settings_link_up()
1023 ks->base.speed = SPEED_1000; in i40e_get_settings_link_up()
1026 ks->base.speed = SPEED_100; in i40e_get_settings_link_up()
1029 ks->base.speed = SPEED_UNKNOWN; in i40e_get_settings_link_up()
1032 ks->base.duplex = DUPLEX_FULL; in i40e_get_settings_link_up()
1036 * i40e_get_settings_link_down - Get the Link settings for when link is down
1037 * @hw: hw structure
1043 static void i40e_get_settings_link_down(struct i40e_hw *hw, in i40e_get_settings_link_down() argument
1048 * supported phy types to figure out what info to display in i40e_get_settings_link_down()
1053 ks->base.speed = SPEED_UNKNOWN; in i40e_get_settings_link_down()
1054 ks->base.duplex = DUPLEX_UNKNOWN; in i40e_get_settings_link_down()
1058 * i40e_get_link_ksettings - Get Link Speed and Duplex settings
1068 struct i40e_pf *pf = np->vsi->back; in i40e_get_link_ksettings()
1069 struct i40e_hw *hw = &pf->hw; in i40e_get_link_ksettings() local
1070 struct i40e_link_status *hw_link_info = &hw->phy.link_info; in i40e_get_link_ksettings()
1071 bool link_up = hw_link_info->link_info & I40E_AQ_LINK_UP; in i40e_get_link_ksettings()
1073 ethtool_link_ksettings_zero_link_mode(ks, supported); in i40e_get_link_ksettings()
1077 i40e_get_settings_link_up(hw, ks, netdev, pf); in i40e_get_link_ksettings()
1079 i40e_get_settings_link_down(hw, ks, pf); in i40e_get_link_ksettings()
1083 ks->base.autoneg = ((hw_link_info->an_info & I40E_AQ_AN_COMPLETED) ? in i40e_get_link_ksettings()
1087 switch (hw->phy.media_type) { in i40e_get_link_ksettings()
1089 ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); in i40e_get_link_ksettings()
1090 ethtool_link_ksettings_add_link_mode(ks, supported, Backplane); in i40e_get_link_ksettings()
1094 ks->base.port = PORT_NONE; in i40e_get_link_ksettings()
1097 ethtool_link_ksettings_add_link_mode(ks, supported, TP); in i40e_get_link_ksettings()
1099 ks->base.port = PORT_TP; in i40e_get_link_ksettings()
1103 ethtool_link_ksettings_add_link_mode(ks, supported, FIBRE); in i40e_get_link_ksettings()
1105 ks->base.port = PORT_DA; in i40e_get_link_ksettings()
1108 ethtool_link_ksettings_add_link_mode(ks, supported, FIBRE); in i40e_get_link_ksettings()
1110 ks->base.port = PORT_FIBRE; in i40e_get_link_ksettings()
1114 ks->base.port = PORT_OTHER; in i40e_get_link_ksettings()
1119 ethtool_link_ksettings_add_link_mode(ks, supported, Pause); in i40e_get_link_ksettings()
1120 ethtool_link_ksettings_add_link_mode(ks, supported, Asym_Pause); in i40e_get_link_ksettings()
1122 switch (hw->fc.requested_mode) { in i40e_get_link_ksettings()
1147 * i40e_speed_to_link_speed - Translate decimal speed to i40e_aq_link_speed
1192 ks->link_modes.supported)) { in i40e_speed_to_link_speed()
1211 * i40e_set_link_ksettings - Set Speed and Duplex
1225 struct i40e_pf *pf = np->vsi->back; in i40e_set_link_ksettings()
1227 struct i40e_vsi *vsi = np->vsi; in i40e_set_link_ksettings()
1228 struct i40e_hw *hw = &pf->hw; in i40e_set_link_ksettings() local
1236 /* Changing port settings is not supported if this isn't the in i40e_set_link_ksettings()
1239 if (hw->partition_id != 1) { in i40e_set_link_ksettings()
1241 return -EOPNOTSUPP; in i40e_set_link_ksettings()
1243 if (vsi != pf->vsi[pf->lan_vsi]) in i40e_set_link_ksettings()
1244 return -EOPNOTSUPP; in i40e_set_link_ksettings()
1245 if (hw->phy.media_type != I40E_MEDIA_TYPE_BASET && in i40e_set_link_ksettings()
1246 hw->phy.media_type != I40E_MEDIA_TYPE_FIBER && in i40e_set_link_ksettings()
1247 hw->phy.media_type != I40E_MEDIA_TYPE_BACKPLANE && in i40e_set_link_ksettings()
1248 hw->phy.media_type != I40E_MEDIA_TYPE_DA && in i40e_set_link_ksettings()
1249 hw->phy.link_info.link_info & I40E_AQ_LINK_UP) in i40e_set_link_ksettings()
1250 return -EOPNOTSUPP; in i40e_set_link_ksettings()
1251 if (hw->device_id == I40E_DEV_ID_KX_B || in i40e_set_link_ksettings()
1252 hw->device_id == I40E_DEV_ID_KX_C || in i40e_set_link_ksettings()
1253 hw->device_id == I40E_DEV_ID_20G_KR2 || in i40e_set_link_ksettings()
1254 hw->device_id == I40E_DEV_ID_20G_KR2_A || in i40e_set_link_ksettings()
1255 hw->device_id == I40E_DEV_ID_25G_B || in i40e_set_link_ksettings()
1256 hw->device_id == I40E_DEV_ID_KX_X722) { in i40e_set_link_ksettings()
1257 netdev_info(netdev, "Changing settings is not supported on backplane.\n"); in i40e_set_link_ksettings()
1258 return -EOPNOTSUPP; in i40e_set_link_ksettings()
1275 /* Get link modes supported by hardware and check against modes in i40e_set_link_ksettings()
1279 safe_ks.link_modes.supported, in i40e_set_link_ksettings()
1281 return -EINVAL; in i40e_set_link_ksettings()
1292 netdev_err(netdev, "Only speed and autoneg are supported.\n"); in i40e_set_link_ksettings()
1293 return -EOPNOTSUPP; in i40e_set_link_ksettings()
1296 while (test_and_set_bit(__I40E_CONFIG_BUSY, pf->state)) { in i40e_set_link_ksettings()
1297 timeout--; in i40e_set_link_ksettings()
1299 return -EBUSY; in i40e_set_link_ksettings()
1304 status = i40e_aq_get_phy_capabilities(hw, false, false, &abilities, in i40e_set_link_ksettings()
1307 err = -EAGAIN; in i40e_set_link_ksettings()
1320 if (!(hw->phy.link_info.an_info & I40E_AQ_AN_COMPLETED)) { in i40e_set_link_ksettings()
1321 /* If autoneg is not supported, return error */ in i40e_set_link_ksettings()
1323 supported, in i40e_set_link_ksettings()
1325 netdev_info(netdev, "Autoneg not supported on this phy\n"); in i40e_set_link_ksettings()
1326 err = -EINVAL; in i40e_set_link_ksettings()
1336 if (hw->phy.link_info.an_info & I40E_AQ_AN_COMPLETED) { in i40e_set_link_ksettings()
1337 /* If autoneg is supported 10GBASE_T is the only PHY in i40e_set_link_ksettings()
1341 supported, in i40e_set_link_ksettings()
1343 hw->phy.media_type != I40E_MEDIA_TYPE_BASET) { in i40e_set_link_ksettings()
1345 err = -EINVAL; in i40e_set_link_ksettings()
1410 netdev_info(netdev, "Given speed is not supported\n"); in i40e_set_link_ksettings()
1411 err = -EOPNOTSUPP; in i40e_set_link_ksettings()
1420 err = -EOPNOTSUPP; in i40e_set_link_ksettings()
1442 hw->phy.link_info.requested_speeds = config.link_speed; in i40e_set_link_ksettings()
1446 if (hw->phy.link_info.link_info & I40E_AQ_LINK_UP) { in i40e_set_link_ksettings()
1456 status = i40e_aq_set_phy_config(hw, &config, NULL); in i40e_set_link_ksettings()
1461 i40e_aq_str(hw, hw->aq.asq_last_status)); in i40e_set_link_ksettings()
1462 err = -EAGAIN; in i40e_set_link_ksettings()
1466 status = i40e_update_link_info(hw); in i40e_set_link_ksettings()
1471 i40e_aq_str(hw, hw->aq.asq_last_status)); in i40e_set_link_ksettings()
1478 clear_bit(__I40E_CONFIG_BUSY, pf->state); in i40e_set_link_ksettings()
1487 struct i40e_pf *pf = np->vsi->back; in i40e_set_fec_cfg()
1488 struct i40e_hw *hw = &pf->hw; in i40e_set_fec_cfg() local
1493 flags = READ_ONCE(pf->flags); in i40e_set_fec_cfg()
1498 status = i40e_aq_get_phy_capabilities(hw, false, false, &abilities, in i40e_set_fec_cfg()
1501 err = -EAGAIN; in i40e_set_fec_cfg()
1518 status = i40e_aq_set_phy_config(hw, &config, NULL); in i40e_set_fec_cfg()
1523 i40e_aq_str(hw, hw->aq.asq_last_status)); in i40e_set_fec_cfg()
1524 err = -EAGAIN; in i40e_set_fec_cfg()
1527 pf->flags = flags; in i40e_set_fec_cfg()
1528 status = i40e_update_link_info(hw); in i40e_set_fec_cfg()
1537 i40e_aq_str(hw, hw->aq.asq_last_status)); in i40e_set_fec_cfg()
1549 struct i40e_pf *pf = np->vsi->back; in i40e_get_fec_param()
1550 struct i40e_hw *hw = &pf->hw; in i40e_get_fec_param() local
1557 status = i40e_aq_get_phy_capabilities(hw, false, false, &abilities, in i40e_get_fec_param()
1560 err = -EAGAIN; in i40e_get_fec_param()
1564 fecparam->fec = 0; in i40e_get_fec_param()
1567 fecparam->fec |= ETHTOOL_FEC_AUTO; in i40e_get_fec_param()
1570 fecparam->fec |= ETHTOOL_FEC_RS; in i40e_get_fec_param()
1573 fecparam->fec |= ETHTOOL_FEC_BASER; in i40e_get_fec_param()
1575 fecparam->fec |= ETHTOOL_FEC_OFF; in i40e_get_fec_param()
1577 if (hw->phy.link_info.fec_info & I40E_AQ_CONFIG_FEC_KR_ENA) in i40e_get_fec_param()
1578 fecparam->active_fec = ETHTOOL_FEC_BASER; in i40e_get_fec_param()
1579 else if (hw->phy.link_info.fec_info & I40E_AQ_CONFIG_FEC_RS_ENA) in i40e_get_fec_param()
1580 fecparam->active_fec = ETHTOOL_FEC_RS; in i40e_get_fec_param()
1582 fecparam->active_fec = ETHTOOL_FEC_OFF; in i40e_get_fec_param()
1591 struct i40e_pf *pf = np->vsi->back; in i40e_set_fec_param()
1592 struct i40e_hw *hw = &pf->hw; in i40e_set_fec_param() local
1595 if (hw->device_id != I40E_DEV_ID_25G_SFP28 && in i40e_set_fec_param()
1596 hw->device_id != I40E_DEV_ID_25G_B && in i40e_set_fec_param()
1597 hw->device_id != I40E_DEV_ID_KX_X722) in i40e_set_fec_param()
1598 return -EPERM; in i40e_set_fec_param()
1600 if (hw->mac.type == I40E_MAC_X722 && in i40e_set_fec_param()
1601 !(hw->flags & I40E_HW_FLAG_X722_FEC_REQUEST_CAPABLE)) { in i40e_set_fec_param()
1602 …netdev_err(netdev, "Setting FEC encoding not supported by firmware. Please update the NVM image.\n… in i40e_set_fec_param()
1603 return -EOPNOTSUPP; in i40e_set_fec_param()
1606 switch (fecparam->fec) { in i40e_set_fec_param()
1623 dev_warn(&pf->pdev->dev, "Unsupported FEC mode: %d", in i40e_set_fec_param()
1624 fecparam->fec); in i40e_set_fec_param()
1625 return -EINVAL; in i40e_set_fec_param()
1635 struct i40e_pf *pf = np->vsi->back; in i40e_nway_reset()
1636 struct i40e_hw *hw = &pf->hw; in i40e_nway_reset() local
1637 bool link_up = hw->phy.link_info.link_info & I40E_AQ_LINK_UP; in i40e_nway_reset()
1640 ret = i40e_aq_set_link_restart_an(hw, link_up, NULL); in i40e_nway_reset()
1644 i40e_aq_str(hw, hw->aq.asq_last_status)); in i40e_nway_reset()
1645 return -EIO; in i40e_nway_reset()
1652 * i40e_get_pauseparam - Get Flow Control status
1656 * Return tx/rx-pause status
1662 struct i40e_pf *pf = np->vsi->back; in i40e_get_pauseparam()
1663 struct i40e_hw *hw = &pf->hw; in i40e_get_pauseparam() local
1664 struct i40e_link_status *hw_link_info = &hw->phy.link_info; in i40e_get_pauseparam()
1665 struct i40e_dcbx_config *dcbx_cfg = &hw->local_dcbx_config; in i40e_get_pauseparam()
1667 pause->autoneg = in i40e_get_pauseparam()
1668 ((hw_link_info->an_info & I40E_AQ_AN_COMPLETED) ? in i40e_get_pauseparam()
1672 if (dcbx_cfg->pfc.pfcenable) { in i40e_get_pauseparam()
1673 pause->rx_pause = 0; in i40e_get_pauseparam()
1674 pause->tx_pause = 0; in i40e_get_pauseparam()
1678 if (hw->fc.current_mode == I40E_FC_RX_PAUSE) { in i40e_get_pauseparam()
1679 pause->rx_pause = 1; in i40e_get_pauseparam()
1680 } else if (hw->fc.current_mode == I40E_FC_TX_PAUSE) { in i40e_get_pauseparam()
1681 pause->tx_pause = 1; in i40e_get_pauseparam()
1682 } else if (hw->fc.current_mode == I40E_FC_FULL) { in i40e_get_pauseparam()
1683 pause->rx_pause = 1; in i40e_get_pauseparam()
1684 pause->tx_pause = 1; in i40e_get_pauseparam()
1689 * i40e_set_pauseparam - Set Flow Control parameter
1697 struct i40e_pf *pf = np->vsi->back; in i40e_set_pauseparam()
1698 struct i40e_vsi *vsi = np->vsi; in i40e_set_pauseparam()
1699 struct i40e_hw *hw = &pf->hw; in i40e_set_pauseparam() local
1700 struct i40e_link_status *hw_link_info = &hw->phy.link_info; in i40e_set_pauseparam()
1701 struct i40e_dcbx_config *dcbx_cfg = &hw->local_dcbx_config; in i40e_set_pauseparam()
1702 bool link_up = hw_link_info->link_info & I40E_AQ_LINK_UP; in i40e_set_pauseparam()
1708 /* Changing the port's flow control is not supported if this isn't the in i40e_set_pauseparam()
1711 if (hw->partition_id != 1) { in i40e_set_pauseparam()
1713 return -EOPNOTSUPP; in i40e_set_pauseparam()
1716 if (vsi != pf->vsi[pf->lan_vsi]) in i40e_set_pauseparam()
1717 return -EOPNOTSUPP; in i40e_set_pauseparam()
1719 is_an = hw_link_info->an_info & I40E_AQ_AN_COMPLETED; in i40e_set_pauseparam()
1720 if (pause->autoneg != is_an) { in i40e_set_pauseparam()
1721 netdev_info(netdev, "To change autoneg please use: ethtool -s <dev> autoneg <on|off>\n"); in i40e_set_pauseparam()
1722 return -EOPNOTSUPP; in i40e_set_pauseparam()
1726 if (!test_bit(__I40E_DOWN, pf->state) && !is_an) { in i40e_set_pauseparam()
1731 if (dcbx_cfg->pfc.pfcenable) { in i40e_set_pauseparam()
1734 return -EOPNOTSUPP; in i40e_set_pauseparam()
1737 if (pause->rx_pause && pause->tx_pause) in i40e_set_pauseparam()
1738 hw->fc.requested_mode = I40E_FC_FULL; in i40e_set_pauseparam()
1739 else if (pause->rx_pause && !pause->tx_pause) in i40e_set_pauseparam()
1740 hw->fc.requested_mode = I40E_FC_RX_PAUSE; in i40e_set_pauseparam()
1741 else if (!pause->rx_pause && pause->tx_pause) in i40e_set_pauseparam()
1742 hw->fc.requested_mode = I40E_FC_TX_PAUSE; in i40e_set_pauseparam()
1743 else if (!pause->rx_pause && !pause->tx_pause) in i40e_set_pauseparam()
1744 hw->fc.requested_mode = I40E_FC_NONE; in i40e_set_pauseparam()
1746 return -EINVAL; in i40e_set_pauseparam()
1756 status = i40e_set_fc(hw, &aq_failures, link_up); in i40e_set_pauseparam()
1761 i40e_aq_str(hw, hw->aq.asq_last_status)); in i40e_set_pauseparam()
1762 err = -EAGAIN; in i40e_set_pauseparam()
1767 i40e_aq_str(hw, hw->aq.asq_last_status)); in i40e_set_pauseparam()
1768 err = -EAGAIN; in i40e_set_pauseparam()
1773 i40e_aq_str(hw, hw->aq.asq_last_status)); in i40e_set_pauseparam()
1774 err = -EAGAIN; in i40e_set_pauseparam()
1777 if (!test_bit(__I40E_DOWN, pf->state) && is_an) { in i40e_set_pauseparam()
1780 if (!test_bit(__I40E_DOWN, pf->state)) in i40e_set_pauseparam()
1790 struct i40e_pf *pf = np->vsi->back; in i40e_get_msglevel()
1791 u32 debug_mask = pf->hw.debug_mask; in i40e_get_msglevel()
1796 return pf->msg_enable; in i40e_get_msglevel()
1802 struct i40e_pf *pf = np->vsi->back; in i40e_set_msglevel()
1805 pf->hw.debug_mask = data; in i40e_set_msglevel()
1807 pf->msg_enable = data; in i40e_set_msglevel()
1825 struct i40e_pf *pf = np->vsi->back; in i40e_get_regs()
1826 struct i40e_hw *hw = &pf->hw; in i40e_get_regs() local
1831 /* Tell ethtool which driver-version-specific regs output we have. in i40e_get_regs()
1838 regs->version = 1; in i40e_get_regs()
1846 reg_buf[ri++] = rd32(hw, reg); in i40e_get_regs()
1856 struct i40e_hw *hw = &np->vsi->back->hw; in i40e_get_eeprom() local
1857 struct i40e_pf *pf = np->vsi->back; in i40e_get_eeprom()
1865 if (eeprom->len == 0) in i40e_get_eeprom()
1866 return -EINVAL; in i40e_get_eeprom()
1869 magic = hw->vendor_id | (hw->device_id << 16); in i40e_get_eeprom()
1870 if (eeprom->magic && eeprom->magic != magic) { in i40e_get_eeprom()
1875 if ((eeprom->magic >> 16) != hw->device_id) in i40e_get_eeprom()
1876 errno = -EINVAL; in i40e_get_eeprom()
1877 else if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) || in i40e_get_eeprom()
1878 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) in i40e_get_eeprom()
1879 errno = -EBUSY; in i40e_get_eeprom()
1881 ret_val = i40e_nvmupd_command(hw, cmd, bytes, &errno); in i40e_get_eeprom()
1883 if ((errno || ret_val) && (hw->debug_mask & I40E_DEBUG_NVM)) in i40e_get_eeprom()
1884 dev_info(&pf->pdev->dev, in i40e_get_eeprom()
1886 ret_val, hw->aq.asq_last_status, errno, in i40e_get_eeprom()
1887 (u8)(cmd->config & I40E_NVM_MOD_PNT_MASK), in i40e_get_eeprom()
1888 cmd->offset, cmd->data_size); in i40e_get_eeprom()
1894 eeprom->magic = hw->vendor_id | (hw->device_id << 16); in i40e_get_eeprom()
1896 eeprom_buff = kzalloc(eeprom->len, GFP_KERNEL); in i40e_get_eeprom()
1898 return -ENOMEM; in i40e_get_eeprom()
1900 ret_val = i40e_acquire_nvm(hw, I40E_RESOURCE_READ); in i40e_get_eeprom()
1902 dev_info(&pf->pdev->dev, in i40e_get_eeprom()
1904 ret_val, hw->aq.asq_last_status); in i40e_get_eeprom()
1908 sectors = eeprom->len / I40E_NVM_SECTOR_SIZE; in i40e_get_eeprom()
1909 sectors += (eeprom->len % I40E_NVM_SECTOR_SIZE) ? 1 : 0; in i40e_get_eeprom()
1913 if (i == (sectors - 1)) { in i40e_get_eeprom()
1914 len = eeprom->len - (I40E_NVM_SECTOR_SIZE * i); in i40e_get_eeprom()
1917 offset = eeprom->offset + (I40E_NVM_SECTOR_SIZE * i), in i40e_get_eeprom()
1918 ret_val = i40e_aq_read_nvm(hw, 0x0, offset, len, in i40e_get_eeprom()
1921 if (ret_val && hw->aq.asq_last_status == I40E_AQ_RC_EPERM) { in i40e_get_eeprom()
1922 dev_info(&pf->pdev->dev, in i40e_get_eeprom()
1927 hw->aq.asq_last_status == I40E_AQ_RC_EACCES) { in i40e_get_eeprom()
1928 dev_info(&pf->pdev->dev, in i40e_get_eeprom()
1933 dev_info(&pf->pdev->dev, in i40e_get_eeprom()
1935 offset, ret_val, hw->aq.asq_last_status); in i40e_get_eeprom()
1940 i40e_release_nvm(hw); in i40e_get_eeprom()
1941 memcpy(bytes, (u8 *)eeprom_buff, eeprom->len); in i40e_get_eeprom()
1950 struct i40e_hw *hw = &np->vsi->back->hw; in i40e_get_eeprom_len() local
1954 if (hw->mac.type == I40E_MAC_X722) { in i40e_get_eeprom_len()
1958 val = (rd32(hw, I40E_GLPCI_LBARCTRL) in i40e_get_eeprom_len()
1970 struct i40e_hw *hw = &np->vsi->back->hw; in i40e_set_eeprom() local
1971 struct i40e_pf *pf = np->vsi->back; in i40e_set_eeprom()
1977 /* normal ethtool set_eeprom is not supported */ in i40e_set_eeprom()
1978 magic = hw->vendor_id | (hw->device_id << 16); in i40e_set_eeprom()
1979 if (eeprom->magic == magic) in i40e_set_eeprom()
1980 errno = -EOPNOTSUPP; in i40e_set_eeprom()
1982 else if (!eeprom->magic || (eeprom->magic >> 16) != hw->device_id) in i40e_set_eeprom()
1983 errno = -EINVAL; in i40e_set_eeprom()
1984 else if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) || in i40e_set_eeprom()
1985 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) in i40e_set_eeprom()
1986 errno = -EBUSY; in i40e_set_eeprom()
1988 ret_val = i40e_nvmupd_command(hw, cmd, bytes, &errno); in i40e_set_eeprom()
1990 if ((errno || ret_val) && (hw->debug_mask & I40E_DEBUG_NVM)) in i40e_set_eeprom()
1991 dev_info(&pf->pdev->dev, in i40e_set_eeprom()
1993 ret_val, hw->aq.asq_last_status, errno, in i40e_set_eeprom()
1994 (u8)(cmd->config & I40E_NVM_MOD_PNT_MASK), in i40e_set_eeprom()
1995 cmd->offset, cmd->data_size); in i40e_set_eeprom()
2004 struct i40e_vsi *vsi = np->vsi; in i40e_get_drvinfo()
2005 struct i40e_pf *pf = vsi->back; in i40e_get_drvinfo()
2007 strscpy(drvinfo->driver, i40e_driver_name, sizeof(drvinfo->driver)); in i40e_get_drvinfo()
2008 strscpy(drvinfo->fw_version, i40e_nvm_version_str(&pf->hw), in i40e_get_drvinfo()
2009 sizeof(drvinfo->fw_version)); in i40e_get_drvinfo()
2010 strscpy(drvinfo->bus_info, pci_name(pf->pdev), in i40e_get_drvinfo()
2011 sizeof(drvinfo->bus_info)); in i40e_get_drvinfo()
2012 drvinfo->n_priv_flags = I40E_PRIV_FLAGS_STR_LEN; in i40e_get_drvinfo()
2013 if (pf->hw.pf_id == 0) in i40e_get_drvinfo()
2014 drvinfo->n_priv_flags += I40E_GL_PRIV_FLAGS_STR_LEN; in i40e_get_drvinfo()
2023 struct i40e_pf *pf = np->vsi->back; in i40e_get_ringparam()
2024 struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi]; in i40e_get_ringparam()
2026 ring->rx_max_pending = I40E_MAX_NUM_DESCRIPTORS; in i40e_get_ringparam()
2027 ring->tx_max_pending = I40E_MAX_NUM_DESCRIPTORS; in i40e_get_ringparam()
2028 ring->rx_mini_max_pending = 0; in i40e_get_ringparam()
2029 ring->rx_jumbo_max_pending = 0; in i40e_get_ringparam()
2030 ring->rx_pending = vsi->rx_rings[0]->count; in i40e_get_ringparam()
2031 ring->tx_pending = vsi->tx_rings[0]->count; in i40e_get_ringparam()
2032 ring->rx_mini_pending = 0; in i40e_get_ringparam()
2033 ring->rx_jumbo_pending = 0; in i40e_get_ringparam()
2039 return index < vsi->num_queue_pairs || in i40e_active_tx_ring_index()
2040 (index >= vsi->alloc_queue_pairs && in i40e_active_tx_ring_index()
2041 index < vsi->alloc_queue_pairs + vsi->num_queue_pairs); in i40e_active_tx_ring_index()
2044 return index < vsi->num_queue_pairs; in i40e_active_tx_ring_index()
2054 struct i40e_hw *hw = &np->vsi->back->hw; in i40e_set_ringparam() local
2055 struct i40e_vsi *vsi = np->vsi; in i40e_set_ringparam()
2056 struct i40e_pf *pf = vsi->back; in i40e_set_ringparam()
2062 if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending)) in i40e_set_ringparam()
2063 return -EINVAL; in i40e_set_ringparam()
2065 if (ring->tx_pending > I40E_MAX_NUM_DESCRIPTORS || in i40e_set_ringparam()
2066 ring->tx_pending < I40E_MIN_NUM_DESCRIPTORS || in i40e_set_ringparam()
2067 ring->rx_pending > I40E_MAX_NUM_DESCRIPTORS || in i40e_set_ringparam()
2068 ring->rx_pending < I40E_MIN_NUM_DESCRIPTORS) { in i40e_set_ringparam()
2070 "Descriptors requested (Tx: %d / Rx: %d) out of range [%d-%d]\n", in i40e_set_ringparam()
2071 ring->tx_pending, ring->rx_pending, in i40e_set_ringparam()
2073 return -EINVAL; in i40e_set_ringparam()
2076 new_tx_count = ALIGN(ring->tx_pending, I40E_REQ_DESCRIPTOR_MULTIPLE); in i40e_set_ringparam()
2077 new_rx_count = ALIGN(ring->rx_pending, I40E_REQ_DESCRIPTOR_MULTIPLE); in i40e_set_ringparam()
2080 if ((new_tx_count == vsi->tx_rings[0]->count) && in i40e_set_ringparam()
2081 (new_rx_count == vsi->rx_rings[0]->count)) in i40e_set_ringparam()
2085 * disallow changing the number of descriptors -- regardless in i40e_set_ringparam()
2089 return -EBUSY; in i40e_set_ringparam()
2091 while (test_and_set_bit(__I40E_CONFIG_BUSY, pf->state)) { in i40e_set_ringparam()
2092 timeout--; in i40e_set_ringparam()
2094 return -EBUSY; in i40e_set_ringparam()
2098 if (!netif_running(vsi->netdev)) { in i40e_set_ringparam()
2099 /* simple case - set for the next time the netdev is started */ in i40e_set_ringparam()
2100 for (i = 0; i < vsi->num_queue_pairs; i++) { in i40e_set_ringparam()
2101 vsi->tx_rings[i]->count = new_tx_count; in i40e_set_ringparam()
2102 vsi->rx_rings[i]->count = new_rx_count; in i40e_set_ringparam()
2104 vsi->xdp_rings[i]->count = new_tx_count; in i40e_set_ringparam()
2106 vsi->num_tx_desc = new_tx_count; in i40e_set_ringparam()
2107 vsi->num_rx_desc = new_rx_count; in i40e_set_ringparam()
2112 * because the ISRs in MSI-X mode get passed pointers in i40e_set_ringparam()
2117 tx_alloc_queue_pairs = vsi->alloc_queue_pairs * in i40e_set_ringparam()
2119 if (new_tx_count != vsi->tx_rings[0]->count) { in i40e_set_ringparam()
2122 vsi->tx_rings[0]->count, new_tx_count); in i40e_set_ringparam()
2126 err = -ENOMEM; in i40e_set_ringparam()
2134 tx_rings[i] = *vsi->tx_rings[i]; in i40e_set_ringparam()
2144 i--; in i40e_set_ringparam()
2158 if (new_rx_count != vsi->rx_rings[0]->count) { in i40e_set_ringparam()
2161 vsi->rx_rings[0]->count, new_rx_count); in i40e_set_ringparam()
2162 rx_rings = kcalloc(vsi->alloc_queue_pairs, in i40e_set_ringparam()
2165 err = -ENOMEM; in i40e_set_ringparam()
2169 for (i = 0; i < vsi->num_queue_pairs; i++) { in i40e_set_ringparam()
2173 rx_rings[i] = *vsi->rx_rings[i]; in i40e_set_ringparam()
2180 /* Clear cloned XDP RX-queue info before setup call */ in i40e_set_ringparam()
2185 rx_rings[i].tail = hw->hw_addr + I40E_PRTGEN_STATUS; in i40e_set_ringparam()
2199 } while (i--); in i40e_set_ringparam()
2216 i40e_free_tx_resources(vsi->tx_rings[i]); in i40e_set_ringparam()
2217 *vsi->tx_rings[i] = tx_rings[i]; in i40e_set_ringparam()
2225 for (i = 0; i < vsi->num_queue_pairs; i++) { in i40e_set_ringparam()
2226 i40e_free_rx_resources(vsi->rx_rings[i]); in i40e_set_ringparam()
2228 rx_rings[i].tail = vsi->rx_rings[i]->tail; in i40e_set_ringparam()
2231 * but the recycling logic will let us re-use in i40e_set_ringparam()
2238 *vsi->rx_rings[i] = rx_rings[i]; in i40e_set_ringparam()
2244 vsi->num_tx_desc = new_tx_count; in i40e_set_ringparam()
2245 vsi->num_rx_desc = new_rx_count; in i40e_set_ringparam()
2253 i40e_free_tx_resources(vsi->tx_rings[i]); in i40e_set_ringparam()
2260 clear_bit(__I40E_CONFIG_BUSY, pf->state); in i40e_set_ringparam()
2266 * i40e_get_stats_count - return the stats count for a device
2273 * obtaining stats is *not* safe against changes based on non-static
2282 struct i40e_vsi *vsi = np->vsi; in i40e_get_stats_count()
2283 struct i40e_pf *pf = vsi->back; in i40e_get_stats_count()
2286 if (vsi == pf->vsi[pf->lan_vsi] && pf->hw.partition_id == 1) in i40e_get_stats_count()
2301 * queues in pairs, we'll just use netdev->num_tx_queues * 2. This in i40e_get_stats_count()
2305 stats_len += I40E_QUEUE_STATS_LEN * 2 * netdev->num_tx_queues; in i40e_get_stats_count()
2313 struct i40e_vsi *vsi = np->vsi; in i40e_get_sset_count()
2314 struct i40e_pf *pf = vsi->back; in i40e_get_sset_count()
2323 (pf->hw.pf_id == 0 ? I40E_GL_PRIV_FLAGS_STR_LEN : 0); in i40e_get_sset_count()
2325 return -EOPNOTSUPP; in i40e_get_sset_count()
2330 * i40e_get_veb_tc_stats - copy VEB TC statistics to formatted structure
2331 * @tc: the TC statistics in VEB structure (veb->tc_stats)
2332 * @i: the index of traffic class in (veb->tc_stats) structure to copy
2334 * Copy VEB TC statistics from structure of arrays (veb->tc_stats) to
2343 .tc_rx_packets = tc->tc_rx_packets[i], in i40e_get_veb_tc_stats()
2344 .tc_rx_bytes = tc->tc_rx_bytes[i], in i40e_get_veb_tc_stats()
2345 .tc_tx_packets = tc->tc_tx_packets[i], in i40e_get_veb_tc_stats()
2346 .tc_tx_bytes = tc->tc_tx_bytes[i], in i40e_get_veb_tc_stats()
2353 * i40e_get_pfc_stats - copy HW PFC statistics to formatted structure
2357 * The PFC stats are found as arrays in pf->stats, which is not easy to pass
2365 .stat = pf->stats.stat[priority] in i40e_get_pfc_stats()
2378 * i40e_get_ethtool_stats - copy stat values into supplied buffer
2384 * pre-allocated to the size returned by i40e_get_stats_count.. Note that all
2395 struct i40e_vsi *vsi = np->vsi; in i40e_get_ethtool_stats()
2396 struct i40e_pf *pf = vsi->back; in i40e_get_ethtool_stats()
2410 for (i = 0; i < netdev->num_tx_queues; i++) { in i40e_get_ethtool_stats()
2411 i40e_add_queue_stats(&data, READ_ONCE(vsi->tx_rings[i])); in i40e_get_ethtool_stats()
2412 i40e_add_queue_stats(&data, READ_ONCE(vsi->rx_rings[i])); in i40e_get_ethtool_stats()
2416 if (vsi != pf->vsi[pf->lan_vsi] || pf->hw.partition_id != 1) in i40e_get_ethtool_stats()
2419 veb_stats = ((pf->lan_veb != I40E_NO_VEB) && in i40e_get_ethtool_stats()
2420 (pf->lan_veb < I40E_MAX_VEB) && in i40e_get_ethtool_stats()
2421 (pf->flags & I40E_FLAG_VEB_STATS_ENABLED)); in i40e_get_ethtool_stats()
2424 veb = pf->veb[pf->lan_veb]; in i40e_get_ethtool_stats()
2438 i40e_get_veb_tc_stats(&veb->tc_stats, i); in i40e_get_ethtool_stats()
2456 WARN_ONCE(data - p != i40e_get_stats_count(netdev), in i40e_get_ethtool_stats()
2461 * i40e_get_stat_strings - copy stat strings into supplied buffer
2466 * pre-allocated with the size reported by i40e_get_stats_count. Note that the
2473 struct i40e_vsi *vsi = np->vsi; in i40e_get_stat_strings()
2474 struct i40e_pf *pf = vsi->back; in i40e_get_stat_strings()
2482 for (i = 0; i < netdev->num_tx_queues; i++) { in i40e_get_stat_strings()
2489 if (vsi != pf->vsi[pf->lan_vsi] || pf->hw.partition_id != 1) in i40e_get_stat_strings()
2503 WARN_ONCE(data - p != i40e_get_stats_count(netdev) * ETH_GSTRING_LEN, in i40e_get_stat_strings()
2510 struct i40e_vsi *vsi = np->vsi; in i40e_get_priv_flag_strings()
2511 struct i40e_pf *pf = vsi->back; in i40e_get_priv_flag_strings()
2517 if (pf->hw.pf_id != 0) in i40e_get_priv_flag_strings()
2547 /* only report HW timestamping if PTP is enabled */ in i40e_get_ts_info()
2548 if (!(pf->flags & I40E_FLAG_PTP)) in i40e_get_ts_info()
2551 info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE | in i40e_get_ts_info()
2558 if (pf->ptp_clock) in i40e_get_ts_info()
2559 info->phc_index = ptp_clock_index(pf->ptp_clock); in i40e_get_ts_info()
2561 info->phc_index = -1; in i40e_get_ts_info()
2563 info->tx_types = BIT(HWTSTAMP_TX_OFF) | BIT(HWTSTAMP_TX_ON); in i40e_get_ts_info()
2565 info->rx_filters = BIT(HWTSTAMP_FILTER_NONE) | in i40e_get_ts_info()
2570 if (pf->hw_features & I40E_HW_PTP_L4_CAPABLE) in i40e_get_ts_info()
2571 info->rx_filters |= BIT(HWTSTAMP_FILTER_PTP_V1_L4_SYNC) | in i40e_get_ts_info()
2586 struct i40e_pf *pf = np->vsi->back; in i40e_link_test()
2590 netif_info(pf, hw, netdev, "link test\n"); in i40e_link_test()
2591 status = i40e_get_link_status(&pf->hw, &link_up); in i40e_link_test()
2609 struct i40e_pf *pf = np->vsi->back; in i40e_reg_test()
2611 netif_info(pf, hw, netdev, "register test\n"); in i40e_reg_test()
2612 *data = i40e_diag_reg_test(&pf->hw); in i40e_reg_test()
2620 struct i40e_pf *pf = np->vsi->back; in i40e_eeprom_test()
2622 netif_info(pf, hw, netdev, "eeprom test\n"); in i40e_eeprom_test()
2623 *data = i40e_diag_eeprom_test(&pf->hw); in i40e_eeprom_test()
2626 pf->hw.nvmupd_state = I40E_NVMUPD_STATE_INIT; in i40e_eeprom_test()
2634 struct i40e_pf *pf = np->vsi->back; in i40e_intr_test()
2635 u16 swc_old = pf->sw_int_count; in i40e_intr_test()
2637 netif_info(pf, hw, netdev, "interrupt test\n"); in i40e_intr_test()
2638 wr32(&pf->hw, I40E_PFINT_DYN_CTL0, in i40e_intr_test()
2645 *data = (swc_old == pf->sw_int_count); in i40e_intr_test()
2652 struct i40e_vf *vfs = pf->vf; in i40e_active_vfs()
2655 for (i = 0; i < pf->num_alloc_vfs; i++) in i40e_active_vfs()
2671 struct i40e_pf *pf = np->vsi->back; in i40e_diag_test()
2673 if (eth_test->flags == ETH_TEST_FL_OFFLINE) { in i40e_diag_test()
2677 set_bit(__I40E_TESTING, pf->state); in i40e_diag_test()
2679 if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) || in i40e_diag_test()
2680 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) { in i40e_diag_test()
2681 dev_warn(&pf->pdev->dev, in i40e_diag_test()
2687 dev_warn(&pf->pdev->dev, in i40e_diag_test()
2697 /* This reset does not affect link - if it is in i40e_diag_test()
2705 eth_test->flags |= ETH_TEST_FL_FAILED; in i40e_diag_test()
2708 eth_test->flags |= ETH_TEST_FL_FAILED; in i40e_diag_test()
2711 eth_test->flags |= ETH_TEST_FL_FAILED; in i40e_diag_test()
2715 eth_test->flags |= ETH_TEST_FL_FAILED; in i40e_diag_test()
2717 clear_bit(__I40E_TESTING, pf->state); in i40e_diag_test()
2727 eth_test->flags |= ETH_TEST_FL_FAILED; in i40e_diag_test()
2743 eth_test->flags |= ETH_TEST_FL_FAILED; in i40e_diag_test()
2744 clear_bit(__I40E_TESTING, pf->state); in i40e_diag_test()
2752 struct i40e_pf *pf = np->vsi->back; in i40e_get_wol()
2753 struct i40e_hw *hw = &pf->hw; in i40e_get_wol() local
2757 i40e_read_nvm_word(hw, I40E_SR_NVM_WAKE_ON_LAN, &wol_nvm_bits); in i40e_get_wol()
2758 if ((BIT(hw->port) & wol_nvm_bits) || (hw->partition_id != 1)) { in i40e_get_wol()
2759 wol->supported = 0; in i40e_get_wol()
2760 wol->wolopts = 0; in i40e_get_wol()
2762 wol->supported = WAKE_MAGIC; in i40e_get_wol()
2763 wol->wolopts = (pf->wol_en ? WAKE_MAGIC : 0); in i40e_get_wol()
2768 * i40e_set_wol - set the WakeOnLAN configuration
2775 struct i40e_pf *pf = np->vsi->back; in i40e_set_wol()
2776 struct i40e_vsi *vsi = np->vsi; in i40e_set_wol()
2777 struct i40e_hw *hw = &pf->hw; in i40e_set_wol() local
2780 /* WoL not supported if this isn't the controlling PF on the port */ in i40e_set_wol()
2781 if (hw->partition_id != 1) { in i40e_set_wol()
2783 return -EOPNOTSUPP; in i40e_set_wol()
2786 if (vsi != pf->vsi[pf->lan_vsi]) in i40e_set_wol()
2787 return -EOPNOTSUPP; in i40e_set_wol()
2790 i40e_read_nvm_word(hw, I40E_SR_NVM_WAKE_ON_LAN, &wol_nvm_bits); in i40e_set_wol()
2791 if (BIT(hw->port) & wol_nvm_bits) in i40e_set_wol()
2792 return -EOPNOTSUPP; in i40e_set_wol()
2794 /* only magic packet is supported */ in i40e_set_wol()
2795 if (wol->wolopts & ~WAKE_MAGIC) in i40e_set_wol()
2796 return -EOPNOTSUPP; in i40e_set_wol()
2799 if (pf->wol_en != !!wol->wolopts) { in i40e_set_wol()
2800 pf->wol_en = !!wol->wolopts; in i40e_set_wol()
2801 device_set_wakeup_enable(&pf->pdev->dev, pf->wol_en); in i40e_set_wol()
2811 struct i40e_pf *pf = np->vsi->back; in i40e_set_phys_id()
2812 struct i40e_hw *hw = &pf->hw; in i40e_set_phys_id() local
2819 if (!(pf->hw_features & I40E_HW_PHY_CONTROLS_LEDS)) { in i40e_set_phys_id()
2820 pf->led_status = i40e_led_get(hw); in i40e_set_phys_id()
2822 if (!(hw->flags & I40E_HW_FLAG_AQ_PHY_ACCESS_CAPABLE)) in i40e_set_phys_id()
2823 i40e_aq_set_phy_debug(hw, I40E_PHY_DEBUG_ALL, in i40e_set_phys_id()
2825 ret = i40e_led_get_phy(hw, &temp_status, in i40e_set_phys_id()
2826 &pf->phy_led_val); in i40e_set_phys_id()
2827 pf->led_status = temp_status; in i40e_set_phys_id()
2831 if (!(pf->hw_features & I40E_HW_PHY_CONTROLS_LEDS)) in i40e_set_phys_id()
2832 i40e_led_set(hw, 0xf, false); in i40e_set_phys_id()
2834 ret = i40e_led_set_phy(hw, true, pf->led_status, 0); in i40e_set_phys_id()
2837 if (!(pf->hw_features & I40E_HW_PHY_CONTROLS_LEDS)) in i40e_set_phys_id()
2838 i40e_led_set(hw, 0x0, false); in i40e_set_phys_id()
2840 ret = i40e_led_set_phy(hw, false, pf->led_status, 0); in i40e_set_phys_id()
2843 if (!(pf->hw_features & I40E_HW_PHY_CONTROLS_LEDS)) { in i40e_set_phys_id()
2844 i40e_led_set(hw, pf->led_status, false); in i40e_set_phys_id()
2846 ret = i40e_led_set_phy(hw, false, pf->led_status, in i40e_set_phys_id()
2847 (pf->phy_led_val | in i40e_set_phys_id()
2849 if (!(hw->flags & I40E_HW_FLAG_AQ_PHY_ACCESS_CAPABLE)) in i40e_set_phys_id()
2850 i40e_aq_set_phy_debug(hw, 0, NULL); in i40e_set_phys_id()
2857 return -ENOENT; in i40e_set_phys_id()
2868 * __i40e_get_coalesce - get per-queue coalesce settings
2873 * Gets the per-queue settings for coalescence. Specifically Rx and Tx usecs
2883 struct i40e_vsi *vsi = np->vsi; in __i40e_get_coalesce()
2885 ec->tx_max_coalesced_frames_irq = vsi->work_limit; in __i40e_get_coalesce()
2886 ec->rx_max_coalesced_frames_irq = vsi->work_limit; in __i40e_get_coalesce()
2893 else if (queue >= vsi->num_queue_pairs) in __i40e_get_coalesce()
2894 return -EINVAL; in __i40e_get_coalesce()
2896 rx_ring = vsi->rx_rings[queue]; in __i40e_get_coalesce()
2897 tx_ring = vsi->tx_rings[queue]; in __i40e_get_coalesce()
2899 if (ITR_IS_DYNAMIC(rx_ring->itr_setting)) in __i40e_get_coalesce()
2900 ec->use_adaptive_rx_coalesce = 1; in __i40e_get_coalesce()
2902 if (ITR_IS_DYNAMIC(tx_ring->itr_setting)) in __i40e_get_coalesce()
2903 ec->use_adaptive_tx_coalesce = 1; in __i40e_get_coalesce()
2905 ec->rx_coalesce_usecs = rx_ring->itr_setting & ~I40E_ITR_DYNAMIC; in __i40e_get_coalesce()
2906 ec->tx_coalesce_usecs = tx_ring->itr_setting & ~I40E_ITR_DYNAMIC; in __i40e_get_coalesce()
2914 ec->rx_coalesce_usecs_high = vsi->int_rate_limit; in __i40e_get_coalesce()
2915 ec->tx_coalesce_usecs_high = vsi->int_rate_limit; in __i40e_get_coalesce()
2921 * i40e_get_coalesce - get a netdev's coalesce settings
2928 * modified per-queue settings, this only guarantees to represent queue 0. See
2936 return __i40e_get_coalesce(netdev, ec, -1); in i40e_get_coalesce()
2940 * i40e_get_per_queue_coalesce - gets coalesce settings for particular queue
2954 * i40e_set_itr_per_queue - set ITR values for specific queue
2965 struct i40e_ring *rx_ring = vsi->rx_rings[queue]; in i40e_set_itr_per_queue()
2966 struct i40e_ring *tx_ring = vsi->tx_rings[queue]; in i40e_set_itr_per_queue()
2967 struct i40e_pf *pf = vsi->back; in i40e_set_itr_per_queue()
2968 struct i40e_hw *hw = &pf->hw; in i40e_set_itr_per_queue() local
2972 intrl = i40e_intrl_usec_to_reg(vsi->int_rate_limit); in i40e_set_itr_per_queue()
2974 rx_ring->itr_setting = ITR_REG_ALIGN(ec->rx_coalesce_usecs); in i40e_set_itr_per_queue()
2975 tx_ring->itr_setting = ITR_REG_ALIGN(ec->tx_coalesce_usecs); in i40e_set_itr_per_queue()
2977 if (ec->use_adaptive_rx_coalesce) in i40e_set_itr_per_queue()
2978 rx_ring->itr_setting |= I40E_ITR_DYNAMIC; in i40e_set_itr_per_queue()
2980 rx_ring->itr_setting &= ~I40E_ITR_DYNAMIC; in i40e_set_itr_per_queue()
2982 if (ec->use_adaptive_tx_coalesce) in i40e_set_itr_per_queue()
2983 tx_ring->itr_setting |= I40E_ITR_DYNAMIC; in i40e_set_itr_per_queue()
2985 tx_ring->itr_setting &= ~I40E_ITR_DYNAMIC; in i40e_set_itr_per_queue()
2987 q_vector = rx_ring->q_vector; in i40e_set_itr_per_queue()
2988 q_vector->rx.target_itr = ITR_TO_REG(rx_ring->itr_setting); in i40e_set_itr_per_queue()
2990 q_vector = tx_ring->q_vector; in i40e_set_itr_per_queue()
2991 q_vector->tx.target_itr = ITR_TO_REG(tx_ring->itr_setting); in i40e_set_itr_per_queue()
2998 wr32(hw, I40E_PFINT_RATEN(q_vector->reg_idx), intrl); in i40e_set_itr_per_queue()
2999 i40e_flush(hw); in i40e_set_itr_per_queue()
3003 * __i40e_set_coalesce - set coalesce settings for particular queue
3016 struct i40e_vsi *vsi = np->vsi; in __i40e_set_coalesce()
3017 struct i40e_pf *pf = vsi->back; in __i40e_set_coalesce()
3020 if (ec->tx_max_coalesced_frames_irq || ec->rx_max_coalesced_frames_irq) in __i40e_set_coalesce()
3021 vsi->work_limit = ec->tx_max_coalesced_frames_irq; in __i40e_set_coalesce()
3024 cur_rx_itr = vsi->rx_rings[0]->itr_setting; in __i40e_set_coalesce()
3025 cur_tx_itr = vsi->tx_rings[0]->itr_setting; in __i40e_set_coalesce()
3026 } else if (queue < vsi->num_queue_pairs) { in __i40e_set_coalesce()
3027 cur_rx_itr = vsi->rx_rings[queue]->itr_setting; in __i40e_set_coalesce()
3028 cur_tx_itr = vsi->tx_rings[queue]->itr_setting; in __i40e_set_coalesce()
3030 netif_info(pf, drv, netdev, "Invalid queue value, queue range is 0 - %d\n", in __i40e_set_coalesce()
3031 vsi->num_queue_pairs - 1); in __i40e_set_coalesce()
3032 return -EINVAL; in __i40e_set_coalesce()
3038 /* tx_coalesce_usecs_high is ignored, use rx-usecs-high instead */ in __i40e_set_coalesce()
3039 if (ec->tx_coalesce_usecs_high != vsi->int_rate_limit) { in __i40e_set_coalesce()
3040 netif_info(pf, drv, netdev, "tx-usecs-high is not used, please program rx-usecs-high\n"); in __i40e_set_coalesce()
3041 return -EINVAL; in __i40e_set_coalesce()
3044 if (ec->rx_coalesce_usecs_high > INTRL_REG_TO_USEC(I40E_MAX_INTRL)) { in __i40e_set_coalesce()
3045 netif_info(pf, drv, netdev, "Invalid value, rx-usecs-high range is 0-%lu\n", in __i40e_set_coalesce()
3047 return -EINVAL; in __i40e_set_coalesce()
3050 if (ec->rx_coalesce_usecs != cur_rx_itr && in __i40e_set_coalesce()
3051 ec->use_adaptive_rx_coalesce) { in __i40e_set_coalesce()
3052 …netif_info(pf, drv, netdev, "RX interrupt moderation cannot be changed if adaptive-rx is enabled.\… in __i40e_set_coalesce()
3053 return -EINVAL; in __i40e_set_coalesce()
3056 if (ec->rx_coalesce_usecs > I40E_MAX_ITR) { in __i40e_set_coalesce()
3057 netif_info(pf, drv, netdev, "Invalid value, rx-usecs range is 0-8160\n"); in __i40e_set_coalesce()
3058 return -EINVAL; in __i40e_set_coalesce()
3061 if (ec->tx_coalesce_usecs != cur_tx_itr && in __i40e_set_coalesce()
3062 ec->use_adaptive_tx_coalesce) { in __i40e_set_coalesce()
3063 …netif_info(pf, drv, netdev, "TX interrupt moderation cannot be changed if adaptive-tx is enabled.\… in __i40e_set_coalesce()
3064 return -EINVAL; in __i40e_set_coalesce()
3067 if (ec->tx_coalesce_usecs > I40E_MAX_ITR) { in __i40e_set_coalesce()
3068 netif_info(pf, drv, netdev, "Invalid value, tx-usecs range is 0-8160\n"); in __i40e_set_coalesce()
3069 return -EINVAL; in __i40e_set_coalesce()
3072 if (ec->use_adaptive_rx_coalesce && !cur_rx_itr) in __i40e_set_coalesce()
3073 ec->rx_coalesce_usecs = I40E_MIN_ITR; in __i40e_set_coalesce()
3075 if (ec->use_adaptive_tx_coalesce && !cur_tx_itr) in __i40e_set_coalesce()
3076 ec->tx_coalesce_usecs = I40E_MIN_ITR; in __i40e_set_coalesce()
3078 intrl_reg = i40e_intrl_usec_to_reg(ec->rx_coalesce_usecs_high); in __i40e_set_coalesce()
3079 vsi->int_rate_limit = INTRL_REG_TO_USEC(intrl_reg); in __i40e_set_coalesce()
3080 if (vsi->int_rate_limit != ec->rx_coalesce_usecs_high) { in __i40e_set_coalesce()
3082 vsi->int_rate_limit); in __i40e_set_coalesce()
3089 for (i = 0; i < vsi->num_queue_pairs; i++) in __i40e_set_coalesce()
3099 * i40e_set_coalesce - set coalesce settings for every queue on the netdev
3112 return __i40e_set_coalesce(netdev, ec, -1); in i40e_set_coalesce()
3116 * i40e_set_per_queue_coalesce - set specific queue's coalesce settings
3130 * i40e_get_rss_hash_opts - Get RSS hash Input Set for each flow type
3134 * Returns Success if the flow is supported, else Invalid Input.
3138 struct i40e_hw *hw = &pf->hw; in i40e_get_rss_hash_opts() local
3142 cmd->data = 0; in i40e_get_rss_hash_opts()
3144 switch (cmd->flow_type) { in i40e_get_rss_hash_opts()
3168 cmd->data |= RXH_IP_SRC | RXH_IP_DST; in i40e_get_rss_hash_opts()
3171 return -EINVAL; in i40e_get_rss_hash_opts()
3176 i_set = (u64)i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(0, in i40e_get_rss_hash_opts()
3178 ((u64)i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(1, in i40e_get_rss_hash_opts()
3185 cmd->data |= RXH_L4_B_0_1; in i40e_get_rss_hash_opts()
3187 cmd->data |= RXH_L4_B_2_3; in i40e_get_rss_hash_opts()
3189 if (cmd->flow_type == TCP_V4_FLOW || in i40e_get_rss_hash_opts()
3190 cmd->flow_type == UDP_V4_FLOW) { in i40e_get_rss_hash_opts()
3191 if (hw->mac.type == I40E_MAC_X722) { in i40e_get_rss_hash_opts()
3193 cmd->data |= RXH_IP_SRC; in i40e_get_rss_hash_opts()
3195 cmd->data |= RXH_IP_DST; in i40e_get_rss_hash_opts()
3198 cmd->data |= RXH_IP_SRC; in i40e_get_rss_hash_opts()
3200 cmd->data |= RXH_IP_DST; in i40e_get_rss_hash_opts()
3202 } else if (cmd->flow_type == TCP_V6_FLOW || in i40e_get_rss_hash_opts()
3203 cmd->flow_type == UDP_V6_FLOW) { in i40e_get_rss_hash_opts()
3205 cmd->data |= RXH_IP_SRC; in i40e_get_rss_hash_opts()
3207 cmd->data |= RXH_IP_DST; in i40e_get_rss_hash_opts()
3215 * i40e_check_mask - Check whether a mask field is set
3231 return -1; in i40e_check_mask()
3235 * i40e_parse_rx_flow_user_data - Deconstruct user-defined data
3239 * Read the user-defined data and deconstruct the value into a structure. No
3240 * other code should read the user-defined data, so as to ensure that every
3243 * The user-defined field is a 64bit Big Endian format value, which we
3248 * Returns 0 if the data is valid, and non-zero if the userdef data is invalid
3262 if (!(fsp->flow_type & FLOW_EXT)) in i40e_parse_rx_flow_user_data()
3265 value = be64_to_cpu(*((__be64 *)fsp->h_ext.data)); in i40e_parse_rx_flow_user_data()
3266 mask = be64_to_cpu(*((__be64 *)fsp->m_ext.data)); in i40e_parse_rx_flow_user_data()
3274 return -EINVAL; in i40e_parse_rx_flow_user_data()
3276 data->flex_word = value & I40E_USERDEF_FLEX_WORD; in i40e_parse_rx_flow_user_data()
3277 data->flex_offset = in i40e_parse_rx_flow_user_data()
3279 data->flex_filter = true; in i40e_parse_rx_flow_user_data()
3286 * i40e_fill_rx_flow_user_data - Fill in user-defined data field
3298 if (data->flex_filter) { in i40e_fill_rx_flow_user_data()
3299 value |= data->flex_word; in i40e_fill_rx_flow_user_data()
3300 value |= (u64)data->flex_offset << 16; in i40e_fill_rx_flow_user_data()
3305 fsp->flow_type |= FLOW_EXT; in i40e_fill_rx_flow_user_data()
3307 *((__be64 *)fsp->h_ext.data) = cpu_to_be64(value); in i40e_fill_rx_flow_user_data()
3308 *((__be64 *)fsp->m_ext.data) = cpu_to_be64(mask); in i40e_fill_rx_flow_user_data()
3312 * i40e_get_ethtool_fdir_all - Populates the rule count of a command
3320 * Returns 0 on success or -EMSGSIZE if entry not found
3331 cmd->data = i40e_get_fd_cnt_all(pf); in i40e_get_ethtool_fdir_all()
3334 &pf->fdir_filter_list, fdir_node) { in i40e_get_ethtool_fdir_all()
3335 if (cnt == cmd->rule_cnt) in i40e_get_ethtool_fdir_all()
3336 return -EMSGSIZE; in i40e_get_ethtool_fdir_all()
3338 rule_locs[cnt] = rule->fd_id; in i40e_get_ethtool_fdir_all()
3342 cmd->rule_cnt = cnt; in i40e_get_ethtool_fdir_all()
3348 * i40e_get_ethtool_fdir_entry - Look up a filter based on Rx flow
3355 * Returns 0 on success or -EINVAL if filter not found
3361 (struct ethtool_rx_flow_spec *)&cmd->fs; in i40e_get_ethtool_fdir_entry()
3369 &pf->fdir_filter_list, fdir_node) { in i40e_get_ethtool_fdir_entry()
3370 if (fsp->location <= rule->fd_id) in i40e_get_ethtool_fdir_entry()
3374 if (!rule || fsp->location != rule->fd_id) in i40e_get_ethtool_fdir_entry()
3375 return -EINVAL; in i40e_get_ethtool_fdir_entry()
3377 fsp->flow_type = rule->flow_type; in i40e_get_ethtool_fdir_entry()
3378 if (fsp->flow_type == IP_USER_FLOW) { in i40e_get_ethtool_fdir_entry()
3379 fsp->h_u.usr_ip4_spec.ip_ver = ETH_RX_NFC_IP4; in i40e_get_ethtool_fdir_entry()
3380 fsp->h_u.usr_ip4_spec.proto = 0; in i40e_get_ethtool_fdir_entry()
3381 fsp->m_u.usr_ip4_spec.proto = 0; in i40e_get_ethtool_fdir_entry()
3384 if (fsp->flow_type == IPV6_USER_FLOW || in i40e_get_ethtool_fdir_entry()
3385 fsp->flow_type == UDP_V6_FLOW || in i40e_get_ethtool_fdir_entry()
3386 fsp->flow_type == TCP_V6_FLOW || in i40e_get_ethtool_fdir_entry()
3387 fsp->flow_type == SCTP_V6_FLOW) { in i40e_get_ethtool_fdir_entry()
3388 /* Reverse the src and dest notion, since the HW views them in i40e_get_ethtool_fdir_entry()
3392 fsp->h_u.tcp_ip6_spec.psrc = rule->dst_port; in i40e_get_ethtool_fdir_entry()
3393 fsp->h_u.tcp_ip6_spec.pdst = rule->src_port; in i40e_get_ethtool_fdir_entry()
3394 memcpy(fsp->h_u.tcp_ip6_spec.ip6dst, rule->src_ip6, in i40e_get_ethtool_fdir_entry()
3396 memcpy(fsp->h_u.tcp_ip6_spec.ip6src, rule->dst_ip6, in i40e_get_ethtool_fdir_entry()
3399 /* Reverse the src and dest notion, since the HW views them in i40e_get_ethtool_fdir_entry()
3403 fsp->h_u.tcp_ip4_spec.psrc = rule->dst_port; in i40e_get_ethtool_fdir_entry()
3404 fsp->h_u.tcp_ip4_spec.pdst = rule->src_port; in i40e_get_ethtool_fdir_entry()
3405 fsp->h_u.tcp_ip4_spec.ip4src = rule->dst_ip; in i40e_get_ethtool_fdir_entry()
3406 fsp->h_u.tcp_ip4_spec.ip4dst = rule->src_ip; in i40e_get_ethtool_fdir_entry()
3409 switch (rule->flow_type) { in i40e_get_ethtool_fdir_entry()
3441 rule->flow_type); in i40e_get_ethtool_fdir_entry()
3450 fsp->m_u.tcp_ip6_spec.ip6src[0] = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3451 fsp->m_u.tcp_ip6_spec.ip6src[1] = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3452 fsp->m_u.tcp_ip6_spec.ip6src[2] = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3453 fsp->m_u.tcp_ip6_spec.ip6src[3] = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3457 fsp->m_u.tcp_ip6_spec.ip6dst[0] = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3458 fsp->m_u.tcp_ip6_spec.ip6dst[1] = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3459 fsp->m_u.tcp_ip6_spec.ip6dst[2] = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3460 fsp->m_u.tcp_ip6_spec.ip6dst[3] = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3464 fsp->m_u.tcp_ip4_spec.ip4src = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3467 fsp->m_u.tcp_ip4_spec.ip4dst = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3470 fsp->m_u.tcp_ip4_spec.psrc = htons(0xFFFF); in i40e_get_ethtool_fdir_entry()
3473 fsp->m_u.tcp_ip4_spec.pdst = htons(0xFFFF); in i40e_get_ethtool_fdir_entry()
3475 if (rule->dest_ctl == I40E_FILTER_PROGRAM_DESC_DEST_DROP_PACKET) in i40e_get_ethtool_fdir_entry()
3476 fsp->ring_cookie = RX_CLS_FLOW_DISC; in i40e_get_ethtool_fdir_entry()
3478 fsp->ring_cookie = rule->q_index; in i40e_get_ethtool_fdir_entry()
3480 if (rule->vlan_tag) { in i40e_get_ethtool_fdir_entry()
3481 fsp->h_ext.vlan_etype = rule->vlan_etype; in i40e_get_ethtool_fdir_entry()
3482 fsp->m_ext.vlan_etype = htons(0xFFFF); in i40e_get_ethtool_fdir_entry()
3483 fsp->h_ext.vlan_tci = rule->vlan_tag; in i40e_get_ethtool_fdir_entry()
3484 fsp->m_ext.vlan_tci = htons(0xFFFF); in i40e_get_ethtool_fdir_entry()
3485 fsp->flow_type |= FLOW_EXT; in i40e_get_ethtool_fdir_entry()
3488 if (rule->dest_vsi != pf->vsi[pf->lan_vsi]->id) { in i40e_get_ethtool_fdir_entry()
3491 vsi = i40e_find_vsi_from_id(pf, rule->dest_vsi); in i40e_get_ethtool_fdir_entry()
3492 if (vsi && vsi->type == I40E_VSI_SRIOV) { in i40e_get_ethtool_fdir_entry()
3493 /* VFs are zero-indexed by the driver, but ethtool in i40e_get_ethtool_fdir_entry()
3494 * expects them to be one-indexed, so add one here in i40e_get_ethtool_fdir_entry()
3496 u64 ring_vf = vsi->vf_id + 1; in i40e_get_ethtool_fdir_entry()
3499 fsp->ring_cookie |= ring_vf; in i40e_get_ethtool_fdir_entry()
3503 if (rule->flex_filter) { in i40e_get_ethtool_fdir_entry()
3505 userdef.flex_word = be16_to_cpu(rule->flex_word); in i40e_get_ethtool_fdir_entry()
3506 userdef.flex_offset = rule->flex_offset; in i40e_get_ethtool_fdir_entry()
3515 * i40e_get_rxnfc - command to get RX flow classification rules
3520 * Returns Success if the command is supported.
3526 struct i40e_vsi *vsi = np->vsi; in i40e_get_rxnfc()
3527 struct i40e_pf *pf = vsi->back; in i40e_get_rxnfc()
3528 int ret = -EOPNOTSUPP; in i40e_get_rxnfc()
3530 switch (cmd->cmd) { in i40e_get_rxnfc()
3532 cmd->data = vsi->rss_size; in i40e_get_rxnfc()
3539 cmd->rule_cnt = pf->fdir_pf_active_filters; in i40e_get_rxnfc()
3541 cmd->data = i40e_get_fd_cnt_all(pf); in i40e_get_rxnfc()
3558 * i40e_get_rss_hash_bits - Read RSS Hash bits from register
3559 * @hw: hw structure
3565 static u64 i40e_get_rss_hash_bits(struct i40e_hw *hw, in i40e_get_rss_hash_bits() argument
3572 if (nfc->data & RXH_L4_B_0_1) in i40e_get_rss_hash_bits()
3576 if (nfc->data & RXH_L4_B_2_3) in i40e_get_rss_hash_bits()
3581 if (nfc->flow_type == TCP_V6_FLOW || nfc->flow_type == UDP_V6_FLOW) { in i40e_get_rss_hash_bits()
3584 } else if (nfc->flow_type == TCP_V4_FLOW || in i40e_get_rss_hash_bits()
3585 nfc->flow_type == UDP_V4_FLOW) { in i40e_get_rss_hash_bits()
3586 if (hw->mac.type == I40E_MAC_X722) { in i40e_get_rss_hash_bits()
3594 /* Any other flow type are not supported here */ in i40e_get_rss_hash_bits()
3598 if (nfc->data & RXH_IP_SRC) in i40e_get_rss_hash_bits()
3602 if (nfc->data & RXH_IP_DST) in i40e_get_rss_hash_bits()
3612 * i40e_set_rss_hash_opt - Enable/Disable flow types for RSS hash
3616 * Returns Success if the flow input set is supported.
3620 struct i40e_hw *hw = &pf->hw; in i40e_set_rss_hash_opt() local
3621 u64 hena = (u64)i40e_read_rx_ctl(hw, I40E_PFQF_HENA(0)) | in i40e_set_rss_hash_opt()
3622 ((u64)i40e_read_rx_ctl(hw, I40E_PFQF_HENA(1)) << 32); in i40e_set_rss_hash_opt()
3628 if (pf->flags & I40E_FLAG_MFP_ENABLED) { in i40e_set_rss_hash_opt()
3629 dev_err(&pf->pdev->dev, in i40e_set_rss_hash_opt()
3630 "Change of RSS hash input set is not supported when MFP mode is enabled\n"); in i40e_set_rss_hash_opt()
3631 return -EOPNOTSUPP; in i40e_set_rss_hash_opt()
3637 if (nfc->data & ~(RXH_IP_SRC | RXH_IP_DST | in i40e_set_rss_hash_opt()
3639 return -EINVAL; in i40e_set_rss_hash_opt()
3641 switch (nfc->flow_type) { in i40e_set_rss_hash_opt()
3644 if (pf->hw_features & I40E_HW_MULTIPLE_TCP_UDP_RSS_PCTYPE) in i40e_set_rss_hash_opt()
3650 if (pf->hw_features & I40E_HW_MULTIPLE_TCP_UDP_RSS_PCTYPE) in i40e_set_rss_hash_opt()
3656 if (pf->hw_features & I40E_HW_MULTIPLE_TCP_UDP_RSS_PCTYPE) { in i40e_set_rss_hash_opt()
3666 if (pf->hw_features & I40E_HW_MULTIPLE_TCP_UDP_RSS_PCTYPE) { in i40e_set_rss_hash_opt()
3678 if ((nfc->data & RXH_L4_B_0_1) || in i40e_set_rss_hash_opt()
3679 (nfc->data & RXH_L4_B_2_3)) in i40e_set_rss_hash_opt()
3680 return -EINVAL; in i40e_set_rss_hash_opt()
3687 if ((nfc->data & RXH_L4_B_0_1) || in i40e_set_rss_hash_opt()
3688 (nfc->data & RXH_L4_B_2_3)) in i40e_set_rss_hash_opt()
3689 return -EINVAL; in i40e_set_rss_hash_opt()
3701 return -EINVAL; in i40e_set_rss_hash_opt()
3708 i_setc = (u64)i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(0, flow_id)) | in i40e_set_rss_hash_opt()
3709 ((u64)i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(1, flow_id)) << 32); in i40e_set_rss_hash_opt()
3710 i_set = i40e_get_rss_hash_bits(&pf->hw, nfc, i_setc); in i40e_set_rss_hash_opt()
3712 i40e_write_rx_ctl(hw, I40E_GLQF_HASH_INSET(0, flow_id), in i40e_set_rss_hash_opt()
3714 i40e_write_rx_ctl(hw, I40E_GLQF_HASH_INSET(1, flow_id), in i40e_set_rss_hash_opt()
3720 i40e_write_rx_ctl(hw, I40E_PFQF_HENA(0), (u32)hena); in i40e_set_rss_hash_opt()
3721 i40e_write_rx_ctl(hw, I40E_PFQF_HENA(1), (u32)(hena >> 32)); in i40e_set_rss_hash_opt()
3722 i40e_flush(hw); in i40e_set_rss_hash_opt()
3728 * i40e_update_ethtool_fdir_entry - Updates the fdir filter entry
3745 struct i40e_pf *pf = vsi->back; in i40e_update_ethtool_fdir_entry()
3747 int err = -EINVAL; in i40e_update_ethtool_fdir_entry()
3753 &pf->fdir_filter_list, fdir_node) { in i40e_update_ethtool_fdir_entry()
3755 if (rule->fd_id >= sw_idx) in i40e_update_ethtool_fdir_entry()
3761 if (rule && (rule->fd_id == sw_idx)) { in i40e_update_ethtool_fdir_entry()
3766 hlist_del(&rule->fdir_node); in i40e_update_ethtool_fdir_entry()
3768 pf->fdir_pf_active_filters--; in i40e_update_ethtool_fdir_entry()
3778 INIT_HLIST_NODE(&input->fdir_node); in i40e_update_ethtool_fdir_entry()
3782 hlist_add_behind(&input->fdir_node, &parent->fdir_node); in i40e_update_ethtool_fdir_entry()
3784 hlist_add_head(&input->fdir_node, in i40e_update_ethtool_fdir_entry()
3785 &pf->fdir_filter_list); in i40e_update_ethtool_fdir_entry()
3788 pf->fdir_pf_active_filters++; in i40e_update_ethtool_fdir_entry()
3794 * i40e_prune_flex_pit_list - Cleanup unused entries in FLX_PIT table
3807 list_for_each_entry_safe(entry, tmp, &pf->l3_flex_pit_list, list) { in i40e_prune_flex_pit_list()
3810 hlist_for_each_entry(rule, &pf->fdir_filter_list, fdir_node) { in i40e_prune_flex_pit_list()
3811 if (rule->flow_type != IP_USER_FLOW) in i40e_prune_flex_pit_list()
3813 if (rule->flex_filter && in i40e_prune_flex_pit_list()
3814 rule->flex_offset == entry->src_offset) { in i40e_prune_flex_pit_list()
3824 list_del(&entry->list); in i40e_prune_flex_pit_list()
3830 list_for_each_entry_safe(entry, tmp, &pf->l4_flex_pit_list, list) { in i40e_prune_flex_pit_list()
3833 hlist_for_each_entry(rule, &pf->fdir_filter_list, fdir_node) { in i40e_prune_flex_pit_list()
3837 if (rule->flow_type == IP_USER_FLOW) in i40e_prune_flex_pit_list()
3839 if (rule->flex_filter && in i40e_prune_flex_pit_list()
3840 rule->flex_offset == entry->src_offset) { in i40e_prune_flex_pit_list()
3850 list_del(&entry->list); in i40e_prune_flex_pit_list()
3857 * i40e_del_fdir_entry - Deletes a Flow Director filter entry
3870 (struct ethtool_rx_flow_spec *)&cmd->fs; in i40e_del_fdir_entry()
3871 struct i40e_pf *pf = vsi->back; in i40e_del_fdir_entry()
3874 if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) || in i40e_del_fdir_entry()
3875 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) in i40e_del_fdir_entry()
3876 return -EBUSY; in i40e_del_fdir_entry()
3878 if (test_bit(__I40E_FD_FLUSH_REQUESTED, pf->state)) in i40e_del_fdir_entry()
3879 return -EBUSY; in i40e_del_fdir_entry()
3881 ret = i40e_update_ethtool_fdir_entry(vsi, NULL, fsp->location, cmd); in i40e_del_fdir_entry()
3890 * i40e_unused_pit_index - Find an unused PIT index for given list
3908 list_for_each_entry(entry, &pf->l4_flex_pit_list, list) in i40e_unused_pit_index()
3909 clear_bit(entry->pit_index, &available_index); in i40e_unused_pit_index()
3911 list_for_each_entry(entry, &pf->l3_flex_pit_list, list) in i40e_unused_pit_index()
3912 clear_bit(entry->pit_index, &available_index); in i40e_unused_pit_index()
3918 * i40e_find_flex_offset - Find an existing flex src_offset
3934 * already programmed, we can simply re-use it. in i40e_find_flex_offset()
3938 if (entry->src_offset == src_offset) in i40e_find_flex_offset()
3948 return ERR_PTR(-ENOSPC); in i40e_find_flex_offset()
3954 * i40e_add_flex_offset - Add src_offset to flex PIT table list
3974 return -ENOMEM; in i40e_add_flex_offset()
3976 new_pit->src_offset = src_offset; in i40e_add_flex_offset()
3977 new_pit->pit_index = pit_index; in i40e_add_flex_offset()
3983 if (new_pit->src_offset < entry->src_offset) { in i40e_add_flex_offset()
3984 list_add_tail(&new_pit->list, &entry->list); in i40e_add_flex_offset()
3992 if (new_pit->src_offset == entry->src_offset) { in i40e_add_flex_offset()
3995 /* If the PIT index is not the same we can't re-use in i40e_add_flex_offset()
3998 if (new_pit->pit_index != entry->pit_index) in i40e_add_flex_offset()
3999 err = -EINVAL; in i40e_add_flex_offset()
4009 list_add_tail(&new_pit->list, flex_pit_list); in i40e_add_flex_offset()
4014 * __i40e_reprogram_flex_pit - Re-program specific FLX_PIT table
4027 * This function will reprogram the FLX_PIT register from a book-keeping
4061 u16 offset = entry->src_offset + j; in __i40e_reprogram_flex_pit()
4065 offset - 3); in __i40e_reprogram_flex_pit()
4068 i40e_write_rx_ctl(&pf->hw, in __i40e_reprogram_flex_pit()
4076 i40e_write_rx_ctl(&pf->hw, in __i40e_reprogram_flex_pit()
4078 I40E_FLEX_PREP_VAL(entry->pit_index + 50, in __i40e_reprogram_flex_pit()
4080 entry->src_offset)); in __i40e_reprogram_flex_pit()
4091 last_offset = list_prev_entry(entry, list)->src_offset + 1; in __i40e_reprogram_flex_pit()
4094 i40e_write_rx_ctl(&pf->hw, in __i40e_reprogram_flex_pit()
4103 * i40e_reprogram_flex_pit - Reprogram all FLX_PIT tables after input set change
4111 __i40e_reprogram_flex_pit(pf, &pf->l3_flex_pit_list, in i40e_reprogram_flex_pit()
4114 __i40e_reprogram_flex_pit(pf, &pf->l4_flex_pit_list, in i40e_reprogram_flex_pit()
4118 i40e_write_rx_ctl(&pf->hw, in i40e_reprogram_flex_pit()
4123 i40e_write_rx_ctl(&pf->hw, in i40e_reprogram_flex_pit()
4130 * i40e_flow_str - Converts a flow_type into a human readable string
4138 switch (fsp->flow_type & ~FLOW_EXT) { in i40e_flow_str()
4161 * i40e_pit_index_to_mask - Return the FLEX mask for a given PIT index
4192 * i40e_print_input_set - Show changes between two input sets
4203 struct i40e_pf *pf = vsi->back; in i40e_print_input_set()
4210 netif_info(pf, drv, vsi->netdev, "L3 source address: %s -> %s\n", in i40e_print_input_set()
4217 netif_info(pf, drv, vsi->netdev, "L3 destination address: %s -> %s\n", in i40e_print_input_set()
4224 netif_info(pf, drv, vsi->netdev, "L4 source port: %s -> %s\n", in i40e_print_input_set()
4231 netif_info(pf, drv, vsi->netdev, "L4 destination port: %s -> %s\n", in i40e_print_input_set()
4238 netif_info(pf, drv, vsi->netdev, "SCTP verification tag: %s -> %s\n", in i40e_print_input_set()
4249 netif_info(pf, drv, vsi->netdev, "FLEX index %d: %s -> %s\n", in i40e_print_input_set()
4255 netif_info(pf, drv, vsi->netdev, " Current input set: %0llx\n", in i40e_print_input_set()
4257 netif_info(pf, drv, vsi->netdev, "Requested input set: %0llx\n", in i40e_print_input_set()
4262 * i40e_check_fdir_input_set - Check that a given rx_flow_spec mask is valid
4280 * as supported, we print a diagnostic message displaying how the input set
4297 struct i40e_pf *pf = vsi->back; in i40e_check_fdir_input_set()
4306 switch (fsp->flow_type & ~FLOW_EXT) { in i40e_check_fdir_input_set()
4309 fdir_filter_count = &pf->fd_sctp4_filter_cnt; in i40e_check_fdir_input_set()
4313 fdir_filter_count = &pf->fd_tcp4_filter_cnt; in i40e_check_fdir_input_set()
4317 fdir_filter_count = &pf->fd_udp4_filter_cnt; in i40e_check_fdir_input_set()
4321 fdir_filter_count = &pf->fd_sctp6_filter_cnt; in i40e_check_fdir_input_set()
4325 fdir_filter_count = &pf->fd_tcp6_filter_cnt; in i40e_check_fdir_input_set()
4329 fdir_filter_count = &pf->fd_udp6_filter_cnt; in i40e_check_fdir_input_set()
4333 fdir_filter_count = &pf->fd_ip4_filter_cnt; in i40e_check_fdir_input_set()
4338 fdir_filter_count = &pf->fd_ip6_filter_cnt; in i40e_check_fdir_input_set()
4342 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4358 switch (fsp->flow_type & ~FLOW_EXT) { in i40e_check_fdir_input_set()
4364 tcp_ip4_spec = &fsp->m_u.tcp_ip4_spec; in i40e_check_fdir_input_set()
4367 if (tcp_ip4_spec->ip4src == htonl(0xFFFFFFFF)) in i40e_check_fdir_input_set()
4369 else if (!tcp_ip4_spec->ip4src) in i40e_check_fdir_input_set()
4372 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4375 if (tcp_ip4_spec->ip4dst == htonl(0xFFFFFFFF)) in i40e_check_fdir_input_set()
4377 else if (!tcp_ip4_spec->ip4dst) in i40e_check_fdir_input_set()
4380 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4383 if (tcp_ip4_spec->psrc == htons(0xFFFF)) in i40e_check_fdir_input_set()
4385 else if (!tcp_ip4_spec->psrc) in i40e_check_fdir_input_set()
4388 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4391 if (tcp_ip4_spec->pdst == htons(0xFFFF)) in i40e_check_fdir_input_set()
4393 else if (!tcp_ip4_spec->pdst) in i40e_check_fdir_input_set()
4396 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4398 /* Filtering on Type of Service is not supported. */ in i40e_check_fdir_input_set()
4399 if (tcp_ip4_spec->tos) in i40e_check_fdir_input_set()
4400 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4408 tcp_ip6_spec = &fsp->m_u.tcp_ip6_spec; in i40e_check_fdir_input_set()
4411 if (ipv6_addr_equal((struct in6_addr *)&tcp_ip6_spec->ip6src, in i40e_check_fdir_input_set()
4415 &tcp_ip6_spec->ip6src)) in i40e_check_fdir_input_set()
4418 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4421 if (ipv6_addr_equal((struct in6_addr *)&tcp_ip6_spec->ip6dst, in i40e_check_fdir_input_set()
4425 &tcp_ip6_spec->ip6dst)) in i40e_check_fdir_input_set()
4428 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4431 if (tcp_ip6_spec->psrc == htons(0xFFFF)) in i40e_check_fdir_input_set()
4433 else if (!tcp_ip6_spec->psrc) in i40e_check_fdir_input_set()
4436 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4439 if (tcp_ip6_spec->pdst == htons(0xFFFF)) in i40e_check_fdir_input_set()
4441 else if (!tcp_ip6_spec->pdst) in i40e_check_fdir_input_set()
4444 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4446 /* Filtering on Traffic Classes is not supported. */ in i40e_check_fdir_input_set()
4447 if (tcp_ip6_spec->tclass) in i40e_check_fdir_input_set()
4448 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4451 usr_ip4_spec = &fsp->m_u.usr_ip4_spec; in i40e_check_fdir_input_set()
4454 if (usr_ip4_spec->ip4src == htonl(0xFFFFFFFF)) in i40e_check_fdir_input_set()
4456 else if (!usr_ip4_spec->ip4src) in i40e_check_fdir_input_set()
4459 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4462 if (usr_ip4_spec->ip4dst == htonl(0xFFFFFFFF)) in i40e_check_fdir_input_set()
4464 else if (!usr_ip4_spec->ip4dst) in i40e_check_fdir_input_set()
4467 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4470 if (usr_ip4_spec->l4_4_bytes) in i40e_check_fdir_input_set()
4471 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4473 /* Filtering on Type of Service is not supported. */ in i40e_check_fdir_input_set()
4474 if (usr_ip4_spec->tos) in i40e_check_fdir_input_set()
4475 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4477 /* Filtering on IP version is not supported */ in i40e_check_fdir_input_set()
4478 if (usr_ip4_spec->ip_ver) in i40e_check_fdir_input_set()
4479 return -EINVAL; in i40e_check_fdir_input_set()
4481 /* Filtering on L4 protocol is not supported */ in i40e_check_fdir_input_set()
4482 if (usr_ip4_spec->proto) in i40e_check_fdir_input_set()
4483 return -EINVAL; in i40e_check_fdir_input_set()
4487 usr_ip6_spec = &fsp->m_u.usr_ip6_spec; in i40e_check_fdir_input_set()
4490 if (ipv6_addr_equal((struct in6_addr *)&usr_ip6_spec->ip6src, in i40e_check_fdir_input_set()
4494 &usr_ip6_spec->ip6src)) in i40e_check_fdir_input_set()
4497 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4500 if (ipv6_addr_equal((struct in6_addr *)&usr_ip6_spec->ip6dst, in i40e_check_fdir_input_set()
4504 &usr_ip6_spec->ip6dst)) in i40e_check_fdir_input_set()
4507 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4509 if (usr_ip6_spec->l4_4_bytes) in i40e_check_fdir_input_set()
4510 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4512 /* Filtering on Traffic class is not supported. */ in i40e_check_fdir_input_set()
4513 if (usr_ip6_spec->tclass) in i40e_check_fdir_input_set()
4514 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4516 /* Filtering on L4 protocol is not supported */ in i40e_check_fdir_input_set()
4517 if (usr_ip6_spec->l4_proto) in i40e_check_fdir_input_set()
4518 return -EINVAL; in i40e_check_fdir_input_set()
4522 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4525 if (fsp->flow_type & FLOW_EXT) { in i40e_check_fdir_input_set()
4529 if (fsp->h_ext.vlan_etype != htons(ETH_P_8021Q) && in i40e_check_fdir_input_set()
4530 fsp->h_ext.vlan_etype != 0) in i40e_check_fdir_input_set()
4531 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4532 if (fsp->m_ext.vlan_tci == htons(0xFFFF)) in i40e_check_fdir_input_set()
4546 if (userdef->flex_filter) { in i40e_check_fdir_input_set()
4550 * must be aligned on 2-byte boundary. in i40e_check_fdir_input_set()
4552 if (userdef->flex_offset & 0x1) { in i40e_check_fdir_input_set()
4553 dev_warn(&pf->pdev->dev, in i40e_check_fdir_input_set()
4554 "Flexible data offset must be 2-byte aligned\n"); in i40e_check_fdir_input_set()
4555 return -EINVAL; in i40e_check_fdir_input_set()
4558 src_offset = userdef->flex_offset >> 1; in i40e_check_fdir_input_set()
4562 dev_warn(&pf->pdev->dev, in i40e_check_fdir_input_set()
4564 return -EINVAL; in i40e_check_fdir_input_set()
4572 flex_pit = i40e_find_flex_offset(&pf->l4_flex_pit_list, in i40e_check_fdir_input_set()
4586 i40e_find_flex_offset(&pf->l3_flex_pit_list, in i40e_check_fdir_input_set()
4597 if (l3_flex_pit->pit_index != in i40e_check_fdir_input_set()
4598 flex_pit->pit_index) { in i40e_check_fdir_input_set()
4599 return -EINVAL; in i40e_check_fdir_input_set()
4618 pit_index = flex_pit->pit_index; in i40e_check_fdir_input_set()
4632 netif_info(pf, drv, vsi->netdev, "Input set change requested for %s flows:\n", in i40e_check_fdir_input_set()
4636 netif_info(pf, drv, vsi->netdev, "FLEX index %d: Offset -> %d", in i40e_check_fdir_input_set()
4644 if (pf->flags & I40E_FLAG_MFP_ENABLED) { in i40e_check_fdir_input_set()
4645 netif_err(pf, drv, vsi->netdev, "Cannot change Flow Director input sets while MFP is enabled\n"); in i40e_check_fdir_input_set()
4646 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4659 …netif_err(pf, drv, vsi->netdev, "Cannot change input set for %s flows until %d preexisting filters… in i40e_check_fdir_input_set()
4662 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4679 err = i40e_add_flex_offset(&pf->l4_flex_pit_list, src_offset, in i40e_check_fdir_input_set()
4685 err = i40e_add_flex_offset(&pf->l3_flex_pit_list, in i40e_check_fdir_input_set()
4699 * i40e_match_fdir_filter - Return true of two filters match
4705 * check any input-set since all filters of the same flow type must use the
4712 if (a->dst_ip != b->dst_ip || in i40e_match_fdir_filter()
4713 a->src_ip != b->src_ip || in i40e_match_fdir_filter()
4714 a->dst_port != b->dst_port || in i40e_match_fdir_filter()
4715 a->src_port != b->src_port || in i40e_match_fdir_filter()
4716 a->flow_type != b->flow_type || in i40e_match_fdir_filter()
4717 a->ipl4_proto != b->ipl4_proto || in i40e_match_fdir_filter()
4718 a->vlan_tag != b->vlan_tag || in i40e_match_fdir_filter()
4719 a->vlan_etype != b->vlan_etype) in i40e_match_fdir_filter()
4726 * i40e_disallow_matching_filters - Check that new filters differ
4753 struct i40e_pf *pf = vsi->back; in i40e_disallow_matching_filters()
4759 &pf->fdir_filter_list, fdir_node) { in i40e_disallow_matching_filters()
4764 if (rule->fd_id == input->fd_id) in i40e_disallow_matching_filters()
4771 dev_warn(&pf->pdev->dev, in i40e_disallow_matching_filters()
4773 rule->fd_id); in i40e_disallow_matching_filters()
4774 return -EINVAL; in i40e_disallow_matching_filters()
4782 * i40e_add_fdir_ethtool - Add/Remove Flow Director filters
4797 int ret = -EINVAL; in i40e_add_fdir_ethtool()
4801 return -EINVAL; in i40e_add_fdir_ethtool()
4802 pf = vsi->back; in i40e_add_fdir_ethtool()
4804 if (!(pf->flags & I40E_FLAG_FD_SB_ENABLED)) in i40e_add_fdir_ethtool()
4805 return -EOPNOTSUPP; in i40e_add_fdir_ethtool()
4807 if (test_bit(__I40E_FD_SB_AUTO_DISABLED, pf->state)) in i40e_add_fdir_ethtool()
4808 return -ENOSPC; in i40e_add_fdir_ethtool()
4810 if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) || in i40e_add_fdir_ethtool()
4811 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) in i40e_add_fdir_ethtool()
4812 return -EBUSY; in i40e_add_fdir_ethtool()
4814 if (test_bit(__I40E_FD_FLUSH_REQUESTED, pf->state)) in i40e_add_fdir_ethtool()
4815 return -EBUSY; in i40e_add_fdir_ethtool()
4817 fsp = (struct ethtool_rx_flow_spec *)&cmd->fs; in i40e_add_fdir_ethtool()
4819 /* Parse the user-defined field */ in i40e_add_fdir_ethtool()
4821 return -EINVAL; in i40e_add_fdir_ethtool()
4823 /* Extended MAC field is not supported */ in i40e_add_fdir_ethtool()
4824 if (fsp->flow_type & FLOW_MAC_EXT) in i40e_add_fdir_ethtool()
4825 return -EINVAL; in i40e_add_fdir_ethtool()
4831 if (fsp->location >= (pf->hw.func_caps.fd_filters_best_effort + in i40e_add_fdir_ethtool()
4832 pf->hw.func_caps.fd_filters_guaranteed)) { in i40e_add_fdir_ethtool()
4833 return -EINVAL; in i40e_add_fdir_ethtool()
4839 if (fsp->ring_cookie == RX_CLS_FLOW_DISC) { in i40e_add_fdir_ethtool()
4842 u32 ring = ethtool_get_flow_spec_ring(fsp->ring_cookie); in i40e_add_fdir_ethtool()
4843 u8 vf = ethtool_get_flow_spec_ring_vf(fsp->ring_cookie); in i40e_add_fdir_ethtool()
4846 if (ring >= vsi->num_queue_pairs) in i40e_add_fdir_ethtool()
4847 return -EINVAL; in i40e_add_fdir_ethtool()
4848 dest_vsi = vsi->id; in i40e_add_fdir_ethtool()
4850 /* VFs are zero-indexed, so we subtract one here */ in i40e_add_fdir_ethtool()
4851 vf--; in i40e_add_fdir_ethtool()
4853 if (vf >= pf->num_alloc_vfs) in i40e_add_fdir_ethtool()
4854 return -EINVAL; in i40e_add_fdir_ethtool()
4855 if (ring >= pf->vf[vf].num_queue_pairs) in i40e_add_fdir_ethtool()
4856 return -EINVAL; in i40e_add_fdir_ethtool()
4857 dest_vsi = pf->vf[vf].lan_vsi_id; in i40e_add_fdir_ethtool()
4866 return -ENOMEM; in i40e_add_fdir_ethtool()
4868 input->fd_id = fsp->location; in i40e_add_fdir_ethtool()
4869 input->q_index = q_index; in i40e_add_fdir_ethtool()
4870 input->dest_vsi = dest_vsi; in i40e_add_fdir_ethtool()
4871 input->dest_ctl = dest_ctl; in i40e_add_fdir_ethtool()
4872 input->fd_status = I40E_FILTER_PROGRAM_DESC_FD_STATUS_FD_ID; in i40e_add_fdir_ethtool()
4873 input->cnt_index = I40E_FD_SB_STAT_IDX(pf->hw.pf_id); in i40e_add_fdir_ethtool()
4874 input->dst_ip = fsp->h_u.tcp_ip4_spec.ip4src; in i40e_add_fdir_ethtool()
4875 input->src_ip = fsp->h_u.tcp_ip4_spec.ip4dst; in i40e_add_fdir_ethtool()
4876 input->flow_type = fsp->flow_type & ~FLOW_EXT; in i40e_add_fdir_ethtool()
4878 input->vlan_etype = fsp->h_ext.vlan_etype; in i40e_add_fdir_ethtool()
4879 if (!fsp->m_ext.vlan_etype && fsp->h_ext.vlan_tci) in i40e_add_fdir_ethtool()
4880 input->vlan_etype = cpu_to_be16(ETH_P_8021Q); in i40e_add_fdir_ethtool()
4881 if (fsp->m_ext.vlan_tci && input->vlan_etype) in i40e_add_fdir_ethtool()
4882 input->vlan_tag = fsp->h_ext.vlan_tci; in i40e_add_fdir_ethtool()
4883 if (input->flow_type == IPV6_USER_FLOW || in i40e_add_fdir_ethtool()
4884 input->flow_type == UDP_V6_FLOW || in i40e_add_fdir_ethtool()
4885 input->flow_type == TCP_V6_FLOW || in i40e_add_fdir_ethtool()
4886 input->flow_type == SCTP_V6_FLOW) { in i40e_add_fdir_ethtool()
4887 /* Reverse the src and dest notion, since the HW expects them in i40e_add_fdir_ethtool()
4891 input->ipl4_proto = fsp->h_u.usr_ip6_spec.l4_proto; in i40e_add_fdir_ethtool()
4892 input->dst_port = fsp->h_u.tcp_ip6_spec.psrc; in i40e_add_fdir_ethtool()
4893 input->src_port = fsp->h_u.tcp_ip6_spec.pdst; in i40e_add_fdir_ethtool()
4894 memcpy(input->dst_ip6, fsp->h_u.ah_ip6_spec.ip6src, in i40e_add_fdir_ethtool()
4896 memcpy(input->src_ip6, fsp->h_u.ah_ip6_spec.ip6dst, in i40e_add_fdir_ethtool()
4899 /* Reverse the src and dest notion, since the HW expects them in i40e_add_fdir_ethtool()
4903 input->ipl4_proto = fsp->h_u.usr_ip4_spec.proto; in i40e_add_fdir_ethtool()
4904 input->dst_port = fsp->h_u.tcp_ip4_spec.psrc; in i40e_add_fdir_ethtool()
4905 input->src_port = fsp->h_u.tcp_ip4_spec.pdst; in i40e_add_fdir_ethtool()
4906 input->dst_ip = fsp->h_u.tcp_ip4_spec.ip4src; in i40e_add_fdir_ethtool()
4907 input->src_ip = fsp->h_u.tcp_ip4_spec.ip4dst; in i40e_add_fdir_ethtool()
4911 input->flex_filter = true; in i40e_add_fdir_ethtool()
4912 input->flex_word = cpu_to_be16(userdef.flex_word); in i40e_add_fdir_ethtool()
4913 input->flex_offset = userdef.flex_offset; in i40e_add_fdir_ethtool()
4923 * to the list as this would cause a use-after-free bug. in i40e_add_fdir_ethtool()
4925 i40e_update_ethtool_fdir_entry(vsi, input, fsp->location, NULL); in i40e_add_fdir_ethtool()
4932 hlist_del(&input->fdir_node); in i40e_add_fdir_ethtool()
4933 pf->fdir_pf_active_filters--; in i40e_add_fdir_ethtool()
4940 * i40e_set_rxnfc - command to set RX flow classification rules
4944 * Returns Success if the command is supported.
4949 struct i40e_vsi *vsi = np->vsi; in i40e_set_rxnfc()
4950 struct i40e_pf *pf = vsi->back; in i40e_set_rxnfc()
4951 int ret = -EOPNOTSUPP; in i40e_set_rxnfc()
4953 switch (cmd->cmd) { in i40e_set_rxnfc()
4971 * i40e_max_channels - get Max number of combined channels supported
4977 return vsi->alloc_queue_pairs; in i40e_max_channels()
4981 * i40e_get_channels - Get the current channels enabled and max supported etc.
4994 struct i40e_vsi *vsi = np->vsi; in i40e_get_channels()
4995 struct i40e_pf *pf = vsi->back; in i40e_get_channels()
4998 ch->max_combined = i40e_max_channels(vsi); in i40e_get_channels()
5001 ch->other_count = (pf->flags & I40E_FLAG_FD_SB_ENABLED) ? 1 : 0; in i40e_get_channels()
5002 ch->max_other = ch->other_count; in i40e_get_channels()
5005 ch->combined_count = vsi->num_queue_pairs; in i40e_get_channels()
5009 * i40e_set_channels - Set the new channels count.
5021 unsigned int count = ch->combined_count; in i40e_set_channels()
5022 struct i40e_vsi *vsi = np->vsi; in i40e_set_channels()
5023 struct i40e_pf *pf = vsi->back; in i40e_set_channels()
5030 if (vsi->type != I40E_VSI_MAIN) in i40e_set_channels()
5031 return -EINVAL; in i40e_set_channels()
5037 return -EINVAL; in i40e_set_channels()
5040 if (!count || ch->rx_count || ch->tx_count) in i40e_set_channels()
5041 return -EINVAL; in i40e_set_channels()
5044 if (ch->other_count != ((pf->flags & I40E_FLAG_FD_SB_ENABLED) ? 1 : 0)) in i40e_set_channels()
5045 return -EINVAL; in i40e_set_channels()
5049 return -EINVAL; in i40e_set_channels()
5055 &pf->fdir_filter_list, fdir_node) { in i40e_set_channels()
5056 if (rule->dest_ctl != drop && count <= rule->q_index) { in i40e_set_channels()
5057 dev_warn(&pf->pdev->dev, in i40e_set_channels()
5059 rule->fd_id, rule->q_index); in i40e_set_channels()
5060 err = -EINVAL; in i40e_set_channels()
5065 dev_err(&pf->pdev->dev, in i40e_set_channels()
5071 /* update feature limits from largest to smallest supported values */ in i40e_set_channels()
5081 return -EINVAL; in i40e_set_channels()
5085 * i40e_get_rxfh_key_size - get the RSS hash key size
5096 * i40e_get_rxfh_indir_size - get the rx flow hash indirection table size
5107 * i40e_get_rxfh - get the rx flow hash indirection table
5120 struct i40e_vsi *vsi = np->vsi; in i40e_get_rxfh()
5134 return -ENOMEM; in i40e_get_rxfh()
5148 * i40e_set_rxfh - set the rx flow hash indirection table
5154 * Returns -EINVAL if the table specifies an invalid queue id, otherwise
5161 struct i40e_vsi *vsi = np->vsi; in i40e_set_rxfh()
5162 struct i40e_pf *pf = vsi->back; in i40e_set_rxfh()
5167 return -EOPNOTSUPP; in i40e_set_rxfh()
5170 if (!vsi->rss_hkey_user) { in i40e_set_rxfh()
5171 vsi->rss_hkey_user = kzalloc(I40E_HKEY_ARRAY_SIZE, in i40e_set_rxfh()
5173 if (!vsi->rss_hkey_user) in i40e_set_rxfh()
5174 return -ENOMEM; in i40e_set_rxfh()
5176 memcpy(vsi->rss_hkey_user, key, I40E_HKEY_ARRAY_SIZE); in i40e_set_rxfh()
5177 seed = vsi->rss_hkey_user; in i40e_set_rxfh()
5179 if (!vsi->rss_lut_user) { in i40e_set_rxfh()
5180 vsi->rss_lut_user = kzalloc(I40E_HLUT_ARRAY_SIZE, GFP_KERNEL); in i40e_set_rxfh()
5181 if (!vsi->rss_lut_user) in i40e_set_rxfh()
5182 return -ENOMEM; in i40e_set_rxfh()
5188 vsi->rss_lut_user[i] = (u8)(indir[i]); in i40e_set_rxfh()
5190 i40e_fill_rss_lut(pf, vsi->rss_lut_user, I40E_HLUT_ARRAY_SIZE, in i40e_set_rxfh()
5191 vsi->rss_size); in i40e_set_rxfh()
5193 return i40e_config_rss(vsi, seed, vsi->rss_lut_user, in i40e_set_rxfh()
5198 * i40e_get_priv_flags - report device private flags
5210 struct i40e_vsi *vsi = np->vsi; in i40e_get_priv_flags()
5211 struct i40e_pf *pf = vsi->back; in i40e_get_priv_flags()
5219 if (priv_flags->flag & pf->flags) in i40e_get_priv_flags()
5223 if (pf->hw.pf_id != 0) in i40e_get_priv_flags()
5231 if (priv_flags->flag & pf->flags) in i40e_get_priv_flags()
5239 * i40e_set_priv_flags - set private flags
5248 struct i40e_vsi *vsi = np->vsi; in i40e_set_priv_flags()
5249 struct i40e_pf *pf = vsi->back; in i40e_set_priv_flags()
5254 orig_flags = READ_ONCE(pf->flags); in i40e_set_priv_flags()
5263 new_flags |= priv_flags->flag; in i40e_set_priv_flags()
5265 new_flags &= ~(priv_flags->flag); in i40e_set_priv_flags()
5267 /* If this is a read-only flag, it can't be changed */ in i40e_set_priv_flags()
5268 if (priv_flags->read_only && in i40e_set_priv_flags()
5270 return -EOPNOTSUPP; in i40e_set_priv_flags()
5273 if (pf->hw.pf_id != 0) in i40e_set_priv_flags()
5282 new_flags |= priv_flags->flag; in i40e_set_priv_flags()
5284 new_flags &= ~(priv_flags->flag); in i40e_set_priv_flags()
5286 /* If this is a read-only flag, it can't be changed */ in i40e_set_priv_flags()
5287 if (priv_flags->read_only && in i40e_set_priv_flags()
5289 return -EOPNOTSUPP; in i40e_set_priv_flags()
5302 * checks to ensure that the changes are supported and safe. in i40e_set_priv_flags()
5305 /* ATR eviction is not supported on all devices */ in i40e_set_priv_flags()
5307 !(pf->hw_features & I40E_HW_ATR_EVICT_CAPABLE)) in i40e_set_priv_flags()
5308 return -EOPNOTSUPP; in i40e_set_priv_flags()
5312 * - on XL710 if NPAR is enabled or FW API version < 1.7 in i40e_set_priv_flags()
5313 * - on X722 with FW API version < 1.6 in i40e_set_priv_flags()
5319 if (!(pf->hw.flags & I40E_HW_FLAG_FW_LLDP_STOPPABLE)) { in i40e_set_priv_flags()
5320 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5322 return -EOPNOTSUPP; in i40e_set_priv_flags()
5327 pf->hw.device_id != I40E_DEV_ID_25G_SFP28 && in i40e_set_priv_flags()
5328 pf->hw.device_id != I40E_DEV_ID_25G_B) { in i40e_set_priv_flags()
5329 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5331 return -EOPNOTSUPP; in i40e_set_priv_flags()
5335 pf->hw.device_id != I40E_DEV_ID_25G_SFP28 && in i40e_set_priv_flags()
5336 pf->hw.device_id != I40E_DEV_ID_25G_B && in i40e_set_priv_flags()
5337 pf->hw.device_id != I40E_DEV_ID_KX_X722) { in i40e_set_priv_flags()
5338 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5340 return -EOPNOTSUPP; in i40e_set_priv_flags()
5351 set_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state); in i40e_set_priv_flags()
5352 set_bit(__I40E_FD_FLUSH_REQUESTED, pf->state); in i40e_set_priv_flags()
5362 ret = i40e_aq_set_switch_config(&pf->hw, sw_flags, valid_flags, in i40e_set_priv_flags()
5364 if (ret && pf->hw.aq.asq_last_status != I40E_AQ_RC_ESRCH) { in i40e_set_priv_flags()
5365 dev_info(&pf->pdev->dev, in i40e_set_priv_flags()
5368 i40e_aq_str(&pf->hw, in i40e_set_priv_flags()
5369 pf->hw.aq.asq_last_status)); in i40e_set_priv_flags()
5389 dev_warn(&pf->pdev->dev, "Cannot change FEC config\n"); in i40e_set_priv_flags()
5394 dev_err(&pf->pdev->dev, in i40e_set_priv_flags()
5395 …"Setting link-down-on-close not supported on this port (because total-port-shutdown is enabled)\n"… in i40e_set_priv_flags()
5396 return -EOPNOTSUPP; in i40e_set_priv_flags()
5400 pf->num_alloc_vfs) { in i40e_set_priv_flags()
5401 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5402 "Changing vf-vlan-pruning flag while VF(s) are active is not supported\n"); in i40e_set_priv_flags()
5403 return -EOPNOTSUPP; in i40e_set_priv_flags()
5408 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5410 return -EOPNOTSUPP; in i40e_set_priv_flags()
5416 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5417 "Turning on link-down-on-close flag may affect other partitions\n"); in i40e_set_priv_flags()
5424 i40e_aq_cfg_lldp_mib_change_event(&pf->hw, false, NULL); in i40e_set_priv_flags()
5425 i40e_aq_stop_lldp(&pf->hw, true, false, NULL); in i40e_set_priv_flags()
5427 status = i40e_aq_start_lldp(&pf->hw, false, NULL); in i40e_set_priv_flags()
5429 adq_err = pf->hw.aq.asq_last_status; in i40e_set_priv_flags()
5432 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5437 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5439 return -EINVAL; in i40e_set_priv_flags()
5441 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5443 return -EBUSY; in i40e_set_priv_flags()
5445 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5448 i40e_aq_str(&pf->hw, in i40e_set_priv_flags()
5450 return -EINVAL; in i40e_set_priv_flags()
5461 pf->flags = new_flags; in i40e_set_priv_flags()
5473 * i40e_get_module_info - get (Q)SFP+ module type info
5481 struct i40e_vsi *vsi = np->vsi; in i40e_get_module_info()
5482 struct i40e_pf *pf = vsi->back; in i40e_get_module_info()
5483 struct i40e_hw *hw = &pf->hw; in i40e_get_module_info() local
5491 if (!(hw->flags & I40E_HW_FLAG_AQ_PHY_ACCESS_CAPABLE)) { in i40e_get_module_info()
5492 …netdev_err(vsi->netdev, "Module EEPROM memory read not supported. Please update the NVM image.\n"); in i40e_get_module_info()
5493 return -EINVAL; in i40e_get_module_info()
5496 status = i40e_update_link_info(hw); in i40e_get_module_info()
5498 return -EIO; in i40e_get_module_info()
5500 if (hw->phy.link_info.phy_type == I40E_PHY_TYPE_EMPTY) { in i40e_get_module_info()
5501 netdev_err(vsi->netdev, "Cannot read module EEPROM memory. No module connected.\n"); in i40e_get_module_info()
5502 return -EINVAL; in i40e_get_module_info()
5505 type = hw->phy.link_info.module_type[0]; in i40e_get_module_info()
5509 status = i40e_aq_get_phy_register(hw, in i40e_get_module_info()
5515 return -EIO; in i40e_get_module_info()
5517 status = i40e_aq_get_phy_register(hw, in i40e_get_module_info()
5523 return -EIO; in i40e_get_module_info()
5529 netdev_warn(vsi->netdev, "Module address swap to access page 0xA2 is not supported.\n"); in i40e_get_module_info()
5530 modinfo->type = ETH_MODULE_SFF_8079; in i40e_get_module_info()
5531 modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN; in i40e_get_module_info()
5533 /* Module is not SFF-8472 compliant */ in i40e_get_module_info()
5534 modinfo->type = ETH_MODULE_SFF_8079; in i40e_get_module_info()
5535 modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN; in i40e_get_module_info()
5537 /* Module is SFF-8472 compliant but doesn't implement 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 modinfo->type = ETH_MODULE_SFF_8472; in i40e_get_module_info()
5544 modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN; in i40e_get_module_info()
5549 status = i40e_aq_get_phy_register(hw, in i40e_get_module_info()
5555 return -EIO; in i40e_get_module_info()
5558 /* Module is SFF-8636 compliant */ in i40e_get_module_info()
5559 modinfo->type = ETH_MODULE_SFF_8636; in i40e_get_module_info()
5560 modinfo->eeprom_len = I40E_MODULE_QSFP_MAX_LEN; in i40e_get_module_info()
5562 modinfo->type = ETH_MODULE_SFF_8436; in i40e_get_module_info()
5563 modinfo->eeprom_len = I40E_MODULE_QSFP_MAX_LEN; in i40e_get_module_info()
5567 modinfo->type = ETH_MODULE_SFF_8636; in i40e_get_module_info()
5568 modinfo->eeprom_len = I40E_MODULE_QSFP_MAX_LEN; in i40e_get_module_info()
5571 netdev_err(vsi->netdev, "Module type unrecognized\n"); in i40e_get_module_info()
5572 return -EINVAL; in i40e_get_module_info()
5578 * i40e_get_module_eeprom - fills buffer with (Q)SFP+ module memory contents
5588 struct i40e_vsi *vsi = np->vsi; in i40e_get_module_eeprom()
5589 struct i40e_pf *pf = vsi->back; in i40e_get_module_eeprom()
5590 struct i40e_hw *hw = &pf->hw; in i40e_get_module_eeprom() local
5596 if (!ee || !ee->len || !data) in i40e_get_module_eeprom()
5597 return -EINVAL; in i40e_get_module_eeprom()
5599 if (hw->phy.link_info.module_type[0] == I40E_MODULE_TYPE_SFP) in i40e_get_module_eeprom()
5602 for (i = 0; i < ee->len; i++) { in i40e_get_module_eeprom()
5603 u32 offset = i + ee->offset; in i40e_get_module_eeprom()
5609 offset -= ETH_MODULE_SFF_8079_LEN; in i40e_get_module_eeprom()
5615 offset -= ETH_MODULE_SFF_8436_LEN / 2; in i40e_get_module_eeprom()
5620 status = i40e_aq_get_phy_register(hw, in i40e_get_module_eeprom()
5624 return -EIO; in i40e_get_module_eeprom()
5634 struct i40e_vsi *vsi = np->vsi; in i40e_get_eee()
5635 struct i40e_pf *pf = vsi->back; in i40e_get_eee()
5636 struct i40e_hw *hw = &pf->hw; in i40e_get_eee() local
5640 status = i40e_aq_get_phy_capabilities(hw, false, true, &phy_cfg, NULL); in i40e_get_eee()
5642 return -EAGAIN; in i40e_get_eee()
5648 return -EOPNOTSUPP; in i40e_get_eee()
5650 edata->supported = SUPPORTED_Autoneg; in i40e_get_eee()
5651 edata->lp_advertised = edata->supported; in i40e_get_eee()
5654 status = i40e_aq_get_phy_capabilities(hw, false, false, &phy_cfg, NULL); in i40e_get_eee()
5656 return -EAGAIN; in i40e_get_eee()
5658 edata->advertised = phy_cfg.eee_capability ? SUPPORTED_Autoneg : 0U; in i40e_get_eee()
5659 edata->eee_enabled = !!edata->advertised; in i40e_get_eee()
5660 edata->tx_lpi_enabled = pf->stats.tx_lpi_status; in i40e_get_eee()
5662 edata->eee_active = pf->stats.tx_lpi_status && pf->stats.rx_lpi_status; in i40e_get_eee()
5671 struct i40e_vsi *vsi = np->vsi; in i40e_is_eee_param_supported()
5672 struct i40e_pf *pf = vsi->back; in i40e_is_eee_param_supported()
5677 {edata->advertised & ~SUPPORTED_Autoneg, "advertise"}, in i40e_is_eee_param_supported()
5678 {edata->tx_lpi_timer, "tx-timer"}, in i40e_is_eee_param_supported()
5679 {edata->tx_lpi_enabled != pf->stats.tx_lpi_status, "tx-lpi"} in i40e_is_eee_param_supported()
5686 "EEE setting %s not supported\n", in i40e_is_eee_param_supported()
5688 return -EOPNOTSUPP; in i40e_is_eee_param_supported()
5700 struct i40e_vsi *vsi = np->vsi; in i40e_set_eee()
5701 struct i40e_pf *pf = vsi->back; in i40e_set_eee()
5702 struct i40e_hw *hw = &pf->hw; in i40e_set_eee() local
5708 return -EOPNOTSUPP; in i40e_set_eee()
5711 status = i40e_aq_get_phy_capabilities(hw, false, true, &abilities, in i40e_set_eee()
5714 return -EAGAIN; in i40e_set_eee()
5720 return -EOPNOTSUPP; in i40e_set_eee()
5726 status = i40e_aq_get_phy_capabilities(hw, false, false, &abilities, in i40e_set_eee()
5729 return -EAGAIN; in i40e_set_eee()
5743 if (edata->eee_enabled) { in i40e_set_eee()
5752 status = i40e_aq_set_phy_config(hw, &config, NULL); in i40e_set_eee()
5754 return -EAGAIN; in i40e_set_eee()
5822 struct i40e_pf *pf = np->vsi->back; in i40e_set_ethtool_ops()
5824 if (!test_bit(__I40E_RECOVERY_MODE, pf->state)) in i40e_set_ethtool_ops()
5825 netdev->ethtool_ops = &i40e_ethtool_ops; in i40e_set_ethtool_ops()
5827 netdev->ethtool_ops = &i40e_ethtool_recovery_mode_ops; in i40e_set_ethtool_ops()