Lines Matching +full:75 +full:- +full:ec

1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2013 - 2018 Intel Corporation. */
15 * struct i40e_stats - definition for an ethtool statistic
16 * @stat_string: statistic name to display in ethtool -S output
64 I40E_QUEUE_STAT("%s-%u.packets", stats.packets),
65 I40E_QUEUE_STAT("%s-%u.bytes", stats.bytes),
69 * i40e_add_one_ethtool_stat - copy the stat into the supplied buffer
92 p = (char *)pointer + stat->stat_offset; in i40e_add_one_ethtool_stat()
93 switch (stat->sizeof_stat) { in i40e_add_one_ethtool_stat()
108 stat->stat_string); in i40e_add_one_ethtool_stat()
114 * __i40e_add_ethtool_stats - copy stats into the ethtool supplied buffer
138 * i40e_add_ethtool_stats - copy stats into ethtool supplied buffer
154 * i40e_add_queue_stats - copy queue statistics into supplied buffer
178 * non-null before attempting to access its syncp. in i40e_add_queue_stats()
181 start = !ring ? 0 : u64_stats_fetch_begin(&ring->syncp); in i40e_add_queue_stats()
186 } while (ring && u64_stats_fetch_retry(&ring->syncp, start)); in i40e_add_queue_stats()
193 * __i40e_add_stat_strings - copy stat strings into ethtool buffer
217 * i40e_add_stat_strings - copy stat strings into ethtool buffer
314 * The PF_STATs are appended to the netdev stats only when ethtool -S
447 I40E_PRIV_FLAG("total-port-shutdown",
450 I40E_PRIV_FLAG("flow-director-atr", I40E_FLAG_FD_ATR_ENA, 0),
451 I40E_PRIV_FLAG("veb-stats", I40E_FLAG_VEB_STATS_ENA, 0),
452 I40E_PRIV_FLAG("hw-atr-eviction", I40E_FLAG_HW_ATR_EVICT_ENA, 0),
453 I40E_PRIV_FLAG("link-down-on-close",
455 I40E_PRIV_FLAG("legacy-rx", I40E_FLAG_LEGACY_RX_ENA, 0),
456 I40E_PRIV_FLAG("disable-source-pruning",
458 I40E_PRIV_FLAG("disable-fw-lldp", I40E_FLAG_FW_LLDP_DIS, 0),
459 I40E_PRIV_FLAG("rs-fec", I40E_FLAG_RS_FEC, 0),
460 I40E_PRIV_FLAG("base-r-fec", I40E_FLAG_BASE_R_FEC, 0),
461 I40E_PRIV_FLAG("vf-vlan-pruning",
463 I40E_PRIV_FLAG("mdd-auto-reset-vf",
471 I40E_PRIV_FLAG("vf-true-promisc-support",
478 * i40e_partition_setting_complaint - generic complaint for MFP restriction
483 dev_info(&pf->pdev->dev, in i40e_partition_setting_complaint()
488 * i40e_phy_type_to_ethtool - convert the phy_types to ethtool link modes
496 struct i40e_link_status *hw_link_info = &pf->hw.phy.link_info; in i40e_phy_type_to_ethtool()
497 u64 phy_types = pf->hw.phy.phy_types; in i40e_phy_type_to_ethtool()
505 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB) in i40e_phy_type_to_ethtool()
508 if (test_bit(I40E_HW_CAP_100M_SGMII, pf->hw.caps)) { in i40e_phy_type_to_ethtool()
522 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_phy_type_to_ethtool()
529 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_phy_type_to_ethtool()
536 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_2_5GB) in i40e_phy_type_to_ethtool()
543 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_5GB) in i40e_phy_type_to_ethtool()
556 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_40GB) in i40e_phy_type_to_ethtool()
563 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_100MB) in i40e_phy_type_to_ethtool()
570 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB) in i40e_phy_type_to_ethtool()
595 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_20GB) in i40e_phy_type_to_ethtool()
602 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_phy_type_to_ethtool()
607 !test_bit(I40E_HW_CAP_CRT_RETIMER, pf->hw.caps)) { in i40e_phy_type_to_ethtool()
610 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_phy_type_to_ethtool()
615 !test_bit(I40E_HW_CAP_CRT_RETIMER, pf->hw.caps)) { in i40e_phy_type_to_ethtool()
618 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB) in i40e_phy_type_to_ethtool()
626 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_25GB) in i40e_phy_type_to_ethtool()
633 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_25GB) in i40e_phy_type_to_ethtool()
641 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_25GB) in i40e_phy_type_to_ethtool()
649 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_25GB) in i40e_phy_type_to_ethtool()
662 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_25GB) { in i40e_phy_type_to_ethtool()
676 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_phy_type_to_ethtool()
683 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_phy_type_to_ethtool()
690 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_phy_type_to_ethtool()
699 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB) in i40e_phy_type_to_ethtool()
736 * i40e_get_settings_link_up_fec - Get the FEC mode encoding from mask
766 * i40e_get_settings_link_up - Get the Link settings for when link is up
777 struct i40e_link_status *hw_link_info = &hw->phy.link_info; in i40e_get_settings_link_up()
779 u32 link_speed = hw_link_info->link_speed; in i40e_get_settings_link_up()
782 switch (hw_link_info->phy_type) { in i40e_get_settings_link_up()
824 i40e_get_settings_link_up_fec(hw_link_info->req_fec_info, ks); in i40e_get_settings_link_up()
839 if (hw_link_info->module_type[2] & in i40e_get_settings_link_up()
841 hw_link_info->module_type[2] & in i40e_get_settings_link_up()
845 if (hw_link_info->requested_speeds & in i40e_get_settings_link_up()
850 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_get_settings_link_up()
871 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_get_settings_link_up()
874 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_5GB) in i40e_get_settings_link_up()
877 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_2_5GB) in i40e_get_settings_link_up()
880 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB) in i40e_get_settings_link_up()
883 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_100MB) in i40e_get_settings_link_up()
911 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) in i40e_get_settings_link_up()
914 i40e_get_settings_link_up_fec(hw_link_info->req_fec_info, ks); in i40e_get_settings_link_up()
920 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB) in i40e_get_settings_link_up()
923 if (test_bit(I40E_HW_CAP_100M_SGMII, pf->hw.caps)) { in i40e_get_settings_link_up()
926 if (hw_link_info->requested_speeds & in i40e_get_settings_link_up()
955 i40e_get_settings_link_up_fec(hw_link_info->req_fec_info, ks); in i40e_get_settings_link_up()
973 i40e_get_settings_link_up_fec(hw_link_info->req_fec_info, ks); in i40e_get_settings_link_up()
984 i40e_get_settings_link_up_fec(hw_link_info->req_fec_info, ks); in i40e_get_settings_link_up()
995 hw_link_info->phy_type); in i40e_get_settings_link_up()
1009 ks->base.speed = SPEED_40000; in i40e_get_settings_link_up()
1012 ks->base.speed = SPEED_25000; in i40e_get_settings_link_up()
1015 ks->base.speed = SPEED_20000; in i40e_get_settings_link_up()
1018 ks->base.speed = SPEED_10000; in i40e_get_settings_link_up()
1021 ks->base.speed = SPEED_5000; in i40e_get_settings_link_up()
1024 ks->base.speed = SPEED_2500; in i40e_get_settings_link_up()
1027 ks->base.speed = SPEED_1000; in i40e_get_settings_link_up()
1030 ks->base.speed = SPEED_100; in i40e_get_settings_link_up()
1033 ks->base.speed = SPEED_UNKNOWN; in i40e_get_settings_link_up()
1036 ks->base.duplex = DUPLEX_FULL; in i40e_get_settings_link_up()
1040 * i40e_get_settings_link_down - Get the Link settings for when link is down
1057 ks->base.speed = SPEED_UNKNOWN; in i40e_get_settings_link_down()
1058 ks->base.duplex = DUPLEX_UNKNOWN; in i40e_get_settings_link_down()
1062 * i40e_get_link_ksettings - Get Link Speed and Duplex settings
1072 struct i40e_pf *pf = np->vsi->back; in i40e_get_link_ksettings()
1073 struct i40e_hw *hw = &pf->hw; in i40e_get_link_ksettings()
1074 struct i40e_link_status *hw_link_info = &hw->phy.link_info; in i40e_get_link_ksettings()
1075 bool link_up = hw_link_info->link_info & I40E_AQ_LINK_UP; in i40e_get_link_ksettings()
1087 ks->base.autoneg = ((hw_link_info->an_info & I40E_AQ_AN_COMPLETED) ? in i40e_get_link_ksettings()
1091 switch (hw->phy.media_type) { in i40e_get_link_ksettings()
1098 ks->base.port = PORT_NONE; in i40e_get_link_ksettings()
1103 ks->base.port = PORT_TP; in i40e_get_link_ksettings()
1109 ks->base.port = PORT_DA; in i40e_get_link_ksettings()
1114 ks->base.port = PORT_FIBRE; in i40e_get_link_ksettings()
1118 ks->base.port = PORT_OTHER; in i40e_get_link_ksettings()
1126 switch (hw->fc.requested_mode) { in i40e_get_link_ksettings()
1151 * i40e_speed_to_link_speed - Translate decimal speed to i40e_aq_link_speed
1196 ks->link_modes.supported)) { in i40e_speed_to_link_speed()
1215 * i40e_set_link_ksettings - Set Speed and Duplex
1229 struct i40e_pf *pf = np->vsi->back; in i40e_set_link_ksettings()
1231 struct i40e_vsi *vsi = np->vsi; in i40e_set_link_ksettings()
1232 struct i40e_hw *hw = &pf->hw; in i40e_set_link_ksettings()
1243 if (hw->partition_id != 1) { in i40e_set_link_ksettings()
1245 return -EOPNOTSUPP; in i40e_set_link_ksettings()
1247 if (vsi->type != I40E_VSI_MAIN) in i40e_set_link_ksettings()
1248 return -EOPNOTSUPP; in i40e_set_link_ksettings()
1249 if (hw->phy.media_type != I40E_MEDIA_TYPE_BASET && in i40e_set_link_ksettings()
1250 hw->phy.media_type != I40E_MEDIA_TYPE_FIBER && in i40e_set_link_ksettings()
1251 hw->phy.media_type != I40E_MEDIA_TYPE_BACKPLANE && in i40e_set_link_ksettings()
1252 hw->phy.media_type != I40E_MEDIA_TYPE_DA && in i40e_set_link_ksettings()
1253 hw->phy.link_info.link_info & I40E_AQ_LINK_UP) in i40e_set_link_ksettings()
1254 return -EOPNOTSUPP; in i40e_set_link_ksettings()
1255 if (hw->device_id == I40E_DEV_ID_KX_B || in i40e_set_link_ksettings()
1256 hw->device_id == I40E_DEV_ID_KX_C || in i40e_set_link_ksettings()
1257 hw->device_id == I40E_DEV_ID_20G_KR2 || in i40e_set_link_ksettings()
1258 hw->device_id == I40E_DEV_ID_20G_KR2_A || in i40e_set_link_ksettings()
1259 hw->device_id == I40E_DEV_ID_25G_B || in i40e_set_link_ksettings()
1260 hw->device_id == I40E_DEV_ID_KX_X722) { in i40e_set_link_ksettings()
1262 return -EOPNOTSUPP; in i40e_set_link_ksettings()
1285 return -EINVAL; in i40e_set_link_ksettings()
1297 return -EOPNOTSUPP; in i40e_set_link_ksettings()
1300 while (test_and_set_bit(__I40E_CONFIG_BUSY, pf->state)) { in i40e_set_link_ksettings()
1301 timeout--; in i40e_set_link_ksettings()
1303 return -EBUSY; in i40e_set_link_ksettings()
1311 err = -EAGAIN; in i40e_set_link_ksettings()
1324 if (!(hw->phy.link_info.an_info & I40E_AQ_AN_COMPLETED)) { in i40e_set_link_ksettings()
1330 err = -EINVAL; in i40e_set_link_ksettings()
1340 if (hw->phy.link_info.an_info & I40E_AQ_AN_COMPLETED) { in i40e_set_link_ksettings()
1347 hw->phy.media_type != I40E_MEDIA_TYPE_BASET) { in i40e_set_link_ksettings()
1349 err = -EINVAL; in i40e_set_link_ksettings()
1415 err = -EOPNOTSUPP; in i40e_set_link_ksettings()
1424 err = -EOPNOTSUPP; in i40e_set_link_ksettings()
1446 hw->phy.link_info.requested_speeds = config.link_speed; in i40e_set_link_ksettings()
1450 if (hw->phy.link_info.link_info & I40E_AQ_LINK_UP) { in i40e_set_link_ksettings()
1465 libie_aq_str(hw->aq.asq_last_status)); in i40e_set_link_ksettings()
1466 err = -EAGAIN; in i40e_set_link_ksettings()
1475 libie_aq_str(hw->aq.asq_last_status)); in i40e_set_link_ksettings()
1482 clear_bit(__I40E_CONFIG_BUSY, pf->state); in i40e_set_link_ksettings()
1491 struct i40e_pf *pf = np->vsi->back; in i40e_set_fec_cfg()
1492 struct i40e_hw *hw = &pf->hw; in i40e_set_fec_cfg()
1501 err = -EAGAIN; in i40e_set_fec_cfg()
1523 libie_aq_str(hw->aq.asq_last_status)); in i40e_set_fec_cfg()
1524 err = -EAGAIN; in i40e_set_fec_cfg()
1527 i40e_set_fec_in_flags(fec_cfg, pf->flags); in i40e_set_fec_cfg()
1537 libie_aq_str(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()
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()
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 !test_bit(I40E_HW_CAP_X722_FEC_REQUEST, hw->caps)) { 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()
1637 bool link_up = hw->phy.link_info.link_info & I40E_AQ_LINK_UP; in i40e_nway_reset()
1644 libie_aq_str(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()
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()
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()
1711 if (hw->partition_id != 1) { in i40e_set_pauseparam()
1713 return -EOPNOTSUPP; in i40e_set_pauseparam()
1716 if (vsi->type != I40E_VSI_MAIN) 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()
1761 libie_aq_str(hw->aq.asq_last_status)); in i40e_set_pauseparam()
1762 err = -EAGAIN; in i40e_set_pauseparam()
1767 libie_aq_str(hw->aq.asq_last_status)); in i40e_set_pauseparam()
1768 err = -EAGAIN; in i40e_set_pauseparam()
1773 libie_aq_str(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()
1779 msleep(75); 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()
1831 /* Tell ethtool which driver-version-specific regs output we have. in i40e_get_regs()
1838 regs->version = 1; in i40e_get_regs()
1856 struct i40e_hw *hw = &np->vsi->back->hw; in i40e_get_eeprom()
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()
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()
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()
1921 if (ret_val && hw->aq.asq_last_status == LIBIE_AQ_RC_EPERM) { in i40e_get_eeprom()
1922 dev_info(&pf->pdev->dev, in i40e_get_eeprom()
1927 hw->aq.asq_last_status == LIBIE_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()
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()
1954 if (hw->mac.type == I40E_MAC_X722) { in i40e_get_eeprom_len()
1969 struct i40e_hw *hw = &np->vsi->back->hw; in i40e_set_eeprom()
1970 struct i40e_pf *pf = np->vsi->back; in i40e_set_eeprom()
1977 magic = hw->vendor_id | (hw->device_id << 16); in i40e_set_eeprom()
1978 if (eeprom->magic == magic) in i40e_set_eeprom()
1979 errno = -EOPNOTSUPP; in i40e_set_eeprom()
1981 else if (!eeprom->magic || (eeprom->magic >> 16) != hw->device_id) in i40e_set_eeprom()
1982 errno = -EINVAL; in i40e_set_eeprom()
1983 else if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) || in i40e_set_eeprom()
1984 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) in i40e_set_eeprom()
1985 errno = -EBUSY; in i40e_set_eeprom()
1989 if ((errno || ret_val) && (hw->debug_mask & I40E_DEBUG_NVM)) in i40e_set_eeprom()
1990 dev_info(&pf->pdev->dev, in i40e_set_eeprom()
1992 ret_val, hw->aq.asq_last_status, errno, in i40e_set_eeprom()
1993 (u8)(cmd->config & I40E_NVM_MOD_PNT_MASK), in i40e_set_eeprom()
1994 cmd->offset, cmd->data_size); in i40e_set_eeprom()
2003 struct i40e_vsi *vsi = np->vsi; in i40e_get_drvinfo()
2004 struct i40e_pf *pf = vsi->back; in i40e_get_drvinfo()
2006 strscpy(drvinfo->driver, i40e_driver_name, sizeof(drvinfo->driver)); in i40e_get_drvinfo()
2007 i40e_nvm_version_str(&pf->hw, drvinfo->fw_version, in i40e_get_drvinfo()
2008 sizeof(drvinfo->fw_version)); in i40e_get_drvinfo()
2009 strscpy(drvinfo->bus_info, pci_name(pf->pdev), in i40e_get_drvinfo()
2010 sizeof(drvinfo->bus_info)); in i40e_get_drvinfo()
2011 drvinfo->n_priv_flags = I40E_PRIV_FLAGS_STR_LEN; in i40e_get_drvinfo()
2012 if (pf->hw.pf_id == 0) in i40e_get_drvinfo()
2013 drvinfo->n_priv_flags += I40E_GL_PRIV_FLAGS_STR_LEN; in i40e_get_drvinfo()
2018 struct i40e_hw *hw = &pf->hw; in i40e_get_max_num_descriptors()
2020 switch (hw->mac.type) { in i40e_get_max_num_descriptors()
2034 struct i40e_pf *pf = np->vsi->back; in i40e_get_ringparam()
2037 ring->rx_max_pending = i40e_get_max_num_descriptors(pf); in i40e_get_ringparam()
2038 ring->tx_max_pending = i40e_get_max_num_descriptors(pf); in i40e_get_ringparam()
2039 ring->rx_mini_max_pending = 0; in i40e_get_ringparam()
2040 ring->rx_jumbo_max_pending = 0; in i40e_get_ringparam()
2041 ring->rx_pending = vsi->rx_rings[0]->count; in i40e_get_ringparam()
2042 ring->tx_pending = vsi->tx_rings[0]->count; in i40e_get_ringparam()
2043 ring->rx_mini_pending = 0; in i40e_get_ringparam()
2044 ring->rx_jumbo_pending = 0; in i40e_get_ringparam()
2050 return index < vsi->num_queue_pairs || in i40e_active_tx_ring_index()
2051 (index >= vsi->alloc_queue_pairs && in i40e_active_tx_ring_index()
2052 index < vsi->alloc_queue_pairs + vsi->num_queue_pairs); in i40e_active_tx_ring_index()
2055 return index < vsi->num_queue_pairs; in i40e_active_tx_ring_index()
2066 struct i40e_hw *hw = &np->vsi->back->hw; in i40e_set_ringparam()
2067 struct i40e_vsi *vsi = np->vsi; in i40e_set_ringparam()
2068 struct i40e_pf *pf = vsi->back; in i40e_set_ringparam()
2073 if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending)) in i40e_set_ringparam()
2074 return -EINVAL; in i40e_set_ringparam()
2077 if (ring->tx_pending > max_num_descriptors || in i40e_set_ringparam()
2078 ring->tx_pending < I40E_MIN_NUM_DESCRIPTORS || in i40e_set_ringparam()
2079 ring->rx_pending > max_num_descriptors || in i40e_set_ringparam()
2080 ring->rx_pending < I40E_MIN_NUM_DESCRIPTORS) { in i40e_set_ringparam()
2082 "Descriptors requested (Tx: %d / Rx: %d) out of range [%d-%d]\n", in i40e_set_ringparam()
2083 ring->tx_pending, ring->rx_pending, in i40e_set_ringparam()
2085 return -EINVAL; in i40e_set_ringparam()
2088 new_tx_count = ALIGN(ring->tx_pending, I40E_REQ_DESCRIPTOR_MULTIPLE); in i40e_set_ringparam()
2089 new_rx_count = ALIGN(ring->rx_pending, I40E_REQ_DESCRIPTOR_MULTIPLE); in i40e_set_ringparam()
2092 if ((new_tx_count == vsi->tx_rings[0]->count) && in i40e_set_ringparam()
2093 (new_rx_count == vsi->rx_rings[0]->count)) in i40e_set_ringparam()
2097 * disallow changing the number of descriptors -- regardless in i40e_set_ringparam()
2101 return -EBUSY; in i40e_set_ringparam()
2103 while (test_and_set_bit(__I40E_CONFIG_BUSY, pf->state)) { in i40e_set_ringparam()
2104 timeout--; in i40e_set_ringparam()
2106 return -EBUSY; in i40e_set_ringparam()
2110 if (!netif_running(vsi->netdev)) { in i40e_set_ringparam()
2111 /* simple case - set for the next time the netdev is started */ in i40e_set_ringparam()
2112 for (i = 0; i < vsi->num_queue_pairs; i++) { in i40e_set_ringparam()
2113 vsi->tx_rings[i]->count = new_tx_count; in i40e_set_ringparam()
2114 vsi->rx_rings[i]->count = new_rx_count; in i40e_set_ringparam()
2116 vsi->xdp_rings[i]->count = new_tx_count; in i40e_set_ringparam()
2118 vsi->num_tx_desc = new_tx_count; in i40e_set_ringparam()
2119 vsi->num_rx_desc = new_rx_count; in i40e_set_ringparam()
2124 * because the ISRs in MSI-X mode get passed pointers in i40e_set_ringparam()
2129 tx_alloc_queue_pairs = vsi->alloc_queue_pairs * in i40e_set_ringparam()
2131 if (new_tx_count != vsi->tx_rings[0]->count) { in i40e_set_ringparam()
2134 vsi->tx_rings[0]->count, new_tx_count); in i40e_set_ringparam()
2138 err = -ENOMEM; in i40e_set_ringparam()
2146 tx_rings[i] = *vsi->tx_rings[i]; in i40e_set_ringparam()
2156 i--; in i40e_set_ringparam()
2170 if (new_rx_count != vsi->rx_rings[0]->count) { in i40e_set_ringparam()
2173 vsi->rx_rings[0]->count, new_rx_count); in i40e_set_ringparam()
2174 rx_rings = kcalloc(vsi->alloc_queue_pairs, in i40e_set_ringparam()
2177 err = -ENOMEM; in i40e_set_ringparam()
2181 for (i = 0; i < vsi->num_queue_pairs; i++) { in i40e_set_ringparam()
2185 rx_rings[i] = *vsi->rx_rings[i]; in i40e_set_ringparam()
2192 /* Clear cloned XDP RX-queue info before setup call */ in i40e_set_ringparam()
2197 rx_rings[i].tail = hw->hw_addr + I40E_PRTGEN_STATUS; in i40e_set_ringparam()
2211 } while (i--); in i40e_set_ringparam()
2228 i40e_free_tx_resources(vsi->tx_rings[i]); in i40e_set_ringparam()
2229 *vsi->tx_rings[i] = tx_rings[i]; in i40e_set_ringparam()
2237 for (i = 0; i < vsi->num_queue_pairs; i++) { in i40e_set_ringparam()
2238 i40e_free_rx_resources(vsi->rx_rings[i]); in i40e_set_ringparam()
2240 rx_rings[i].tail = vsi->rx_rings[i]->tail; in i40e_set_ringparam()
2243 * but the recycling logic will let us re-use in i40e_set_ringparam()
2250 *vsi->rx_rings[i] = rx_rings[i]; in i40e_set_ringparam()
2256 vsi->num_tx_desc = new_tx_count; in i40e_set_ringparam()
2257 vsi->num_rx_desc = new_rx_count; in i40e_set_ringparam()
2265 i40e_free_tx_resources(vsi->tx_rings[i]); in i40e_set_ringparam()
2272 clear_bit(__I40E_CONFIG_BUSY, pf->state); in i40e_set_ringparam()
2278 * i40e_get_stats_count - return the stats count for a device
2285 * obtaining stats is *not* safe against changes based on non-static
2294 struct i40e_vsi *vsi = np->vsi; in i40e_get_stats_count()
2295 struct i40e_pf *pf = vsi->back; in i40e_get_stats_count()
2298 if (vsi->type == I40E_VSI_MAIN && pf->hw.partition_id == 1) in i40e_get_stats_count()
2313 * queues in pairs, we'll just use netdev->num_tx_queues * 2. This in i40e_get_stats_count()
2317 stats_len += I40E_QUEUE_STATS_LEN * 2 * netdev->num_tx_queues; in i40e_get_stats_count()
2325 struct i40e_vsi *vsi = np->vsi; in i40e_get_sset_count()
2326 struct i40e_pf *pf = vsi->back; in i40e_get_sset_count()
2335 (pf->hw.pf_id == 0 ? I40E_GL_PRIV_FLAGS_STR_LEN : 0); in i40e_get_sset_count()
2337 return -EOPNOTSUPP; in i40e_get_sset_count()
2342 * i40e_get_veb_tc_stats - copy VEB TC statistics to formatted structure
2343 * @tc: the TC statistics in VEB structure (veb->tc_stats)
2344 * @i: the index of traffic class in (veb->tc_stats) structure to copy
2346 * Copy VEB TC statistics from structure of arrays (veb->tc_stats) to
2355 .tc_rx_packets = tc->tc_rx_packets[i], in i40e_get_veb_tc_stats()
2356 .tc_rx_bytes = tc->tc_rx_bytes[i], in i40e_get_veb_tc_stats()
2357 .tc_tx_packets = tc->tc_tx_packets[i], in i40e_get_veb_tc_stats()
2358 .tc_tx_bytes = tc->tc_tx_bytes[i], in i40e_get_veb_tc_stats()
2365 * i40e_get_pfc_stats - copy HW PFC statistics to formatted structure
2369 * The PFC stats are found as arrays in pf->stats, which is not easy to pass
2377 .stat = pf->stats.stat[priority] in i40e_get_pfc_stats()
2390 * i40e_get_ethtool_stats - copy stat values into supplied buffer
2396 * pre-allocated to the size returned by i40e_get_stats_count.. Note that all
2407 struct i40e_vsi *vsi = np->vsi; in i40e_get_ethtool_stats()
2408 struct i40e_pf *pf = vsi->back; in i40e_get_ethtool_stats()
2422 for (i = 0; i < netdev->num_tx_queues; i++) { in i40e_get_ethtool_stats()
2423 i40e_add_queue_stats(&data, READ_ONCE(vsi->tx_rings[i])); in i40e_get_ethtool_stats()
2424 i40e_add_queue_stats(&data, READ_ONCE(vsi->rx_rings[i])); in i40e_get_ethtool_stats()
2428 if (vsi->type != I40E_VSI_MAIN || pf->hw.partition_id != 1) in i40e_get_ethtool_stats()
2432 veb_stats = veb && test_bit(I40E_FLAG_VEB_STATS_ENA, pf->flags); in i40e_get_ethtool_stats()
2447 i40e_get_veb_tc_stats(&veb->tc_stats, i); in i40e_get_ethtool_stats()
2465 WARN_ONCE(data - p != i40e_get_stats_count(netdev), in i40e_get_ethtool_stats()
2470 * i40e_get_stat_strings - copy stat strings into supplied buffer
2475 * pre-allocated with the size reported by i40e_get_stats_count. Note that the
2482 struct i40e_vsi *vsi = np->vsi; in i40e_get_stat_strings()
2483 struct i40e_pf *pf = vsi->back; in i40e_get_stat_strings()
2491 for (i = 0; i < netdev->num_tx_queues; i++) { in i40e_get_stat_strings()
2498 if (vsi->type != I40E_VSI_MAIN || pf->hw.partition_id != 1) in i40e_get_stat_strings()
2512 WARN_ONCE(data - p != i40e_get_stats_count(netdev) * ETH_GSTRING_LEN, in i40e_get_stat_strings()
2519 struct i40e_vsi *vsi = np->vsi; in i40e_get_priv_flag_strings()
2520 struct i40e_pf *pf = vsi->back; in i40e_get_priv_flag_strings()
2526 if (pf->hw.pf_id != 0) in i40e_get_priv_flag_strings()
2557 if (!test_bit(I40E_FLAG_PTP_ENA, pf->flags)) in i40e_get_ts_info()
2560 info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE | in i40e_get_ts_info()
2565 if (pf->ptp_clock) in i40e_get_ts_info()
2566 info->phc_index = ptp_clock_index(pf->ptp_clock); in i40e_get_ts_info()
2568 info->tx_types = BIT(HWTSTAMP_TX_OFF) | BIT(HWTSTAMP_TX_ON); in i40e_get_ts_info()
2570 info->rx_filters = BIT(HWTSTAMP_FILTER_NONE) | in i40e_get_ts_info()
2575 if (test_bit(I40E_HW_CAP_PTP_L4, pf->hw.caps)) in i40e_get_ts_info()
2576 info->rx_filters |= BIT(HWTSTAMP_FILTER_PTP_V1_L4_SYNC) | in i40e_get_ts_info()
2591 struct i40e_pf *pf = np->vsi->back; in i40e_link_test()
2596 status = i40e_get_link_status(&pf->hw, &link_up); in i40e_link_test()
2614 struct i40e_pf *pf = np->vsi->back; in i40e_reg_test()
2617 *data = i40e_diag_reg_test(&pf->hw); in i40e_reg_test()
2625 struct i40e_pf *pf = np->vsi->back; in i40e_eeprom_test()
2628 *data = i40e_diag_eeprom_test(&pf->hw); in i40e_eeprom_test()
2631 pf->hw.nvmupd_state = I40E_NVMUPD_STATE_INIT; in i40e_eeprom_test()
2639 struct i40e_pf *pf = np->vsi->back; in i40e_intr_test()
2640 u16 swc_old = pf->sw_int_count; in i40e_intr_test()
2643 wr32(&pf->hw, I40E_PFINT_DYN_CTL0, in i40e_intr_test()
2650 *data = (swc_old == pf->sw_int_count); in i40e_intr_test()
2657 struct i40e_vf *vfs = pf->vf; in i40e_active_vfs()
2660 for (i = 0; i < pf->num_alloc_vfs; i++) in i40e_active_vfs()
2676 struct i40e_pf *pf = np->vsi->back; in i40e_diag_test()
2678 if (eth_test->flags == ETH_TEST_FL_OFFLINE) { in i40e_diag_test()
2682 set_bit(__I40E_TESTING, pf->state); in i40e_diag_test()
2684 if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) || in i40e_diag_test()
2685 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) { in i40e_diag_test()
2686 dev_warn(&pf->pdev->dev, in i40e_diag_test()
2692 dev_warn(&pf->pdev->dev, in i40e_diag_test()
2702 /* This reset does not affect link - if it is in i40e_diag_test()
2710 eth_test->flags |= ETH_TEST_FL_FAILED; in i40e_diag_test()
2713 eth_test->flags |= ETH_TEST_FL_FAILED; in i40e_diag_test()
2716 eth_test->flags |= ETH_TEST_FL_FAILED; in i40e_diag_test()
2720 eth_test->flags |= ETH_TEST_FL_FAILED; in i40e_diag_test()
2722 clear_bit(__I40E_TESTING, pf->state); in i40e_diag_test()
2732 eth_test->flags |= ETH_TEST_FL_FAILED; in i40e_diag_test()
2748 eth_test->flags |= ETH_TEST_FL_FAILED; in i40e_diag_test()
2749 clear_bit(__I40E_TESTING, pf->state); in i40e_diag_test()
2757 struct i40e_pf *pf = np->vsi->back; in i40e_get_link_ext_stats()
2759 stats->link_down_events = pf->link_down_events; in i40e_get_link_ext_stats()
2766 struct i40e_pf *pf = np->vsi->back; in i40e_get_wol()
2767 struct i40e_hw *hw = &pf->hw; in i40e_get_wol()
2772 if ((BIT(hw->port) & wol_nvm_bits) || (hw->partition_id != 1)) { in i40e_get_wol()
2773 wol->supported = 0; in i40e_get_wol()
2774 wol->wolopts = 0; in i40e_get_wol()
2776 wol->supported = WAKE_MAGIC; in i40e_get_wol()
2777 wol->wolopts = (pf->wol_en ? WAKE_MAGIC : 0); in i40e_get_wol()
2782 * i40e_set_wol - set the WakeOnLAN configuration
2789 struct i40e_pf *pf = np->vsi->back; in i40e_set_wol()
2790 struct i40e_vsi *vsi = np->vsi; in i40e_set_wol()
2791 struct i40e_hw *hw = &pf->hw; in i40e_set_wol()
2795 if (hw->partition_id != 1) { in i40e_set_wol()
2797 return -EOPNOTSUPP; in i40e_set_wol()
2800 if (vsi->type != I40E_VSI_MAIN) in i40e_set_wol()
2801 return -EOPNOTSUPP; in i40e_set_wol()
2805 if (BIT(hw->port) & wol_nvm_bits) in i40e_set_wol()
2806 return -EOPNOTSUPP; in i40e_set_wol()
2809 if (wol->wolopts & ~WAKE_MAGIC) in i40e_set_wol()
2810 return -EOPNOTSUPP; in i40e_set_wol()
2813 if (pf->wol_en != !!wol->wolopts) { in i40e_set_wol()
2814 pf->wol_en = !!wol->wolopts; in i40e_set_wol()
2815 device_set_wakeup_enable(&pf->pdev->dev, pf->wol_en); in i40e_set_wol()
2825 struct i40e_pf *pf = np->vsi->back; in i40e_set_phys_id()
2826 struct i40e_hw *hw = &pf->hw; in i40e_set_phys_id()
2833 if (!test_bit(I40E_HW_CAP_PHY_CONTROLS_LEDS, pf->hw.caps)) { in i40e_set_phys_id()
2834 pf->led_status = i40e_led_get(hw); in i40e_set_phys_id()
2836 if (!test_bit(I40E_HW_CAP_AQ_PHY_ACCESS, hw->caps)) in i40e_set_phys_id()
2840 &pf->phy_led_val); in i40e_set_phys_id()
2841 pf->led_status = temp_status; in i40e_set_phys_id()
2845 if (!test_bit(I40E_HW_CAP_PHY_CONTROLS_LEDS, pf->hw.caps)) in i40e_set_phys_id()
2848 ret = i40e_led_set_phy(hw, true, pf->led_status, 0); in i40e_set_phys_id()
2851 if (!test_bit(I40E_HW_CAP_PHY_CONTROLS_LEDS, pf->hw.caps)) in i40e_set_phys_id()
2854 ret = i40e_led_set_phy(hw, false, pf->led_status, 0); in i40e_set_phys_id()
2857 if (!test_bit(I40E_HW_CAP_PHY_CONTROLS_LEDS, pf->hw.caps)) { in i40e_set_phys_id()
2858 i40e_led_set(hw, pf->led_status, false); in i40e_set_phys_id()
2860 ret = i40e_led_set_phy(hw, false, pf->led_status, in i40e_set_phys_id()
2861 (pf->phy_led_val | in i40e_set_phys_id()
2863 if (!test_bit(I40E_HW_CAP_AQ_PHY_ACCESS, hw->caps)) in i40e_set_phys_id()
2871 return -ENOENT; in i40e_set_phys_id()
2882 * __i40e_get_coalesce - get per-queue coalesce settings
2884 * @ec: ethtool coalesce data structure
2887 * Gets the per-queue settings for coalescence. Specifically Rx and Tx usecs
2892 struct ethtool_coalesce *ec, in __i40e_get_coalesce() argument
2897 struct i40e_vsi *vsi = np->vsi; in __i40e_get_coalesce()
2899 ec->tx_max_coalesced_frames_irq = vsi->work_limit; in __i40e_get_coalesce()
2906 else if (queue >= vsi->num_queue_pairs) in __i40e_get_coalesce()
2907 return -EINVAL; in __i40e_get_coalesce()
2909 rx_ring = vsi->rx_rings[queue]; in __i40e_get_coalesce()
2910 tx_ring = vsi->tx_rings[queue]; in __i40e_get_coalesce()
2912 if (ITR_IS_DYNAMIC(rx_ring->itr_setting)) in __i40e_get_coalesce()
2913 ec->use_adaptive_rx_coalesce = 1; in __i40e_get_coalesce()
2915 if (ITR_IS_DYNAMIC(tx_ring->itr_setting)) in __i40e_get_coalesce()
2916 ec->use_adaptive_tx_coalesce = 1; in __i40e_get_coalesce()
2918 ec->rx_coalesce_usecs = rx_ring->itr_setting & ~I40E_ITR_DYNAMIC; in __i40e_get_coalesce()
2919 ec->tx_coalesce_usecs = tx_ring->itr_setting & ~I40E_ITR_DYNAMIC; in __i40e_get_coalesce()
2927 ec->rx_coalesce_usecs_high = vsi->int_rate_limit; in __i40e_get_coalesce()
2928 ec->tx_coalesce_usecs_high = vsi->int_rate_limit; in __i40e_get_coalesce()
2934 * i40e_get_coalesce - get a netdev's coalesce settings
2936 * @ec: ethtool coalesce data structure
2941 * modified per-queue settings, this only guarantees to represent queue 0. See
2945 struct ethtool_coalesce *ec, in i40e_get_coalesce() argument
2949 return __i40e_get_coalesce(netdev, ec, -1); in i40e_get_coalesce()
2953 * i40e_get_per_queue_coalesce - gets coalesce settings for particular queue
2955 * @ec: ethtool's coalesce settings
2961 struct ethtool_coalesce *ec) in i40e_get_per_queue_coalesce() argument
2963 return __i40e_get_coalesce(netdev, ec, queue); in i40e_get_per_queue_coalesce()
2967 * i40e_set_itr_per_queue - set ITR values for specific queue
2969 * @ec: coalesce settings from ethtool
2975 struct ethtool_coalesce *ec, in i40e_set_itr_per_queue() argument
2978 struct i40e_ring *rx_ring = vsi->rx_rings[queue]; in i40e_set_itr_per_queue()
2979 struct i40e_ring *tx_ring = vsi->tx_rings[queue]; in i40e_set_itr_per_queue()
2980 struct i40e_pf *pf = vsi->back; in i40e_set_itr_per_queue()
2981 struct i40e_hw *hw = &pf->hw; in i40e_set_itr_per_queue()
2985 intrl = i40e_intrl_usec_to_reg(vsi->int_rate_limit); in i40e_set_itr_per_queue()
2987 rx_ring->itr_setting = ITR_REG_ALIGN(ec->rx_coalesce_usecs); in i40e_set_itr_per_queue()
2988 tx_ring->itr_setting = ITR_REG_ALIGN(ec->tx_coalesce_usecs); in i40e_set_itr_per_queue()
2990 if (ec->use_adaptive_rx_coalesce) in i40e_set_itr_per_queue()
2991 rx_ring->itr_setting |= I40E_ITR_DYNAMIC; in i40e_set_itr_per_queue()
2993 rx_ring->itr_setting &= ~I40E_ITR_DYNAMIC; in i40e_set_itr_per_queue()
2995 if (ec->use_adaptive_tx_coalesce) in i40e_set_itr_per_queue()
2996 tx_ring->itr_setting |= I40E_ITR_DYNAMIC; in i40e_set_itr_per_queue()
2998 tx_ring->itr_setting &= ~I40E_ITR_DYNAMIC; in i40e_set_itr_per_queue()
3000 q_vector = rx_ring->q_vector; in i40e_set_itr_per_queue()
3001 q_vector->rx.target_itr = ITR_TO_REG(rx_ring->itr_setting); in i40e_set_itr_per_queue()
3003 q_vector = tx_ring->q_vector; in i40e_set_itr_per_queue()
3004 q_vector->tx.target_itr = ITR_TO_REG(tx_ring->itr_setting); in i40e_set_itr_per_queue()
3011 wr32(hw, I40E_PFINT_RATEN(q_vector->reg_idx), intrl); in i40e_set_itr_per_queue()
3016 * __i40e_set_coalesce - set coalesce settings for particular queue
3018 * @ec: ethtool coalesce settings
3024 struct ethtool_coalesce *ec, in __i40e_set_coalesce() argument
3029 struct i40e_vsi *vsi = np->vsi; in __i40e_set_coalesce()
3030 struct i40e_pf *pf = vsi->back; in __i40e_set_coalesce()
3033 if (ec->tx_max_coalesced_frames_irq) in __i40e_set_coalesce()
3034 vsi->work_limit = ec->tx_max_coalesced_frames_irq; in __i40e_set_coalesce()
3037 cur_rx_itr = vsi->rx_rings[0]->itr_setting; in __i40e_set_coalesce()
3038 cur_tx_itr = vsi->tx_rings[0]->itr_setting; in __i40e_set_coalesce()
3039 } else if (queue < vsi->num_queue_pairs) { in __i40e_set_coalesce()
3040 cur_rx_itr = vsi->rx_rings[queue]->itr_setting; in __i40e_set_coalesce()
3041 cur_tx_itr = vsi->tx_rings[queue]->itr_setting; in __i40e_set_coalesce()
3043 netif_info(pf, drv, netdev, "Invalid queue value, queue range is 0 - %d\n", in __i40e_set_coalesce()
3044 vsi->num_queue_pairs - 1); in __i40e_set_coalesce()
3045 return -EINVAL; in __i40e_set_coalesce()
3051 /* tx_coalesce_usecs_high is ignored, use rx-usecs-high instead */ in __i40e_set_coalesce()
3052 if (ec->tx_coalesce_usecs_high != vsi->int_rate_limit) { in __i40e_set_coalesce()
3053 netif_info(pf, drv, netdev, "tx-usecs-high is not used, please program rx-usecs-high\n"); in __i40e_set_coalesce()
3054 return -EINVAL; in __i40e_set_coalesce()
3057 if (ec->rx_coalesce_usecs_high > INTRL_REG_TO_USEC(I40E_MAX_INTRL)) { in __i40e_set_coalesce()
3058 netif_info(pf, drv, netdev, "Invalid value, rx-usecs-high range is 0-%lu\n", in __i40e_set_coalesce()
3060 return -EINVAL; in __i40e_set_coalesce()
3063 if (ec->rx_coalesce_usecs != cur_rx_itr && in __i40e_set_coalesce()
3064 ec->use_adaptive_rx_coalesce) { in __i40e_set_coalesce()
3065 …netif_info(pf, drv, netdev, "RX interrupt moderation cannot be changed if adaptive-rx is enabled.\… in __i40e_set_coalesce()
3066 return -EINVAL; in __i40e_set_coalesce()
3069 if (ec->rx_coalesce_usecs > I40E_MAX_ITR) { in __i40e_set_coalesce()
3070 netif_info(pf, drv, netdev, "Invalid value, rx-usecs range is 0-8160\n"); in __i40e_set_coalesce()
3071 return -EINVAL; in __i40e_set_coalesce()
3074 if (ec->tx_coalesce_usecs != cur_tx_itr && in __i40e_set_coalesce()
3075 ec->use_adaptive_tx_coalesce) { in __i40e_set_coalesce()
3076 …netif_info(pf, drv, netdev, "TX interrupt moderation cannot be changed if adaptive-tx is enabled.\… in __i40e_set_coalesce()
3077 return -EINVAL; in __i40e_set_coalesce()
3080 if (ec->tx_coalesce_usecs > I40E_MAX_ITR) { in __i40e_set_coalesce()
3081 netif_info(pf, drv, netdev, "Invalid value, tx-usecs range is 0-8160\n"); in __i40e_set_coalesce()
3082 return -EINVAL; in __i40e_set_coalesce()
3085 if (ec->use_adaptive_rx_coalesce && !cur_rx_itr) in __i40e_set_coalesce()
3086 ec->rx_coalesce_usecs = I40E_MIN_ITR; in __i40e_set_coalesce()
3088 if (ec->use_adaptive_tx_coalesce && !cur_tx_itr) in __i40e_set_coalesce()
3089 ec->tx_coalesce_usecs = I40E_MIN_ITR; in __i40e_set_coalesce()
3091 intrl_reg = i40e_intrl_usec_to_reg(ec->rx_coalesce_usecs_high); in __i40e_set_coalesce()
3092 vsi->int_rate_limit = INTRL_REG_TO_USEC(intrl_reg); in __i40e_set_coalesce()
3093 if (vsi->int_rate_limit != ec->rx_coalesce_usecs_high) { in __i40e_set_coalesce()
3095 vsi->int_rate_limit); in __i40e_set_coalesce()
3102 for (i = 0; i < vsi->num_queue_pairs; i++) in __i40e_set_coalesce()
3103 i40e_set_itr_per_queue(vsi, ec, i); in __i40e_set_coalesce()
3105 i40e_set_itr_per_queue(vsi, ec, queue); in __i40e_set_coalesce()
3112 * i40e_set_coalesce - set coalesce settings for every queue on the netdev
3114 * @ec: ethtool coalesce settings
3121 struct ethtool_coalesce *ec, in i40e_set_coalesce() argument
3125 return __i40e_set_coalesce(netdev, ec, -1); in i40e_set_coalesce()
3129 * i40e_set_per_queue_coalesce - set specific queue's coalesce settings
3131 * @ec: ethtool's coalesce settings
3137 struct ethtool_coalesce *ec) in i40e_set_per_queue_coalesce() argument
3139 return __i40e_set_coalesce(netdev, ec, queue); in i40e_set_per_queue_coalesce()
3146 struct i40e_vsi *vsi = np->vsi; in i40e_get_rxfh_fields()
3147 struct i40e_pf *pf = vsi->back; in i40e_get_rxfh_fields()
3148 struct i40e_hw *hw = &pf->hw; in i40e_get_rxfh_fields()
3152 cmd->data = 0; in i40e_get_rxfh_fields()
3154 switch (cmd->flow_type) { in i40e_get_rxfh_fields()
3178 cmd->data |= RXH_IP_SRC | RXH_IP_DST; in i40e_get_rxfh_fields()
3181 return -EINVAL; in i40e_get_rxfh_fields()
3195 cmd->data |= RXH_L4_B_0_1; in i40e_get_rxfh_fields()
3197 cmd->data |= RXH_L4_B_2_3; in i40e_get_rxfh_fields()
3199 if (cmd->flow_type == TCP_V4_FLOW || in i40e_get_rxfh_fields()
3200 cmd->flow_type == UDP_V4_FLOW) { in i40e_get_rxfh_fields()
3201 if (hw->mac.type == I40E_MAC_X722) { in i40e_get_rxfh_fields()
3203 cmd->data |= RXH_IP_SRC; in i40e_get_rxfh_fields()
3205 cmd->data |= RXH_IP_DST; in i40e_get_rxfh_fields()
3208 cmd->data |= RXH_IP_SRC; in i40e_get_rxfh_fields()
3210 cmd->data |= RXH_IP_DST; in i40e_get_rxfh_fields()
3212 } else if (cmd->flow_type == TCP_V6_FLOW || in i40e_get_rxfh_fields()
3213 cmd->flow_type == UDP_V6_FLOW) { in i40e_get_rxfh_fields()
3215 cmd->data |= RXH_IP_SRC; in i40e_get_rxfh_fields()
3217 cmd->data |= RXH_IP_DST; in i40e_get_rxfh_fields()
3225 * i40e_check_mask - Check whether a mask field is set
3241 return -1; in i40e_check_mask()
3245 * i40e_parse_rx_flow_user_data - Deconstruct user-defined data
3249 * Read the user-defined data and deconstruct the value into a structure. No
3250 * other code should read the user-defined data, so as to ensure that every
3253 * The user-defined field is a 64bit Big Endian format value, which we
3258 * Returns 0 if the data is valid, and non-zero if the userdef data is invalid
3272 if (!(fsp->flow_type & FLOW_EXT)) in i40e_parse_rx_flow_user_data()
3275 value = be64_to_cpu(*((__be64 *)fsp->h_ext.data)); in i40e_parse_rx_flow_user_data()
3276 mask = be64_to_cpu(*((__be64 *)fsp->m_ext.data)); in i40e_parse_rx_flow_user_data()
3284 return -EINVAL; in i40e_parse_rx_flow_user_data()
3286 data->flex_word = value & I40E_USERDEF_FLEX_WORD; in i40e_parse_rx_flow_user_data()
3287 data->flex_offset = in i40e_parse_rx_flow_user_data()
3289 data->flex_filter = true; in i40e_parse_rx_flow_user_data()
3296 * i40e_fill_rx_flow_user_data - Fill in user-defined data field
3308 if (data->flex_filter) { in i40e_fill_rx_flow_user_data()
3309 value |= data->flex_word; in i40e_fill_rx_flow_user_data()
3310 value |= (u64)data->flex_offset << 16; in i40e_fill_rx_flow_user_data()
3315 fsp->flow_type |= FLOW_EXT; in i40e_fill_rx_flow_user_data()
3317 *((__be64 *)fsp->h_ext.data) = cpu_to_be64(value); in i40e_fill_rx_flow_user_data()
3318 *((__be64 *)fsp->m_ext.data) = cpu_to_be64(mask); in i40e_fill_rx_flow_user_data()
3322 * i40e_get_ethtool_fdir_all - Populates the rule count of a command
3330 * Returns 0 on success or -EMSGSIZE if entry not found
3341 cmd->data = i40e_get_fd_cnt_all(pf); in i40e_get_ethtool_fdir_all()
3344 &pf->fdir_filter_list, fdir_node) { in i40e_get_ethtool_fdir_all()
3345 if (cnt == cmd->rule_cnt) in i40e_get_ethtool_fdir_all()
3346 return -EMSGSIZE; in i40e_get_ethtool_fdir_all()
3348 rule_locs[cnt] = rule->fd_id; in i40e_get_ethtool_fdir_all()
3352 cmd->rule_cnt = cnt; in i40e_get_ethtool_fdir_all()
3358 * i40e_get_ethtool_fdir_entry - Look up a filter based on Rx flow
3365 * Returns 0 on success or -EINVAL if filter not found
3371 (struct ethtool_rx_flow_spec *)&cmd->fs; in i40e_get_ethtool_fdir_entry()
3380 &pf->fdir_filter_list, fdir_node) { in i40e_get_ethtool_fdir_entry()
3381 if (fsp->location <= rule->fd_id) in i40e_get_ethtool_fdir_entry()
3385 if (!rule || fsp->location != rule->fd_id) in i40e_get_ethtool_fdir_entry()
3386 return -EINVAL; in i40e_get_ethtool_fdir_entry()
3388 fsp->flow_type = rule->flow_type; in i40e_get_ethtool_fdir_entry()
3389 if (fsp->flow_type == IP_USER_FLOW) { in i40e_get_ethtool_fdir_entry()
3390 fsp->h_u.usr_ip4_spec.ip_ver = ETH_RX_NFC_IP4; in i40e_get_ethtool_fdir_entry()
3391 fsp->h_u.usr_ip4_spec.proto = 0; in i40e_get_ethtool_fdir_entry()
3392 fsp->m_u.usr_ip4_spec.proto = 0; in i40e_get_ethtool_fdir_entry()
3395 if (fsp->flow_type == IPV6_USER_FLOW || in i40e_get_ethtool_fdir_entry()
3396 fsp->flow_type == UDP_V6_FLOW || in i40e_get_ethtool_fdir_entry()
3397 fsp->flow_type == TCP_V6_FLOW || in i40e_get_ethtool_fdir_entry()
3398 fsp->flow_type == SCTP_V6_FLOW) { in i40e_get_ethtool_fdir_entry()
3403 fsp->h_u.tcp_ip6_spec.psrc = rule->dst_port; in i40e_get_ethtool_fdir_entry()
3404 fsp->h_u.tcp_ip6_spec.pdst = rule->src_port; in i40e_get_ethtool_fdir_entry()
3405 memcpy(fsp->h_u.tcp_ip6_spec.ip6dst, rule->src_ip6, in i40e_get_ethtool_fdir_entry()
3407 memcpy(fsp->h_u.tcp_ip6_spec.ip6src, rule->dst_ip6, in i40e_get_ethtool_fdir_entry()
3414 fsp->h_u.tcp_ip4_spec.psrc = rule->dst_port; in i40e_get_ethtool_fdir_entry()
3415 fsp->h_u.tcp_ip4_spec.pdst = rule->src_port; in i40e_get_ethtool_fdir_entry()
3416 fsp->h_u.tcp_ip4_spec.ip4src = rule->dst_ip; in i40e_get_ethtool_fdir_entry()
3417 fsp->h_u.tcp_ip4_spec.ip4dst = rule->src_ip; in i40e_get_ethtool_fdir_entry()
3420 switch (rule->flow_type) { in i40e_get_ethtool_fdir_entry()
3452 rule->flow_type); in i40e_get_ethtool_fdir_entry()
3461 fsp->m_u.tcp_ip6_spec.ip6src[0] = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3462 fsp->m_u.tcp_ip6_spec.ip6src[1] = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3463 fsp->m_u.tcp_ip6_spec.ip6src[2] = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3464 fsp->m_u.tcp_ip6_spec.ip6src[3] = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3468 fsp->m_u.tcp_ip6_spec.ip6dst[0] = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3469 fsp->m_u.tcp_ip6_spec.ip6dst[1] = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3470 fsp->m_u.tcp_ip6_spec.ip6dst[2] = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3471 fsp->m_u.tcp_ip6_spec.ip6dst[3] = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3475 fsp->m_u.tcp_ip4_spec.ip4src = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3478 fsp->m_u.tcp_ip4_spec.ip4dst = htonl(0xFFFFFFFF); in i40e_get_ethtool_fdir_entry()
3481 fsp->m_u.tcp_ip4_spec.psrc = htons(0xFFFF); in i40e_get_ethtool_fdir_entry()
3484 fsp->m_u.tcp_ip4_spec.pdst = htons(0xFFFF); in i40e_get_ethtool_fdir_entry()
3486 if (rule->dest_ctl == I40E_FILTER_PROGRAM_DESC_DEST_DROP_PACKET) in i40e_get_ethtool_fdir_entry()
3487 fsp->ring_cookie = RX_CLS_FLOW_DISC; in i40e_get_ethtool_fdir_entry()
3489 fsp->ring_cookie = rule->q_index; in i40e_get_ethtool_fdir_entry()
3491 if (rule->vlan_tag) { in i40e_get_ethtool_fdir_entry()
3492 fsp->h_ext.vlan_etype = rule->vlan_etype; in i40e_get_ethtool_fdir_entry()
3493 fsp->m_ext.vlan_etype = htons(0xFFFF); in i40e_get_ethtool_fdir_entry()
3494 fsp->h_ext.vlan_tci = rule->vlan_tag; in i40e_get_ethtool_fdir_entry()
3495 fsp->m_ext.vlan_tci = htons(0xFFFF); in i40e_get_ethtool_fdir_entry()
3496 fsp->flow_type |= FLOW_EXT; in i40e_get_ethtool_fdir_entry()
3500 if (rule->dest_vsi != vsi->id) { in i40e_get_ethtool_fdir_entry()
3501 vsi = i40e_find_vsi_from_id(pf, rule->dest_vsi); in i40e_get_ethtool_fdir_entry()
3502 if (vsi && vsi->type == I40E_VSI_SRIOV) { in i40e_get_ethtool_fdir_entry()
3503 /* VFs are zero-indexed by the driver, but ethtool in i40e_get_ethtool_fdir_entry()
3504 * expects them to be one-indexed, so add one here in i40e_get_ethtool_fdir_entry()
3506 u64 ring_vf = vsi->vf_id + 1; in i40e_get_ethtool_fdir_entry()
3509 fsp->ring_cookie |= ring_vf; in i40e_get_ethtool_fdir_entry()
3513 if (rule->flex_filter) { in i40e_get_ethtool_fdir_entry()
3515 userdef.flex_word = be16_to_cpu(rule->flex_word); in i40e_get_ethtool_fdir_entry()
3516 userdef.flex_offset = rule->flex_offset; in i40e_get_ethtool_fdir_entry()
3525 * i40e_get_rxnfc - command to get RX flow classification rules
3536 struct i40e_vsi *vsi = np->vsi; in i40e_get_rxnfc()
3537 struct i40e_pf *pf = vsi->back; in i40e_get_rxnfc()
3538 int ret = -EOPNOTSUPP; in i40e_get_rxnfc()
3540 switch (cmd->cmd) { in i40e_get_rxnfc()
3542 cmd->data = vsi->rss_size; in i40e_get_rxnfc()
3546 cmd->rule_cnt = pf->fdir_pf_active_filters; in i40e_get_rxnfc()
3548 cmd->data = i40e_get_fd_cnt_all(pf); in i40e_get_rxnfc()
3565 * i40e_get_rss_hash_bits - Read RSS Hash bits from register
3579 if (nfc->data & RXH_L4_B_0_1) in i40e_get_rss_hash_bits()
3583 if (nfc->data & RXH_L4_B_2_3) in i40e_get_rss_hash_bits()
3588 if (nfc->flow_type == TCP_V6_FLOW || nfc->flow_type == UDP_V6_FLOW) { in i40e_get_rss_hash_bits()
3591 } else if (nfc->flow_type == TCP_V4_FLOW || in i40e_get_rss_hash_bits()
3592 nfc->flow_type == UDP_V4_FLOW) { in i40e_get_rss_hash_bits()
3593 if (hw->mac.type == I40E_MAC_X722) { in i40e_get_rss_hash_bits()
3605 if (nfc->data & RXH_IP_SRC) in i40e_get_rss_hash_bits()
3609 if (nfc->data & RXH_IP_DST) in i40e_get_rss_hash_bits()
3623 struct i40e_vsi *vsi = np->vsi; in i40e_set_rxfh_fields()
3624 struct i40e_pf *pf = vsi->back; in i40e_set_rxfh_fields()
3625 struct i40e_hw *hw = &pf->hw; in i40e_set_rxfh_fields()
3633 if (test_bit(I40E_FLAG_MFP_ENA, pf->flags)) { in i40e_set_rxfh_fields()
3634 dev_err(&pf->pdev->dev, in i40e_set_rxfh_fields()
3636 return -EOPNOTSUPP; in i40e_set_rxfh_fields()
3642 if (nfc->data & ~(RXH_IP_SRC | RXH_IP_DST | in i40e_set_rxfh_fields()
3644 return -EINVAL; in i40e_set_rxfh_fields()
3646 switch (nfc->flow_type) { in i40e_set_rxfh_fields()
3650 pf->hw.caps)) in i40e_set_rxfh_fields()
3657 pf->hw.caps)) in i40e_set_rxfh_fields()
3664 pf->hw.caps)) { in i40e_set_rxfh_fields()
3675 pf->hw.caps)) { in i40e_set_rxfh_fields()
3687 if ((nfc->data & RXH_L4_B_0_1) || in i40e_set_rxfh_fields()
3688 (nfc->data & RXH_L4_B_2_3)) in i40e_set_rxfh_fields()
3689 return -EINVAL; in i40e_set_rxfh_fields()
3696 if ((nfc->data & RXH_L4_B_0_1) || in i40e_set_rxfh_fields()
3697 (nfc->data & RXH_L4_B_2_3)) in i40e_set_rxfh_fields()
3698 return -EINVAL; in i40e_set_rxfh_fields()
3710 return -EINVAL; in i40e_set_rxfh_fields()
3719 i_set = i40e_get_rss_hash_bits(&pf->hw, nfc, i_setc); in i40e_set_rxfh_fields()
3737 * i40e_update_ethtool_fdir_entry - Updates the fdir filter entry
3754 struct i40e_pf *pf = vsi->back; in i40e_update_ethtool_fdir_entry()
3756 int err = -EINVAL; in i40e_update_ethtool_fdir_entry()
3762 &pf->fdir_filter_list, fdir_node) { in i40e_update_ethtool_fdir_entry()
3764 if (rule->fd_id >= sw_idx) in i40e_update_ethtool_fdir_entry()
3770 if (rule && (rule->fd_id == sw_idx)) { in i40e_update_ethtool_fdir_entry()
3775 hlist_del(&rule->fdir_node); in i40e_update_ethtool_fdir_entry()
3777 pf->fdir_pf_active_filters--; in i40e_update_ethtool_fdir_entry()
3787 INIT_HLIST_NODE(&input->fdir_node); in i40e_update_ethtool_fdir_entry()
3791 hlist_add_behind(&input->fdir_node, &parent->fdir_node); in i40e_update_ethtool_fdir_entry()
3793 hlist_add_head(&input->fdir_node, in i40e_update_ethtool_fdir_entry()
3794 &pf->fdir_filter_list); in i40e_update_ethtool_fdir_entry()
3797 pf->fdir_pf_active_filters++; in i40e_update_ethtool_fdir_entry()
3803 * i40e_prune_flex_pit_list - Cleanup unused entries in FLX_PIT table
3816 list_for_each_entry_safe(entry, tmp, &pf->l3_flex_pit_list, list) { in i40e_prune_flex_pit_list()
3819 hlist_for_each_entry(rule, &pf->fdir_filter_list, fdir_node) { in i40e_prune_flex_pit_list()
3820 if (rule->flow_type != IP_USER_FLOW) in i40e_prune_flex_pit_list()
3822 if (rule->flex_filter && in i40e_prune_flex_pit_list()
3823 rule->flex_offset == entry->src_offset) { in i40e_prune_flex_pit_list()
3833 list_del(&entry->list); in i40e_prune_flex_pit_list()
3839 list_for_each_entry_safe(entry, tmp, &pf->l4_flex_pit_list, list) { in i40e_prune_flex_pit_list()
3842 hlist_for_each_entry(rule, &pf->fdir_filter_list, fdir_node) { in i40e_prune_flex_pit_list()
3846 if (rule->flow_type == IP_USER_FLOW) in i40e_prune_flex_pit_list()
3848 if (rule->flex_filter && in i40e_prune_flex_pit_list()
3849 rule->flex_offset == entry->src_offset) { in i40e_prune_flex_pit_list()
3859 list_del(&entry->list); in i40e_prune_flex_pit_list()
3866 * i40e_del_fdir_entry - Deletes a Flow Director filter entry
3879 (struct ethtool_rx_flow_spec *)&cmd->fs; in i40e_del_fdir_entry()
3880 struct i40e_pf *pf = vsi->back; in i40e_del_fdir_entry()
3883 if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) || in i40e_del_fdir_entry()
3884 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) in i40e_del_fdir_entry()
3885 return -EBUSY; in i40e_del_fdir_entry()
3887 if (test_bit(__I40E_FD_FLUSH_REQUESTED, pf->state)) in i40e_del_fdir_entry()
3888 return -EBUSY; in i40e_del_fdir_entry()
3890 ret = i40e_update_ethtool_fdir_entry(vsi, NULL, fsp->location, cmd); in i40e_del_fdir_entry()
3899 * i40e_unused_pit_index - Find an unused PIT index for given list
3917 list_for_each_entry(entry, &pf->l4_flex_pit_list, list) in i40e_unused_pit_index()
3918 clear_bit(entry->pit_index, &available_index); in i40e_unused_pit_index()
3920 list_for_each_entry(entry, &pf->l3_flex_pit_list, list) in i40e_unused_pit_index()
3921 clear_bit(entry->pit_index, &available_index); in i40e_unused_pit_index()
3927 * i40e_find_flex_offset - Find an existing flex src_offset
3943 * already programmed, we can simply re-use it. in i40e_find_flex_offset()
3947 if (entry->src_offset == src_offset) in i40e_find_flex_offset()
3957 return ERR_PTR(-ENOSPC); in i40e_find_flex_offset()
3963 * i40e_add_flex_offset - Add src_offset to flex PIT table list
3983 return -ENOMEM; in i40e_add_flex_offset()
3985 new_pit->src_offset = src_offset; in i40e_add_flex_offset()
3986 new_pit->pit_index = pit_index; in i40e_add_flex_offset()
3992 if (new_pit->src_offset < entry->src_offset) { in i40e_add_flex_offset()
3993 list_add_tail(&new_pit->list, &entry->list); in i40e_add_flex_offset()
4001 if (new_pit->src_offset == entry->src_offset) { in i40e_add_flex_offset()
4004 /* If the PIT index is not the same we can't re-use in i40e_add_flex_offset()
4007 if (new_pit->pit_index != entry->pit_index) in i40e_add_flex_offset()
4008 err = -EINVAL; in i40e_add_flex_offset()
4018 list_add_tail(&new_pit->list, flex_pit_list); in i40e_add_flex_offset()
4023 * __i40e_reprogram_flex_pit - Re-program specific FLX_PIT table
4036 * This function will reprogram the FLX_PIT register from a book-keeping
4070 u16 offset = entry->src_offset + j; in __i40e_reprogram_flex_pit()
4074 offset - 3); in __i40e_reprogram_flex_pit()
4077 i40e_write_rx_ctl(&pf->hw, in __i40e_reprogram_flex_pit()
4085 i40e_write_rx_ctl(&pf->hw, in __i40e_reprogram_flex_pit()
4087 I40E_FLEX_PREP_VAL(entry->pit_index + 50, in __i40e_reprogram_flex_pit()
4089 entry->src_offset)); in __i40e_reprogram_flex_pit()
4100 last_offset = list_prev_entry(entry, list)->src_offset + 1; in __i40e_reprogram_flex_pit()
4103 i40e_write_rx_ctl(&pf->hw, in __i40e_reprogram_flex_pit()
4112 * i40e_reprogram_flex_pit - Reprogram all FLX_PIT tables after input set change
4120 __i40e_reprogram_flex_pit(pf, &pf->l3_flex_pit_list, in i40e_reprogram_flex_pit()
4123 __i40e_reprogram_flex_pit(pf, &pf->l4_flex_pit_list, in i40e_reprogram_flex_pit()
4127 i40e_write_rx_ctl(&pf->hw, in i40e_reprogram_flex_pit()
4132 i40e_write_rx_ctl(&pf->hw, in i40e_reprogram_flex_pit()
4139 * i40e_flow_str - Converts a flow_type into a human readable string
4147 switch (fsp->flow_type & ~FLOW_EXT) { in i40e_flow_str()
4170 * i40e_pit_index_to_mask - Return the FLEX mask for a given PIT index
4201 * i40e_print_input_set - Show changes between two input sets
4212 struct i40e_pf *pf = vsi->back; in i40e_print_input_set()
4219 netif_info(pf, drv, vsi->netdev, "L3 source address: %s -> %s\n", in i40e_print_input_set()
4226 netif_info(pf, drv, vsi->netdev, "L3 destination address: %s -> %s\n", in i40e_print_input_set()
4233 netif_info(pf, drv, vsi->netdev, "L4 source port: %s -> %s\n", in i40e_print_input_set()
4240 netif_info(pf, drv, vsi->netdev, "L4 destination port: %s -> %s\n", in i40e_print_input_set()
4247 netif_info(pf, drv, vsi->netdev, "SCTP verification tag: %s -> %s\n", in i40e_print_input_set()
4258 netif_info(pf, drv, vsi->netdev, "FLEX index %d: %s -> %s\n", in i40e_print_input_set()
4264 netif_info(pf, drv, vsi->netdev, " Current input set: %0llx\n", in i40e_print_input_set()
4266 netif_info(pf, drv, vsi->netdev, "Requested input set: %0llx\n", in i40e_print_input_set()
4271 * i40e_check_fdir_input_set - Check that a given rx_flow_spec mask is valid
4306 struct i40e_pf *pf = vsi->back; in i40e_check_fdir_input_set()
4315 switch (fsp->flow_type & ~FLOW_EXT) { in i40e_check_fdir_input_set()
4318 fdir_filter_count = &pf->fd_sctp4_filter_cnt; in i40e_check_fdir_input_set()
4322 fdir_filter_count = &pf->fd_tcp4_filter_cnt; in i40e_check_fdir_input_set()
4326 fdir_filter_count = &pf->fd_udp4_filter_cnt; in i40e_check_fdir_input_set()
4330 fdir_filter_count = &pf->fd_sctp6_filter_cnt; in i40e_check_fdir_input_set()
4334 fdir_filter_count = &pf->fd_tcp6_filter_cnt; in i40e_check_fdir_input_set()
4338 fdir_filter_count = &pf->fd_udp6_filter_cnt; in i40e_check_fdir_input_set()
4342 fdir_filter_count = &pf->fd_ip4_filter_cnt; in i40e_check_fdir_input_set()
4347 fdir_filter_count = &pf->fd_ip6_filter_cnt; in i40e_check_fdir_input_set()
4351 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4367 switch (fsp->flow_type & ~FLOW_EXT) { in i40e_check_fdir_input_set()
4373 tcp_ip4_spec = &fsp->m_u.tcp_ip4_spec; in i40e_check_fdir_input_set()
4376 if (tcp_ip4_spec->ip4src == htonl(0xFFFFFFFF)) in i40e_check_fdir_input_set()
4378 else if (!tcp_ip4_spec->ip4src) in i40e_check_fdir_input_set()
4381 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4384 if (tcp_ip4_spec->ip4dst == htonl(0xFFFFFFFF)) in i40e_check_fdir_input_set()
4386 else if (!tcp_ip4_spec->ip4dst) in i40e_check_fdir_input_set()
4389 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4392 if (tcp_ip4_spec->psrc == htons(0xFFFF)) in i40e_check_fdir_input_set()
4394 else if (!tcp_ip4_spec->psrc) in i40e_check_fdir_input_set()
4397 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4400 if (tcp_ip4_spec->pdst == htons(0xFFFF)) in i40e_check_fdir_input_set()
4402 else if (!tcp_ip4_spec->pdst) in i40e_check_fdir_input_set()
4405 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4408 if (tcp_ip4_spec->tos) in i40e_check_fdir_input_set()
4409 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4417 tcp_ip6_spec = &fsp->m_u.tcp_ip6_spec; in i40e_check_fdir_input_set()
4420 if (ipv6_addr_equal((struct in6_addr *)&tcp_ip6_spec->ip6src, in i40e_check_fdir_input_set()
4424 &tcp_ip6_spec->ip6src)) in i40e_check_fdir_input_set()
4427 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4430 if (ipv6_addr_equal((struct in6_addr *)&tcp_ip6_spec->ip6dst, in i40e_check_fdir_input_set()
4434 &tcp_ip6_spec->ip6dst)) in i40e_check_fdir_input_set()
4437 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4440 if (tcp_ip6_spec->psrc == htons(0xFFFF)) in i40e_check_fdir_input_set()
4442 else if (!tcp_ip6_spec->psrc) in i40e_check_fdir_input_set()
4445 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4448 if (tcp_ip6_spec->pdst == htons(0xFFFF)) in i40e_check_fdir_input_set()
4450 else if (!tcp_ip6_spec->pdst) in i40e_check_fdir_input_set()
4453 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4456 if (tcp_ip6_spec->tclass) in i40e_check_fdir_input_set()
4457 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4460 usr_ip4_spec = &fsp->m_u.usr_ip4_spec; in i40e_check_fdir_input_set()
4463 if (usr_ip4_spec->ip4src == htonl(0xFFFFFFFF)) in i40e_check_fdir_input_set()
4465 else if (!usr_ip4_spec->ip4src) in i40e_check_fdir_input_set()
4468 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4471 if (usr_ip4_spec->ip4dst == htonl(0xFFFFFFFF)) in i40e_check_fdir_input_set()
4473 else if (!usr_ip4_spec->ip4dst) in i40e_check_fdir_input_set()
4476 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4479 if (usr_ip4_spec->l4_4_bytes) in i40e_check_fdir_input_set()
4480 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4483 if (usr_ip4_spec->tos) in i40e_check_fdir_input_set()
4484 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4487 if (usr_ip4_spec->ip_ver) in i40e_check_fdir_input_set()
4488 return -EINVAL; in i40e_check_fdir_input_set()
4491 if (usr_ip4_spec->proto) in i40e_check_fdir_input_set()
4492 return -EINVAL; in i40e_check_fdir_input_set()
4496 usr_ip6_spec = &fsp->m_u.usr_ip6_spec; in i40e_check_fdir_input_set()
4499 if (ipv6_addr_equal((struct in6_addr *)&usr_ip6_spec->ip6src, in i40e_check_fdir_input_set()
4503 &usr_ip6_spec->ip6src)) in i40e_check_fdir_input_set()
4506 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4509 if (ipv6_addr_equal((struct in6_addr *)&usr_ip6_spec->ip6dst, in i40e_check_fdir_input_set()
4513 &usr_ip6_spec->ip6dst)) in i40e_check_fdir_input_set()
4516 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4518 if (usr_ip6_spec->l4_4_bytes) in i40e_check_fdir_input_set()
4519 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4522 if (usr_ip6_spec->tclass) in i40e_check_fdir_input_set()
4523 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4526 if (usr_ip6_spec->l4_proto) in i40e_check_fdir_input_set()
4527 return -EINVAL; in i40e_check_fdir_input_set()
4531 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4534 if (fsp->flow_type & FLOW_EXT) { in i40e_check_fdir_input_set()
4538 if (fsp->h_ext.vlan_etype != htons(ETH_P_8021Q) && in i40e_check_fdir_input_set()
4539 fsp->h_ext.vlan_etype != 0) in i40e_check_fdir_input_set()
4540 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4541 if (fsp->m_ext.vlan_tci == htons(0xFFFF)) in i40e_check_fdir_input_set()
4555 if (userdef->flex_filter) { in i40e_check_fdir_input_set()
4559 * must be aligned on 2-byte boundary. in i40e_check_fdir_input_set()
4561 if (userdef->flex_offset & 0x1) { in i40e_check_fdir_input_set()
4562 dev_warn(&pf->pdev->dev, in i40e_check_fdir_input_set()
4563 "Flexible data offset must be 2-byte aligned\n"); in i40e_check_fdir_input_set()
4564 return -EINVAL; in i40e_check_fdir_input_set()
4567 src_offset = userdef->flex_offset >> 1; in i40e_check_fdir_input_set()
4571 dev_warn(&pf->pdev->dev, in i40e_check_fdir_input_set()
4573 return -EINVAL; in i40e_check_fdir_input_set()
4581 flex_pit = i40e_find_flex_offset(&pf->l4_flex_pit_list, in i40e_check_fdir_input_set()
4595 i40e_find_flex_offset(&pf->l3_flex_pit_list, in i40e_check_fdir_input_set()
4606 if (l3_flex_pit->pit_index != in i40e_check_fdir_input_set()
4607 flex_pit->pit_index) { in i40e_check_fdir_input_set()
4608 return -EINVAL; in i40e_check_fdir_input_set()
4627 pit_index = flex_pit->pit_index; in i40e_check_fdir_input_set()
4641 netif_info(pf, drv, vsi->netdev, "Input set change requested for %s flows:\n", in i40e_check_fdir_input_set()
4645 netif_info(pf, drv, vsi->netdev, "FLEX index %d: Offset -> %d", in i40e_check_fdir_input_set()
4653 if (test_bit(I40E_FLAG_MFP_ENA, pf->flags)) { in i40e_check_fdir_input_set()
4654 netif_err(pf, drv, vsi->netdev, "Cannot change Flow Director input sets while MFP is enabled\n"); in i40e_check_fdir_input_set()
4655 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4668 …netif_err(pf, drv, vsi->netdev, "Cannot change input set for %s flows until %d preexisting filters… in i40e_check_fdir_input_set()
4671 return -EOPNOTSUPP; in i40e_check_fdir_input_set()
4688 err = i40e_add_flex_offset(&pf->l4_flex_pit_list, src_offset, in i40e_check_fdir_input_set()
4694 err = i40e_add_flex_offset(&pf->l3_flex_pit_list, in i40e_check_fdir_input_set()
4708 * i40e_match_fdir_filter - Return true of two filters match
4714 * check any input-set since all filters of the same flow type must use the
4721 if (a->dst_ip != b->dst_ip || in i40e_match_fdir_filter()
4722 a->src_ip != b->src_ip || in i40e_match_fdir_filter()
4723 a->dst_port != b->dst_port || in i40e_match_fdir_filter()
4724 a->src_port != b->src_port || in i40e_match_fdir_filter()
4725 a->flow_type != b->flow_type || in i40e_match_fdir_filter()
4726 a->ipl4_proto != b->ipl4_proto || in i40e_match_fdir_filter()
4727 a->vlan_tag != b->vlan_tag || in i40e_match_fdir_filter()
4728 a->vlan_etype != b->vlan_etype) in i40e_match_fdir_filter()
4735 * i40e_disallow_matching_filters - Check that new filters differ
4762 struct i40e_pf *pf = vsi->back; in i40e_disallow_matching_filters()
4768 &pf->fdir_filter_list, fdir_node) { in i40e_disallow_matching_filters()
4773 if (rule->fd_id == input->fd_id) in i40e_disallow_matching_filters()
4780 dev_warn(&pf->pdev->dev, in i40e_disallow_matching_filters()
4782 rule->fd_id); in i40e_disallow_matching_filters()
4783 return -EINVAL; in i40e_disallow_matching_filters()
4791 * i40e_add_fdir_ethtool - Add/Remove Flow Director filters
4806 int ret = -EINVAL; in i40e_add_fdir_ethtool()
4810 return -EINVAL; in i40e_add_fdir_ethtool()
4811 pf = vsi->back; in i40e_add_fdir_ethtool()
4813 if (!test_bit(I40E_FLAG_FD_SB_ENA, pf->flags)) in i40e_add_fdir_ethtool()
4814 return -EOPNOTSUPP; in i40e_add_fdir_ethtool()
4816 if (test_bit(__I40E_FD_SB_AUTO_DISABLED, pf->state)) in i40e_add_fdir_ethtool()
4817 return -ENOSPC; in i40e_add_fdir_ethtool()
4819 if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) || in i40e_add_fdir_ethtool()
4820 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) in i40e_add_fdir_ethtool()
4821 return -EBUSY; in i40e_add_fdir_ethtool()
4823 if (test_bit(__I40E_FD_FLUSH_REQUESTED, pf->state)) in i40e_add_fdir_ethtool()
4824 return -EBUSY; in i40e_add_fdir_ethtool()
4826 fsp = (struct ethtool_rx_flow_spec *)&cmd->fs; in i40e_add_fdir_ethtool()
4828 /* Parse the user-defined field */ in i40e_add_fdir_ethtool()
4830 return -EINVAL; in i40e_add_fdir_ethtool()
4833 if (fsp->flow_type & FLOW_MAC_EXT) in i40e_add_fdir_ethtool()
4834 return -EINVAL; in i40e_add_fdir_ethtool()
4840 if (fsp->location >= (pf->hw.func_caps.fd_filters_best_effort + in i40e_add_fdir_ethtool()
4841 pf->hw.func_caps.fd_filters_guaranteed)) { in i40e_add_fdir_ethtool()
4842 return -EINVAL; in i40e_add_fdir_ethtool()
4848 if (fsp->ring_cookie == RX_CLS_FLOW_DISC) { in i40e_add_fdir_ethtool()
4851 u32 ring = ethtool_get_flow_spec_ring(fsp->ring_cookie); in i40e_add_fdir_ethtool()
4852 u8 vf = ethtool_get_flow_spec_ring_vf(fsp->ring_cookie); in i40e_add_fdir_ethtool()
4855 if (ring >= vsi->num_queue_pairs) in i40e_add_fdir_ethtool()
4856 return -EINVAL; in i40e_add_fdir_ethtool()
4857 dest_vsi = vsi->id; in i40e_add_fdir_ethtool()
4859 /* VFs are zero-indexed, so we subtract one here */ in i40e_add_fdir_ethtool()
4860 vf--; in i40e_add_fdir_ethtool()
4862 if (vf >= pf->num_alloc_vfs) in i40e_add_fdir_ethtool()
4863 return -EINVAL; in i40e_add_fdir_ethtool()
4864 if (ring >= pf->vf[vf].num_queue_pairs) in i40e_add_fdir_ethtool()
4865 return -EINVAL; in i40e_add_fdir_ethtool()
4866 dest_vsi = pf->vf[vf].lan_vsi_id; in i40e_add_fdir_ethtool()
4875 return -ENOMEM; in i40e_add_fdir_ethtool()
4877 input->fd_id = fsp->location; in i40e_add_fdir_ethtool()
4878 input->q_index = q_index; in i40e_add_fdir_ethtool()
4879 input->dest_vsi = dest_vsi; in i40e_add_fdir_ethtool()
4880 input->dest_ctl = dest_ctl; in i40e_add_fdir_ethtool()
4881 input->fd_status = I40E_FILTER_PROGRAM_DESC_FD_STATUS_FD_ID; in i40e_add_fdir_ethtool()
4882 input->cnt_index = I40E_FD_SB_STAT_IDX(pf->hw.pf_id); in i40e_add_fdir_ethtool()
4883 input->dst_ip = fsp->h_u.tcp_ip4_spec.ip4src; in i40e_add_fdir_ethtool()
4884 input->src_ip = fsp->h_u.tcp_ip4_spec.ip4dst; in i40e_add_fdir_ethtool()
4885 input->flow_type = fsp->flow_type & ~FLOW_EXT; in i40e_add_fdir_ethtool()
4887 input->vlan_etype = fsp->h_ext.vlan_etype; in i40e_add_fdir_ethtool()
4888 if (!fsp->m_ext.vlan_etype && fsp->h_ext.vlan_tci) in i40e_add_fdir_ethtool()
4889 input->vlan_etype = cpu_to_be16(ETH_P_8021Q); in i40e_add_fdir_ethtool()
4890 if (fsp->m_ext.vlan_tci && input->vlan_etype) in i40e_add_fdir_ethtool()
4891 input->vlan_tag = fsp->h_ext.vlan_tci; in i40e_add_fdir_ethtool()
4892 if (input->flow_type == IPV6_USER_FLOW || in i40e_add_fdir_ethtool()
4893 input->flow_type == UDP_V6_FLOW || in i40e_add_fdir_ethtool()
4894 input->flow_type == TCP_V6_FLOW || in i40e_add_fdir_ethtool()
4895 input->flow_type == SCTP_V6_FLOW) { in i40e_add_fdir_ethtool()
4900 input->ipl4_proto = fsp->h_u.usr_ip6_spec.l4_proto; in i40e_add_fdir_ethtool()
4901 input->dst_port = fsp->h_u.tcp_ip6_spec.psrc; in i40e_add_fdir_ethtool()
4902 input->src_port = fsp->h_u.tcp_ip6_spec.pdst; in i40e_add_fdir_ethtool()
4903 memcpy(input->dst_ip6, fsp->h_u.ah_ip6_spec.ip6src, in i40e_add_fdir_ethtool()
4905 memcpy(input->src_ip6, fsp->h_u.ah_ip6_spec.ip6dst, in i40e_add_fdir_ethtool()
4912 input->ipl4_proto = fsp->h_u.usr_ip4_spec.proto; in i40e_add_fdir_ethtool()
4913 input->dst_port = fsp->h_u.tcp_ip4_spec.psrc; in i40e_add_fdir_ethtool()
4914 input->src_port = fsp->h_u.tcp_ip4_spec.pdst; in i40e_add_fdir_ethtool()
4915 input->dst_ip = fsp->h_u.tcp_ip4_spec.ip4src; in i40e_add_fdir_ethtool()
4916 input->src_ip = fsp->h_u.tcp_ip4_spec.ip4dst; in i40e_add_fdir_ethtool()
4920 input->flex_filter = true; in i40e_add_fdir_ethtool()
4921 input->flex_word = cpu_to_be16(userdef.flex_word); in i40e_add_fdir_ethtool()
4922 input->flex_offset = userdef.flex_offset; in i40e_add_fdir_ethtool()
4932 * to the list as this would cause a use-after-free bug. in i40e_add_fdir_ethtool()
4934 i40e_update_ethtool_fdir_entry(vsi, input, fsp->location, NULL); in i40e_add_fdir_ethtool()
4941 hlist_del(&input->fdir_node); in i40e_add_fdir_ethtool()
4942 pf->fdir_pf_active_filters--; in i40e_add_fdir_ethtool()
4949 * i40e_set_rxnfc - command to set RX flow classification rules
4958 struct i40e_vsi *vsi = np->vsi; in i40e_set_rxnfc()
4959 int ret = -EOPNOTSUPP; in i40e_set_rxnfc()
4961 switch (cmd->cmd) { in i40e_set_rxnfc()
4976 * i40e_max_channels - get Max number of combined channels supported
4982 return vsi->alloc_queue_pairs; in i40e_max_channels()
4986 * i40e_get_channels - Get the current channels enabled and max supported etc.
4999 struct i40e_vsi *vsi = np->vsi; in i40e_get_channels()
5000 struct i40e_pf *pf = vsi->back; in i40e_get_channels()
5003 ch->max_combined = i40e_max_channels(vsi); in i40e_get_channels()
5006 ch->other_count = test_bit(I40E_FLAG_FD_SB_ENA, pf->flags) ? 1 : 0; in i40e_get_channels()
5007 ch->max_other = ch->other_count; in i40e_get_channels()
5010 ch->combined_count = vsi->num_queue_pairs; in i40e_get_channels()
5014 * i40e_set_channels - Set the new channels count.
5026 unsigned int count = ch->combined_count; in i40e_set_channels()
5027 struct i40e_vsi *vsi = np->vsi; in i40e_set_channels()
5028 struct i40e_pf *pf = vsi->back; in i40e_set_channels()
5035 if (vsi->type != I40E_VSI_MAIN) in i40e_set_channels()
5036 return -EINVAL; in i40e_set_channels()
5042 return -EINVAL; in i40e_set_channels()
5045 if (!count || ch->rx_count || ch->tx_count) in i40e_set_channels()
5046 return -EINVAL; in i40e_set_channels()
5049 if (ch->other_count != (test_bit(I40E_FLAG_FD_SB_ENA, pf->flags) ? 1 : 0)) in i40e_set_channels()
5050 return -EINVAL; in i40e_set_channels()
5054 return -EINVAL; in i40e_set_channels()
5060 &pf->fdir_filter_list, fdir_node) { in i40e_set_channels()
5061 if (rule->dest_ctl != drop && count <= rule->q_index) { in i40e_set_channels()
5062 dev_warn(&pf->pdev->dev, in i40e_set_channels()
5064 rule->fd_id, rule->q_index); in i40e_set_channels()
5065 err = -EINVAL; in i40e_set_channels()
5070 dev_err(&pf->pdev->dev, in i40e_set_channels()
5086 return -EINVAL; in i40e_set_channels()
5090 * i40e_get_rxfh_key_size - get the RSS hash key size
5101 * i40e_get_rxfh_indir_size - get the rx flow hash indirection table size
5112 * i40e_get_rxfh - get the rx flow hash indirection table
5123 struct i40e_vsi *vsi = np->vsi; in i40e_get_rxfh()
5128 rxfh->hfunc = ETH_RSS_HASH_TOP; in i40e_get_rxfh()
5130 if (!rxfh->indir) in i40e_get_rxfh()
5133 seed = rxfh->key; in i40e_get_rxfh()
5136 return -ENOMEM; in i40e_get_rxfh()
5141 rxfh->indir[i] = (u32)(lut[i]); in i40e_get_rxfh()
5150 * i40e_set_rxfh - set the rx flow hash indirection table
5155 * Returns -EINVAL if the table specifies an invalid queue id, otherwise
5163 struct i40e_vsi *vsi = np->vsi; in i40e_set_rxfh()
5164 struct i40e_pf *pf = vsi->back; in i40e_set_rxfh()
5168 if (rxfh->hfunc != ETH_RSS_HASH_NO_CHANGE && in i40e_set_rxfh()
5169 rxfh->hfunc != ETH_RSS_HASH_TOP) in i40e_set_rxfh()
5170 return -EOPNOTSUPP; in i40e_set_rxfh()
5172 if (rxfh->key) { in i40e_set_rxfh()
5173 if (!vsi->rss_hkey_user) { in i40e_set_rxfh()
5174 vsi->rss_hkey_user = kzalloc(I40E_HKEY_ARRAY_SIZE, in i40e_set_rxfh()
5176 if (!vsi->rss_hkey_user) in i40e_set_rxfh()
5177 return -ENOMEM; in i40e_set_rxfh()
5179 memcpy(vsi->rss_hkey_user, rxfh->key, I40E_HKEY_ARRAY_SIZE); in i40e_set_rxfh()
5180 seed = vsi->rss_hkey_user; in i40e_set_rxfh()
5182 if (!vsi->rss_lut_user) { in i40e_set_rxfh()
5183 vsi->rss_lut_user = kzalloc(I40E_HLUT_ARRAY_SIZE, GFP_KERNEL); in i40e_set_rxfh()
5184 if (!vsi->rss_lut_user) in i40e_set_rxfh()
5185 return -ENOMEM; in i40e_set_rxfh()
5189 if (rxfh->indir) in i40e_set_rxfh()
5191 vsi->rss_lut_user[i] = (u8)(rxfh->indir[i]); in i40e_set_rxfh()
5193 i40e_fill_rss_lut(pf, vsi->rss_lut_user, I40E_HLUT_ARRAY_SIZE, in i40e_set_rxfh()
5194 vsi->rss_size); in i40e_set_rxfh()
5196 return i40e_config_rss(vsi, seed, vsi->rss_lut_user, in i40e_set_rxfh()
5201 * i40e_get_priv_flags - report device private flags
5213 struct i40e_vsi *vsi = np->vsi; in i40e_get_priv_flags()
5214 struct i40e_pf *pf = vsi->back; in i40e_get_priv_flags()
5222 if (test_bit(priv_flag->bitno, pf->flags)) in i40e_get_priv_flags()
5226 if (pf->hw.pf_id != 0) in i40e_get_priv_flags()
5234 if (test_bit(priv_flag->bitno, pf->flags)) in i40e_get_priv_flags()
5242 * i40e_set_priv_flags - set private flags
5252 struct i40e_vsi *vsi = np->vsi; in i40e_set_priv_flags()
5253 struct i40e_pf *pf = vsi->back; in i40e_set_priv_flags()
5259 bitmap_copy(orig_flags, pf->flags, I40E_PF_FLAGS_NBITS); in i40e_set_priv_flags()
5260 bitmap_copy(new_flags, pf->flags, I40E_PF_FLAGS_NBITS); in i40e_set_priv_flags()
5269 /* If this is a read-only flag, it can't be changed */ in i40e_set_priv_flags()
5270 if (priv_flag->read_only && in i40e_set_priv_flags()
5271 test_bit(priv_flag->bitno, orig_flags) != new_val) in i40e_set_priv_flags()
5272 return -EOPNOTSUPP; in i40e_set_priv_flags()
5275 set_bit(priv_flag->bitno, new_flags); in i40e_set_priv_flags()
5277 clear_bit(priv_flag->bitno, new_flags); in i40e_set_priv_flags()
5280 if (pf->hw.pf_id != 0) in i40e_set_priv_flags()
5290 /* If this is a read-only flag, it can't be changed */ in i40e_set_priv_flags()
5291 if (priv_flag->read_only && in i40e_set_priv_flags()
5292 test_bit(priv_flag->bitno, orig_flags) != new_val) in i40e_set_priv_flags()
5293 return -EOPNOTSUPP; in i40e_set_priv_flags()
5296 set_bit(priv_flag->bitno, new_flags); in i40e_set_priv_flags()
5298 clear_bit(priv_flag->bitno, new_flags); in i40e_set_priv_flags()
5318 !test_bit(I40E_HW_CAP_ATR_EVICT, pf->hw.caps)) in i40e_set_priv_flags()
5319 return -EOPNOTSUPP; in i40e_set_priv_flags()
5323 * - on XL710 if NPAR is enabled or FW API version < 1.7 in i40e_set_priv_flags()
5324 * - on X722 with FW API version < 1.6 in i40e_set_priv_flags()
5330 !test_bit(I40E_HW_CAP_FW_LLDP_STOPPABLE, pf->hw.caps)) { in i40e_set_priv_flags()
5331 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5333 return -EOPNOTSUPP; in i40e_set_priv_flags()
5337 pf->hw.device_id != I40E_DEV_ID_25G_SFP28 && in i40e_set_priv_flags()
5338 pf->hw.device_id != I40E_DEV_ID_25G_B) { in i40e_set_priv_flags()
5339 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5341 return -EOPNOTSUPP; in i40e_set_priv_flags()
5345 pf->hw.device_id != I40E_DEV_ID_25G_SFP28 && in i40e_set_priv_flags()
5346 pf->hw.device_id != I40E_DEV_ID_25G_B && in i40e_set_priv_flags()
5347 pf->hw.device_id != I40E_DEV_ID_KX_X722) { in i40e_set_priv_flags()
5348 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5350 return -EOPNOTSUPP; in i40e_set_priv_flags()
5361 set_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state); in i40e_set_priv_flags()
5362 set_bit(__I40E_FD_FLUSH_REQUESTED, pf->state); in i40e_set_priv_flags()
5372 ret = i40e_aq_set_switch_config(&pf->hw, sw_flags, valid_flags, in i40e_set_priv_flags()
5374 if (ret && pf->hw.aq.asq_last_status != LIBIE_AQ_RC_ESRCH) { in i40e_set_priv_flags()
5375 dev_info(&pf->pdev->dev, in i40e_set_priv_flags()
5378 libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_set_priv_flags()
5398 dev_warn(&pf->pdev->dev, "Cannot change FEC config\n"); in i40e_set_priv_flags()
5403 dev_err(&pf->pdev->dev, in i40e_set_priv_flags()
5404 …"Setting link-down-on-close not supported on this port (because total-port-shutdown is enabled)\n"… in i40e_set_priv_flags()
5405 return -EOPNOTSUPP; in i40e_set_priv_flags()
5409 pf->num_alloc_vfs) { in i40e_set_priv_flags()
5410 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5411 "Changing vf-vlan-pruning flag while VF(s) are active is not supported\n"); in i40e_set_priv_flags()
5412 return -EOPNOTSUPP; in i40e_set_priv_flags()
5417 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5419 return -EOPNOTSUPP; in i40e_set_priv_flags()
5425 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5426 "Turning on link-down-on-close flag may affect other partitions\n"); in i40e_set_priv_flags()
5433 i40e_aq_cfg_lldp_mib_change_event(&pf->hw, false, NULL); in i40e_set_priv_flags()
5434 i40e_aq_stop_lldp(&pf->hw, true, false, NULL); in i40e_set_priv_flags()
5436 status = i40e_aq_start_lldp(&pf->hw, false, NULL); in i40e_set_priv_flags()
5438 adq_err = pf->hw.aq.asq_last_status; in i40e_set_priv_flags()
5441 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5446 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5448 return -EINVAL; in i40e_set_priv_flags()
5450 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5452 return -EBUSY; in i40e_set_priv_flags()
5454 dev_warn(&pf->pdev->dev, in i40e_set_priv_flags()
5458 return -EINVAL; in i40e_set_priv_flags()
5469 bitmap_copy(pf->flags, new_flags, I40E_PF_FLAGS_NBITS); in i40e_set_priv_flags()
5481 * i40e_get_module_info - get (Q)SFP+ module type info
5489 struct i40e_vsi *vsi = np->vsi; in i40e_get_module_info()
5490 struct i40e_pf *pf = vsi->back; in i40e_get_module_info()
5491 struct i40e_hw *hw = &pf->hw; in i40e_get_module_info()
5499 if (!test_bit(I40E_HW_CAP_AQ_PHY_ACCESS, hw->caps)) { in i40e_get_module_info()
5500 …netdev_err(vsi->netdev, "Module EEPROM memory read not supported. Please update the NVM image.\n"); in i40e_get_module_info()
5501 return -EINVAL; in i40e_get_module_info()
5506 return -EIO; in i40e_get_module_info()
5508 if (hw->phy.link_info.phy_type == I40E_PHY_TYPE_EMPTY) { in i40e_get_module_info()
5509 netdev_err(vsi->netdev, "Cannot read module EEPROM memory. No module connected.\n"); in i40e_get_module_info()
5510 return -EINVAL; in i40e_get_module_info()
5513 type = hw->phy.link_info.module_type[0]; in i40e_get_module_info()
5523 return -EIO; in i40e_get_module_info()
5531 return -EIO; in i40e_get_module_info()
5537 netdev_warn(vsi->netdev, "Module address swap to access page 0xA2 is not supported.\n"); in i40e_get_module_info()
5538 modinfo->type = ETH_MODULE_SFF_8079; in i40e_get_module_info()
5539 modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN; in i40e_get_module_info()
5541 /* Module is not SFF-8472 compliant */ in i40e_get_module_info()
5542 modinfo->type = ETH_MODULE_SFF_8079; in i40e_get_module_info()
5543 modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN; in i40e_get_module_info()
5545 /* Module is SFF-8472 compliant but doesn't implement in i40e_get_module_info()
5548 modinfo->type = ETH_MODULE_SFF_8079; in i40e_get_module_info()
5549 modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN; in i40e_get_module_info()
5551 modinfo->type = ETH_MODULE_SFF_8472; in i40e_get_module_info()
5552 modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN; in i40e_get_module_info()
5563 return -EIO; in i40e_get_module_info()
5566 /* Module is SFF-8636 compliant */ 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()
5570 modinfo->type = ETH_MODULE_SFF_8436; in i40e_get_module_info()
5571 modinfo->eeprom_len = I40E_MODULE_QSFP_MAX_LEN; in i40e_get_module_info()
5575 modinfo->type = ETH_MODULE_SFF_8636; in i40e_get_module_info()
5576 modinfo->eeprom_len = I40E_MODULE_QSFP_MAX_LEN; in i40e_get_module_info()
5579 netdev_dbg(vsi->netdev, "SFP module type unrecognized or no SFP connector used.\n"); in i40e_get_module_info()
5580 return -EOPNOTSUPP; in i40e_get_module_info()
5586 * i40e_get_module_eeprom - fills buffer with (Q)SFP+ module memory contents
5596 struct i40e_vsi *vsi = np->vsi; in i40e_get_module_eeprom()
5597 struct i40e_pf *pf = vsi->back; in i40e_get_module_eeprom()
5598 struct i40e_hw *hw = &pf->hw; in i40e_get_module_eeprom()
5604 if (!ee || !ee->len || !data) in i40e_get_module_eeprom()
5605 return -EINVAL; in i40e_get_module_eeprom()
5607 if (hw->phy.link_info.module_type[0] == I40E_MODULE_TYPE_SFP) in i40e_get_module_eeprom()
5610 for (i = 0; i < ee->len; i++) { in i40e_get_module_eeprom()
5611 u32 offset = i + ee->offset; in i40e_get_module_eeprom()
5617 offset -= ETH_MODULE_SFF_8079_LEN; in i40e_get_module_eeprom()
5623 offset -= ETH_MODULE_SFF_8436_LEN / 2; in i40e_get_module_eeprom()
5632 return -EIO; in i40e_get_module_eeprom()
5653 for (unsigned int i = ARRAY_SIZE(lut); i--; ) in i40e_eee_capability_to_kedata_supported()
5662 struct i40e_vsi *vsi = np->vsi; in i40e_get_eee()
5663 struct i40e_pf *pf = vsi->back; in i40e_get_eee()
5664 struct i40e_hw *hw = &pf->hw; in i40e_get_eee()
5670 return -EAGAIN; in i40e_get_eee()
5676 return -EOPNOTSUPP; in i40e_get_eee()
5679 edata->supported); in i40e_get_eee()
5680 linkmode_copy(edata->lp_advertised, edata->supported); in i40e_get_eee()
5685 return -EAGAIN; in i40e_get_eee()
5687 linkmode_zero(edata->advertised); in i40e_get_eee()
5689 linkmode_copy(edata->advertised, edata->supported); in i40e_get_eee()
5690 edata->eee_enabled = !!phy_cfg.eee_capability; in i40e_get_eee()
5691 edata->tx_lpi_enabled = pf->stats.tx_lpi_status; in i40e_get_eee()
5693 edata->eee_active = pf->stats.tx_lpi_status && pf->stats.rx_lpi_status; in i40e_get_eee()
5702 struct i40e_vsi *vsi = np->vsi; in i40e_is_eee_param_supported()
5703 struct i40e_pf *pf = vsi->back; in i40e_is_eee_param_supported()
5708 {!!(edata->advertised[0] & ~edata->supported[0]), "advertise"}, in i40e_is_eee_param_supported()
5709 {!!edata->tx_lpi_timer, "tx-timer"}, in i40e_is_eee_param_supported()
5710 {edata->tx_lpi_enabled != pf->stats.tx_lpi_status, "tx-lpi"} in i40e_is_eee_param_supported()
5719 return -EOPNOTSUPP; in i40e_is_eee_param_supported()
5731 struct i40e_vsi *vsi = np->vsi; in i40e_set_eee()
5732 struct i40e_pf *pf = vsi->back; in i40e_set_eee()
5733 struct i40e_hw *hw = &pf->hw; in i40e_set_eee()
5739 return -EOPNOTSUPP; in i40e_set_eee()
5745 return -EAGAIN; in i40e_set_eee()
5751 return -EOPNOTSUPP; in i40e_set_eee()
5760 return -EAGAIN; in i40e_set_eee()
5774 if (edata->eee_enabled) { in i40e_set_eee()
5785 return -EAGAIN; in i40e_set_eee()
5856 struct i40e_pf *pf = np->vsi->back; in i40e_set_ethtool_ops()
5858 if (!test_bit(__I40E_RECOVERY_MODE, pf->state)) in i40e_set_ethtool_ops()
5859 netdev->ethtool_ops = &i40e_ethtool_ops; in i40e_set_ethtool_ops()
5861 netdev->ethtool_ops = &i40e_ethtool_recovery_mode_ops; in i40e_set_ethtool_ops()