Lines Matching +full:no +full:- +full:loopback +full:- +full:test
1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright 2005-2006 Fen Systems Ltd.
5 * Copyright 2006-2013 Solarflare Communications Inc.
30 /* Initialiser for a struct ef4_sw_stat_desc with type-checking */
36 &((struct ef4_##source_name *)0)->field) ? \
110 efx->type->set_id_led(efx, mode); in ef4_ethtool_phys_id()
120 struct ef4_link_state *link_state = &efx->link_state; in ef4_ethtool_get_link_ksettings()
122 mutex_lock(&efx->mac_lock); in ef4_ethtool_get_link_ksettings()
123 efx->phy_op->get_link_ksettings(efx, cmd); in ef4_ethtool_get_link_ksettings()
124 mutex_unlock(&efx->mac_lock); in ef4_ethtool_get_link_ksettings()
126 /* Both MACs support pause frames (bidirectional and respond-only) */ in ef4_ethtool_get_link_ksettings()
131 cmd->base.speed = link_state->speed; in ef4_ethtool_get_link_ksettings()
132 cmd->base.duplex = link_state->fd ? DUPLEX_FULL : DUPLEX_HALF; in ef4_ethtool_get_link_ksettings()
147 if ((cmd->base.speed == SPEED_1000) && in ef4_ethtool_set_link_ksettings()
148 (cmd->base.duplex != DUPLEX_FULL)) { in ef4_ethtool_set_link_ksettings()
149 netif_dbg(efx, drv, efx->net_dev, in ef4_ethtool_set_link_ksettings()
151 return -EINVAL; in ef4_ethtool_set_link_ksettings()
154 mutex_lock(&efx->mac_lock); in ef4_ethtool_set_link_ksettings()
155 rc = efx->phy_op->set_link_ksettings(efx, cmd); in ef4_ethtool_set_link_ksettings()
156 mutex_unlock(&efx->mac_lock); in ef4_ethtool_set_link_ksettings()
165 strscpy(info->driver, KBUILD_MODNAME, sizeof(info->driver)); in ef4_ethtool_get_drvinfo()
166 strscpy(info->version, EF4_DRIVER_VERSION, sizeof(info->version)); in ef4_ethtool_get_drvinfo()
167 strscpy(info->bus_info, pci_name(efx->pci_dev), sizeof(info->bus_info)); in ef4_ethtool_get_drvinfo()
180 regs->version = efx->type->revision; in ef4_ethtool_get_regs()
187 return efx->msg_enable; in ef4_ethtool_get_msglevel()
193 efx->msg_enable = msg_enable; in ef4_ethtool_set_msglevel()
197 * ef4_fill_test - fill in an individual self-test entry
198 * @test_index: Index of the test
200 * @data: Ethtool test results, or %NULL
201 * @test: Pointer to test result (used only if data != %NULL)
204 * @test_format: Test name format (e.g. "loopback.\%s.tx.sent")
205 * @test_id: Test id (e.g. "PHYXS" for "loopback.PHYXS.tx_sent")
207 * Fill in an individual self-test entry.
210 int *test, const char *unit_format, int unit_id, in ef4_fill_test() argument
217 data[test_index] = *test; in ef4_fill_test()
229 "%-6s %-24s", unit_str, test_str); in ef4_fill_test()
233 #define EF4_CHANNEL_NAME(_channel) "chan%d", _channel->channel
234 #define EF4_TX_QUEUE_NAME(_tx_queue) "txq%d", _tx_queue->queue
235 #define EF4_RX_QUEUE_NAME(_rx_queue) "rxq%d", _rx_queue->queue
237 "loopback.%s." _counter, STRING_TABLE_LOOKUP(_mode, ef4_loopback_mode)
240 * ef4_fill_loopback_test - fill in a block of loopback self-test entries
242 * @lb_tests: Efx loopback self-test results structure
243 * @mode: Loopback test mode
244 * @test_index: Starting index of the test
246 * @data: Ethtool test results, or %NULL
248 * Fill in a block of loopback self-test entries. Return new test
258 ef4_get_channel(efx, efx->tx_channel_offset); in ef4_fill_loopback_test()
263 &lb_tests->tx_sent[tx_queue->queue], in ef4_fill_loopback_test()
267 &lb_tests->tx_done[tx_queue->queue], in ef4_fill_loopback_test()
272 &lb_tests->rx_good, in ef4_fill_loopback_test()
276 &lb_tests->rx_bad, in ef4_fill_loopback_test()
284 * ef4_ethtool_fill_self_tests - get self-test details
286 * @tests: Efx self-test results structure, or %NULL
288 * @data: Ethtool test results, or %NULL
290 * Get self-test number of strings, strings, and/or test results.
291 * Return number of strings (== number of test results).
304 ef4_fill_test(n++, strings, data, &tests->phy_alive, in ef4_ethtool_fill_self_tests()
306 ef4_fill_test(n++, strings, data, &tests->nvram, in ef4_ethtool_fill_self_tests()
308 ef4_fill_test(n++, strings, data, &tests->interrupt, in ef4_ethtool_fill_self_tests()
314 &tests->eventq_dma[channel->channel], in ef4_ethtool_fill_self_tests()
318 &tests->eventq_int[channel->channel], in ef4_ethtool_fill_self_tests()
323 ef4_fill_test(n++, strings, data, &tests->memory, in ef4_ethtool_fill_self_tests()
325 ef4_fill_test(n++, strings, data, &tests->registers, in ef4_ethtool_fill_self_tests()
328 if (efx->phy_op->run_tests != NULL) { in ef4_ethtool_fill_self_tests()
329 EF4_BUG_ON_PARANOID(efx->phy_op->test_name == NULL); in ef4_ethtool_fill_self_tests()
335 name = efx->phy_op->test_name(efx, i); in ef4_ethtool_fill_self_tests()
339 ef4_fill_test(n++, strings, data, &tests->phy_ext[i], in ef4_ethtool_fill_self_tests()
344 /* Loopback tests */ in ef4_ethtool_fill_self_tests()
346 if (!(efx->loopback_modes & (1 << mode))) in ef4_ethtool_fill_self_tests()
349 &tests->loopback[mode], mode, n, in ef4_ethtool_fill_self_tests()
367 ethtool_sprintf(strings, "tx-%u.tx_packets", in ef4_describe_per_queue_stats()
368 channel->tx_queue[0].queue / in ef4_describe_per_queue_stats()
378 ethtool_sprintf(strings, "rx-%d.rx_packets", in ef4_describe_per_queue_stats()
379 channel->channel); in ef4_describe_per_queue_stats()
392 return efx->type->describe_stats(efx, NULL) + in ef4_ethtool_get_sset_count()
398 return -EINVAL; in ef4_ethtool_get_sset_count()
410 efx->type->describe_stats(efx, &strings); in ef4_ethtool_get_strings()
419 /* No other string sets */ in ef4_ethtool_get_strings()
435 spin_lock_bh(&efx->stats_lock); in ef4_ethtool_get_stats()
438 data += efx->type->update_stats(efx, data, NULL); in ef4_ethtool_get_stats()
443 switch (stat->source) { in ef4_ethtool_get_stats()
445 data[i] = stat->get_stat((void *)efx + stat->offset); in ef4_ethtool_get_stats()
450 data[i] += stat->get_stat((void *)channel + in ef4_ethtool_get_stats()
451 stat->offset); in ef4_ethtool_get_stats()
458 stat->get_stat((void *)tx_queue in ef4_ethtool_get_stats()
459 + stat->offset); in ef4_ethtool_get_stats()
466 spin_unlock_bh(&efx->stats_lock); in ef4_ethtool_get_stats()
472 *data += tx_queue->tx_packets; in ef4_ethtool_get_stats()
481 *data += rx_queue->rx_packets; in ef4_ethtool_get_stats()
489 struct ethtool_test *test, u64 *data) in ef4_ethtool_self_test() argument
494 int rc = -ENOMEM; in ef4_ethtool_self_test()
500 if (efx->state != STATE_READY) { in ef4_ethtool_self_test()
501 rc = -EBUSY; in ef4_ethtool_self_test()
505 netif_info(efx, drv, efx->net_dev, "starting %sline testing\n", in ef4_ethtool_self_test()
506 (test->flags & ETH_TEST_FL_OFFLINE) ? "off" : "on"); in ef4_ethtool_self_test()
509 already_up = (efx->net_dev->flags & IFF_UP); in ef4_ethtool_self_test()
511 rc = dev_open(efx->net_dev, NULL); in ef4_ethtool_self_test()
513 netif_err(efx, drv, efx->net_dev, in ef4_ethtool_self_test()
519 rc = ef4_selftest(efx, ef4_tests, test->flags); in ef4_ethtool_self_test()
522 dev_close(efx->net_dev); in ef4_ethtool_self_test()
524 netif_info(efx, drv, efx->net_dev, "%s %sline self-tests\n", in ef4_ethtool_self_test()
526 (test->flags & ETH_TEST_FL_OFFLINE) ? "off" : "on"); in ef4_ethtool_self_test()
533 test->flags |= ETH_TEST_FL_FAILED; in ef4_ethtool_self_test()
541 return mdio45_nway_restart(&efx->mdio); in ef4_ethtool_nway_reset()
584 coalesce->tx_coalesce_usecs = tx_usecs; in ef4_ethtool_get_coalesce()
585 coalesce->tx_coalesce_usecs_irq = tx_usecs; in ef4_ethtool_get_coalesce()
586 coalesce->rx_coalesce_usecs = rx_usecs; in ef4_ethtool_get_coalesce()
587 coalesce->rx_coalesce_usecs_irq = rx_usecs; in ef4_ethtool_get_coalesce()
588 coalesce->use_adaptive_rx_coalesce = rx_adaptive; in ef4_ethtool_get_coalesce()
606 if (coalesce->rx_coalesce_usecs != rx_usecs) in ef4_ethtool_set_coalesce()
607 rx_usecs = coalesce->rx_coalesce_usecs; in ef4_ethtool_set_coalesce()
609 rx_usecs = coalesce->rx_coalesce_usecs_irq; in ef4_ethtool_set_coalesce()
611 adaptive = coalesce->use_adaptive_rx_coalesce; in ef4_ethtool_set_coalesce()
616 rx_may_override_tx = (coalesce->tx_coalesce_usecs == tx_usecs && in ef4_ethtool_set_coalesce()
617 coalesce->tx_coalesce_usecs_irq == tx_usecs); in ef4_ethtool_set_coalesce()
618 if (coalesce->tx_coalesce_usecs != tx_usecs) in ef4_ethtool_set_coalesce()
619 tx_usecs = coalesce->tx_coalesce_usecs; in ef4_ethtool_set_coalesce()
621 tx_usecs = coalesce->tx_coalesce_usecs_irq; in ef4_ethtool_set_coalesce()
629 efx->type->push_irq_moderation(channel); in ef4_ethtool_set_coalesce()
642 ring->rx_max_pending = EF4_MAX_DMAQ_SIZE; in ef4_ethtool_get_ringparam()
643 ring->tx_max_pending = EF4_MAX_DMAQ_SIZE; in ef4_ethtool_get_ringparam()
644 ring->rx_pending = efx->rxq_entries; in ef4_ethtool_get_ringparam()
645 ring->tx_pending = efx->txq_entries; in ef4_ethtool_get_ringparam()
657 if (ring->rx_mini_pending || ring->rx_jumbo_pending || in ef4_ethtool_set_ringparam()
658 ring->rx_pending > EF4_MAX_DMAQ_SIZE || in ef4_ethtool_set_ringparam()
659 ring->tx_pending > EF4_MAX_DMAQ_SIZE) in ef4_ethtool_set_ringparam()
660 return -EINVAL; in ef4_ethtool_set_ringparam()
662 if (ring->rx_pending < EF4_RXQ_MIN_ENT) { in ef4_ethtool_set_ringparam()
663 netif_err(efx, drv, efx->net_dev, in ef4_ethtool_set_ringparam()
666 return -EINVAL; in ef4_ethtool_set_ringparam()
669 txq_entries = max(ring->tx_pending, EF4_TXQ_MIN_ENT(efx)); in ef4_ethtool_set_ringparam()
670 if (txq_entries != ring->tx_pending) in ef4_ethtool_set_ringparam()
671 netif_warn(efx, drv, efx->net_dev, in ef4_ethtool_set_ringparam()
675 return ef4_realloc_channels(efx, ring->rx_pending, txq_entries); in ef4_ethtool_set_ringparam()
686 mutex_lock(&efx->mac_lock); in ef4_ethtool_set_pauseparam()
688 wanted_fc = ((pause->rx_pause ? EF4_FC_RX : 0) | in ef4_ethtool_set_pauseparam()
689 (pause->tx_pause ? EF4_FC_TX : 0) | in ef4_ethtool_set_pauseparam()
690 (pause->autoneg ? EF4_FC_AUTO : 0)); in ef4_ethtool_set_pauseparam()
693 netif_dbg(efx, drv, efx->net_dev, in ef4_ethtool_set_pauseparam()
695 rc = -EINVAL; in ef4_ethtool_set_pauseparam()
699 if ((wanted_fc & EF4_FC_AUTO) && !efx->link_advertising) { in ef4_ethtool_set_pauseparam()
700 netif_dbg(efx, drv, efx->net_dev, in ef4_ethtool_set_pauseparam()
702 rc = -EINVAL; in ef4_ethtool_set_pauseparam()
707 if (efx->type->prepare_enable_fc_tx && in ef4_ethtool_set_pauseparam()
708 (wanted_fc & EF4_FC_TX) && !(efx->wanted_fc & EF4_FC_TX)) in ef4_ethtool_set_pauseparam()
709 efx->type->prepare_enable_fc_tx(efx); in ef4_ethtool_set_pauseparam()
711 old_adv = efx->link_advertising; in ef4_ethtool_set_pauseparam()
712 old_fc = efx->wanted_fc; in ef4_ethtool_set_pauseparam()
714 if (efx->link_advertising != old_adv || in ef4_ethtool_set_pauseparam()
715 (efx->wanted_fc ^ old_fc) & EF4_FC_AUTO) { in ef4_ethtool_set_pauseparam()
716 rc = efx->phy_op->reconfigure(efx); in ef4_ethtool_set_pauseparam()
718 netif_err(efx, drv, efx->net_dev, in ef4_ethtool_set_pauseparam()
726 * if the user just changed the advertised capabilities, but there's no in ef4_ethtool_set_pauseparam()
731 mutex_unlock(&efx->mac_lock); in ef4_ethtool_set_pauseparam()
741 pause->rx_pause = !!(efx->wanted_fc & EF4_FC_RX); in ef4_ethtool_get_pauseparam()
742 pause->tx_pause = !!(efx->wanted_fc & EF4_FC_TX); in ef4_ethtool_get_pauseparam()
743 pause->autoneg = !!(efx->wanted_fc & EF4_FC_AUTO); in ef4_ethtool_get_pauseparam()
750 return efx->type->get_wol(efx, wol); in ef4_ethtool_get_wol()
758 return efx->type->set_wol(efx, wol->wolopts); in ef4_ethtool_set_wol()
766 rc = efx->type->map_reset_flags(flags); in ef4_ethtool_reset()
789 struct ethtool_tcpip4_spec *ip_entry = &rule->h_u.tcp_ip4_spec; in ef4_ethtool_get_class_rule()
790 struct ethtool_tcpip4_spec *ip_mask = &rule->m_u.tcp_ip4_spec; in ef4_ethtool_get_class_rule()
791 struct ethtool_usrip4_spec *uip_entry = &rule->h_u.usr_ip4_spec; in ef4_ethtool_get_class_rule()
792 struct ethtool_usrip4_spec *uip_mask = &rule->m_u.usr_ip4_spec; in ef4_ethtool_get_class_rule()
793 struct ethtool_tcpip6_spec *ip6_entry = &rule->h_u.tcp_ip6_spec; in ef4_ethtool_get_class_rule()
794 struct ethtool_tcpip6_spec *ip6_mask = &rule->m_u.tcp_ip6_spec; in ef4_ethtool_get_class_rule()
795 struct ethtool_usrip6_spec *uip6_entry = &rule->h_u.usr_ip6_spec; in ef4_ethtool_get_class_rule()
796 struct ethtool_usrip6_spec *uip6_mask = &rule->m_u.usr_ip6_spec; in ef4_ethtool_get_class_rule()
797 struct ethhdr *mac_entry = &rule->h_u.ether_spec; in ef4_ethtool_get_class_rule()
798 struct ethhdr *mac_mask = &rule->m_u.ether_spec; in ef4_ethtool_get_class_rule()
803 rule->location, &spec); in ef4_ethtool_get_class_rule()
808 rule->ring_cookie = RX_CLS_FLOW_DISC; in ef4_ethtool_get_class_rule()
810 rule->ring_cookie = spec.dmaq_id; in ef4_ethtool_get_class_rule()
821 rule->flow_type = ((spec.ip_proto == IPPROTO_TCP) ? in ef4_ethtool_get_class_rule()
824 ip_entry->ip4dst = spec.loc_host[0]; in ef4_ethtool_get_class_rule()
825 ip_mask->ip4dst = IP4_ADDR_FULL_MASK; in ef4_ethtool_get_class_rule()
828 ip_entry->ip4src = spec.rem_host[0]; in ef4_ethtool_get_class_rule()
829 ip_mask->ip4src = IP4_ADDR_FULL_MASK; in ef4_ethtool_get_class_rule()
832 ip_entry->pdst = spec.loc_port; in ef4_ethtool_get_class_rule()
833 ip_mask->pdst = PORT_FULL_MASK; in ef4_ethtool_get_class_rule()
836 ip_entry->psrc = spec.rem_port; in ef4_ethtool_get_class_rule()
837 ip_mask->psrc = PORT_FULL_MASK; in ef4_ethtool_get_class_rule()
848 rule->flow_type = ((spec.ip_proto == IPPROTO_TCP) ? in ef4_ethtool_get_class_rule()
851 memcpy(ip6_entry->ip6dst, spec.loc_host, in ef4_ethtool_get_class_rule()
852 sizeof(ip6_entry->ip6dst)); in ef4_ethtool_get_class_rule()
853 ip6_fill_mask(ip6_mask->ip6dst); in ef4_ethtool_get_class_rule()
856 memcpy(ip6_entry->ip6src, spec.rem_host, in ef4_ethtool_get_class_rule()
857 sizeof(ip6_entry->ip6src)); in ef4_ethtool_get_class_rule()
858 ip6_fill_mask(ip6_mask->ip6src); in ef4_ethtool_get_class_rule()
861 ip6_entry->pdst = spec.loc_port; in ef4_ethtool_get_class_rule()
862 ip6_mask->pdst = PORT_FULL_MASK; in ef4_ethtool_get_class_rule()
865 ip6_entry->psrc = spec.rem_port; in ef4_ethtool_get_class_rule()
866 ip6_mask->psrc = PORT_FULL_MASK; in ef4_ethtool_get_class_rule()
872 rule->flow_type = ETHER_FLOW; in ef4_ethtool_get_class_rule()
875 ether_addr_copy(mac_entry->h_dest, spec.loc_mac); in ef4_ethtool_get_class_rule()
877 eth_broadcast_addr(mac_mask->h_dest); in ef4_ethtool_get_class_rule()
879 ether_addr_copy(mac_mask->h_dest, in ef4_ethtool_get_class_rule()
883 ether_addr_copy(mac_entry->h_source, spec.rem_mac); in ef4_ethtool_get_class_rule()
884 eth_broadcast_addr(mac_mask->h_source); in ef4_ethtool_get_class_rule()
887 mac_entry->h_proto = spec.ether_type; in ef4_ethtool_get_class_rule()
888 mac_mask->h_proto = ETHER_TYPE_FULL_MASK; in ef4_ethtool_get_class_rule()
896 rule->flow_type = IPV4_USER_FLOW; in ef4_ethtool_get_class_rule()
897 uip_entry->ip_ver = ETH_RX_NFC_IP4; in ef4_ethtool_get_class_rule()
899 uip_mask->proto = IP_PROTO_FULL_MASK; in ef4_ethtool_get_class_rule()
900 uip_entry->proto = spec.ip_proto; in ef4_ethtool_get_class_rule()
903 uip_entry->ip4dst = spec.loc_host[0]; in ef4_ethtool_get_class_rule()
904 uip_mask->ip4dst = IP4_ADDR_FULL_MASK; in ef4_ethtool_get_class_rule()
907 uip_entry->ip4src = spec.rem_host[0]; in ef4_ethtool_get_class_rule()
908 uip_mask->ip4src = IP4_ADDR_FULL_MASK; in ef4_ethtool_get_class_rule()
916 rule->flow_type = IPV6_USER_FLOW; in ef4_ethtool_get_class_rule()
918 uip6_mask->l4_proto = IP_PROTO_FULL_MASK; in ef4_ethtool_get_class_rule()
919 uip6_entry->l4_proto = spec.ip_proto; in ef4_ethtool_get_class_rule()
922 memcpy(uip6_entry->ip6dst, spec.loc_host, in ef4_ethtool_get_class_rule()
923 sizeof(uip6_entry->ip6dst)); in ef4_ethtool_get_class_rule()
924 ip6_fill_mask(uip6_mask->ip6dst); in ef4_ethtool_get_class_rule()
927 memcpy(uip6_entry->ip6src, spec.rem_host, in ef4_ethtool_get_class_rule()
928 sizeof(uip6_entry->ip6src)); in ef4_ethtool_get_class_rule()
929 ip6_fill_mask(uip6_mask->ip6src); in ef4_ethtool_get_class_rule()
934 return -EINVAL; in ef4_ethtool_get_class_rule()
938 rule->flow_type |= FLOW_EXT; in ef4_ethtool_get_class_rule()
939 rule->h_ext.vlan_tci = spec.outer_vid; in ef4_ethtool_get_class_rule()
940 rule->m_ext.vlan_tci = htons(0xfff); in ef4_ethtool_get_class_rule()
952 switch (info->cmd) { in ef4_ethtool_get_rxnfc()
954 info->data = efx->n_rx_channels; in ef4_ethtool_get_rxnfc()
960 info->data = 0; in ef4_ethtool_get_rxnfc()
961 switch (info->flow_type) { in ef4_ethtool_get_rxnfc()
963 info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; in ef4_ethtool_get_rxnfc()
969 info->data |= RXH_IP_SRC | RXH_IP_DST; in ef4_ethtool_get_rxnfc()
976 info->data = 0; in ef4_ethtool_get_rxnfc()
981 info->data = ef4_filter_get_rx_id_limit(efx); in ef4_ethtool_get_rxnfc()
982 if (info->data == 0) in ef4_ethtool_get_rxnfc()
983 return -EOPNOTSUPP; in ef4_ethtool_get_rxnfc()
984 info->data |= RX_CLS_LOC_SPECIAL; in ef4_ethtool_get_rxnfc()
985 info->rule_cnt = in ef4_ethtool_get_rxnfc()
991 return -EOPNOTSUPP; in ef4_ethtool_get_rxnfc()
992 return ef4_ethtool_get_class_rule(efx, &info->fs); in ef4_ethtool_get_rxnfc()
996 info->data = ef4_filter_get_rx_id_limit(efx); in ef4_ethtool_get_rxnfc()
997 if (info->data == 0) in ef4_ethtool_get_rxnfc()
998 return -EOPNOTSUPP; in ef4_ethtool_get_rxnfc()
1000 rule_locs, info->rule_cnt); in ef4_ethtool_get_rxnfc()
1003 info->rule_cnt = rc; in ef4_ethtool_get_rxnfc()
1008 return -EOPNOTSUPP; in ef4_ethtool_get_rxnfc()
1025 struct ethtool_tcpip4_spec *ip_entry = &rule->h_u.tcp_ip4_spec; in ef4_ethtool_set_class_rule()
1026 struct ethtool_tcpip4_spec *ip_mask = &rule->m_u.tcp_ip4_spec; in ef4_ethtool_set_class_rule()
1027 struct ethtool_usrip4_spec *uip_entry = &rule->h_u.usr_ip4_spec; in ef4_ethtool_set_class_rule()
1028 struct ethtool_usrip4_spec *uip_mask = &rule->m_u.usr_ip4_spec; in ef4_ethtool_set_class_rule()
1029 struct ethtool_tcpip6_spec *ip6_entry = &rule->h_u.tcp_ip6_spec; in ef4_ethtool_set_class_rule()
1030 struct ethtool_tcpip6_spec *ip6_mask = &rule->m_u.tcp_ip6_spec; in ef4_ethtool_set_class_rule()
1031 struct ethtool_usrip6_spec *uip6_entry = &rule->h_u.usr_ip6_spec; in ef4_ethtool_set_class_rule()
1032 struct ethtool_usrip6_spec *uip6_mask = &rule->m_u.usr_ip6_spec; in ef4_ethtool_set_class_rule()
1033 struct ethhdr *mac_entry = &rule->h_u.ether_spec; in ef4_ethtool_set_class_rule()
1034 struct ethhdr *mac_mask = &rule->m_u.ether_spec; in ef4_ethtool_set_class_rule()
1039 if (rule->location != RX_CLS_LOC_ANY) in ef4_ethtool_set_class_rule()
1040 return -EINVAL; in ef4_ethtool_set_class_rule()
1042 /* Range-check ring_cookie */ in ef4_ethtool_set_class_rule()
1043 if (rule->ring_cookie >= efx->n_rx_channels && in ef4_ethtool_set_class_rule()
1044 rule->ring_cookie != RX_CLS_FLOW_DISC) in ef4_ethtool_set_class_rule()
1045 return -EINVAL; in ef4_ethtool_set_class_rule()
1048 if ((rule->flow_type & FLOW_EXT) && in ef4_ethtool_set_class_rule()
1049 (rule->m_ext.vlan_etype || rule->m_ext.data[0] || in ef4_ethtool_set_class_rule()
1050 rule->m_ext.data[1])) in ef4_ethtool_set_class_rule()
1051 return -EINVAL; in ef4_ethtool_set_class_rule()
1054 efx->rx_scatter ? EF4_FILTER_FLAG_RX_SCATTER : 0, in ef4_ethtool_set_class_rule()
1055 (rule->ring_cookie == RX_CLS_FLOW_DISC) ? in ef4_ethtool_set_class_rule()
1056 EF4_FILTER_RX_DMAQ_ID_DROP : rule->ring_cookie); in ef4_ethtool_set_class_rule()
1058 switch (rule->flow_type & ~FLOW_EXT) { in ef4_ethtool_set_class_rule()
1064 spec.ip_proto = ((rule->flow_type & ~FLOW_EXT) == TCP_V4_FLOW ? in ef4_ethtool_set_class_rule()
1066 if (ip_mask->ip4dst) { in ef4_ethtool_set_class_rule()
1067 if (ip_mask->ip4dst != IP4_ADDR_FULL_MASK) in ef4_ethtool_set_class_rule()
1068 return -EINVAL; in ef4_ethtool_set_class_rule()
1070 spec.loc_host[0] = ip_entry->ip4dst; in ef4_ethtool_set_class_rule()
1072 if (ip_mask->ip4src) { in ef4_ethtool_set_class_rule()
1073 if (ip_mask->ip4src != IP4_ADDR_FULL_MASK) in ef4_ethtool_set_class_rule()
1074 return -EINVAL; in ef4_ethtool_set_class_rule()
1076 spec.rem_host[0] = ip_entry->ip4src; in ef4_ethtool_set_class_rule()
1078 if (ip_mask->pdst) { in ef4_ethtool_set_class_rule()
1079 if (ip_mask->pdst != PORT_FULL_MASK) in ef4_ethtool_set_class_rule()
1080 return -EINVAL; in ef4_ethtool_set_class_rule()
1082 spec.loc_port = ip_entry->pdst; in ef4_ethtool_set_class_rule()
1084 if (ip_mask->psrc) { in ef4_ethtool_set_class_rule()
1085 if (ip_mask->psrc != PORT_FULL_MASK) in ef4_ethtool_set_class_rule()
1086 return -EINVAL; in ef4_ethtool_set_class_rule()
1088 spec.rem_port = ip_entry->psrc; in ef4_ethtool_set_class_rule()
1090 if (ip_mask->tos) in ef4_ethtool_set_class_rule()
1091 return -EINVAL; in ef4_ethtool_set_class_rule()
1099 spec.ip_proto = ((rule->flow_type & ~FLOW_EXT) == TCP_V6_FLOW ? in ef4_ethtool_set_class_rule()
1101 if (!ip6_mask_is_empty(ip6_mask->ip6dst)) { in ef4_ethtool_set_class_rule()
1102 if (!ip6_mask_is_full(ip6_mask->ip6dst)) in ef4_ethtool_set_class_rule()
1103 return -EINVAL; in ef4_ethtool_set_class_rule()
1105 memcpy(spec.loc_host, ip6_entry->ip6dst, sizeof(spec.loc_host)); in ef4_ethtool_set_class_rule()
1107 if (!ip6_mask_is_empty(ip6_mask->ip6src)) { in ef4_ethtool_set_class_rule()
1108 if (!ip6_mask_is_full(ip6_mask->ip6src)) in ef4_ethtool_set_class_rule()
1109 return -EINVAL; in ef4_ethtool_set_class_rule()
1111 memcpy(spec.rem_host, ip6_entry->ip6src, sizeof(spec.rem_host)); in ef4_ethtool_set_class_rule()
1113 if (ip6_mask->pdst) { in ef4_ethtool_set_class_rule()
1114 if (ip6_mask->pdst != PORT_FULL_MASK) in ef4_ethtool_set_class_rule()
1115 return -EINVAL; in ef4_ethtool_set_class_rule()
1117 spec.loc_port = ip6_entry->pdst; in ef4_ethtool_set_class_rule()
1119 if (ip6_mask->psrc) { in ef4_ethtool_set_class_rule()
1120 if (ip6_mask->psrc != PORT_FULL_MASK) in ef4_ethtool_set_class_rule()
1121 return -EINVAL; in ef4_ethtool_set_class_rule()
1123 spec.rem_port = ip6_entry->psrc; in ef4_ethtool_set_class_rule()
1125 if (ip6_mask->tclass) in ef4_ethtool_set_class_rule()
1126 return -EINVAL; in ef4_ethtool_set_class_rule()
1130 if (uip_mask->l4_4_bytes || uip_mask->tos || uip_mask->ip_ver || in ef4_ethtool_set_class_rule()
1131 uip_entry->ip_ver != ETH_RX_NFC_IP4) in ef4_ethtool_set_class_rule()
1132 return -EINVAL; in ef4_ethtool_set_class_rule()
1135 if (uip_mask->ip4dst) { in ef4_ethtool_set_class_rule()
1136 if (uip_mask->ip4dst != IP4_ADDR_FULL_MASK) in ef4_ethtool_set_class_rule()
1137 return -EINVAL; in ef4_ethtool_set_class_rule()
1139 spec.loc_host[0] = uip_entry->ip4dst; in ef4_ethtool_set_class_rule()
1141 if (uip_mask->ip4src) { in ef4_ethtool_set_class_rule()
1142 if (uip_mask->ip4src != IP4_ADDR_FULL_MASK) in ef4_ethtool_set_class_rule()
1143 return -EINVAL; in ef4_ethtool_set_class_rule()
1145 spec.rem_host[0] = uip_entry->ip4src; in ef4_ethtool_set_class_rule()
1147 if (uip_mask->proto) { in ef4_ethtool_set_class_rule()
1148 if (uip_mask->proto != IP_PROTO_FULL_MASK) in ef4_ethtool_set_class_rule()
1149 return -EINVAL; in ef4_ethtool_set_class_rule()
1151 spec.ip_proto = uip_entry->proto; in ef4_ethtool_set_class_rule()
1156 if (uip6_mask->l4_4_bytes || uip6_mask->tclass) in ef4_ethtool_set_class_rule()
1157 return -EINVAL; in ef4_ethtool_set_class_rule()
1160 if (!ip6_mask_is_empty(uip6_mask->ip6dst)) { in ef4_ethtool_set_class_rule()
1161 if (!ip6_mask_is_full(uip6_mask->ip6dst)) in ef4_ethtool_set_class_rule()
1162 return -EINVAL; in ef4_ethtool_set_class_rule()
1164 memcpy(spec.loc_host, uip6_entry->ip6dst, sizeof(spec.loc_host)); in ef4_ethtool_set_class_rule()
1166 if (!ip6_mask_is_empty(uip6_mask->ip6src)) { in ef4_ethtool_set_class_rule()
1167 if (!ip6_mask_is_full(uip6_mask->ip6src)) in ef4_ethtool_set_class_rule()
1168 return -EINVAL; in ef4_ethtool_set_class_rule()
1170 memcpy(spec.rem_host, uip6_entry->ip6src, sizeof(spec.rem_host)); in ef4_ethtool_set_class_rule()
1172 if (uip6_mask->l4_proto) { in ef4_ethtool_set_class_rule()
1173 if (uip6_mask->l4_proto != IP_PROTO_FULL_MASK) in ef4_ethtool_set_class_rule()
1174 return -EINVAL; in ef4_ethtool_set_class_rule()
1176 spec.ip_proto = uip6_entry->l4_proto; in ef4_ethtool_set_class_rule()
1181 if (!is_zero_ether_addr(mac_mask->h_dest)) { in ef4_ethtool_set_class_rule()
1182 if (ether_addr_equal(mac_mask->h_dest, in ef4_ethtool_set_class_rule()
1185 else if (is_broadcast_ether_addr(mac_mask->h_dest)) in ef4_ethtool_set_class_rule()
1188 return -EINVAL; in ef4_ethtool_set_class_rule()
1189 ether_addr_copy(spec.loc_mac, mac_entry->h_dest); in ef4_ethtool_set_class_rule()
1191 if (!is_zero_ether_addr(mac_mask->h_source)) { in ef4_ethtool_set_class_rule()
1192 if (!is_broadcast_ether_addr(mac_mask->h_source)) in ef4_ethtool_set_class_rule()
1193 return -EINVAL; in ef4_ethtool_set_class_rule()
1195 ether_addr_copy(spec.rem_mac, mac_entry->h_source); in ef4_ethtool_set_class_rule()
1197 if (mac_mask->h_proto) { in ef4_ethtool_set_class_rule()
1198 if (mac_mask->h_proto != ETHER_TYPE_FULL_MASK) in ef4_ethtool_set_class_rule()
1199 return -EINVAL; in ef4_ethtool_set_class_rule()
1201 spec.ether_type = mac_entry->h_proto; in ef4_ethtool_set_class_rule()
1206 return -EINVAL; in ef4_ethtool_set_class_rule()
1209 if ((rule->flow_type & FLOW_EXT) && rule->m_ext.vlan_tci) { in ef4_ethtool_set_class_rule()
1210 if (rule->m_ext.vlan_tci != htons(0xfff)) in ef4_ethtool_set_class_rule()
1211 return -EINVAL; in ef4_ethtool_set_class_rule()
1213 spec.outer_vid = rule->h_ext.vlan_tci; in ef4_ethtool_set_class_rule()
1220 rule->location = rc; in ef4_ethtool_set_class_rule()
1230 return -EOPNOTSUPP; in ef4_ethtool_set_rxnfc()
1232 switch (info->cmd) { in ef4_ethtool_set_rxnfc()
1234 return ef4_ethtool_set_class_rule(efx, &info->fs); in ef4_ethtool_set_rxnfc()
1238 info->fs.location); in ef4_ethtool_set_rxnfc()
1241 return -EOPNOTSUPP; in ef4_ethtool_set_rxnfc()
1250 efx->n_rx_channels == 1) ? in ef4_ethtool_get_rxfh_indir_size()
1251 0 : ARRAY_SIZE(efx->rx_indir_table)); in ef4_ethtool_get_rxfh_indir_size()
1259 rxfh->hfunc = ETH_RSS_HASH_TOP; in ef4_ethtool_get_rxfh()
1260 if (rxfh->indir) in ef4_ethtool_get_rxfh()
1261 memcpy(rxfh->indir, efx->rx_indir_table, in ef4_ethtool_get_rxfh()
1262 sizeof(efx->rx_indir_table)); in ef4_ethtool_get_rxfh()
1273 if (rxfh->key || in ef4_ethtool_set_rxfh()
1274 (rxfh->hfunc != ETH_RSS_HASH_NO_CHANGE && in ef4_ethtool_set_rxfh()
1275 rxfh->hfunc != ETH_RSS_HASH_TOP)) in ef4_ethtool_set_rxfh()
1276 return -EOPNOTSUPP; in ef4_ethtool_set_rxfh()
1277 if (!rxfh->indir) in ef4_ethtool_set_rxfh()
1280 return efx->type->rx_push_rss_config(efx, true, rxfh->indir); in ef4_ethtool_set_rxfh()
1290 if (!efx->phy_op || !efx->phy_op->get_module_eeprom) in ef4_ethtool_get_module_eeprom()
1291 return -EOPNOTSUPP; in ef4_ethtool_get_module_eeprom()
1293 mutex_lock(&efx->mac_lock); in ef4_ethtool_get_module_eeprom()
1294 ret = efx->phy_op->get_module_eeprom(efx, ee, data); in ef4_ethtool_get_module_eeprom()
1295 mutex_unlock(&efx->mac_lock); in ef4_ethtool_get_module_eeprom()
1306 if (!efx->phy_op || !efx->phy_op->get_module_info) in ef4_ethtool_get_module_info()
1307 return -EOPNOTSUPP; in ef4_ethtool_get_module_info()
1309 mutex_lock(&efx->mac_lock); in ef4_ethtool_get_module_info()
1310 ret = efx->phy_op->get_module_info(efx, modinfo); in ef4_ethtool_get_module_info()
1311 mutex_unlock(&efx->mac_lock); in ef4_ethtool_get_module_info()