Lines Matching +full:hw +full:- +full:channels

1 // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
2 /* Copyright 2014-2016 Freescale Semiconductor Inc.
3 * Copyright 2016-2022 NXP
10 #include "dpaa2-eth.h"
14 "[hw] rx frames",
15 "[hw] rx bytes",
16 "[hw] rx mcast frames",
17 "[hw] rx mcast bytes",
18 "[hw] rx bcast frames",
19 "[hw] rx bcast bytes",
20 "[hw] tx frames",
21 "[hw] tx bytes",
22 "[hw] tx mcast frames",
23 "[hw] tx mcast bytes",
24 "[hw] tx bcast frames",
25 "[hw] tx bcast bytes",
26 "[hw] rx filtered frames",
27 "[hw] rx discarded frames",
28 "[hw] rx nobuffer discards",
29 "[hw] tx discarded frames",
30 "[hw] tx confirmed frames",
31 "[hw] tx dequeued bytes",
32 "[hw] tx dequeued frames",
33 "[hw] tx rejected bytes",
34 "[hw] tx rejected frames",
35 "[hw] tx pending frames",
41 /* per-cpu stats */
76 strscpy(drvinfo->driver, KBUILD_MODNAME, sizeof(drvinfo->driver)); in dpaa2_eth_get_drvinfo()
78 snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), in dpaa2_eth_get_drvinfo()
79 "%u.%u", priv->dpni_ver_major, priv->dpni_ver_minor); in dpaa2_eth_get_drvinfo()
81 strscpy(drvinfo->bus_info, dev_name(net_dev->dev.parent->parent), in dpaa2_eth_get_drvinfo()
82 sizeof(drvinfo->bus_info)); in dpaa2_eth_get_drvinfo()
88 int err = -EOPNOTSUPP; in dpaa2_eth_nway_reset()
90 mutex_lock(&priv->mac_lock); in dpaa2_eth_nway_reset()
93 err = phylink_ethtool_nway_reset(priv->mac->phylink); in dpaa2_eth_nway_reset()
95 mutex_unlock(&priv->mac_lock); in dpaa2_eth_nway_reset()
107 mutex_lock(&priv->mac_lock); in dpaa2_eth_get_link_ksettings()
110 err = phylink_ethtool_ksettings_get(priv->mac->phylink, in dpaa2_eth_get_link_ksettings()
112 mutex_unlock(&priv->mac_lock); in dpaa2_eth_get_link_ksettings()
116 mutex_unlock(&priv->mac_lock); in dpaa2_eth_get_link_ksettings()
118 link_settings->base.autoneg = AUTONEG_DISABLE; in dpaa2_eth_get_link_ksettings()
119 if (!(priv->link_state.options & DPNI_LINK_OPT_HALF_DUPLEX)) in dpaa2_eth_get_link_ksettings()
120 link_settings->base.duplex = DUPLEX_FULL; in dpaa2_eth_get_link_ksettings()
121 link_settings->base.speed = priv->link_state.rate; in dpaa2_eth_get_link_ksettings()
131 int err = -EOPNOTSUPP; in dpaa2_eth_set_link_ksettings()
133 mutex_lock(&priv->mac_lock); in dpaa2_eth_set_link_ksettings()
136 err = phylink_ethtool_ksettings_set(priv->mac->phylink, in dpaa2_eth_set_link_ksettings()
139 mutex_unlock(&priv->mac_lock); in dpaa2_eth_set_link_ksettings()
148 u64 link_options = priv->link_state.options; in dpaa2_eth_get_pauseparam()
150 mutex_lock(&priv->mac_lock); in dpaa2_eth_get_pauseparam()
153 phylink_ethtool_get_pauseparam(priv->mac->phylink, pause); in dpaa2_eth_get_pauseparam()
154 mutex_unlock(&priv->mac_lock); in dpaa2_eth_get_pauseparam()
158 mutex_unlock(&priv->mac_lock); in dpaa2_eth_get_pauseparam()
160 pause->rx_pause = dpaa2_eth_rx_pause_enabled(link_options); in dpaa2_eth_get_pauseparam()
161 pause->tx_pause = dpaa2_eth_tx_pause_enabled(link_options); in dpaa2_eth_get_pauseparam()
162 pause->autoneg = AUTONEG_DISABLE; in dpaa2_eth_get_pauseparam()
175 return -EOPNOTSUPP; in dpaa2_eth_set_pauseparam()
178 mutex_lock(&priv->mac_lock); in dpaa2_eth_set_pauseparam()
181 err = phylink_ethtool_set_pauseparam(priv->mac->phylink, in dpaa2_eth_set_pauseparam()
183 mutex_unlock(&priv->mac_lock); in dpaa2_eth_set_pauseparam()
187 mutex_unlock(&priv->mac_lock); in dpaa2_eth_set_pauseparam()
189 if (pause->autoneg) in dpaa2_eth_set_pauseparam()
190 return -EOPNOTSUPP; in dpaa2_eth_set_pauseparam()
192 cfg.rate = priv->link_state.rate; in dpaa2_eth_set_pauseparam()
193 cfg.options = priv->link_state.options; in dpaa2_eth_set_pauseparam()
194 if (pause->rx_pause) in dpaa2_eth_set_pauseparam()
198 if (!!pause->rx_pause ^ !!pause->tx_pause) in dpaa2_eth_set_pauseparam()
203 if (cfg.options == priv->link_state.options) in dpaa2_eth_set_pauseparam()
206 err = dpni_set_link_cfg(priv->mc_io, 0, priv->mc_token, &cfg); in dpaa2_eth_set_pauseparam()
212 priv->link_state.options = cfg.options; in dpaa2_eth_set_pauseparam()
240 return -EOPNOTSUPP; in dpaa2_eth_get_sset_count()
277 err = dpni_get_statistics(priv->mc_io, 0, priv->mc_token, in dpaa2_eth_get_ethtool_stats()
279 if (err == -EINVAL) in dpaa2_eth_get_ethtool_stats()
290 /* Print per-cpu extra stats */ in dpaa2_eth_get_ethtool_stats()
292 extras = per_cpu_ptr(priv->percpu_extras, k); in dpaa2_eth_get_ethtool_stats()
298 /* Per-channel stats */ in dpaa2_eth_get_ethtool_stats()
299 for (k = 0; k < priv->num_channels; k++) { in dpaa2_eth_get_ethtool_stats()
300 ch_stats = &priv->channel[k]->stats; in dpaa2_eth_get_ethtool_stats()
306 for (j = 0; j < priv->num_fqs; j++) { in dpaa2_eth_get_ethtool_stats()
308 err = dpaa2_io_query_fq_count(NULL, priv->fq[j].fqid, in dpaa2_eth_get_ethtool_stats()
315 if (priv->fq[j].type == DPAA2_TX_CONF_FQ) { in dpaa2_eth_get_ethtool_stats()
329 for (j = 0; j < priv->num_bps; j++) { in dpaa2_eth_get_ethtool_stats()
330 err = dpaa2_io_query_bp_count(NULL, priv->bp[j]->bpid, &buf_cnt); in dpaa2_eth_get_ethtool_stats()
339 mutex_lock(&priv->mac_lock); in dpaa2_eth_get_ethtool_stats()
342 dpaa2_mac_get_ethtool_stats(priv->mac, data + i); in dpaa2_eth_get_ethtool_stats()
344 mutex_unlock(&priv->mac_lock); in dpaa2_eth_get_ethtool_stats()
352 if (eth_mask->h_proto) { in dpaa2_eth_prep_eth_rule()
354 *(__be16 *)(key + off) = eth_value->h_proto; in dpaa2_eth_prep_eth_rule()
355 *(__be16 *)(mask + off) = eth_mask->h_proto; in dpaa2_eth_prep_eth_rule()
359 if (!is_zero_ether_addr(eth_mask->h_source)) { in dpaa2_eth_prep_eth_rule()
361 ether_addr_copy(key + off, eth_value->h_source); in dpaa2_eth_prep_eth_rule()
362 ether_addr_copy(mask + off, eth_mask->h_source); in dpaa2_eth_prep_eth_rule()
366 if (!is_zero_ether_addr(eth_mask->h_dest)) { in dpaa2_eth_prep_eth_rule()
368 ether_addr_copy(key + off, eth_value->h_dest); in dpaa2_eth_prep_eth_rule()
369 ether_addr_copy(mask + off, eth_mask->h_dest); in dpaa2_eth_prep_eth_rule()
383 if (uip_mask->tos || uip_mask->ip_ver) in dpaa2_eth_prep_uip_rule()
384 return -EOPNOTSUPP; in dpaa2_eth_prep_uip_rule()
386 if (uip_mask->ip4src) { in dpaa2_eth_prep_uip_rule()
388 *(__be32 *)(key + off) = uip_value->ip4src; in dpaa2_eth_prep_uip_rule()
389 *(__be32 *)(mask + off) = uip_mask->ip4src; in dpaa2_eth_prep_uip_rule()
393 if (uip_mask->ip4dst) { in dpaa2_eth_prep_uip_rule()
395 *(__be32 *)(key + off) = uip_value->ip4dst; in dpaa2_eth_prep_uip_rule()
396 *(__be32 *)(mask + off) = uip_mask->ip4dst; in dpaa2_eth_prep_uip_rule()
400 if (uip_mask->proto) { in dpaa2_eth_prep_uip_rule()
402 *(u8 *)(key + off) = uip_value->proto; in dpaa2_eth_prep_uip_rule()
403 *(u8 *)(mask + off) = uip_mask->proto; in dpaa2_eth_prep_uip_rule()
407 if (uip_mask->l4_4_bytes) { in dpaa2_eth_prep_uip_rule()
408 tmp_value = be32_to_cpu(uip_value->l4_4_bytes); in dpaa2_eth_prep_uip_rule()
409 tmp_mask = be32_to_cpu(uip_mask->l4_4_bytes); in dpaa2_eth_prep_uip_rule()
437 if (l4_mask->tos) in dpaa2_eth_prep_l4_rule()
438 return -EOPNOTSUPP; in dpaa2_eth_prep_l4_rule()
440 if (l4_mask->ip4src) { in dpaa2_eth_prep_l4_rule()
442 *(__be32 *)(key + off) = l4_value->ip4src; in dpaa2_eth_prep_l4_rule()
443 *(__be32 *)(mask + off) = l4_mask->ip4src; in dpaa2_eth_prep_l4_rule()
447 if (l4_mask->ip4dst) { in dpaa2_eth_prep_l4_rule()
449 *(__be32 *)(key + off) = l4_value->ip4dst; in dpaa2_eth_prep_l4_rule()
450 *(__be32 *)(mask + off) = l4_mask->ip4dst; in dpaa2_eth_prep_l4_rule()
454 if (l4_mask->psrc) { in dpaa2_eth_prep_l4_rule()
456 *(__be16 *)(key + off) = l4_value->psrc; in dpaa2_eth_prep_l4_rule()
457 *(__be16 *)(mask + off) = l4_mask->psrc; in dpaa2_eth_prep_l4_rule()
461 if (l4_mask->pdst) { in dpaa2_eth_prep_l4_rule()
463 *(__be16 *)(key + off) = l4_value->pdst; in dpaa2_eth_prep_l4_rule()
464 *(__be16 *)(mask + off) = l4_mask->pdst; in dpaa2_eth_prep_l4_rule()
488 if (ext_mask->vlan_etype) in dpaa2_eth_prep_ext_rule()
489 return -EOPNOTSUPP; in dpaa2_eth_prep_ext_rule()
491 if (ext_mask->vlan_tci) { in dpaa2_eth_prep_ext_rule()
493 *(__be16 *)(key + off) = ext_value->vlan_tci; in dpaa2_eth_prep_ext_rule()
494 *(__be16 *)(mask + off) = ext_mask->vlan_tci; in dpaa2_eth_prep_ext_rule()
507 if (!is_zero_ether_addr(ext_mask->h_dest)) { in dpaa2_eth_prep_mac_ext_rule()
509 ether_addr_copy(key + off, ext_value->h_dest); in dpaa2_eth_prep_mac_ext_rule()
510 ether_addr_copy(mask + off, ext_mask->h_dest); in dpaa2_eth_prep_mac_ext_rule()
522 switch (fs->flow_type & 0xFF) { in dpaa2_eth_prep_cls_rule()
524 err = dpaa2_eth_prep_eth_rule(&fs->h_u.ether_spec, &fs->m_u.ether_spec, in dpaa2_eth_prep_cls_rule()
528 err = dpaa2_eth_prep_uip_rule(&fs->h_u.usr_ip4_spec, in dpaa2_eth_prep_cls_rule()
529 &fs->m_u.usr_ip4_spec, key, mask, fields); in dpaa2_eth_prep_cls_rule()
532 err = dpaa2_eth_prep_l4_rule(&fs->h_u.tcp_ip4_spec, &fs->m_u.tcp_ip4_spec, in dpaa2_eth_prep_cls_rule()
536 err = dpaa2_eth_prep_l4_rule(&fs->h_u.udp_ip4_spec, &fs->m_u.udp_ip4_spec, in dpaa2_eth_prep_cls_rule()
540 err = dpaa2_eth_prep_l4_rule(&fs->h_u.sctp_ip4_spec, in dpaa2_eth_prep_cls_rule()
541 &fs->m_u.sctp_ip4_spec, key, mask, in dpaa2_eth_prep_cls_rule()
545 return -EOPNOTSUPP; in dpaa2_eth_prep_cls_rule()
551 if (fs->flow_type & FLOW_EXT) { in dpaa2_eth_prep_cls_rule()
552 err = dpaa2_eth_prep_ext_rule(&fs->h_ext, &fs->m_ext, key, mask, fields); in dpaa2_eth_prep_cls_rule()
557 if (fs->flow_type & FLOW_MAC_EXT) { in dpaa2_eth_prep_cls_rule()
558 err = dpaa2_eth_prep_mac_ext_rule(&fs->h_ext, &fs->m_ext, key, in dpaa2_eth_prep_cls_rule()
572 struct device *dev = net_dev->dev.parent; in dpaa2_eth_do_cls_rule()
580 if (fs->ring_cookie != RX_CLS_FLOW_DISC && in dpaa2_eth_do_cls_rule()
581 fs->ring_cookie >= dpaa2_eth_queue_count(priv)) in dpaa2_eth_do_cls_rule()
582 return -EINVAL; in dpaa2_eth_do_cls_rule()
589 return -ENOMEM; in dpaa2_eth_do_cls_rule()
606 if (!priv->rx_cls_fields) { in dpaa2_eth_do_cls_rule()
611 priv->rx_cls_fields = fields; in dpaa2_eth_do_cls_rule()
612 } else if (priv->rx_cls_fields != fields) { in dpaa2_eth_do_cls_rule()
614 err = -EOPNOTSUPP; in dpaa2_eth_do_cls_rule()
625 err = -ENOMEM; in dpaa2_eth_do_cls_rule()
634 if (fs->ring_cookie == RX_CLS_FLOW_DISC) in dpaa2_eth_do_cls_rule()
637 fs_act.flow_id = fs->ring_cookie; in dpaa2_eth_do_cls_rule()
641 err = dpni_add_fs_entry(priv->mc_io, 0, priv->mc_token, in dpaa2_eth_do_cls_rule()
642 i, fs->location, &rule_cfg, in dpaa2_eth_do_cls_rule()
645 err = dpni_remove_fs_entry(priv->mc_io, 0, in dpaa2_eth_do_cls_rule()
646 priv->mc_token, i, in dpaa2_eth_do_cls_rule()
648 if (err || priv->dpni_attrs.options & DPNI_OPT_SHARED_FS) in dpaa2_eth_do_cls_rule()
665 if (priv->cls_rules[i].in_use) in dpaa2_eth_num_cls_rules()
677 int err = -EINVAL; in dpaa2_eth_update_cls_rule()
679 if (!priv->rx_cls_enabled) in dpaa2_eth_update_cls_rule()
680 return -EOPNOTSUPP; in dpaa2_eth_update_cls_rule()
683 return -EINVAL; in dpaa2_eth_update_cls_rule()
685 rule = &priv->cls_rules[location]; in dpaa2_eth_update_cls_rule()
688 if (rule->in_use) { in dpaa2_eth_update_cls_rule()
689 err = dpaa2_eth_do_cls_rule(net_dev, &rule->fs, false); in dpaa2_eth_update_cls_rule()
693 rule->in_use = 0; in dpaa2_eth_update_cls_rule()
697 priv->rx_cls_fields = 0; in dpaa2_eth_update_cls_rule()
708 rule->in_use = 1; in dpaa2_eth_update_cls_rule()
709 rule->fs = *new_fs; in dpaa2_eth_update_cls_rule()
721 switch (rxnfc->cmd) { in dpaa2_eth_get_rxnfc()
723 /* we purposely ignore cmd->flow_type for now, because the in dpaa2_eth_get_rxnfc()
727 rxnfc->data = priv->rx_hash_fields; in dpaa2_eth_get_rxnfc()
730 rxnfc->data = dpaa2_eth_queue_count(priv); in dpaa2_eth_get_rxnfc()
733 rxnfc->rule_cnt = 0; in dpaa2_eth_get_rxnfc()
734 rxnfc->rule_cnt = dpaa2_eth_num_cls_rules(priv); in dpaa2_eth_get_rxnfc()
735 rxnfc->data = max_rules; in dpaa2_eth_get_rxnfc()
738 if (rxnfc->fs.location >= max_rules) in dpaa2_eth_get_rxnfc()
739 return -EINVAL; in dpaa2_eth_get_rxnfc()
740 rxnfc->fs.location = array_index_nospec(rxnfc->fs.location, in dpaa2_eth_get_rxnfc()
742 if (!priv->cls_rules[rxnfc->fs.location].in_use) in dpaa2_eth_get_rxnfc()
743 return -EINVAL; in dpaa2_eth_get_rxnfc()
744 rxnfc->fs = priv->cls_rules[rxnfc->fs.location].fs; in dpaa2_eth_get_rxnfc()
748 if (!priv->cls_rules[i].in_use) in dpaa2_eth_get_rxnfc()
750 if (j == rxnfc->rule_cnt) in dpaa2_eth_get_rxnfc()
751 return -EMSGSIZE; in dpaa2_eth_get_rxnfc()
754 rxnfc->rule_cnt = j; in dpaa2_eth_get_rxnfc()
755 rxnfc->data = max_rules; in dpaa2_eth_get_rxnfc()
758 return -EOPNOTSUPP; in dpaa2_eth_get_rxnfc()
769 switch (rxnfc->cmd) { in dpaa2_eth_set_rxnfc()
771 if ((rxnfc->data & DPAA2_RXH_SUPPORTED) != rxnfc->data) in dpaa2_eth_set_rxnfc()
772 return -EOPNOTSUPP; in dpaa2_eth_set_rxnfc()
773 err = dpaa2_eth_set_hash(net_dev, rxnfc->data); in dpaa2_eth_set_rxnfc()
776 err = dpaa2_eth_update_cls_rule(net_dev, &rxnfc->fs, rxnfc->fs.location); in dpaa2_eth_set_rxnfc()
779 err = dpaa2_eth_update_cls_rule(net_dev, NULL, rxnfc->fs.location); in dpaa2_eth_set_rxnfc()
782 err = -EOPNOTSUPP; in dpaa2_eth_set_rxnfc()
788 int dpaa2_phc_index = -1;
797 info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE | in dpaa2_eth_get_ts_info()
801 info->phc_index = dpaa2_phc_index; in dpaa2_eth_get_ts_info()
803 info->tx_types = (1 << HWTSTAMP_TX_OFF) | in dpaa2_eth_get_ts_info()
807 info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) | in dpaa2_eth_get_ts_info()
819 switch (tuna->id) { in dpaa2_eth_get_tunable()
821 *(u32 *)data = priv->rx_copybreak; in dpaa2_eth_get_tunable()
824 err = -EOPNOTSUPP; in dpaa2_eth_get_tunable()
838 switch (tuna->id) { in dpaa2_eth_set_tunable()
840 priv->rx_copybreak = *(u32 *)data; in dpaa2_eth_set_tunable()
843 err = -EOPNOTSUPP; in dpaa2_eth_set_tunable()
856 struct dpaa2_io *dpio = priv->channel[0]->dpio; in dpaa2_eth_get_coalesce()
858 dpaa2_io_get_irq_coalescing(dpio, &ic->rx_coalesce_usecs); in dpaa2_eth_get_coalesce()
859 ic->use_adaptive_rx_coalesce = dpaa2_io_get_adaptive_coalescing(dpio); in dpaa2_eth_get_coalesce()
876 dpio = priv->channel[0]->dpio; in dpaa2_eth_set_coalesce()
881 for (i = 0; i < priv->num_channels; i++) { in dpaa2_eth_set_coalesce()
882 dpio = priv->channel[i]->dpio; in dpaa2_eth_set_coalesce()
885 ic->use_adaptive_rx_coalesce); in dpaa2_eth_set_coalesce()
886 err = dpaa2_io_set_irq_coalescing(dpio, ic->rx_coalesce_usecs); in dpaa2_eth_set_coalesce()
895 dpio = priv->channel[j]->dpio; in dpaa2_eth_set_coalesce()
905 struct ethtool_channels *channels) in dpaa2_eth_get_channels() argument
910 channels->max_rx = queue_count; in dpaa2_eth_get_channels()
911 channels->max_tx = queue_count; in dpaa2_eth_get_channels()
912 channels->rx_count = queue_count; in dpaa2_eth_get_channels()
913 channels->tx_count = queue_count; in dpaa2_eth_get_channels()
916 channels->max_other = queue_count + 1; in dpaa2_eth_get_channels()
917 channels->max_combined = channels->max_rx + in dpaa2_eth_get_channels()
918 channels->max_tx + in dpaa2_eth_get_channels()
919 channels->max_other; in dpaa2_eth_get_channels()
921 channels->other_count = queue_count + 1; in dpaa2_eth_get_channels()
922 channels->combined_count = channels->rx_count + in dpaa2_eth_get_channels()
923 channels->tx_count + in dpaa2_eth_get_channels()
924 channels->other_count; in dpaa2_eth_get_channels()