Lines Matching +full:self +full:- +full:advertising
1 // SPDX-License-Identifier: GPL-2.0+
2 // Copyright (c) 2016-2017 Hisilicon Limited.
20 /* Tx per-queue statistics */
46 /* Rx per-queue statistics */
84 struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev); in hns3_lp_setup()
87 if (!h->ae_algo->ops->set_loopback || in hns3_lp_setup()
88 !h->ae_algo->ops->set_promisc_mode) in hns3_lp_setup()
89 return -EOPNOTSUPP; in hns3_lp_setup()
96 ret = h->ae_algo->ops->set_loopback(h, loop, en); in hns3_lp_setup()
99 ret = -ENOTSUPP; in hns3_lp_setup()
103 if (ret || ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V2) in hns3_lp_setup()
107 h->ae_algo->ops->set_promisc_mode(h, true, true); in hns3_lp_setup()
149 struct net_device *ndev = skb->dev; in hns3_lp_setup_skb()
160 memcpy(ethh->h_dest, ndev->dev_addr, ETH_ALEN); in hns3_lp_setup_skb()
168 ae_dev = pci_get_drvdata(handle->pdev); in hns3_lp_setup_skb()
169 if (ae_dev->dev_version < HNAE3_DEVICE_VERSION_V2) in hns3_lp_setup_skb()
170 ethh->h_dest[5] += HNS3_NIC_LB_DST_MAC_ADDR; in hns3_lp_setup_skb()
171 eth_zero_addr(ethh->h_source); in hns3_lp_setup_skb()
172 ethh->h_proto = htons(ETH_P_ARP); in hns3_lp_setup_skb()
182 struct hns3_enet_tqp_vector *tqp_vector = ring->tqp_vector; in hns3_lb_check_skb_data()
183 unsigned char *packet = skb->data; in hns3_lb_check_skb_data()
195 tqp_vector->rx_group.total_packets++; in hns3_lb_check_skb_data()
198 skb->data, len, true); in hns3_lb_check_skb_data()
205 struct hnae3_handle *h = priv->ae_handle; in hns3_lb_check_rx_ring()
209 kinfo = &h->kinfo; in hns3_lb_check_rx_ring()
210 for (i = kinfo->num_tqps; i < kinfo->num_tqps * 2; i++) { in hns3_lb_check_rx_ring()
211 struct hns3_enet_ring *ring = &priv->ring[i]; in hns3_lb_check_rx_ring()
215 rx_group = &ring->tqp_vector->rx_group; in hns3_lb_check_rx_ring()
216 pre_rx_pkt = rx_group->total_packets; in hns3_lb_check_rx_ring()
222 rcv_good_pkt_total += (rx_group->total_packets - pre_rx_pkt); in hns3_lb_check_rx_ring()
223 rx_group->total_packets = pre_rx_pkt; in hns3_lb_check_rx_ring()
234 struct hns3_enet_ring *ring = &priv->ring[i]; in hns3_lb_clear_tx_ring()
241 * hns3_lp_run_test - run loopback test
257 skb->dev = ndev; in hns3_lp_run_test()
259 skb->queue_mapping = HNS3_NIC_LB_TEST_RING_ID; in hns3_lp_run_test()
305 h->flags & HNAE3_SUPPORT_APP_LOOPBACK; in hns3_set_selftest_param()
309 h->flags & HNAE3_SUPPORT_SERDES_SERIAL_LOOPBACK; in hns3_set_selftest_param()
314 h->flags & HNAE3_SUPPORT_SERDES_PARALLEL_LOOPBACK; in hns3_set_selftest_param()
318 h->flags & HNAE3_SUPPORT_PHY_LOOPBACK; in hns3_set_selftest_param()
325 struct hnae3_handle *h = priv->ae_handle; in hns3_selftest_prepare()
328 netdev_info(ndev, "self test start\n"); in hns3_selftest_prepare()
333 ndev->netdev_ops->ndo_stop(ndev); in hns3_selftest_prepare()
337 if (h->ae_algo->ops->enable_vlan_filter && in hns3_selftest_prepare()
338 ndev->features & NETIF_F_HW_VLAN_CTAG_FILTER) in hns3_selftest_prepare()
339 h->ae_algo->ops->enable_vlan_filter(h, false); in hns3_selftest_prepare()
346 if (h->ae_algo->ops->halt_autoneg) in hns3_selftest_prepare()
347 h->ae_algo->ops->halt_autoneg(h, true); in hns3_selftest_prepare()
349 set_bit(HNS3_NIC_STATE_TESTING, &priv->state); in hns3_selftest_prepare()
355 struct hnae3_handle *h = priv->ae_handle; in hns3_selftest_restore()
357 clear_bit(HNS3_NIC_STATE_TESTING, &priv->state); in hns3_selftest_restore()
359 if (h->ae_algo->ops->halt_autoneg) in hns3_selftest_restore()
360 h->ae_algo->ops->halt_autoneg(h, false); in hns3_selftest_restore()
363 if (h->ae_algo->ops->enable_vlan_filter && in hns3_selftest_restore()
364 ndev->features & NETIF_F_HW_VLAN_CTAG_FILTER) in hns3_selftest_restore()
365 h->ae_algo->ops->enable_vlan_filter(h, true); in hns3_selftest_restore()
369 ndev->netdev_ops->ndo_open(ndev); in hns3_selftest_restore()
372 netdev_info(ndev, "self test end\n"); in hns3_selftest_restore()
394 eth_test->flags |= ETH_TEST_FL_FAILED; in hns3_do_selftest()
401 * hns3_nic_self_test - self test
418 if (eth_test->flags != ETH_TEST_FL_OFFLINE) in hns3_self_test()
432 set_bit(HNAE3_PFLAG_LIMIT_PROMISC, &handle->priv_flags); in hns3_update_limit_promisc_mode()
434 clear_bit(HNAE3_PFLAG_LIMIT_PROMISC, &handle->priv_flags); in hns3_update_limit_promisc_mode()
446 const struct hnae3_ae_ops *ops = h->ae_algo->ops; in hns3_get_sset_count()
448 if (!ops->get_sset_count) in hns3_get_sset_count()
449 return -EOPNOTSUPP; in hns3_get_sset_count()
453 return ((HNS3_TQP_STATS_COUNT * h->kinfo.num_tqps) + in hns3_get_sset_count()
454 ops->get_sset_count(h, stringset)); in hns3_get_sset_count()
457 return ops->get_sset_count(h, stringset); in hns3_get_sset_count()
463 return -EOPNOTSUPP; in hns3_get_sset_count()
477 data[ETH_GSTRING_LEN - 1] = '\0'; in hns3_update_strings()
482 size_left = (ETH_GSTRING_LEN - 1) - n1; in hns3_update_strings()
495 struct hnae3_knic_private_info *kinfo = &handle->kinfo; in hns3_get_strings_tqps()
501 kinfo->num_tqps, tx_prefix); in hns3_get_strings_tqps()
505 kinfo->num_tqps, rx_prefix); in hns3_get_strings_tqps()
513 const struct hnae3_ae_ops *ops = h->ae_algo->ops; in hns3_get_strings()
517 if (!ops->get_strings) in hns3_get_strings()
523 ops->get_strings(h, stringset, (u8 *)buff); in hns3_get_strings()
526 ops->get_strings(h, stringset, data); in hns3_get_strings()
542 struct hns3_nic_priv *nic_priv = (struct hns3_nic_priv *)handle->priv; in hns3_get_stats_tqps()
543 struct hnae3_knic_private_info *kinfo = &handle->kinfo; in hns3_get_stats_tqps()
549 for (i = 0; i < kinfo->num_tqps; i++) { in hns3_get_stats_tqps()
550 ring = &nic_priv->ring[i]; in hns3_get_stats_tqps()
558 for (i = 0; i < kinfo->num_tqps; i++) { in hns3_get_stats_tqps()
559 ring = &nic_priv->ring[i + kinfo->num_tqps]; in hns3_get_stats_tqps()
569 /* hns3_get_stats - get detail statistics.
585 if (!h->ae_algo->ops->get_stats || !h->ae_algo->ops->update_stats) { in hns3_get_stats()
590 h->ae_algo->ops->update_stats(h, &netdev->stats); in hns3_get_stats()
592 /* get per-queue stats */ in hns3_get_stats()
596 h->ae_algo->ops->get_stats(h, p); in hns3_get_stats()
603 struct hnae3_handle *h = priv->ae_handle; in hns3_get_drvinfo()
606 if (!h->ae_algo->ops->get_fw_version) { in hns3_get_drvinfo()
611 strncpy(drvinfo->driver, h->pdev->driver->name, in hns3_get_drvinfo()
612 sizeof(drvinfo->driver)); in hns3_get_drvinfo()
613 drvinfo->driver[sizeof(drvinfo->driver) - 1] = '\0'; in hns3_get_drvinfo()
615 strncpy(drvinfo->bus_info, pci_name(h->pdev), in hns3_get_drvinfo()
616 sizeof(drvinfo->bus_info)); in hns3_get_drvinfo()
617 drvinfo->bus_info[ETHTOOL_BUSINFO_LEN - 1] = '\0'; in hns3_get_drvinfo()
619 fw_version = priv->ae_handle->ae_algo->ops->get_fw_version(h); in hns3_get_drvinfo()
621 snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), in hns3_get_drvinfo()
637 if (h->ae_algo->ops->get_status) in hns3_get_link()
638 return h->ae_algo->ops->get_status(h); in hns3_get_link()
647 struct hnae3_handle *h = priv->ae_handle; in hns3_get_ringparam()
648 int queue_num = h->kinfo.num_tqps; in hns3_get_ringparam()
655 param->tx_max_pending = HNS3_RING_MAX_PENDING; in hns3_get_ringparam()
656 param->rx_max_pending = HNS3_RING_MAX_PENDING; in hns3_get_ringparam()
658 param->tx_pending = priv->ring[0].desc_num; in hns3_get_ringparam()
659 param->rx_pending = priv->ring[queue_num].desc_num; in hns3_get_ringparam()
666 struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev); in hns3_get_pauseparam()
668 if (!test_bit(HNAE3_DEV_SUPPORT_PAUSE_B, ae_dev->caps)) in hns3_get_pauseparam()
671 if (h->ae_algo->ops->get_pauseparam) in hns3_get_pauseparam()
672 h->ae_algo->ops->get_pauseparam(h, ¶m->autoneg, in hns3_get_pauseparam()
673 ¶m->rx_pause, ¶m->tx_pause); in hns3_get_pauseparam()
680 struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev); in hns3_set_pauseparam()
682 if (!test_bit(HNAE3_DEV_SUPPORT_PAUSE_B, ae_dev->caps)) in hns3_set_pauseparam()
683 return -EOPNOTSUPP; in hns3_set_pauseparam()
687 param->autoneg, param->rx_pause, param->tx_pause); in hns3_set_pauseparam()
689 if (h->ae_algo->ops->set_pauseparam) in hns3_set_pauseparam()
690 return h->ae_algo->ops->set_pauseparam(h, param->autoneg, in hns3_set_pauseparam()
691 param->rx_pause, in hns3_set_pauseparam()
692 param->tx_pause); in hns3_set_pauseparam()
693 return -EOPNOTSUPP; in hns3_set_pauseparam()
699 const struct hnae3_ae_ops *ops = h->ae_algo->ops; in hns3_get_ksettings()
702 if (ops->get_ksettings_an_result) in hns3_get_ksettings()
703 ops->get_ksettings_an_result(h, in hns3_get_ksettings()
704 &cmd->base.autoneg, in hns3_get_ksettings()
705 &cmd->base.speed, in hns3_get_ksettings()
706 &cmd->base.duplex); in hns3_get_ksettings()
709 if (ops->get_link_mode) in hns3_get_ksettings()
710 ops->get_link_mode(h, in hns3_get_ksettings()
711 cmd->link_modes.supported, in hns3_get_ksettings()
712 cmd->link_modes.advertising); in hns3_get_ksettings()
715 if (ops->get_mdix_mode) in hns3_get_ksettings()
716 ops->get_mdix_mode(h, &cmd->base.eth_tp_mdix_ctrl, in hns3_get_ksettings()
717 &cmd->base.eth_tp_mdix); in hns3_get_ksettings()
724 struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev); in hns3_get_link_ksettings()
730 ops = h->ae_algo->ops; in hns3_get_link_ksettings()
731 if (ops->get_media_type) in hns3_get_link_ksettings()
732 ops->get_media_type(h, &media_type, &module_type); in hns3_get_link_ksettings()
734 return -EOPNOTSUPP; in hns3_get_link_ksettings()
738 cmd->base.port = PORT_NONE; in hns3_get_link_ksettings()
743 cmd->base.port = PORT_DA; in hns3_get_link_ksettings()
745 cmd->base.port = PORT_FIBRE; in hns3_get_link_ksettings()
750 cmd->base.port = PORT_NONE; in hns3_get_link_ksettings()
754 cmd->base.port = PORT_TP; in hns3_get_link_ksettings()
755 if (test_bit(HNAE3_DEV_SUPPORT_PHY_IMP_B, ae_dev->caps) && in hns3_get_link_ksettings()
756 ops->get_phy_link_ksettings) in hns3_get_link_ksettings()
757 ops->get_phy_link_ksettings(h, cmd); in hns3_get_link_ksettings()
758 else if (!netdev->phydev) in hns3_get_link_ksettings()
761 phy_ethtool_ksettings_get(netdev->phydev, cmd); in hns3_get_link_ksettings()
770 cmd->base.mdio_support = ETH_MDIO_SUPPORTS_C22; in hns3_get_link_ksettings()
774 cmd->base.speed = SPEED_UNKNOWN; in hns3_get_link_ksettings()
775 cmd->base.duplex = DUPLEX_UNKNOWN; in hns3_get_link_ksettings()
785 const struct hnae3_ae_ops *ops = handle->ae_algo->ops; in hns3_check_ksettings_param()
796 if (cmd->base.autoneg) in hns3_check_ksettings_param()
799 if (ops->get_ksettings_an_result) { in hns3_check_ksettings_param()
800 ops->get_ksettings_an_result(handle, &autoneg, &speed, &duplex); in hns3_check_ksettings_param()
801 if (cmd->base.autoneg == autoneg && cmd->base.speed == speed && in hns3_check_ksettings_param()
802 cmd->base.duplex == duplex) in hns3_check_ksettings_param()
806 if (ops->get_media_type) in hns3_check_ksettings_param()
807 ops->get_media_type(handle, &media_type, &module_type); in hns3_check_ksettings_param()
809 if (cmd->base.duplex == DUPLEX_HALF && in hns3_check_ksettings_param()
813 return -EINVAL; in hns3_check_ksettings_param()
816 if (ops->check_port_speed) { in hns3_check_ksettings_param()
817 ret = ops->check_port_speed(handle, cmd->base.speed); in hns3_check_ksettings_param()
831 struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev); in hns3_set_link_ksettings()
832 const struct hnae3_ae_ops *ops = handle->ae_algo->ops; in hns3_set_link_ksettings()
836 if (cmd->base.speed == SPEED_1000 && cmd->base.duplex == DUPLEX_HALF) in hns3_set_link_ksettings()
837 return -EINVAL; in hns3_set_link_ksettings()
841 netdev->phydev ? "phy" : "mac", in hns3_set_link_ksettings()
842 cmd->base.autoneg, cmd->base.speed, cmd->base.duplex); in hns3_set_link_ksettings()
845 if (netdev->phydev) { in hns3_set_link_ksettings()
846 if (cmd->base.speed == SPEED_1000 && in hns3_set_link_ksettings()
847 cmd->base.autoneg == AUTONEG_DISABLE) in hns3_set_link_ksettings()
848 return -EINVAL; in hns3_set_link_ksettings()
850 return phy_ethtool_ksettings_set(netdev->phydev, cmd); in hns3_set_link_ksettings()
851 } else if (test_bit(HNAE3_DEV_SUPPORT_PHY_IMP_B, ae_dev->caps) && in hns3_set_link_ksettings()
852 ops->set_phy_link_ksettings) { in hns3_set_link_ksettings()
853 return ops->set_phy_link_ksettings(handle, cmd); in hns3_set_link_ksettings()
856 if (ae_dev->dev_version < HNAE3_DEVICE_VERSION_V2) in hns3_set_link_ksettings()
857 return -EOPNOTSUPP; in hns3_set_link_ksettings()
863 if (ops->set_autoneg) { in hns3_set_link_ksettings()
864 ret = ops->set_autoneg(handle, cmd->base.autoneg); in hns3_set_link_ksettings()
872 if (cmd->base.autoneg) { in hns3_set_link_ksettings()
878 if (ops->cfg_mac_speed_dup_h) in hns3_set_link_ksettings()
879 ret = ops->cfg_mac_speed_dup_h(handle, cmd->base.speed, in hns3_set_link_ksettings()
880 cmd->base.duplex); in hns3_set_link_ksettings()
889 if (!h->ae_algo->ops->get_rss_key_size) in hns3_get_rss_key_size()
892 return h->ae_algo->ops->get_rss_key_size(h); in hns3_get_rss_key_size()
898 struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev); in hns3_get_rss_indir_size()
900 return ae_dev->dev_specs.rss_ind_tbl_size; in hns3_get_rss_indir_size()
908 if (!h->ae_algo->ops->get_rss) in hns3_get_rss()
909 return -EOPNOTSUPP; in hns3_get_rss()
911 return h->ae_algo->ops->get_rss(h, indir, key, hfunc); in hns3_get_rss()
918 struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev); in hns3_set_rss()
920 if (!h->ae_algo->ops->set_rss) in hns3_set_rss()
921 return -EOPNOTSUPP; in hns3_set_rss()
923 if ((ae_dev->dev_version < HNAE3_DEVICE_VERSION_V2 && in hns3_set_rss()
927 return -EOPNOTSUPP; in hns3_set_rss()
933 return -EOPNOTSUPP; in hns3_set_rss()
936 return h->ae_algo->ops->set_rss(h, indir, key, hfunc); in hns3_set_rss()
945 switch (cmd->cmd) { in hns3_get_rxnfc()
947 cmd->data = h->kinfo.num_tqps; in hns3_get_rxnfc()
950 if (h->ae_algo->ops->get_rss_tuple) in hns3_get_rxnfc()
951 return h->ae_algo->ops->get_rss_tuple(h, cmd); in hns3_get_rxnfc()
952 return -EOPNOTSUPP; in hns3_get_rxnfc()
954 if (h->ae_algo->ops->get_fd_rule_cnt) in hns3_get_rxnfc()
955 return h->ae_algo->ops->get_fd_rule_cnt(h, cmd); in hns3_get_rxnfc()
956 return -EOPNOTSUPP; in hns3_get_rxnfc()
958 if (h->ae_algo->ops->get_fd_rule_info) in hns3_get_rxnfc()
959 return h->ae_algo->ops->get_fd_rule_info(h, cmd); in hns3_get_rxnfc()
960 return -EOPNOTSUPP; in hns3_get_rxnfc()
962 if (h->ae_algo->ops->get_fd_all_rules) in hns3_get_rxnfc()
963 return h->ae_algo->ops->get_fd_all_rules(h, cmd, in hns3_get_rxnfc()
965 return -EOPNOTSUPP; in hns3_get_rxnfc()
967 return -EOPNOTSUPP; in hns3_get_rxnfc()
985 struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev); in hns3_set_reset()
986 const struct hnae3_ae_ops *ops = h->ae_algo->ops; in hns3_set_reset()
990 if (ops->ae_dev_resetting && ops->ae_dev_resetting(h)) in hns3_set_reset()
991 return -EBUSY; in hns3_set_reset()
993 if (!ops->set_default_reset_request || !ops->reset_event) in hns3_set_reset()
994 return -EOPNOTSUPP; in hns3_set_reset()
996 if (h->flags & HNAE3_SUPPORT_VF) { in hns3_set_reset()
1013 ae_dev->dev_version <= HNAE3_DEVICE_VERSION_V2)) in hns3_set_reset()
1014 return -EOPNOTSUPP; in hns3_set_reset()
1018 ops->set_default_reset_request(ae_dev, rst_type); in hns3_set_reset()
1020 ops->reset_event(h->pdev, h); in hns3_set_reset()
1028 struct hnae3_handle *h = priv->ae_handle; in hns3_change_all_ring_bd_num()
1031 h->kinfo.num_tx_desc = tx_desc_num; in hns3_change_all_ring_bd_num()
1032 h->kinfo.num_rx_desc = rx_desc_num; in hns3_change_all_ring_bd_num()
1034 for (i = 0; i < h->kinfo.num_tqps; i++) { in hns3_change_all_ring_bd_num()
1035 priv->ring[i].desc_num = tx_desc_num; in hns3_change_all_ring_bd_num()
1036 priv->ring[i + h->kinfo.num_tqps].desc_num = rx_desc_num; in hns3_change_all_ring_bd_num()
1042 struct hnae3_handle *handle = priv->ae_handle; in hns3_backup_ringparam()
1046 tmp_rings = kcalloc(handle->kinfo.num_tqps * 2, in hns3_backup_ringparam()
1051 for (i = 0; i < handle->kinfo.num_tqps * 2; i++) { in hns3_backup_ringparam()
1052 memcpy(&tmp_rings[i], &priv->ring[i], in hns3_backup_ringparam()
1064 return -EBUSY; in hns3_check_ringparam()
1066 if (param->rx_mini_pending || param->rx_jumbo_pending) in hns3_check_ringparam()
1067 return -EINVAL; in hns3_check_ringparam()
1069 if (param->tx_pending > HNS3_RING_MAX_PENDING || in hns3_check_ringparam()
1070 param->tx_pending < HNS3_RING_MIN_PENDING || in hns3_check_ringparam()
1071 param->rx_pending > HNS3_RING_MAX_PENDING || in hns3_check_ringparam()
1072 param->rx_pending < HNS3_RING_MIN_PENDING) { in hns3_check_ringparam()
1073 netdev_err(ndev, "Queue depth out of range [%d-%d]\n", in hns3_check_ringparam()
1075 return -EINVAL; in hns3_check_ringparam()
1085 struct hnae3_handle *h = priv->ae_handle; in hns3_set_ringparam()
1090 u16 queue_num = h->kinfo.num_tqps; in hns3_set_ringparam()
1098 new_tx_desc_num = ALIGN(param->tx_pending, HNS3_RING_BD_MULTIPLE); in hns3_set_ringparam()
1099 new_rx_desc_num = ALIGN(param->rx_pending, HNS3_RING_BD_MULTIPLE); in hns3_set_ringparam()
1100 old_tx_desc_num = priv->ring[0].desc_num; in hns3_set_ringparam()
1101 old_rx_desc_num = priv->ring[queue_num].desc_num; in hns3_set_ringparam()
1110 return -ENOMEM; in hns3_set_ringparam()
1119 ndev->netdev_ops->ndo_stop(ndev); in hns3_set_ringparam()
1129 for (i = 0; i < h->kinfo.num_tqps * 2; i++) in hns3_set_ringparam()
1130 memcpy(&priv->ring[i], &tmp_rings[i], in hns3_set_ringparam()
1133 for (i = 0; i < h->kinfo.num_tqps * 2; i++) in hns3_set_ringparam()
1140 ret = ndev->netdev_ops->ndo_open(ndev); in hns3_set_ringparam()
1149 switch (cmd->cmd) { in hns3_set_rxnfc()
1151 if (h->ae_algo->ops->set_rss_tuple) in hns3_set_rxnfc()
1152 return h->ae_algo->ops->set_rss_tuple(h, cmd); in hns3_set_rxnfc()
1153 return -EOPNOTSUPP; in hns3_set_rxnfc()
1155 if (h->ae_algo->ops->add_fd_entry) in hns3_set_rxnfc()
1156 return h->ae_algo->ops->add_fd_entry(h, cmd); in hns3_set_rxnfc()
1157 return -EOPNOTSUPP; in hns3_set_rxnfc()
1159 if (h->ae_algo->ops->del_fd_entry) in hns3_set_rxnfc()
1160 return h->ae_algo->ops->del_fd_entry(h, cmd); in hns3_set_rxnfc()
1161 return -EOPNOTSUPP; in hns3_set_rxnfc()
1163 return -EOPNOTSUPP; in hns3_set_rxnfc()
1170 const struct hnae3_ae_ops *ops = handle->ae_algo->ops; in hns3_nway_reset()
1171 struct phy_device *phy = netdev->phydev; in hns3_nway_reset()
1179 return -EBUSY; in hns3_nway_reset()
1182 if (!ops->get_autoneg || !ops->restart_autoneg) in hns3_nway_reset()
1183 return -EOPNOTSUPP; in hns3_nway_reset()
1185 autoneg = ops->get_autoneg(handle); in hns3_nway_reset()
1189 return -EINVAL; in hns3_nway_reset()
1198 return ops->restart_autoneg(handle); in hns3_nway_reset()
1206 if (h->ae_algo->ops->get_channels) in hns3_get_channels()
1207 h->ae_algo->ops->get_channels(h, ch); in hns3_get_channels()
1216 struct hns3_enet_coalesce *tx_coal = &priv->tx_coal; in hns3_get_coalesce()
1217 struct hns3_enet_coalesce *rx_coal = &priv->rx_coal; in hns3_get_coalesce()
1218 struct hnae3_handle *h = priv->ae_handle; in hns3_get_coalesce()
1221 return -EBUSY; in hns3_get_coalesce()
1223 cmd->use_adaptive_tx_coalesce = tx_coal->adapt_enable; in hns3_get_coalesce()
1224 cmd->use_adaptive_rx_coalesce = rx_coal->adapt_enable; in hns3_get_coalesce()
1226 cmd->tx_coalesce_usecs = tx_coal->int_gl; in hns3_get_coalesce()
1227 cmd->rx_coalesce_usecs = rx_coal->int_gl; in hns3_get_coalesce()
1229 cmd->tx_coalesce_usecs_high = h->kinfo.int_rl_setting; in hns3_get_coalesce()
1230 cmd->rx_coalesce_usecs_high = h->kinfo.int_rl_setting; in hns3_get_coalesce()
1232 cmd->tx_max_coalesced_frames = tx_coal->int_ql; in hns3_get_coalesce()
1233 cmd->rx_max_coalesced_frames = rx_coal->int_ql; in hns3_get_coalesce()
1235 kernel_coal->use_cqe_mode_tx = (priv->tx_cqe_mode == in hns3_get_coalesce()
1237 kernel_coal->use_cqe_mode_rx = (priv->rx_cqe_mode == in hns3_get_coalesce()
1247 struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev); in hns3_check_gl_coalesce_para()
1250 if (cmd->rx_coalesce_usecs > ae_dev->dev_specs.max_int_gl) { in hns3_check_gl_coalesce_para()
1252 "invalid rx-usecs value, rx-usecs range is 0-%u\n", in hns3_check_gl_coalesce_para()
1253 ae_dev->dev_specs.max_int_gl); in hns3_check_gl_coalesce_para()
1254 return -EINVAL; in hns3_check_gl_coalesce_para()
1257 if (cmd->tx_coalesce_usecs > ae_dev->dev_specs.max_int_gl) { in hns3_check_gl_coalesce_para()
1259 "invalid tx-usecs value, tx-usecs range is 0-%u\n", in hns3_check_gl_coalesce_para()
1260 ae_dev->dev_specs.max_int_gl); in hns3_check_gl_coalesce_para()
1261 return -EINVAL; in hns3_check_gl_coalesce_para()
1267 if (ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V3) in hns3_check_gl_coalesce_para()
1270 rx_gl = hns3_gl_round_down(cmd->rx_coalesce_usecs); in hns3_check_gl_coalesce_para()
1271 if (rx_gl != cmd->rx_coalesce_usecs) { in hns3_check_gl_coalesce_para()
1274 cmd->rx_coalesce_usecs, rx_gl); in hns3_check_gl_coalesce_para()
1277 tx_gl = hns3_gl_round_down(cmd->tx_coalesce_usecs); in hns3_check_gl_coalesce_para()
1278 if (tx_gl != cmd->tx_coalesce_usecs) { in hns3_check_gl_coalesce_para()
1281 cmd->tx_coalesce_usecs, tx_gl); in hns3_check_gl_coalesce_para()
1292 if (cmd->tx_coalesce_usecs_high != cmd->rx_coalesce_usecs_high) { in hns3_check_rl_coalesce_para()
1295 return -EINVAL; in hns3_check_rl_coalesce_para()
1298 if (cmd->rx_coalesce_usecs_high > HNS3_INT_RL_MAX) { in hns3_check_rl_coalesce_para()
1300 "Invalid usecs_high value, usecs_high range is 0-%d\n", in hns3_check_rl_coalesce_para()
1302 return -EINVAL; in hns3_check_rl_coalesce_para()
1305 rl = hns3_rl_round_down(cmd->rx_coalesce_usecs_high); in hns3_check_rl_coalesce_para()
1306 if (rl != cmd->rx_coalesce_usecs_high) { in hns3_check_rl_coalesce_para()
1309 cmd->rx_coalesce_usecs_high, rl); in hns3_check_rl_coalesce_para()
1319 struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev); in hns3_check_ql_coalesce_param()
1321 if ((cmd->tx_max_coalesced_frames || cmd->rx_max_coalesced_frames) && in hns3_check_ql_coalesce_param()
1322 !ae_dev->dev_specs.int_ql_max) { in hns3_check_ql_coalesce_param()
1324 return -EOPNOTSUPP; in hns3_check_ql_coalesce_param()
1327 if (cmd->tx_max_coalesced_frames > ae_dev->dev_specs.int_ql_max || in hns3_check_ql_coalesce_param()
1328 cmd->rx_max_coalesced_frames > ae_dev->dev_specs.int_ql_max) { in hns3_check_ql_coalesce_param()
1330 "invalid coalesced_frames value, range is 0-%u\n", in hns3_check_ql_coalesce_param()
1331 ae_dev->dev_specs.int_ql_max); in hns3_check_ql_coalesce_param()
1332 return -ERANGE; in hns3_check_ql_coalesce_param()
1366 struct hnae3_handle *h = priv->ae_handle; in hns3_set_coalesce_per_queue()
1367 int queue_num = h->kinfo.num_tqps; in hns3_set_coalesce_per_queue()
1369 tx_vector = priv->ring[queue].tqp_vector; in hns3_set_coalesce_per_queue()
1370 rx_vector = priv->ring[queue_num + queue].tqp_vector; in hns3_set_coalesce_per_queue()
1372 tx_vector->tx_group.coal.adapt_enable = in hns3_set_coalesce_per_queue()
1373 cmd->use_adaptive_tx_coalesce; in hns3_set_coalesce_per_queue()
1374 rx_vector->rx_group.coal.adapt_enable = in hns3_set_coalesce_per_queue()
1375 cmd->use_adaptive_rx_coalesce; in hns3_set_coalesce_per_queue()
1377 tx_vector->tx_group.coal.int_gl = cmd->tx_coalesce_usecs; in hns3_set_coalesce_per_queue()
1378 rx_vector->rx_group.coal.int_gl = cmd->rx_coalesce_usecs; in hns3_set_coalesce_per_queue()
1380 tx_vector->tx_group.coal.int_ql = cmd->tx_max_coalesced_frames; in hns3_set_coalesce_per_queue()
1381 rx_vector->rx_group.coal.int_ql = cmd->rx_max_coalesced_frames; in hns3_set_coalesce_per_queue()
1384 tx_vector->tx_group.coal.int_gl); in hns3_set_coalesce_per_queue()
1386 rx_vector->rx_group.coal.int_gl); in hns3_set_coalesce_per_queue()
1388 hns3_set_vector_coalesce_rl(tx_vector, h->kinfo.int_rl_setting); in hns3_set_coalesce_per_queue()
1389 hns3_set_vector_coalesce_rl(rx_vector, h->kinfo.int_rl_setting); in hns3_set_coalesce_per_queue()
1391 if (tx_vector->tx_group.coal.ql_enable) in hns3_set_coalesce_per_queue()
1393 tx_vector->tx_group.coal.int_ql); in hns3_set_coalesce_per_queue()
1394 if (rx_vector->rx_group.coal.ql_enable) in hns3_set_coalesce_per_queue()
1396 rx_vector->rx_group.coal.int_ql); in hns3_set_coalesce_per_queue()
1406 struct hns3_enet_coalesce *tx_coal = &priv->tx_coal; in hns3_set_coalesce()
1407 struct hns3_enet_coalesce *rx_coal = &priv->rx_coal; in hns3_set_coalesce()
1408 u16 queue_num = h->kinfo.num_tqps; in hns3_set_coalesce()
1415 return -EBUSY; in hns3_set_coalesce()
1421 h->kinfo.int_rl_setting = in hns3_set_coalesce()
1422 hns3_rl_round_down(cmd->rx_coalesce_usecs_high); in hns3_set_coalesce()
1424 tx_coal->adapt_enable = cmd->use_adaptive_tx_coalesce; in hns3_set_coalesce()
1425 rx_coal->adapt_enable = cmd->use_adaptive_rx_coalesce; in hns3_set_coalesce()
1427 tx_coal->int_gl = cmd->tx_coalesce_usecs; in hns3_set_coalesce()
1428 rx_coal->int_gl = cmd->rx_coalesce_usecs; in hns3_set_coalesce()
1430 tx_coal->int_ql = cmd->tx_max_coalesced_frames; in hns3_set_coalesce()
1431 rx_coal->int_ql = cmd->rx_max_coalesced_frames; in hns3_set_coalesce()
1436 tx_mode = kernel_coal->use_cqe_mode_tx ? in hns3_set_coalesce()
1439 rx_mode = kernel_coal->use_cqe_mode_rx ? in hns3_set_coalesce()
1451 if (!h->ae_algo->ops->get_regs_len) in hns3_get_regs_len()
1452 return -EOPNOTSUPP; in hns3_get_regs_len()
1454 return h->ae_algo->ops->get_regs_len(h); in hns3_get_regs_len()
1462 if (!h->ae_algo->ops->get_regs) in hns3_get_regs()
1465 h->ae_algo->ops->get_regs(h, &cmd->version, data); in hns3_get_regs()
1473 if (!h->ae_algo->ops->set_led_id) in hns3_set_phys_id()
1474 return -EOPNOTSUPP; in hns3_set_phys_id()
1476 return h->ae_algo->ops->set_led_id(h, state); in hns3_set_phys_id()
1483 return h->msg_enable; in hns3_get_msglevel()
1490 h->msg_enable = msg_level; in hns3_set_msglevel()
1534 struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev); in hns3_get_fecparam()
1535 const struct hnae3_ae_ops *ops = handle->ae_algo->ops; in hns3_get_fecparam()
1539 if (!test_bit(HNAE3_DEV_SUPPORT_FEC_B, ae_dev->caps)) in hns3_get_fecparam()
1540 return -EOPNOTSUPP; in hns3_get_fecparam()
1542 if (!ops->get_fec) in hns3_get_fecparam()
1543 return -EOPNOTSUPP; in hns3_get_fecparam()
1545 ops->get_fec(handle, &fec_ability, &fec_mode); in hns3_get_fecparam()
1547 fec->fec = loc_to_eth_fec(fec_ability); in hns3_get_fecparam()
1548 fec->active_fec = loc_to_eth_fec(fec_mode); in hns3_get_fecparam()
1557 struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev); in hns3_set_fecparam()
1558 const struct hnae3_ae_ops *ops = handle->ae_algo->ops; in hns3_set_fecparam()
1561 if (!test_bit(HNAE3_DEV_SUPPORT_FEC_B, ae_dev->caps)) in hns3_set_fecparam()
1562 return -EOPNOTSUPP; in hns3_set_fecparam()
1564 if (!ops->set_fec) in hns3_set_fecparam()
1565 return -EOPNOTSUPP; in hns3_set_fecparam()
1566 fec_mode = eth_to_loc_fec(fec->fec); in hns3_set_fecparam()
1570 return ops->set_fec(handle, fec_mode); in hns3_set_fecparam()
1579 struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev); in hns3_get_module_info()
1580 const struct hnae3_ae_ops *ops = handle->ae_algo->ops; in hns3_get_module_info()
1584 if (ae_dev->dev_version < HNAE3_DEVICE_VERSION_V2 || in hns3_get_module_info()
1585 !ops->get_module_eeprom) in hns3_get_module_info()
1586 return -EOPNOTSUPP; in hns3_get_module_info()
1589 ret = ops->get_module_eeprom(handle, 0, sizeof(sfp_type) / sizeof(u8), in hns3_get_module_info()
1596 modinfo->type = ETH_MODULE_SFF_8472; in hns3_get_module_info()
1597 modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN; in hns3_get_module_info()
1600 modinfo->type = ETH_MODULE_SFF_8436; in hns3_get_module_info()
1601 modinfo->eeprom_len = ETH_MODULE_SFF_8436_MAX_LEN; in hns3_get_module_info()
1605 modinfo->type = ETH_MODULE_SFF_8436; in hns3_get_module_info()
1606 modinfo->eeprom_len = ETH_MODULE_SFF_8436_MAX_LEN; in hns3_get_module_info()
1608 modinfo->type = ETH_MODULE_SFF_8636; in hns3_get_module_info()
1609 modinfo->eeprom_len = ETH_MODULE_SFF_8636_MAX_LEN; in hns3_get_module_info()
1613 modinfo->type = ETH_MODULE_SFF_8636; in hns3_get_module_info()
1614 modinfo->eeprom_len = ETH_MODULE_SFF_8636_MAX_LEN; in hns3_get_module_info()
1619 return -EINVAL; in hns3_get_module_info()
1629 struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev); in hns3_get_module_eeprom()
1630 const struct hnae3_ae_ops *ops = handle->ae_algo->ops; in hns3_get_module_eeprom()
1632 if (ae_dev->dev_version < HNAE3_DEVICE_VERSION_V2 || in hns3_get_module_eeprom()
1633 !ops->get_module_eeprom) in hns3_get_module_eeprom()
1634 return -EOPNOTSUPP; in hns3_get_module_eeprom()
1636 if (!ee->len) in hns3_get_module_eeprom()
1637 return -EINVAL; in hns3_get_module_eeprom()
1639 memset(data, 0, ee->len); in hns3_get_module_eeprom()
1641 return ops->get_module_eeprom(handle, ee->offset, ee->len, data); in hns3_get_module_eeprom()
1648 return handle->priv_flags; in hns3_get_priv_flags()
1656 if ((changed & BIT(i)) && !test_bit(i, &h->supported_pflags)) { in hns3_check_priv_flags()
1657 netdev_err(h->netdev, "%s is unsupported\n", in hns3_check_priv_flags()
1659 return -EOPNOTSUPP; in hns3_check_priv_flags()
1668 u32 changed = pflags ^ handle->priv_flags; in hns3_set_priv_flags()
1678 bool enable = !(handle->priv_flags & BIT(i)); in hns3_set_priv_flags()
1681 handle->priv_flags |= BIT(i); in hns3_set_priv_flags()
1683 handle->priv_flags &= ~BIT(i); in hns3_set_priv_flags()
1698 switch (tuna->id) { in hns3_get_tunable()
1701 *(u32 *)data = priv->tx_copybreak; in hns3_get_tunable()
1704 *(u32 *)data = priv->rx_copybreak; in hns3_get_tunable()
1707 ret = -EOPNOTSUPP; in hns3_get_tunable()
1719 struct hnae3_handle *h = priv->ae_handle; in hns3_set_tunable()
1722 switch (tuna->id) { in hns3_set_tunable()
1724 priv->tx_copybreak = *(u32 *)data; in hns3_set_tunable()
1726 for (i = 0; i < h->kinfo.num_tqps; i++) in hns3_set_tunable()
1727 priv->ring[i].tx_copybreak = priv->tx_copybreak; in hns3_set_tunable()
1731 priv->rx_copybreak = *(u32 *)data; in hns3_set_tunable()
1733 for (i = h->kinfo.num_tqps; i < h->kinfo.num_tqps * 2; i++) in hns3_set_tunable()
1734 priv->ring[i].rx_copybreak = priv->rx_copybreak; in hns3_set_tunable()
1738 ret = -EOPNOTSUPP; in hns3_set_tunable()
1757 if (handle->ae_algo->ops->get_ts_info) in hns3_get_ts_info()
1758 return handle->ae_algo->ops->get_ts_info(handle, info); in hns3_get_ts_info()
1807 return -ENODATA; in hns3_get_link_ext_state()
1809 if (!h->ae_algo->ops->get_link_diagnosis_info) in hns3_get_link_ext_state()
1810 return -EOPNOTSUPP; in hns3_get_link_ext_state()
1812 ret = h->ae_algo->ops->get_link_diagnosis_info(h, &status_code); in hns3_get_link_ext_state()
1818 if (map->status_code == status_code) { in hns3_get_link_ext_state()
1819 info->link_ext_state = map->link_ext_state; in hns3_get_link_ext_state()
1820 info->__link_ext_substate = map->link_ext_substate; in hns3_get_link_ext_state()
1825 return -ENODATA; in hns3_get_link_ext_state()
1906 if (h->flags & HNAE3_SUPPORT_VF) in hns3_ethtool_set_ops()
1907 netdev->ethtool_ops = &hns3vf_ethtool_ops; in hns3_ethtool_set_ops()
1909 netdev->ethtool_ops = &hns3_ethtool_ops; in hns3_ethtool_set_ops()