Lines Matching +full:no +full:- +full:loopback +full:- +full:test

1 // SPDX-License-Identifier: GPL-2.0-only
31 /* Initialiser for a struct efx_sw_stat_desc with type-checking */
37 &((struct efx_##source_name *)0)->field) ? \
105 "log-tc-errors",
117 strscpy(info->driver, KBUILD_MODNAME, sizeof(info->driver)); in efx_ethtool_get_drvinfo()
118 efx_mcdi_print_fwver(efx, info->fw_version, in efx_ethtool_get_drvinfo()
119 sizeof(info->fw_version)); in efx_ethtool_get_drvinfo()
120 strscpy(info->bus_info, pci_name(efx->pci_dev), sizeof(info->bus_info)); in efx_ethtool_get_drvinfo()
127 return efx->msg_enable; in efx_ethtool_get_msglevel()
134 efx->msg_enable = msg_enable; in efx_ethtool_set_msglevel()
138 struct ethtool_test *test, u64 *data) in efx_ethtool_self_test() argument
143 int rc = -ENOMEM; in efx_ethtool_self_test()
149 if (!efx_net_active(efx->state)) { in efx_ethtool_self_test()
150 rc = -EBUSY; in efx_ethtool_self_test()
154 netif_info(efx, drv, efx->net_dev, "starting %sline testing\n", in efx_ethtool_self_test()
155 (test->flags & ETH_TEST_FL_OFFLINE) ? "off" : "on"); in efx_ethtool_self_test()
158 already_up = (efx->net_dev->flags & IFF_UP); in efx_ethtool_self_test()
160 rc = dev_open(efx->net_dev, NULL); in efx_ethtool_self_test()
162 netif_err(efx, drv, efx->net_dev, in efx_ethtool_self_test()
168 rc = efx_selftest(efx, efx_tests, test->flags); in efx_ethtool_self_test()
171 dev_close(efx->net_dev); in efx_ethtool_self_test()
173 netif_info(efx, drv, efx->net_dev, "%s %sline self-tests\n", in efx_ethtool_self_test()
175 (test->flags & ETH_TEST_FL_OFFLINE) ? "off" : "on"); in efx_ethtool_self_test()
182 test->flags |= ETH_TEST_FL_FAILED; in efx_ethtool_self_test()
190 pause->rx_pause = !!(efx->wanted_fc & EFX_FC_RX); in efx_ethtool_get_pauseparam()
191 pause->tx_pause = !!(efx->wanted_fc & EFX_FC_TX); in efx_ethtool_get_pauseparam()
192 pause->autoneg = !!(efx->wanted_fc & EFX_FC_AUTO); in efx_ethtool_get_pauseparam()
203 mutex_lock(&efx->mac_lock); in efx_ethtool_set_pauseparam()
205 wanted_fc = ((pause->rx_pause ? EFX_FC_RX : 0) | in efx_ethtool_set_pauseparam()
206 (pause->tx_pause ? EFX_FC_TX : 0) | in efx_ethtool_set_pauseparam()
207 (pause->autoneg ? EFX_FC_AUTO : 0)); in efx_ethtool_set_pauseparam()
210 netif_dbg(efx, drv, efx->net_dev, in efx_ethtool_set_pauseparam()
212 rc = -EINVAL; in efx_ethtool_set_pauseparam()
216 if ((wanted_fc & EFX_FC_AUTO) && !efx->link_advertising[0]) { in efx_ethtool_set_pauseparam()
217 netif_dbg(efx, drv, efx->net_dev, in efx_ethtool_set_pauseparam()
219 rc = -EINVAL; in efx_ethtool_set_pauseparam()
224 if (efx->type->prepare_enable_fc_tx && in efx_ethtool_set_pauseparam()
225 (wanted_fc & EFX_FC_TX) && !(efx->wanted_fc & EFX_FC_TX)) in efx_ethtool_set_pauseparam()
226 efx->type->prepare_enable_fc_tx(efx); in efx_ethtool_set_pauseparam()
228 old_adv = efx->link_advertising[0]; in efx_ethtool_set_pauseparam()
229 old_fc = efx->wanted_fc; in efx_ethtool_set_pauseparam()
231 if (efx->link_advertising[0] != old_adv || in efx_ethtool_set_pauseparam()
232 (efx->wanted_fc ^ old_fc) & EFX_FC_AUTO) { in efx_ethtool_set_pauseparam()
235 netif_err(efx, drv, efx->net_dev, in efx_ethtool_set_pauseparam()
243 * if the user just changed the advertised capabilities, but there's no in efx_ethtool_set_pauseparam()
248 mutex_unlock(&efx->mac_lock); in efx_ethtool_set_pauseparam()
254 * efx_fill_test - fill in an individual self-test entry
255 * @test_index: Index of the test
257 * @data: Ethtool test results, or %NULL
258 * @test: Pointer to test result (used only if data != %NULL)
261 * @test_format: Test name format (e.g. "loopback.\%s.tx.sent")
262 * @test_id: Test id (e.g. "PHYXS" for "loopback.PHYXS.tx_sent")
264 * Fill in an individual self-test entry.
267 int *test, const char *unit_format, int unit_id, in efx_fill_test() argument
274 data[test_index] = *test; in efx_fill_test()
286 "%-6s %-24s", unit_str, test_str); in efx_fill_test()
290 #define EFX_CHANNEL_NAME(_channel) "chan%d", _channel->channel
291 #define EFX_TX_QUEUE_NAME(_tx_queue) "txq%d", _tx_queue->label
293 "loopback.%s." _counter, STRING_TABLE_LOOKUP(_mode, efx_loopback_mode)
296 * efx_fill_loopback_test - fill in a block of loopback self-test entries
298 * @lb_tests: Efx loopback self-test results structure
299 * @mode: Loopback test mode
300 * @test_index: Starting index of the test
302 * @data: Ethtool test results, or %NULL
304 * Fill in a block of loopback self-test entries. Return new test
314 efx_get_channel(efx, efx->tx_channel_offset); in efx_fill_loopback_test()
319 &lb_tests->tx_sent[tx_queue->label], in efx_fill_loopback_test()
323 &lb_tests->tx_done[tx_queue->label], in efx_fill_loopback_test()
328 &lb_tests->rx_good, in efx_fill_loopback_test()
332 &lb_tests->rx_bad, in efx_fill_loopback_test()
340 * efx_ethtool_fill_self_tests - get self-test details
342 * @tests: Efx self-test results structure, or %NULL
344 * @data: Ethtool test results, or %NULL
346 * Get self-test number of strings, strings, and/or test results.
347 * Return number of strings (== number of test results).
360 efx_fill_test(n++, strings, data, &tests->phy_alive, in efx_ethtool_fill_self_tests()
362 efx_fill_test(n++, strings, data, &tests->nvram, in efx_ethtool_fill_self_tests()
364 efx_fill_test(n++, strings, data, &tests->interrupt, in efx_ethtool_fill_self_tests()
370 &tests->eventq_dma[channel->channel], in efx_ethtool_fill_self_tests()
374 &tests->eventq_int[channel->channel], in efx_ethtool_fill_self_tests()
379 efx_fill_test(n++, strings, data, &tests->memory, in efx_ethtool_fill_self_tests()
381 efx_fill_test(n++, strings, data, &tests->registers, in efx_ethtool_fill_self_tests()
392 efx_fill_test(n++, strings, data, &tests->phy_ext[i], "phy", 0, name, NULL); in efx_ethtool_fill_self_tests()
395 /* Loopback tests */ in efx_ethtool_fill_self_tests()
397 if (!(efx->loopback_modes & (1 << mode))) in efx_ethtool_fill_self_tests()
400 &tests->loopback[mode], mode, n, in efx_ethtool_fill_self_tests()
417 "tx-%u.tx_packets", in efx_describe_per_queue_stats()
418 channel->tx_queue[0].queue / in efx_describe_per_queue_stats()
430 "rx-%d.rx_packets", channel->channel); in efx_describe_per_queue_stats()
435 if (efx->xdp_tx_queue_count && efx->xdp_tx_queues) { in efx_describe_per_queue_stats()
438 for (xdp = 0; xdp < efx->xdp_tx_queue_count; xdp++) { in efx_describe_per_queue_stats()
442 "tx-xdp-cpu-%hu.tx_packets", xdp); in efx_describe_per_queue_stats()
457 return efx->type->describe_stats(efx, NULL) + in efx_ethtool_get_sset_count()
466 return -EINVAL; in efx_ethtool_get_sset_count()
478 strings += (efx->type->describe_stats(efx, strings) * in efx_ethtool_get_strings()
498 /* No other string sets */ in efx_ethtool_get_strings()
508 if (efx->log_tc_errs) in efx_ethtool_get_priv_flags()
518 efx->log_tc_errs = in efx_ethtool_set_priv_flags()
535 spin_lock_bh(&efx->stats_lock); in efx_ethtool_get_stats()
538 data += efx->type->update_stats(efx, data, NULL); in efx_ethtool_get_stats()
543 switch (stat->source) { in efx_ethtool_get_stats()
545 data[i] = stat->get_stat((void *)efx + stat->offset); in efx_ethtool_get_stats()
550 data[i] += stat->get_stat((void *)channel + in efx_ethtool_get_stats()
551 stat->offset); in efx_ethtool_get_stats()
558 stat->get_stat((void *)tx_queue in efx_ethtool_get_stats()
559 + stat->offset); in efx_ethtool_get_stats()
566 spin_unlock_bh(&efx->stats_lock); in efx_ethtool_get_stats()
572 *data += tx_queue->tx_packets; in efx_ethtool_get_stats()
581 *data += rx_queue->rx_packets; in efx_ethtool_get_stats()
586 if (efx->xdp_tx_queue_count && efx->xdp_tx_queues) { in efx_ethtool_get_stats()
589 for (xdp = 0; xdp < efx->xdp_tx_queue_count; xdp++) { in efx_ethtool_get_stats()
590 data[0] = efx->xdp_tx_queues[xdp]->tx_packets; in efx_ethtool_get_stats()
603 struct efx_link_state *link_state = &efx->link_state; in efx_ethtool_get_link_ksettings()
605 mutex_lock(&efx->mac_lock); in efx_ethtool_get_link_ksettings()
607 mutex_unlock(&efx->mac_lock); in efx_ethtool_get_link_ksettings()
609 /* Both MACs support pause frames (bidirectional and respond-only) */ in efx_ethtool_get_link_ksettings()
614 cmd->base.speed = link_state->speed; in efx_ethtool_get_link_ksettings()
615 cmd->base.duplex = link_state->fd ? DUPLEX_FULL : DUPLEX_HALF; in efx_ethtool_get_link_ksettings()
629 if ((cmd->base.speed == SPEED_1000) && in efx_ethtool_set_link_ksettings()
630 (cmd->base.duplex != DUPLEX_FULL)) { in efx_ethtool_set_link_ksettings()
631 netif_dbg(efx, drv, efx->net_dev, in efx_ethtool_set_link_ksettings()
633 return -EINVAL; in efx_ethtool_set_link_ksettings()
636 mutex_lock(&efx->mac_lock); in efx_ethtool_set_link_ksettings()
638 mutex_unlock(&efx->mac_lock); in efx_ethtool_set_link_ksettings()
648 mutex_lock(&efx->mac_lock); in efx_ethtool_get_fecparam()
650 mutex_unlock(&efx->mac_lock); in efx_ethtool_get_fecparam()
661 mutex_lock(&efx->mac_lock); in efx_ethtool_set_fecparam()
663 mutex_unlock(&efx->mac_lock); in efx_ethtool_set_fecparam()
685 struct ethtool_tcpip4_spec *ip_entry = &rule->h_u.tcp_ip4_spec; in efx_ethtool_get_class_rule()
686 struct ethtool_tcpip4_spec *ip_mask = &rule->m_u.tcp_ip4_spec; in efx_ethtool_get_class_rule()
687 struct ethtool_usrip4_spec *uip_entry = &rule->h_u.usr_ip4_spec; in efx_ethtool_get_class_rule()
688 struct ethtool_usrip4_spec *uip_mask = &rule->m_u.usr_ip4_spec; in efx_ethtool_get_class_rule()
689 struct ethtool_tcpip6_spec *ip6_entry = &rule->h_u.tcp_ip6_spec; in efx_ethtool_get_class_rule()
690 struct ethtool_tcpip6_spec *ip6_mask = &rule->m_u.tcp_ip6_spec; in efx_ethtool_get_class_rule()
691 struct ethtool_usrip6_spec *uip6_entry = &rule->h_u.usr_ip6_spec; in efx_ethtool_get_class_rule()
692 struct ethtool_usrip6_spec *uip6_mask = &rule->m_u.usr_ip6_spec; in efx_ethtool_get_class_rule()
693 struct ethhdr *mac_entry = &rule->h_u.ether_spec; in efx_ethtool_get_class_rule()
694 struct ethhdr *mac_mask = &rule->m_u.ether_spec; in efx_ethtool_get_class_rule()
699 rule->location, &spec); in efx_ethtool_get_class_rule()
704 rule->ring_cookie = RX_CLS_FLOW_DISC; in efx_ethtool_get_class_rule()
706 rule->ring_cookie = spec.dmaq_id; in efx_ethtool_get_class_rule()
717 rule->flow_type = ((spec.ip_proto == IPPROTO_TCP) ? in efx_ethtool_get_class_rule()
720 ip_entry->ip4dst = spec.loc_host[0]; in efx_ethtool_get_class_rule()
721 ip_mask->ip4dst = IP4_ADDR_FULL_MASK; in efx_ethtool_get_class_rule()
724 ip_entry->ip4src = spec.rem_host[0]; in efx_ethtool_get_class_rule()
725 ip_mask->ip4src = IP4_ADDR_FULL_MASK; in efx_ethtool_get_class_rule()
728 ip_entry->pdst = spec.loc_port; in efx_ethtool_get_class_rule()
729 ip_mask->pdst = PORT_FULL_MASK; in efx_ethtool_get_class_rule()
732 ip_entry->psrc = spec.rem_port; in efx_ethtool_get_class_rule()
733 ip_mask->psrc = PORT_FULL_MASK; in efx_ethtool_get_class_rule()
744 rule->flow_type = ((spec.ip_proto == IPPROTO_TCP) ? in efx_ethtool_get_class_rule()
747 memcpy(ip6_entry->ip6dst, spec.loc_host, in efx_ethtool_get_class_rule()
748 sizeof(ip6_entry->ip6dst)); in efx_ethtool_get_class_rule()
749 ip6_fill_mask(ip6_mask->ip6dst); in efx_ethtool_get_class_rule()
752 memcpy(ip6_entry->ip6src, spec.rem_host, in efx_ethtool_get_class_rule()
753 sizeof(ip6_entry->ip6src)); in efx_ethtool_get_class_rule()
754 ip6_fill_mask(ip6_mask->ip6src); in efx_ethtool_get_class_rule()
757 ip6_entry->pdst = spec.loc_port; in efx_ethtool_get_class_rule()
758 ip6_mask->pdst = PORT_FULL_MASK; in efx_ethtool_get_class_rule()
761 ip6_entry->psrc = spec.rem_port; in efx_ethtool_get_class_rule()
762 ip6_mask->psrc = PORT_FULL_MASK; in efx_ethtool_get_class_rule()
768 rule->flow_type = ETHER_FLOW; in efx_ethtool_get_class_rule()
771 ether_addr_copy(mac_entry->h_dest, spec.loc_mac); in efx_ethtool_get_class_rule()
773 eth_broadcast_addr(mac_mask->h_dest); in efx_ethtool_get_class_rule()
775 ether_addr_copy(mac_mask->h_dest, in efx_ethtool_get_class_rule()
779 ether_addr_copy(mac_entry->h_source, spec.rem_mac); in efx_ethtool_get_class_rule()
780 eth_broadcast_addr(mac_mask->h_source); in efx_ethtool_get_class_rule()
783 mac_entry->h_proto = spec.ether_type; in efx_ethtool_get_class_rule()
784 mac_mask->h_proto = ETHER_TYPE_FULL_MASK; in efx_ethtool_get_class_rule()
792 rule->flow_type = IPV4_USER_FLOW; in efx_ethtool_get_class_rule()
793 uip_entry->ip_ver = ETH_RX_NFC_IP4; in efx_ethtool_get_class_rule()
795 uip_mask->proto = IP_PROTO_FULL_MASK; in efx_ethtool_get_class_rule()
796 uip_entry->proto = spec.ip_proto; in efx_ethtool_get_class_rule()
799 uip_entry->ip4dst = spec.loc_host[0]; in efx_ethtool_get_class_rule()
800 uip_mask->ip4dst = IP4_ADDR_FULL_MASK; in efx_ethtool_get_class_rule()
803 uip_entry->ip4src = spec.rem_host[0]; in efx_ethtool_get_class_rule()
804 uip_mask->ip4src = IP4_ADDR_FULL_MASK; in efx_ethtool_get_class_rule()
812 rule->flow_type = IPV6_USER_FLOW; in efx_ethtool_get_class_rule()
814 uip6_mask->l4_proto = IP_PROTO_FULL_MASK; in efx_ethtool_get_class_rule()
815 uip6_entry->l4_proto = spec.ip_proto; in efx_ethtool_get_class_rule()
818 memcpy(uip6_entry->ip6dst, spec.loc_host, in efx_ethtool_get_class_rule()
819 sizeof(uip6_entry->ip6dst)); in efx_ethtool_get_class_rule()
820 ip6_fill_mask(uip6_mask->ip6dst); in efx_ethtool_get_class_rule()
823 memcpy(uip6_entry->ip6src, spec.rem_host, in efx_ethtool_get_class_rule()
824 sizeof(uip6_entry->ip6src)); in efx_ethtool_get_class_rule()
825 ip6_fill_mask(uip6_mask->ip6src); in efx_ethtool_get_class_rule()
830 return -EINVAL; in efx_ethtool_get_class_rule()
834 rule->flow_type |= FLOW_EXT; in efx_ethtool_get_class_rule()
835 rule->h_ext.vlan_tci = spec.outer_vid; in efx_ethtool_get_class_rule()
836 rule->m_ext.vlan_tci = htons(0xfff); in efx_ethtool_get_class_rule()
840 rule->flow_type |= FLOW_RSS; in efx_ethtool_get_class_rule()
854 switch (info->cmd) { in efx_ethtool_get_rxnfc()
856 info->data = efx->n_rx_channels; in efx_ethtool_get_rxnfc()
860 struct efx_rss_context *ctx = &efx->rss_context; in efx_ethtool_get_rxnfc()
863 mutex_lock(&efx->rss_lock); in efx_ethtool_get_rxnfc()
864 if (info->flow_type & FLOW_RSS && info->rss_context) { in efx_ethtool_get_rxnfc()
865 ctx = efx_find_rss_context_entry(efx, info->rss_context); in efx_ethtool_get_rxnfc()
867 rc = -ENOENT; in efx_ethtool_get_rxnfc()
873 if (!efx_rss_active(ctx)) /* No RSS */ in efx_ethtool_get_rxnfc()
876 switch (info->flow_type & ~FLOW_RSS) { in efx_ethtool_get_rxnfc()
879 if (ctx->rx_hash_udp_4tuple) in efx_ethtool_get_rxnfc()
902 info->data = data; in efx_ethtool_get_rxnfc()
904 mutex_unlock(&efx->rss_lock); in efx_ethtool_get_rxnfc()
909 info->data = efx_filter_get_rx_id_limit(efx); in efx_ethtool_get_rxnfc()
910 if (info->data == 0) in efx_ethtool_get_rxnfc()
911 return -EOPNOTSUPP; in efx_ethtool_get_rxnfc()
912 info->data |= RX_CLS_LOC_SPECIAL; in efx_ethtool_get_rxnfc()
913 info->rule_cnt = in efx_ethtool_get_rxnfc()
919 return -EOPNOTSUPP; in efx_ethtool_get_rxnfc()
920 rc = efx_ethtool_get_class_rule(efx, &info->fs, &rss_context); in efx_ethtool_get_rxnfc()
923 if (info->fs.flow_type & FLOW_RSS) in efx_ethtool_get_rxnfc()
924 info->rss_context = rss_context; in efx_ethtool_get_rxnfc()
928 info->data = efx_filter_get_rx_id_limit(efx); in efx_ethtool_get_rxnfc()
929 if (info->data == 0) in efx_ethtool_get_rxnfc()
930 return -EOPNOTSUPP; in efx_ethtool_get_rxnfc()
932 rule_locs, info->rule_cnt); in efx_ethtool_get_rxnfc()
935 info->rule_cnt = rc; in efx_ethtool_get_rxnfc()
939 return -EOPNOTSUPP; in efx_ethtool_get_rxnfc()
957 struct ethtool_tcpip4_spec *ip_entry = &rule->h_u.tcp_ip4_spec; in efx_ethtool_set_class_rule()
958 struct ethtool_tcpip4_spec *ip_mask = &rule->m_u.tcp_ip4_spec; in efx_ethtool_set_class_rule()
959 struct ethtool_usrip4_spec *uip_entry = &rule->h_u.usr_ip4_spec; in efx_ethtool_set_class_rule()
960 struct ethtool_usrip4_spec *uip_mask = &rule->m_u.usr_ip4_spec; in efx_ethtool_set_class_rule()
961 struct ethtool_tcpip6_spec *ip6_entry = &rule->h_u.tcp_ip6_spec; in efx_ethtool_set_class_rule()
962 struct ethtool_tcpip6_spec *ip6_mask = &rule->m_u.tcp_ip6_spec; in efx_ethtool_set_class_rule()
963 struct ethtool_usrip6_spec *uip6_entry = &rule->h_u.usr_ip6_spec; in efx_ethtool_set_class_rule()
964 struct ethtool_usrip6_spec *uip6_mask = &rule->m_u.usr_ip6_spec; in efx_ethtool_set_class_rule()
965 u32 flow_type = rule->flow_type & ~(FLOW_EXT | FLOW_RSS); in efx_ethtool_set_class_rule()
966 struct ethhdr *mac_entry = &rule->h_u.ether_spec; in efx_ethtool_set_class_rule()
967 struct ethhdr *mac_mask = &rule->m_u.ether_spec; in efx_ethtool_set_class_rule()
973 if (rule->location != RX_CLS_LOC_ANY) in efx_ethtool_set_class_rule()
974 return -EINVAL; in efx_ethtool_set_class_rule()
976 /* Range-check ring_cookie */ in efx_ethtool_set_class_rule()
977 if (rule->ring_cookie >= efx->n_rx_channels && in efx_ethtool_set_class_rule()
978 rule->ring_cookie != RX_CLS_FLOW_DISC) in efx_ethtool_set_class_rule()
979 return -EINVAL; in efx_ethtool_set_class_rule()
982 if ((rule->flow_type & FLOW_EXT) && in efx_ethtool_set_class_rule()
983 (rule->m_ext.vlan_etype || rule->m_ext.data[0] || in efx_ethtool_set_class_rule()
984 rule->m_ext.data[1])) in efx_ethtool_set_class_rule()
985 return -EINVAL; in efx_ethtool_set_class_rule()
987 if (efx->rx_scatter) in efx_ethtool_set_class_rule()
989 if (rule->flow_type & FLOW_RSS) in efx_ethtool_set_class_rule()
993 (rule->ring_cookie == RX_CLS_FLOW_DISC) ? in efx_ethtool_set_class_rule()
994 EFX_FILTER_RX_DMAQ_ID_DROP : rule->ring_cookie); in efx_ethtool_set_class_rule()
996 if (rule->flow_type & FLOW_RSS) in efx_ethtool_set_class_rule()
1007 if (ip_mask->ip4dst) { in efx_ethtool_set_class_rule()
1008 if (ip_mask->ip4dst != IP4_ADDR_FULL_MASK) in efx_ethtool_set_class_rule()
1009 return -EINVAL; in efx_ethtool_set_class_rule()
1011 spec.loc_host[0] = ip_entry->ip4dst; in efx_ethtool_set_class_rule()
1013 if (ip_mask->ip4src) { in efx_ethtool_set_class_rule()
1014 if (ip_mask->ip4src != IP4_ADDR_FULL_MASK) in efx_ethtool_set_class_rule()
1015 return -EINVAL; in efx_ethtool_set_class_rule()
1017 spec.rem_host[0] = ip_entry->ip4src; in efx_ethtool_set_class_rule()
1019 if (ip_mask->pdst) { in efx_ethtool_set_class_rule()
1020 if (ip_mask->pdst != PORT_FULL_MASK) in efx_ethtool_set_class_rule()
1021 return -EINVAL; in efx_ethtool_set_class_rule()
1023 spec.loc_port = ip_entry->pdst; in efx_ethtool_set_class_rule()
1025 if (ip_mask->psrc) { in efx_ethtool_set_class_rule()
1026 if (ip_mask->psrc != PORT_FULL_MASK) in efx_ethtool_set_class_rule()
1027 return -EINVAL; in efx_ethtool_set_class_rule()
1029 spec.rem_port = ip_entry->psrc; in efx_ethtool_set_class_rule()
1031 if (ip_mask->tos) in efx_ethtool_set_class_rule()
1032 return -EINVAL; in efx_ethtool_set_class_rule()
1042 if (!ip6_mask_is_empty(ip6_mask->ip6dst)) { in efx_ethtool_set_class_rule()
1043 if (!ip6_mask_is_full(ip6_mask->ip6dst)) in efx_ethtool_set_class_rule()
1044 return -EINVAL; in efx_ethtool_set_class_rule()
1046 memcpy(spec.loc_host, ip6_entry->ip6dst, sizeof(spec.loc_host)); in efx_ethtool_set_class_rule()
1048 if (!ip6_mask_is_empty(ip6_mask->ip6src)) { in efx_ethtool_set_class_rule()
1049 if (!ip6_mask_is_full(ip6_mask->ip6src)) in efx_ethtool_set_class_rule()
1050 return -EINVAL; in efx_ethtool_set_class_rule()
1052 memcpy(spec.rem_host, ip6_entry->ip6src, sizeof(spec.rem_host)); in efx_ethtool_set_class_rule()
1054 if (ip6_mask->pdst) { in efx_ethtool_set_class_rule()
1055 if (ip6_mask->pdst != PORT_FULL_MASK) in efx_ethtool_set_class_rule()
1056 return -EINVAL; in efx_ethtool_set_class_rule()
1058 spec.loc_port = ip6_entry->pdst; in efx_ethtool_set_class_rule()
1060 if (ip6_mask->psrc) { in efx_ethtool_set_class_rule()
1061 if (ip6_mask->psrc != PORT_FULL_MASK) in efx_ethtool_set_class_rule()
1062 return -EINVAL; in efx_ethtool_set_class_rule()
1064 spec.rem_port = ip6_entry->psrc; in efx_ethtool_set_class_rule()
1066 if (ip6_mask->tclass) in efx_ethtool_set_class_rule()
1067 return -EINVAL; in efx_ethtool_set_class_rule()
1071 if (uip_mask->l4_4_bytes || uip_mask->tos || uip_mask->ip_ver || in efx_ethtool_set_class_rule()
1072 uip_entry->ip_ver != ETH_RX_NFC_IP4) in efx_ethtool_set_class_rule()
1073 return -EINVAL; in efx_ethtool_set_class_rule()
1076 if (uip_mask->ip4dst) { in efx_ethtool_set_class_rule()
1077 if (uip_mask->ip4dst != IP4_ADDR_FULL_MASK) in efx_ethtool_set_class_rule()
1078 return -EINVAL; in efx_ethtool_set_class_rule()
1080 spec.loc_host[0] = uip_entry->ip4dst; in efx_ethtool_set_class_rule()
1082 if (uip_mask->ip4src) { in efx_ethtool_set_class_rule()
1083 if (uip_mask->ip4src != IP4_ADDR_FULL_MASK) in efx_ethtool_set_class_rule()
1084 return -EINVAL; in efx_ethtool_set_class_rule()
1086 spec.rem_host[0] = uip_entry->ip4src; in efx_ethtool_set_class_rule()
1088 if (uip_mask->proto) { in efx_ethtool_set_class_rule()
1089 if (uip_mask->proto != IP_PROTO_FULL_MASK) in efx_ethtool_set_class_rule()
1090 return -EINVAL; in efx_ethtool_set_class_rule()
1092 spec.ip_proto = uip_entry->proto; in efx_ethtool_set_class_rule()
1097 if (uip6_mask->l4_4_bytes || uip6_mask->tclass) in efx_ethtool_set_class_rule()
1098 return -EINVAL; in efx_ethtool_set_class_rule()
1101 if (!ip6_mask_is_empty(uip6_mask->ip6dst)) { in efx_ethtool_set_class_rule()
1102 if (!ip6_mask_is_full(uip6_mask->ip6dst)) in efx_ethtool_set_class_rule()
1103 return -EINVAL; in efx_ethtool_set_class_rule()
1105 memcpy(spec.loc_host, uip6_entry->ip6dst, sizeof(spec.loc_host)); in efx_ethtool_set_class_rule()
1107 if (!ip6_mask_is_empty(uip6_mask->ip6src)) { in efx_ethtool_set_class_rule()
1108 if (!ip6_mask_is_full(uip6_mask->ip6src)) in efx_ethtool_set_class_rule()
1109 return -EINVAL; in efx_ethtool_set_class_rule()
1111 memcpy(spec.rem_host, uip6_entry->ip6src, sizeof(spec.rem_host)); in efx_ethtool_set_class_rule()
1113 if (uip6_mask->l4_proto) { in efx_ethtool_set_class_rule()
1114 if (uip6_mask->l4_proto != IP_PROTO_FULL_MASK) in efx_ethtool_set_class_rule()
1115 return -EINVAL; in efx_ethtool_set_class_rule()
1117 spec.ip_proto = uip6_entry->l4_proto; in efx_ethtool_set_class_rule()
1122 if (!is_zero_ether_addr(mac_mask->h_dest)) { in efx_ethtool_set_class_rule()
1123 if (ether_addr_equal(mac_mask->h_dest, in efx_ethtool_set_class_rule()
1126 else if (is_broadcast_ether_addr(mac_mask->h_dest)) in efx_ethtool_set_class_rule()
1129 return -EINVAL; in efx_ethtool_set_class_rule()
1130 ether_addr_copy(spec.loc_mac, mac_entry->h_dest); in efx_ethtool_set_class_rule()
1132 if (!is_zero_ether_addr(mac_mask->h_source)) { in efx_ethtool_set_class_rule()
1133 if (!is_broadcast_ether_addr(mac_mask->h_source)) in efx_ethtool_set_class_rule()
1134 return -EINVAL; in efx_ethtool_set_class_rule()
1136 ether_addr_copy(spec.rem_mac, mac_entry->h_source); in efx_ethtool_set_class_rule()
1138 if (mac_mask->h_proto) { in efx_ethtool_set_class_rule()
1139 if (mac_mask->h_proto != ETHER_TYPE_FULL_MASK) in efx_ethtool_set_class_rule()
1140 return -EINVAL; in efx_ethtool_set_class_rule()
1142 spec.ether_type = mac_entry->h_proto; in efx_ethtool_set_class_rule()
1147 return -EINVAL; in efx_ethtool_set_class_rule()
1150 if ((rule->flow_type & FLOW_EXT) && rule->m_ext.vlan_tci) { in efx_ethtool_set_class_rule()
1151 if (rule->m_ext.vlan_tci != htons(0xfff)) in efx_ethtool_set_class_rule()
1152 return -EINVAL; in efx_ethtool_set_class_rule()
1154 spec.outer_vid = rule->h_ext.vlan_tci; in efx_ethtool_set_class_rule()
1161 rule->location = rc; in efx_ethtool_set_class_rule()
1171 return -EOPNOTSUPP; in efx_ethtool_set_rxnfc()
1173 switch (info->cmd) { in efx_ethtool_set_rxnfc()
1175 return efx_ethtool_set_class_rule(efx, &info->fs, in efx_ethtool_set_rxnfc()
1176 info->rss_context); in efx_ethtool_set_rxnfc()
1180 info->fs.location); in efx_ethtool_set_rxnfc()
1183 return -EOPNOTSUPP; in efx_ethtool_set_rxnfc()
1191 if (efx->n_rx_channels == 1) in efx_ethtool_get_rxfh_indir_size()
1193 return ARRAY_SIZE(efx->rss_context.rx_indir_table); in efx_ethtool_get_rxfh_indir_size()
1200 return efx->type->rx_hash_key_size; in efx_ethtool_get_rxfh_key_size()
1209 rc = efx->type->rx_pull_rss_config(efx); in efx_ethtool_get_rxfh()
1216 memcpy(indir, efx->rss_context.rx_indir_table, in efx_ethtool_get_rxfh()
1217 sizeof(efx->rss_context.rx_indir_table)); in efx_ethtool_get_rxfh()
1219 memcpy(key, efx->rss_context.rx_hash_key, in efx_ethtool_get_rxfh()
1220 efx->type->rx_hash_key_size); in efx_ethtool_get_rxfh()
1231 return -EOPNOTSUPP; in efx_ethtool_set_rxfh()
1236 key = efx->rss_context.rx_hash_key; in efx_ethtool_set_rxfh()
1238 indir = efx->rss_context.rx_indir_table; in efx_ethtool_set_rxfh()
1240 return efx->type->rx_push_rss_config(efx, true, indir, key); in efx_ethtool_set_rxfh()
1250 if (!efx->type->rx_pull_rss_context_config) in efx_ethtool_get_rxfh_context()
1251 return -EOPNOTSUPP; in efx_ethtool_get_rxfh_context()
1253 mutex_lock(&efx->rss_lock); in efx_ethtool_get_rxfh_context()
1256 rc = -ENOENT; in efx_ethtool_get_rxfh_context()
1259 rc = efx->type->rx_pull_rss_context_config(efx, ctx); in efx_ethtool_get_rxfh_context()
1266 memcpy(indir, ctx->rx_indir_table, sizeof(ctx->rx_indir_table)); in efx_ethtool_get_rxfh_context()
1268 memcpy(key, ctx->rx_hash_key, efx->type->rx_hash_key_size); in efx_ethtool_get_rxfh_context()
1270 mutex_unlock(&efx->rss_lock); in efx_ethtool_get_rxfh_context()
1284 if (!efx->type->rx_push_rss_context_config) in efx_ethtool_set_rxfh_context()
1285 return -EOPNOTSUPP; in efx_ethtool_set_rxfh_context()
1288 return -EOPNOTSUPP; in efx_ethtool_set_rxfh_context()
1290 mutex_lock(&efx->rss_lock); in efx_ethtool_set_rxfh_context()
1295 rc = -EINVAL; in efx_ethtool_set_rxfh_context()
1300 rc = -ENOMEM; in efx_ethtool_set_rxfh_context()
1303 ctx->context_id = EFX_MCDI_RSS_CONTEXT_INVALID; in efx_ethtool_set_rxfh_context()
1306 netdev_rss_key_fill(ctx->rx_hash_key, sizeof(ctx->rx_hash_key)); in efx_ethtool_set_rxfh_context()
1311 rc = -ENOENT; in efx_ethtool_set_rxfh_context()
1318 rc = efx->type->rx_push_rss_context_config(efx, ctx, NULL, NULL); in efx_ethtool_set_rxfh_context()
1325 key = ctx->rx_hash_key; in efx_ethtool_set_rxfh_context()
1327 indir = ctx->rx_indir_table; in efx_ethtool_set_rxfh_context()
1329 rc = efx->type->rx_push_rss_context_config(efx, ctx, indir, key); in efx_ethtool_set_rxfh_context()
1333 *rss_context = ctx->user_id; in efx_ethtool_set_rxfh_context()
1335 mutex_unlock(&efx->rss_lock); in efx_ethtool_set_rxfh_context()
1344 rc = efx->type->map_reset_flags(flags); in efx_ethtool_reset()
1358 mutex_lock(&efx->mac_lock); in efx_ethtool_get_module_eeprom()
1360 mutex_unlock(&efx->mac_lock); in efx_ethtool_get_module_eeprom()
1371 mutex_lock(&efx->mac_lock); in efx_ethtool_get_module_info()
1373 mutex_unlock(&efx->mac_lock); in efx_ethtool_get_module_info()