Lines Matching +full:mac +full:- +full:s
1 // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
2 /* Copyright 2017-2019 NXP */
44 struct enetc_hw *hw = &priv->si->hw; in enetc_get_reglen()
48 len += ARRAY_SIZE(enetc_txbdr_regs) * priv->num_tx_rings; in enetc_get_reglen()
49 len += ARRAY_SIZE(enetc_rxbdr_regs) * priv->num_rx_rings; in enetc_get_reglen()
51 if (hw->port) in enetc_get_reglen()
54 if (hw->port && !!(priv->si->hw_features & ENETC_SI_F_QBU)) in enetc_get_reglen()
66 struct enetc_hw *hw = &priv->si->hw; in enetc_get_regs()
76 for (i = 0; i < priv->num_tx_rings; i++) { in enetc_get_regs()
85 for (i = 0; i < priv->num_rx_rings; i++) { in enetc_get_regs()
94 if (!hw->port) in enetc_get_regs()
103 if (priv->si->hw_features & ENETC_SI_F_QBU) { in enetc_get_regs()
118 { ENETC_SIRUCA, "SI rx u-cast frames" },
119 { ENETC_SIRMCA, "SI rx m-cast frames" },
122 { ENETC_SITUCA, "SI tx u-cast frames" },
123 { ENETC_SITMCA, "SI tx m-cast frames" },
146 { ENETC_PM_REOCT(0), "MAC rx ethernet octets" },
147 { ENETC_PM_RALN(0), "MAC rx alignment errors" },
148 { ENETC_PM_RXPF(0), "MAC rx valid pause frames" },
149 { ENETC_PM_RFRM(0), "MAC rx valid frames" },
150 { ENETC_PM_RFCS(0), "MAC rx fcs errors" },
151 { ENETC_PM_RVLAN(0), "MAC rx VLAN frames" },
152 { ENETC_PM_RERR(0), "MAC rx frame errors" },
153 { ENETC_PM_RUCA(0), "MAC rx unicast frames" },
154 { ENETC_PM_RMCA(0), "MAC rx multicast frames" },
155 { ENETC_PM_RBCA(0), "MAC rx broadcast frames" },
156 { ENETC_PM_RDRP(0), "MAC rx dropped packets" },
157 { ENETC_PM_RPKT(0), "MAC rx packets" },
158 { ENETC_PM_RUND(0), "MAC rx undersized packets" },
159 { ENETC_PM_R64(0), "MAC rx 64 byte packets" },
160 { ENETC_PM_R127(0), "MAC rx 65-127 byte packets" },
161 { ENETC_PM_R255(0), "MAC rx 128-255 byte packets" },
162 { ENETC_PM_R511(0), "MAC rx 256-511 byte packets" },
163 { ENETC_PM_R1023(0), "MAC rx 512-1023 byte packets" },
164 { ENETC_PM_R1522(0), "MAC rx 1024-1522 byte packets" },
165 { ENETC_PM_R1523X(0), "MAC rx 1523 to max-octet packets" },
166 { ENETC_PM_ROVR(0), "MAC rx oversized packets" },
167 { ENETC_PM_RJBR(0), "MAC rx jabber packets" },
168 { ENETC_PM_RFRG(0), "MAC rx fragment packets" },
169 { ENETC_PM_RCNP(0), "MAC rx control packets" },
170 { ENETC_PM_RDRNTP(0), "MAC rx fifo drop" },
171 { ENETC_PM_TEOCT(0), "MAC tx ethernet octets" },
172 { ENETC_PM_TOCT(0), "MAC tx octets" },
173 { ENETC_PM_TCRSE(0), "MAC tx carrier sense errors" },
174 { ENETC_PM_TXPF(0), "MAC tx valid pause frames" },
175 { ENETC_PM_TFRM(0), "MAC tx frames" },
176 { ENETC_PM_TFCS(0), "MAC tx fcs errors" },
177 { ENETC_PM_TVLAN(0), "MAC tx VLAN frames" },
178 { ENETC_PM_TERR(0), "MAC tx frame errors" },
179 { ENETC_PM_TUCA(0), "MAC tx unicast frames" },
180 { ENETC_PM_TMCA(0), "MAC tx multicast frames" },
181 { ENETC_PM_TBCA(0), "MAC tx broadcast frames" },
182 { ENETC_PM_TPKT(0), "MAC tx packets" },
183 { ENETC_PM_TUND(0), "MAC tx undersized packets" },
184 { ENETC_PM_T64(0), "MAC tx 64 byte packets" },
185 { ENETC_PM_T127(0), "MAC tx 65-127 byte packets" },
186 { ENETC_PM_T255(0), "MAC tx 128-255 byte packets" },
187 { ENETC_PM_T511(0), "MAC tx 256-511 byte packets" },
188 { ENETC_PM_T1023(0), "MAC tx 512-1023 byte packets" },
189 { ENETC_PM_T1522(0), "MAC tx 1024-1522 byte packets" },
190 { ENETC_PM_T1523X(0), "MAC tx 1523 to max-octet packets" },
191 { ENETC_PM_TCNP(0), "MAC tx control packets" },
192 { ENETC_PM_TDFR(0), "MAC tx deferred packets" },
193 { ENETC_PM_TMCOL(0), "MAC tx multiple collisions" },
194 { ENETC_PM_TSCOL(0), "MAC tx single collisions" },
195 { ENETC_PM_TLCOL(0), "MAC tx late collisions" },
196 { ENETC_PM_TECOL(0), "MAC tx excessive collisions" },
197 { ENETC_UFDMF, "SI MAC nomatch u-cast discards" },
198 { ENETC_MFDMF, "SI MAC nomatch m-cast discards" },
199 { ENETC_PBFDSIR, "SI MAC nomatch b-cast discards" },
200 { ENETC_PUFDVFR, "SI VLAN nomatch u-cast discards" },
201 { ENETC_PMFDVFR, "SI VLAN nomatch m-cast discards" },
202 { ENETC_PBFDVFR, "SI VLAN nomatch b-cast discards" },
233 return -EOPNOTSUPP; in enetc_get_sset_count()
236 ARRAY_SIZE(tx_ring_stats) * priv->num_tx_rings + in enetc_get_sset_count()
237 ARRAY_SIZE(rx_ring_stats) * priv->num_rx_rings; in enetc_get_sset_count()
239 if (!enetc_si_is_pf(priv->si)) in enetc_get_sset_count()
259 for (i = 0; i < priv->num_tx_rings; i++) { in enetc_get_strings()
266 for (i = 0; i < priv->num_rx_rings; i++) { in enetc_get_strings()
274 if (!enetc_si_is_pf(priv->si)) in enetc_get_strings()
290 struct enetc_hw *hw = &priv->si->hw; in enetc_get_ethtool_stats()
296 for (i = 0; i < priv->num_tx_rings; i++) { in enetc_get_ethtool_stats()
297 data[o++] = priv->tx_ring[i]->stats.packets; in enetc_get_ethtool_stats()
298 data[o++] = priv->tx_ring[i]->stats.xdp_tx; in enetc_get_ethtool_stats()
299 data[o++] = priv->tx_ring[i]->stats.xdp_tx_drops; in enetc_get_ethtool_stats()
300 data[o++] = priv->tx_ring[i]->stats.win_drop; in enetc_get_ethtool_stats()
303 for (i = 0; i < priv->num_rx_rings; i++) { in enetc_get_ethtool_stats()
304 data[o++] = priv->rx_ring[i]->stats.packets; in enetc_get_ethtool_stats()
305 data[o++] = priv->rx_ring[i]->stats.rx_alloc_errs; in enetc_get_ethtool_stats()
306 data[o++] = priv->rx_ring[i]->stats.xdp_drops; in enetc_get_ethtool_stats()
307 data[o++] = priv->rx_ring[i]->stats.recycles; in enetc_get_ethtool_stats()
308 data[o++] = priv->rx_ring[i]->stats.recycle_failures; in enetc_get_ethtool_stats()
309 data[o++] = priv->rx_ring[i]->stats.xdp_redirect; in enetc_get_ethtool_stats()
310 data[o++] = priv->rx_ring[i]->stats.xdp_redirect_failures; in enetc_get_ethtool_stats()
313 if (!enetc_si_is_pf(priv->si)) in enetc_get_ethtool_stats()
320 static void enetc_pause_stats(struct enetc_hw *hw, int mac, in enetc_pause_stats() argument
323 pause_stats->tx_pause_frames = enetc_port_rd(hw, ENETC_PM_TXPF(mac)); in enetc_pause_stats()
324 pause_stats->rx_pause_frames = enetc_port_rd(hw, ENETC_PM_RXPF(mac)); in enetc_pause_stats()
331 struct enetc_hw *hw = &priv->si->hw; in enetc_get_pause_stats()
332 struct enetc_si *si = priv->si; in enetc_get_pause_stats()
334 switch (pause_stats->src) { in enetc_get_pause_stats()
339 if (si->hw_features & ENETC_SI_F_QBU) in enetc_get_pause_stats()
348 static void enetc_mac_stats(struct enetc_hw *hw, int mac, in enetc_mac_stats() argument
349 struct ethtool_eth_mac_stats *s) in enetc_mac_stats() argument
351 s->FramesTransmittedOK = enetc_port_rd(hw, ENETC_PM_TFRM(mac)); in enetc_mac_stats()
352 s->SingleCollisionFrames = enetc_port_rd(hw, ENETC_PM_TSCOL(mac)); in enetc_mac_stats()
353 s->MultipleCollisionFrames = enetc_port_rd(hw, ENETC_PM_TMCOL(mac)); in enetc_mac_stats()
354 s->FramesReceivedOK = enetc_port_rd(hw, ENETC_PM_RFRM(mac)); in enetc_mac_stats()
355 s->FrameCheckSequenceErrors = enetc_port_rd(hw, ENETC_PM_RFCS(mac)); in enetc_mac_stats()
356 s->AlignmentErrors = enetc_port_rd(hw, ENETC_PM_RALN(mac)); in enetc_mac_stats()
357 s->OctetsTransmittedOK = enetc_port_rd(hw, ENETC_PM_TEOCT(mac)); in enetc_mac_stats()
358 s->FramesWithDeferredXmissions = enetc_port_rd(hw, ENETC_PM_TDFR(mac)); in enetc_mac_stats()
359 s->LateCollisions = enetc_port_rd(hw, ENETC_PM_TLCOL(mac)); in enetc_mac_stats()
360 s->FramesAbortedDueToXSColls = enetc_port_rd(hw, ENETC_PM_TECOL(mac)); in enetc_mac_stats()
361 s->FramesLostDueToIntMACXmitError = enetc_port_rd(hw, ENETC_PM_TERR(mac)); in enetc_mac_stats()
362 s->CarrierSenseErrors = enetc_port_rd(hw, ENETC_PM_TCRSE(mac)); in enetc_mac_stats()
363 s->OctetsReceivedOK = enetc_port_rd(hw, ENETC_PM_REOCT(mac)); in enetc_mac_stats()
364 s->FramesLostDueToIntMACRcvError = enetc_port_rd(hw, ENETC_PM_RDRNTP(mac)); in enetc_mac_stats()
365 s->MulticastFramesXmittedOK = enetc_port_rd(hw, ENETC_PM_TMCA(mac)); in enetc_mac_stats()
366 s->BroadcastFramesXmittedOK = enetc_port_rd(hw, ENETC_PM_TBCA(mac)); in enetc_mac_stats()
367 s->MulticastFramesReceivedOK = enetc_port_rd(hw, ENETC_PM_RMCA(mac)); in enetc_mac_stats()
368 s->BroadcastFramesReceivedOK = enetc_port_rd(hw, ENETC_PM_RBCA(mac)); in enetc_mac_stats()
371 static void enetc_ctrl_stats(struct enetc_hw *hw, int mac, in enetc_ctrl_stats() argument
372 struct ethtool_eth_ctrl_stats *s) in enetc_ctrl_stats() argument
374 s->MACControlFramesTransmitted = enetc_port_rd(hw, ENETC_PM_TCNP(mac)); in enetc_ctrl_stats()
375 s->MACControlFramesReceived = enetc_port_rd(hw, ENETC_PM_RCNP(mac)); in enetc_ctrl_stats()
389 static void enetc_rmon_stats(struct enetc_hw *hw, int mac, in enetc_rmon_stats() argument
390 struct ethtool_rmon_stats *s) in enetc_rmon_stats() argument
392 s->undersize_pkts = enetc_port_rd(hw, ENETC_PM_RUND(mac)); in enetc_rmon_stats()
393 s->oversize_pkts = enetc_port_rd(hw, ENETC_PM_ROVR(mac)); in enetc_rmon_stats()
394 s->fragments = enetc_port_rd(hw, ENETC_PM_RFRG(mac)); in enetc_rmon_stats()
395 s->jabbers = enetc_port_rd(hw, ENETC_PM_RJBR(mac)); in enetc_rmon_stats()
397 s->hist[0] = enetc_port_rd(hw, ENETC_PM_R64(mac)); in enetc_rmon_stats()
398 s->hist[1] = enetc_port_rd(hw, ENETC_PM_R127(mac)); in enetc_rmon_stats()
399 s->hist[2] = enetc_port_rd(hw, ENETC_PM_R255(mac)); in enetc_rmon_stats()
400 s->hist[3] = enetc_port_rd(hw, ENETC_PM_R511(mac)); in enetc_rmon_stats()
401 s->hist[4] = enetc_port_rd(hw, ENETC_PM_R1023(mac)); in enetc_rmon_stats()
402 s->hist[5] = enetc_port_rd(hw, ENETC_PM_R1522(mac)); in enetc_rmon_stats()
403 s->hist[6] = enetc_port_rd(hw, ENETC_PM_R1523X(mac)); in enetc_rmon_stats()
405 s->hist_tx[0] = enetc_port_rd(hw, ENETC_PM_T64(mac)); in enetc_rmon_stats()
406 s->hist_tx[1] = enetc_port_rd(hw, ENETC_PM_T127(mac)); in enetc_rmon_stats()
407 s->hist_tx[2] = enetc_port_rd(hw, ENETC_PM_T255(mac)); in enetc_rmon_stats()
408 s->hist_tx[3] = enetc_port_rd(hw, ENETC_PM_T511(mac)); in enetc_rmon_stats()
409 s->hist_tx[4] = enetc_port_rd(hw, ENETC_PM_T1023(mac)); in enetc_rmon_stats()
410 s->hist_tx[5] = enetc_port_rd(hw, ENETC_PM_T1522(mac)); in enetc_rmon_stats()
411 s->hist_tx[6] = enetc_port_rd(hw, ENETC_PM_T1523X(mac)); in enetc_rmon_stats()
418 struct enetc_hw *hw = &priv->si->hw; in enetc_get_eth_mac_stats()
419 struct enetc_si *si = priv->si; in enetc_get_eth_mac_stats()
421 switch (mac_stats->src) { in enetc_get_eth_mac_stats()
426 if (si->hw_features & ENETC_SI_F_QBU) in enetc_get_eth_mac_stats()
439 struct enetc_hw *hw = &priv->si->hw; in enetc_get_eth_ctrl_stats()
440 struct enetc_si *si = priv->si; in enetc_get_eth_ctrl_stats()
442 switch (ctrl_stats->src) { in enetc_get_eth_ctrl_stats()
447 if (si->hw_features & ENETC_SI_F_QBU) in enetc_get_eth_ctrl_stats()
461 struct enetc_hw *hw = &priv->si->hw; in enetc_get_rmon_stats()
462 struct enetc_si *si = priv->si; in enetc_get_rmon_stats()
466 switch (rmon_stats->src) { in enetc_get_rmon_stats()
471 if (si->hw_features & ENETC_SI_F_QBU) in enetc_get_rmon_stats()
499 if (rxnfc->flow_type >= ARRAY_SIZE(rsshash)) in enetc_get_rsshash()
500 return -EINVAL; in enetc_get_rsshash()
502 rxnfc->data = rsshash[rxnfc->flow_type]; in enetc_get_rsshash()
507 /* current HW spec does byte reversal on everything including MAC addresses */
513 dst[i] = src[ETH_ALEN - i - 1]; in ether_addr_copy_swap()
527 switch (fs->flow_type & 0xff) { in enetc_set_cls_entry()
529 l4ip4_h = &fs->h_u.tcp_ip4_spec; in enetc_set_cls_entry()
530 l4ip4_m = &fs->m_u.tcp_ip4_spec; in enetc_set_cls_entry()
533 l4ip4_h = &fs->h_u.udp_ip4_spec; in enetc_set_cls_entry()
534 l4ip4_m = &fs->m_u.udp_ip4_spec; in enetc_set_cls_entry()
537 l4ip4_h = &fs->h_u.sctp_ip4_spec; in enetc_set_cls_entry()
538 l4ip4_m = &fs->m_u.sctp_ip4_spec; in enetc_set_cls_entry()
540 rfse.sip_h[0] = l4ip4_h->ip4src; in enetc_set_cls_entry()
541 rfse.sip_m[0] = l4ip4_m->ip4src; in enetc_set_cls_entry()
542 rfse.dip_h[0] = l4ip4_h->ip4dst; in enetc_set_cls_entry()
543 rfse.dip_m[0] = l4ip4_m->ip4dst; in enetc_set_cls_entry()
544 rfse.sport_h = ntohs(l4ip4_h->psrc); in enetc_set_cls_entry()
545 rfse.sport_m = ntohs(l4ip4_m->psrc); in enetc_set_cls_entry()
546 rfse.dport_h = ntohs(l4ip4_h->pdst); in enetc_set_cls_entry()
547 rfse.dport_m = ntohs(l4ip4_m->pdst); in enetc_set_cls_entry()
548 if (l4ip4_m->tos) in enetc_set_cls_entry()
549 netdev_warn(si->ndev, "ToS field is not supported and was ignored\n"); in enetc_set_cls_entry()
554 l3ip4_h = &fs->h_u.usr_ip4_spec; in enetc_set_cls_entry()
555 l3ip4_m = &fs->m_u.usr_ip4_spec; in enetc_set_cls_entry()
557 rfse.sip_h[0] = l3ip4_h->ip4src; in enetc_set_cls_entry()
558 rfse.sip_m[0] = l3ip4_m->ip4src; in enetc_set_cls_entry()
559 rfse.dip_h[0] = l3ip4_h->ip4dst; in enetc_set_cls_entry()
560 rfse.dip_m[0] = l3ip4_m->ip4dst; in enetc_set_cls_entry()
561 if (l3ip4_m->tos) in enetc_set_cls_entry()
562 netdev_warn(si->ndev, "ToS field is not supported and was ignored\n"); in enetc_set_cls_entry()
567 eth_h = &fs->h_u.ether_spec; in enetc_set_cls_entry()
568 eth_m = &fs->m_u.ether_spec; in enetc_set_cls_entry()
570 ether_addr_copy_swap(rfse.smac_h, eth_h->h_source); in enetc_set_cls_entry()
571 ether_addr_copy_swap(rfse.smac_m, eth_m->h_source); in enetc_set_cls_entry()
572 ether_addr_copy_swap(rfse.dmac_h, eth_h->h_dest); in enetc_set_cls_entry()
573 ether_addr_copy_swap(rfse.dmac_m, eth_m->h_dest); in enetc_set_cls_entry()
574 rfse.ethtype_h = ntohs(eth_h->h_proto); in enetc_set_cls_entry()
575 rfse.ethtype_m = ntohs(eth_m->h_proto); in enetc_set_cls_entry()
578 return -EOPNOTSUPP; in enetc_set_cls_entry()
582 if (fs->ring_cookie != RX_CLS_FLOW_DISC) { in enetc_set_cls_entry()
584 rfse.result = fs->ring_cookie; in enetc_set_cls_entry()
587 return enetc_set_fs_entry(si, &rfse, fs->location); in enetc_set_cls_entry()
596 switch (rxnfc->cmd) { in enetc_get_rxnfc()
598 rxnfc->data = priv->num_rx_rings; in enetc_get_rxnfc()
605 rxnfc->data = priv->si->num_fs_entries; in enetc_get_rxnfc()
607 rxnfc->rule_cnt = 0; in enetc_get_rxnfc()
608 for (i = 0; i < priv->si->num_fs_entries; i++) in enetc_get_rxnfc()
609 if (priv->cls_rules[i].used) in enetc_get_rxnfc()
610 rxnfc->rule_cnt++; in enetc_get_rxnfc()
613 if (rxnfc->fs.location >= priv->si->num_fs_entries) in enetc_get_rxnfc()
614 return -EINVAL; in enetc_get_rxnfc()
617 rxnfc->fs = priv->cls_rules[rxnfc->fs.location].fs; in enetc_get_rxnfc()
621 rxnfc->data = priv->si->num_fs_entries; in enetc_get_rxnfc()
624 for (i = 0; i < priv->si->num_fs_entries; i++) { in enetc_get_rxnfc()
625 if (!priv->cls_rules[i].used) in enetc_get_rxnfc()
627 if (j == rxnfc->rule_cnt) in enetc_get_rxnfc()
628 return -EMSGSIZE; in enetc_get_rxnfc()
632 rxnfc->rule_cnt = j; in enetc_get_rxnfc()
635 return -EOPNOTSUPP; in enetc_get_rxnfc()
646 switch (rxnfc->cmd) { in enetc_set_rxnfc()
648 if (rxnfc->fs.location >= priv->si->num_fs_entries) in enetc_set_rxnfc()
649 return -EINVAL; in enetc_set_rxnfc()
651 if (rxnfc->fs.ring_cookie >= priv->num_rx_rings && in enetc_set_rxnfc()
652 rxnfc->fs.ring_cookie != RX_CLS_FLOW_DISC) in enetc_set_rxnfc()
653 return -EINVAL; in enetc_set_rxnfc()
655 err = enetc_set_cls_entry(priv->si, &rxnfc->fs, true); in enetc_set_rxnfc()
658 priv->cls_rules[rxnfc->fs.location].fs = rxnfc->fs; in enetc_set_rxnfc()
659 priv->cls_rules[rxnfc->fs.location].used = 1; in enetc_set_rxnfc()
662 if (rxnfc->fs.location >= priv->si->num_fs_entries) in enetc_set_rxnfc()
663 return -EINVAL; in enetc_set_rxnfc()
665 err = enetc_set_cls_entry(priv->si, &rxnfc->fs, false); in enetc_set_rxnfc()
668 priv->cls_rules[rxnfc->fs.location].used = 0; in enetc_set_rxnfc()
671 return -EOPNOTSUPP; in enetc_set_rxnfc()
682 return (priv->si->hw.port) ? ENETC_RSSHASH_KEY_SIZE : 0; in enetc_get_rxfh_key_size()
690 return priv->si->num_rss; in enetc_get_rxfh_indir_size()
697 struct enetc_hw *hw = &priv->si->hw; in enetc_get_rxfh()
701 rxfh->hfunc = ETH_RSS_HASH_TOP; in enetc_get_rxfh()
704 if (rxfh->key && hw->port) in enetc_get_rxfh()
706 ((u32 *)rxfh->key)[i] = enetc_port_rd(hw, in enetc_get_rxfh()
710 if (rxfh->indir) in enetc_get_rxfh()
711 err = enetc_get_rss_table(priv->si, rxfh->indir, in enetc_get_rxfh()
712 priv->si->num_rss); in enetc_get_rxfh()
731 struct enetc_hw *hw = &priv->si->hw; in enetc_set_rxfh()
735 if (rxfh->key && hw->port) in enetc_set_rxfh()
736 enetc_set_rss_key(hw, rxfh->key); in enetc_set_rxfh()
739 if (rxfh->indir) in enetc_set_rxfh()
740 err = enetc_set_rss_table(priv->si, rxfh->indir, in enetc_set_rxfh()
741 priv->si->num_rss); in enetc_set_rxfh()
753 ring->rx_pending = priv->rx_bd_count; in enetc_get_ringparam()
754 ring->tx_pending = priv->tx_bd_count; in enetc_get_ringparam()
758 struct enetc_hw *hw = &priv->si->hw; in enetc_get_ringparam()
761 if (val != priv->rx_bd_count) in enetc_get_ringparam()
766 if (val != priv->tx_bd_count) in enetc_get_ringparam()
777 struct enetc_int_vector *v = priv->int_vector[0]; in enetc_get_coalesce()
779 ic->tx_coalesce_usecs = enetc_cycles_to_usecs(priv->tx_ictt); in enetc_get_coalesce()
780 ic->rx_coalesce_usecs = enetc_cycles_to_usecs(v->rx_ictt); in enetc_get_coalesce()
782 ic->tx_max_coalesced_frames = ENETC_TXIC_PKTTHR; in enetc_get_coalesce()
783 ic->rx_max_coalesced_frames = ENETC_RXIC_PKTTHR; in enetc_get_coalesce()
785 ic->use_adaptive_rx_coalesce = priv->ic_mode & ENETC_IC_RX_ADAPTIVE; in enetc_get_coalesce()
800 tx_ictt = enetc_usecs_to_cycles(ic->tx_coalesce_usecs); in enetc_set_coalesce()
801 rx_ictt = enetc_usecs_to_cycles(ic->rx_coalesce_usecs); in enetc_set_coalesce()
803 if (ic->rx_max_coalesced_frames != ENETC_RXIC_PKTTHR) in enetc_set_coalesce()
804 return -EOPNOTSUPP; in enetc_set_coalesce()
806 if (ic->tx_max_coalesced_frames != ENETC_TXIC_PKTTHR) in enetc_set_coalesce()
807 return -EOPNOTSUPP; in enetc_set_coalesce()
810 if (ic->use_adaptive_rx_coalesce) { in enetc_set_coalesce()
820 changed = (ic_mode != priv->ic_mode) || (priv->tx_ictt != tx_ictt); in enetc_set_coalesce()
822 priv->ic_mode = ic_mode; in enetc_set_coalesce()
823 priv->tx_ictt = tx_ictt; in enetc_set_coalesce()
825 for (i = 0; i < priv->bdr_int_num; i++) { in enetc_set_coalesce()
826 struct enetc_int_vector *v = priv->int_vector[i]; in enetc_set_coalesce()
828 v->rx_ictt = rx_ictt; in enetc_set_coalesce()
829 v->rx_dim_en = !!(ic_mode & ENETC_IC_RX_ADAPTIVE); in enetc_set_coalesce()
850 info->phc_index = *phc_idx; in enetc_get_ts_info()
855 info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE; in enetc_get_ts_info()
860 info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE | in enetc_get_ts_info()
865 info->tx_types = (1 << HWTSTAMP_TX_OFF) | in enetc_get_ts_info()
869 info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) | in enetc_get_ts_info()
878 wol->supported = 0; in enetc_get_wol()
879 wol->wolopts = 0; in enetc_get_wol()
881 if (dev->phydev) in enetc_get_wol()
882 phy_ethtool_get_wol(dev->phydev, wol); in enetc_get_wol()
890 if (!dev->phydev) in enetc_set_wol()
891 return -EOPNOTSUPP; in enetc_set_wol()
893 ret = phy_ethtool_set_wol(dev->phydev, wol); in enetc_set_wol()
895 device_set_wakeup_enable(&dev->dev, wol->wolopts); in enetc_set_wol()
905 phylink_ethtool_get_pauseparam(priv->phylink, pause); in enetc_get_pauseparam()
913 return phylink_ethtool_set_pauseparam(priv->phylink, pause); in enetc_set_pauseparam()
921 if (!priv->phylink) in enetc_get_link_ksettings()
922 return -EOPNOTSUPP; in enetc_get_link_ksettings()
924 return phylink_ethtool_ksettings_get(priv->phylink, cmd); in enetc_get_link_ksettings()
932 if (!priv->phylink) in enetc_set_link_ksettings()
933 return -EOPNOTSUPP; in enetc_set_link_ksettings()
935 return phylink_ethtool_ksettings_set(priv->phylink, cmd); in enetc_set_link_ksettings()
939 struct ethtool_mm_stats *s) in enetc_get_mm_stats() argument
942 struct enetc_hw *hw = &priv->si->hw; in enetc_get_mm_stats()
943 struct enetc_si *si = priv->si; in enetc_get_mm_stats()
945 if (!(si->hw_features & ENETC_SI_F_QBU)) in enetc_get_mm_stats()
948 s->MACMergeFrameAssErrorCount = enetc_port_rd(hw, ENETC_MMFAECR); in enetc_get_mm_stats()
949 s->MACMergeFrameSmdErrorCount = enetc_port_rd(hw, ENETC_MMFSECR); in enetc_get_mm_stats()
950 s->MACMergeFrameAssOkCount = enetc_port_rd(hw, ENETC_MMFAOCR); in enetc_get_mm_stats()
951 s->MACMergeFragCountRx = enetc_port_rd(hw, ENETC_MMFCRXR); in enetc_get_mm_stats()
952 s->MACMergeFragCountTx = enetc_port_rd(hw, ENETC_MMFCTXR); in enetc_get_mm_stats()
953 s->MACMergeHoldCount = enetc_port_rd(hw, ENETC_MMHCR); in enetc_get_mm_stats()
959 struct enetc_si *si = priv->si; in enetc_get_mm()
960 struct enetc_hw *hw = &si->hw; in enetc_get_mm()
963 if (!(si->hw_features & ENETC_SI_F_QBU)) in enetc_get_mm()
964 return -EOPNOTSUPP; in enetc_get_mm()
966 mutex_lock(&priv->mm_lock); in enetc_get_mm()
969 state->pmac_enabled = !!(val & ENETC_PFPMR_PMACE); in enetc_get_mm()
975 state->verify_status = ETHTOOL_MM_VERIFY_STATUS_DISABLED; in enetc_get_mm()
978 state->verify_status = ETHTOOL_MM_VERIFY_STATUS_VERIFYING; in enetc_get_mm()
981 state->verify_status = ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED; in enetc_get_mm()
984 state->verify_status = ETHTOOL_MM_VERIFY_STATUS_FAILED; in enetc_get_mm()
988 state->verify_status = ETHTOOL_MM_VERIFY_STATUS_UNKNOWN; in enetc_get_mm()
993 state->tx_min_frag_size = ethtool_mm_frag_size_add_to_min(rafs); in enetc_get_mm()
995 state->rx_min_frag_size = ethtool_mm_frag_size_add_to_min(lafs); in enetc_get_mm()
996 state->tx_enabled = !!(val & ENETC_MMCSR_LPE); /* mirror of MMCSR_ME */ in enetc_get_mm()
997 state->tx_active = state->tx_enabled && in enetc_get_mm()
998 (state->verify_status == ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED || in enetc_get_mm()
999 state->verify_status == ETHTOOL_MM_VERIFY_STATUS_DISABLED); in enetc_get_mm()
1000 state->verify_enabled = !(val & ENETC_MMCSR_VDIS); in enetc_get_mm()
1001 state->verify_time = ENETC_MMCSR_GET_VT(val); in enetc_get_mm()
1005 state->max_verify_time = 127; in enetc_get_mm()
1007 mutex_unlock(&priv->mm_lock); in enetc_get_mm()
1018 * attempts. To not sleep forever, it relies on a non-zero verify_time, in enetc_mm_wait_tx_active()
1044 /* ENETC does not have an IRQ to notify changes to the MAC Merge TX status
1050 struct enetc_hw *hw = &priv->si->hw; in enetc_mm_commit_preemptible_tcs()
1065 preemptible_tcs = priv->preemptible_tcs; in enetc_mm_commit_preemptible_tcs()
1070 /* FIXME: Workaround for the link partner's verification failing if ENETC
1076 u32 val = enetc_port_rd(&si->hw, ENETC_PM0_CMD_CFG); in enetc_restart_emac_rx()
1078 enetc_port_wr(&si->hw, ENETC_PM0_CMD_CFG, val & ~ENETC_PM0_RX_EN); in enetc_restart_emac_rx()
1081 enetc_port_wr(&si->hw, ENETC_PM0_CMD_CFG, val); in enetc_restart_emac_rx()
1088 struct enetc_hw *hw = &priv->si->hw; in enetc_set_mm()
1089 struct enetc_si *si = priv->si; in enetc_set_mm()
1093 if (!(si->hw_features & ENETC_SI_F_QBU)) in enetc_set_mm()
1094 return -EOPNOTSUPP; in enetc_set_mm()
1096 err = ethtool_mm_frag_size_min_to_add(cfg->tx_min_frag_size, in enetc_set_mm()
1101 mutex_lock(&priv->mm_lock); in enetc_set_mm()
1104 if (cfg->pmac_enabled) in enetc_set_mm()
1112 if (cfg->verify_enabled) in enetc_set_mm()
1117 if (cfg->tx_enabled) in enetc_set_mm()
1118 priv->active_offloads |= ENETC_F_QBU; in enetc_set_mm()
1120 priv->active_offloads &= ~ENETC_F_QBU; in enetc_set_mm()
1122 /* If link is up, enable/disable MAC Merge right away */ in enetc_set_mm()
1124 if (!!(priv->active_offloads & ENETC_F_QBU)) in enetc_set_mm()
1131 val |= ENETC_MMCSR_VT(cfg->verify_time); in enetc_set_mm()
1138 enetc_restart_emac_rx(priv->si); in enetc_set_mm()
1142 mutex_unlock(&priv->mm_lock); in enetc_set_mm()
1149 * According to 802.3 Figure 99-8 - Verify state diagram, the LINK_FAIL bit
1150 * should have been sufficient to re-trigger verification, but for ENETC it
1152 * re-trigger verification when link comes up.
1156 struct enetc_hw *hw = &priv->si->hw; in enetc_mm_link_state_update()
1159 mutex_lock(&priv->mm_lock); in enetc_mm_link_state_update()
1165 if (priv->active_offloads & ENETC_F_QBU) in enetc_mm_link_state_update()
1169 if (priv->active_offloads & ENETC_F_QBU) in enetc_mm_link_state_update()
1177 mutex_unlock(&priv->mm_lock); in enetc_mm_link_state_update()
1241 if (enetc_si_is_pf(priv->si)) in enetc_set_ethtool_ops()
1242 ndev->ethtool_ops = &enetc_pf_ethtool_ops; in enetc_set_ethtool_ops()
1244 ndev->ethtool_ops = &enetc_vf_ethtool_ops; in enetc_set_ethtool_ops()