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()
245 return -EOPNOTSUPP; in dpaa2_eth_get_sset_count()
282 err = dpni_get_statistics(priv->mc_io, 0, priv->mc_token, in dpaa2_eth_get_ethtool_stats()
284 if (err == -EINVAL) in dpaa2_eth_get_ethtool_stats()
295 /* Print per-cpu extra stats */ in dpaa2_eth_get_ethtool_stats()
297 extras = per_cpu_ptr(priv->percpu_extras, k); in dpaa2_eth_get_ethtool_stats()
303 /* Per-channel stats */ in dpaa2_eth_get_ethtool_stats()
304 for (k = 0; k < priv->num_channels; k++) { in dpaa2_eth_get_ethtool_stats()
305 ch_stats = &priv->channel[k]->stats; in dpaa2_eth_get_ethtool_stats()
311 for (j = 0; j < priv->num_fqs; j++) { in dpaa2_eth_get_ethtool_stats()
313 err = dpaa2_io_query_fq_count(NULL, priv->fq[j].fqid, in dpaa2_eth_get_ethtool_stats()
320 if (priv->fq[j].type == DPAA2_TX_CONF_FQ) { in dpaa2_eth_get_ethtool_stats()
334 for (j = 0; j < priv->num_bps; j++) { in dpaa2_eth_get_ethtool_stats()
335 err = dpaa2_io_query_bp_count(NULL, priv->bp[j]->bpid, &buf_cnt); in dpaa2_eth_get_ethtool_stats()
344 mutex_lock(&priv->mac_lock); in dpaa2_eth_get_ethtool_stats()
347 dpaa2_mac_get_ethtool_stats(priv->mac, data + i); in dpaa2_eth_get_ethtool_stats()
349 mutex_unlock(&priv->mac_lock); in dpaa2_eth_get_ethtool_stats()
357 if (eth_mask->h_proto) { in dpaa2_eth_prep_eth_rule()
359 *(__be16 *)(key + off) = eth_value->h_proto; in dpaa2_eth_prep_eth_rule()
360 *(__be16 *)(mask + off) = eth_mask->h_proto; in dpaa2_eth_prep_eth_rule()
364 if (!is_zero_ether_addr(eth_mask->h_source)) { in dpaa2_eth_prep_eth_rule()
366 ether_addr_copy(key + off, eth_value->h_source); in dpaa2_eth_prep_eth_rule()
367 ether_addr_copy(mask + off, eth_mask->h_source); in dpaa2_eth_prep_eth_rule()
371 if (!is_zero_ether_addr(eth_mask->h_dest)) { in dpaa2_eth_prep_eth_rule()
373 ether_addr_copy(key + off, eth_value->h_dest); in dpaa2_eth_prep_eth_rule()
374 ether_addr_copy(mask + off, eth_mask->h_dest); in dpaa2_eth_prep_eth_rule()
388 if (uip_mask->tos || uip_mask->ip_ver) in dpaa2_eth_prep_uip_rule()
389 return -EOPNOTSUPP; in dpaa2_eth_prep_uip_rule()
391 if (uip_mask->ip4src) { in dpaa2_eth_prep_uip_rule()
393 *(__be32 *)(key + off) = uip_value->ip4src; in dpaa2_eth_prep_uip_rule()
394 *(__be32 *)(mask + off) = uip_mask->ip4src; in dpaa2_eth_prep_uip_rule()
398 if (uip_mask->ip4dst) { in dpaa2_eth_prep_uip_rule()
400 *(__be32 *)(key + off) = uip_value->ip4dst; in dpaa2_eth_prep_uip_rule()
401 *(__be32 *)(mask + off) = uip_mask->ip4dst; in dpaa2_eth_prep_uip_rule()
405 if (uip_mask->proto) { in dpaa2_eth_prep_uip_rule()
407 *(u8 *)(key + off) = uip_value->proto; in dpaa2_eth_prep_uip_rule()
408 *(u8 *)(mask + off) = uip_mask->proto; in dpaa2_eth_prep_uip_rule()
412 if (uip_mask->l4_4_bytes) { in dpaa2_eth_prep_uip_rule()
413 tmp_value = be32_to_cpu(uip_value->l4_4_bytes); in dpaa2_eth_prep_uip_rule()
414 tmp_mask = be32_to_cpu(uip_mask->l4_4_bytes); in dpaa2_eth_prep_uip_rule()
442 if (l4_mask->tos) in dpaa2_eth_prep_l4_rule()
443 return -EOPNOTSUPP; in dpaa2_eth_prep_l4_rule()
445 if (l4_mask->ip4src) { in dpaa2_eth_prep_l4_rule()
447 *(__be32 *)(key + off) = l4_value->ip4src; in dpaa2_eth_prep_l4_rule()
448 *(__be32 *)(mask + off) = l4_mask->ip4src; in dpaa2_eth_prep_l4_rule()
452 if (l4_mask->ip4dst) { in dpaa2_eth_prep_l4_rule()
454 *(__be32 *)(key + off) = l4_value->ip4dst; in dpaa2_eth_prep_l4_rule()
455 *(__be32 *)(mask + off) = l4_mask->ip4dst; in dpaa2_eth_prep_l4_rule()
459 if (l4_mask->psrc) { in dpaa2_eth_prep_l4_rule()
461 *(__be16 *)(key + off) = l4_value->psrc; in dpaa2_eth_prep_l4_rule()
462 *(__be16 *)(mask + off) = l4_mask->psrc; in dpaa2_eth_prep_l4_rule()
466 if (l4_mask->pdst) { in dpaa2_eth_prep_l4_rule()
468 *(__be16 *)(key + off) = l4_value->pdst; in dpaa2_eth_prep_l4_rule()
469 *(__be16 *)(mask + off) = l4_mask->pdst; in dpaa2_eth_prep_l4_rule()
493 if (ext_mask->vlan_etype) in dpaa2_eth_prep_ext_rule()
494 return -EOPNOTSUPP; in dpaa2_eth_prep_ext_rule()
496 if (ext_mask->vlan_tci) { in dpaa2_eth_prep_ext_rule()
498 *(__be16 *)(key + off) = ext_value->vlan_tci; in dpaa2_eth_prep_ext_rule()
499 *(__be16 *)(mask + off) = ext_mask->vlan_tci; in dpaa2_eth_prep_ext_rule()
512 if (!is_zero_ether_addr(ext_mask->h_dest)) { in dpaa2_eth_prep_mac_ext_rule()
514 ether_addr_copy(key + off, ext_value->h_dest); in dpaa2_eth_prep_mac_ext_rule()
515 ether_addr_copy(mask + off, ext_mask->h_dest); in dpaa2_eth_prep_mac_ext_rule()
527 switch (fs->flow_type & 0xFF) { in dpaa2_eth_prep_cls_rule()
529 err = dpaa2_eth_prep_eth_rule(&fs->h_u.ether_spec, &fs->m_u.ether_spec, in dpaa2_eth_prep_cls_rule()
533 err = dpaa2_eth_prep_uip_rule(&fs->h_u.usr_ip4_spec, in dpaa2_eth_prep_cls_rule()
534 &fs->m_u.usr_ip4_spec, key, mask, fields); in dpaa2_eth_prep_cls_rule()
537 err = dpaa2_eth_prep_l4_rule(&fs->h_u.tcp_ip4_spec, &fs->m_u.tcp_ip4_spec, in dpaa2_eth_prep_cls_rule()
541 err = dpaa2_eth_prep_l4_rule(&fs->h_u.udp_ip4_spec, &fs->m_u.udp_ip4_spec, in dpaa2_eth_prep_cls_rule()
545 err = dpaa2_eth_prep_l4_rule(&fs->h_u.sctp_ip4_spec, in dpaa2_eth_prep_cls_rule()
546 &fs->m_u.sctp_ip4_spec, key, mask, in dpaa2_eth_prep_cls_rule()
550 return -EOPNOTSUPP; in dpaa2_eth_prep_cls_rule()
556 if (fs->flow_type & FLOW_EXT) { in dpaa2_eth_prep_cls_rule()
557 err = dpaa2_eth_prep_ext_rule(&fs->h_ext, &fs->m_ext, key, mask, fields); in dpaa2_eth_prep_cls_rule()
562 if (fs->flow_type & FLOW_MAC_EXT) { in dpaa2_eth_prep_cls_rule()
563 err = dpaa2_eth_prep_mac_ext_rule(&fs->h_ext, &fs->m_ext, key, in dpaa2_eth_prep_cls_rule()
577 struct device *dev = net_dev->dev.parent; in dpaa2_eth_do_cls_rule()
585 if (fs->ring_cookie != RX_CLS_FLOW_DISC && in dpaa2_eth_do_cls_rule()
586 fs->ring_cookie >= dpaa2_eth_queue_count(priv)) in dpaa2_eth_do_cls_rule()
587 return -EINVAL; in dpaa2_eth_do_cls_rule()
594 return -ENOMEM; in dpaa2_eth_do_cls_rule()
611 if (!priv->rx_cls_fields) { in dpaa2_eth_do_cls_rule()
616 priv->rx_cls_fields = fields; in dpaa2_eth_do_cls_rule()
617 } else if (priv->rx_cls_fields != fields) { in dpaa2_eth_do_cls_rule()
619 err = -EOPNOTSUPP; in dpaa2_eth_do_cls_rule()
630 err = -ENOMEM; in dpaa2_eth_do_cls_rule()
639 if (fs->ring_cookie == RX_CLS_FLOW_DISC) in dpaa2_eth_do_cls_rule()
642 fs_act.flow_id = fs->ring_cookie; in dpaa2_eth_do_cls_rule()
646 err = dpni_add_fs_entry(priv->mc_io, 0, priv->mc_token, in dpaa2_eth_do_cls_rule()
647 i, fs->location, &rule_cfg, in dpaa2_eth_do_cls_rule()
650 err = dpni_remove_fs_entry(priv->mc_io, 0, in dpaa2_eth_do_cls_rule()
651 priv->mc_token, i, in dpaa2_eth_do_cls_rule()
653 if (err || priv->dpni_attrs.options & DPNI_OPT_SHARED_FS) in dpaa2_eth_do_cls_rule()
670 if (priv->cls_rules[i].in_use) in dpaa2_eth_num_cls_rules()
682 int err = -EINVAL; in dpaa2_eth_update_cls_rule()
684 if (!priv->rx_cls_enabled) in dpaa2_eth_update_cls_rule()
685 return -EOPNOTSUPP; in dpaa2_eth_update_cls_rule()
688 return -EINVAL; in dpaa2_eth_update_cls_rule()
690 rule = &priv->cls_rules[location]; in dpaa2_eth_update_cls_rule()
693 if (rule->in_use) { in dpaa2_eth_update_cls_rule()
694 err = dpaa2_eth_do_cls_rule(net_dev, &rule->fs, false); in dpaa2_eth_update_cls_rule()
698 rule->in_use = 0; in dpaa2_eth_update_cls_rule()
702 priv->rx_cls_fields = 0; in dpaa2_eth_update_cls_rule()
713 rule->in_use = 1; in dpaa2_eth_update_cls_rule()
714 rule->fs = *new_fs; in dpaa2_eth_update_cls_rule()
726 switch (rxnfc->cmd) { in dpaa2_eth_get_rxnfc()
728 /* we purposely ignore cmd->flow_type for now, because the in dpaa2_eth_get_rxnfc()
732 rxnfc->data = priv->rx_hash_fields; in dpaa2_eth_get_rxnfc()
735 rxnfc->data = dpaa2_eth_queue_count(priv); in dpaa2_eth_get_rxnfc()
738 rxnfc->rule_cnt = 0; in dpaa2_eth_get_rxnfc()
739 rxnfc->rule_cnt = dpaa2_eth_num_cls_rules(priv); in dpaa2_eth_get_rxnfc()
740 rxnfc->data = max_rules; in dpaa2_eth_get_rxnfc()
743 if (rxnfc->fs.location >= max_rules) in dpaa2_eth_get_rxnfc()
744 return -EINVAL; in dpaa2_eth_get_rxnfc()
745 rxnfc->fs.location = array_index_nospec(rxnfc->fs.location, in dpaa2_eth_get_rxnfc()
747 if (!priv->cls_rules[rxnfc->fs.location].in_use) in dpaa2_eth_get_rxnfc()
748 return -EINVAL; in dpaa2_eth_get_rxnfc()
749 rxnfc->fs = priv->cls_rules[rxnfc->fs.location].fs; in dpaa2_eth_get_rxnfc()
753 if (!priv->cls_rules[i].in_use) in dpaa2_eth_get_rxnfc()
755 if (j == rxnfc->rule_cnt) in dpaa2_eth_get_rxnfc()
756 return -EMSGSIZE; in dpaa2_eth_get_rxnfc()
759 rxnfc->rule_cnt = j; in dpaa2_eth_get_rxnfc()
760 rxnfc->data = max_rules; in dpaa2_eth_get_rxnfc()
763 return -EOPNOTSUPP; in dpaa2_eth_get_rxnfc()
774 switch (rxnfc->cmd) { in dpaa2_eth_set_rxnfc()
776 if ((rxnfc->data & DPAA2_RXH_SUPPORTED) != rxnfc->data) in dpaa2_eth_set_rxnfc()
777 return -EOPNOTSUPP; in dpaa2_eth_set_rxnfc()
778 err = dpaa2_eth_set_hash(net_dev, rxnfc->data); in dpaa2_eth_set_rxnfc()
781 err = dpaa2_eth_update_cls_rule(net_dev, &rxnfc->fs, rxnfc->fs.location); in dpaa2_eth_set_rxnfc()
784 err = dpaa2_eth_update_cls_rule(net_dev, NULL, rxnfc->fs.location); in dpaa2_eth_set_rxnfc()
787 err = -EOPNOTSUPP; in dpaa2_eth_set_rxnfc()
793 int dpaa2_phc_index = -1;
802 info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE | in dpaa2_eth_get_ts_info()
806 info->phc_index = dpaa2_phc_index; in dpaa2_eth_get_ts_info()
808 info->tx_types = (1 << HWTSTAMP_TX_OFF) | in dpaa2_eth_get_ts_info()
812 info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) | in dpaa2_eth_get_ts_info()
824 switch (tuna->id) { in dpaa2_eth_get_tunable()
826 *(u32 *)data = priv->rx_copybreak; in dpaa2_eth_get_tunable()
829 err = -EOPNOTSUPP; in dpaa2_eth_get_tunable()
843 switch (tuna->id) { in dpaa2_eth_set_tunable()
845 priv->rx_copybreak = *(u32 *)data; in dpaa2_eth_set_tunable()
848 err = -EOPNOTSUPP; in dpaa2_eth_set_tunable()
861 struct dpaa2_io *dpio = priv->channel[0]->dpio; in dpaa2_eth_get_coalesce()
863 dpaa2_io_get_irq_coalescing(dpio, &ic->rx_coalesce_usecs); in dpaa2_eth_get_coalesce()
864 ic->use_adaptive_rx_coalesce = dpaa2_io_get_adaptive_coalescing(dpio); in dpaa2_eth_get_coalesce()
881 dpio = priv->channel[0]->dpio; in dpaa2_eth_set_coalesce()
886 for (i = 0; i < priv->num_channels; i++) { in dpaa2_eth_set_coalesce()
887 dpio = priv->channel[i]->dpio; in dpaa2_eth_set_coalesce()
890 ic->use_adaptive_rx_coalesce); in dpaa2_eth_set_coalesce()
891 err = dpaa2_io_set_irq_coalescing(dpio, ic->rx_coalesce_usecs); in dpaa2_eth_set_coalesce()
900 dpio = priv->channel[j]->dpio; in dpaa2_eth_set_coalesce()
910 struct ethtool_channels *channels) in dpaa2_eth_get_channels() argument
915 channels->max_rx = queue_count; in dpaa2_eth_get_channels()
916 channels->max_tx = queue_count; in dpaa2_eth_get_channels()
917 channels->rx_count = queue_count; in dpaa2_eth_get_channels()
918 channels->tx_count = queue_count; in dpaa2_eth_get_channels()
921 channels->max_other = queue_count + 1; in dpaa2_eth_get_channels()
922 channels->max_combined = channels->max_rx + in dpaa2_eth_get_channels()
923 channels->max_tx + in dpaa2_eth_get_channels()
924 channels->max_other; in dpaa2_eth_get_channels()
926 channels->other_count = queue_count + 1; in dpaa2_eth_get_channels()
927 channels->combined_count = channels->rx_count + in dpaa2_eth_get_channels()
928 channels->tx_count + in dpaa2_eth_get_channels()
929 channels->other_count; in dpaa2_eth_get_channels()