1 // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
2 /* Copyright 2017-2019 NXP */
4 #include <linux/net_tstamp.h>
5 #include <linux/module.h>
8 static const u32 enetc_si_regs[] = {
9 ENETC_SIMR, ENETC_SIPMAR0, ENETC_SIPMAR1, ENETC_SICBDRMR,
10 ENETC_SICBDRSR, ENETC_SICBDRBAR0, ENETC_SICBDRBAR1, ENETC_SICBDRPIR,
11 ENETC_SICBDRCIR, ENETC_SICBDRLENR, ENETC_SICAPR0, ENETC_SICAPR1,
15 static const u32 enetc_txbdr_regs[] = {
16 ENETC_TBMR, ENETC_TBSR, ENETC_TBBAR0, ENETC_TBBAR1,
17 ENETC_TBPIR, ENETC_TBCIR, ENETC_TBLENR, ENETC_TBIER
20 static const u32 enetc_rxbdr_regs[] = {
21 ENETC_RBMR, ENETC_RBSR, ENETC_RBBSR, ENETC_RBCIR, ENETC_RBBAR0,
22 ENETC_RBBAR1, ENETC_RBPIR, ENETC_RBLENR, ENETC_RBICIR0, ENETC_RBIER
25 static const u32 enetc_port_regs[] = {
26 ENETC_PMR, ENETC_PSR, ENETC_PSIPMR, ENETC_PSIPMAR0(0),
27 ENETC_PSIPMAR1(0), ENETC_PTXMBAR, ENETC_PCAPR0, ENETC_PCAPR1,
28 ENETC_PSICFGR0(0), ENETC_PRFSCAPR, ENETC_PTCMSDUR(0),
29 ENETC_PM0_CMD_CFG, ENETC_PM0_MAXFRM, ENETC_PM0_IF_MODE
32 static int enetc_get_reglen(struct net_device *ndev)
34 struct enetc_ndev_priv *priv = netdev_priv(ndev);
35 struct enetc_hw *hw = &priv->si->hw;
38 len = ARRAY_SIZE(enetc_si_regs);
39 len += ARRAY_SIZE(enetc_txbdr_regs) * priv->num_tx_rings;
40 len += ARRAY_SIZE(enetc_rxbdr_regs) * priv->num_rx_rings;
43 len += ARRAY_SIZE(enetc_port_regs);
45 len *= sizeof(u32) * 2; /* store 2 entries per reg: addr and value */
50 static void enetc_get_regs(struct net_device *ndev, struct ethtool_regs *regs,
53 struct enetc_ndev_priv *priv = netdev_priv(ndev);
54 struct enetc_hw *hw = &priv->si->hw;
55 u32 *buf = (u32 *)regbuf;
59 for (i = 0; i < ARRAY_SIZE(enetc_si_regs); i++) {
60 *buf++ = enetc_si_regs[i];
61 *buf++ = enetc_rd(hw, enetc_si_regs[i]);
64 for (i = 0; i < priv->num_tx_rings; i++) {
65 for (j = 0; j < ARRAY_SIZE(enetc_txbdr_regs); j++) {
66 addr = ENETC_BDR(TX, i, enetc_txbdr_regs[j]);
69 *buf++ = enetc_rd(hw, addr);
73 for (i = 0; i < priv->num_rx_rings; i++) {
74 for (j = 0; j < ARRAY_SIZE(enetc_rxbdr_regs); j++) {
75 addr = ENETC_BDR(RX, i, enetc_rxbdr_regs[j]);
78 *buf++ = enetc_rd(hw, addr);
85 for (i = 0; i < ARRAY_SIZE(enetc_port_regs); i++) {
86 addr = ENETC_PORT_BASE + enetc_port_regs[i];
88 *buf++ = enetc_rd(hw, addr);
94 char name[ETH_GSTRING_LEN];
95 } enetc_si_counters[] = {
96 { ENETC_SIROCT, "SI rx octets" },
97 { ENETC_SIRFRM, "SI rx frames" },
98 { ENETC_SIRUCA, "SI rx u-cast frames" },
99 { ENETC_SIRMCA, "SI rx m-cast frames" },
100 { ENETC_SITOCT, "SI tx octets" },
101 { ENETC_SITFRM, "SI tx frames" },
102 { ENETC_SITUCA, "SI tx u-cast frames" },
103 { ENETC_SITMCA, "SI tx m-cast frames" },
104 { ENETC_RBDCR(0), "Rx ring 0 discarded frames" },
105 { ENETC_RBDCR(1), "Rx ring 1 discarded frames" },
106 { ENETC_RBDCR(2), "Rx ring 2 discarded frames" },
107 { ENETC_RBDCR(3), "Rx ring 3 discarded frames" },
108 { ENETC_RBDCR(4), "Rx ring 4 discarded frames" },
109 { ENETC_RBDCR(5), "Rx ring 5 discarded frames" },
110 { ENETC_RBDCR(6), "Rx ring 6 discarded frames" },
111 { ENETC_RBDCR(7), "Rx ring 7 discarded frames" },
112 { ENETC_RBDCR(8), "Rx ring 8 discarded frames" },
113 { ENETC_RBDCR(9), "Rx ring 9 discarded frames" },
114 { ENETC_RBDCR(10), "Rx ring 10 discarded frames" },
115 { ENETC_RBDCR(11), "Rx ring 11 discarded frames" },
116 { ENETC_RBDCR(12), "Rx ring 12 discarded frames" },
117 { ENETC_RBDCR(13), "Rx ring 13 discarded frames" },
118 { ENETC_RBDCR(14), "Rx ring 14 discarded frames" },
119 { ENETC_RBDCR(15), "Rx ring 15 discarded frames" },
122 static const struct {
124 char name[ETH_GSTRING_LEN];
125 } enetc_port_counters[] = {
126 { ENETC_PM0_REOCT, "MAC rx ethernet octets" },
127 { ENETC_PM0_RALN, "MAC rx alignment errors" },
128 { ENETC_PM0_RXPF, "MAC rx valid pause frames" },
129 { ENETC_PM0_RFRM, "MAC rx valid frames" },
130 { ENETC_PM0_RFCS, "MAC rx fcs errors" },
131 { ENETC_PM0_RVLAN, "MAC rx VLAN frames" },
132 { ENETC_PM0_RERR, "MAC rx frame errors" },
133 { ENETC_PM0_RUCA, "MAC rx unicast frames" },
134 { ENETC_PM0_RMCA, "MAC rx multicast frames" },
135 { ENETC_PM0_RBCA, "MAC rx broadcast frames" },
136 { ENETC_PM0_RDRP, "MAC rx dropped packets" },
137 { ENETC_PM0_RPKT, "MAC rx packets" },
138 { ENETC_PM0_RUND, "MAC rx undersized packets" },
139 { ENETC_PM0_R64, "MAC rx 64 byte packets" },
140 { ENETC_PM0_R127, "MAC rx 65-127 byte packets" },
141 { ENETC_PM0_R255, "MAC rx 128-255 byte packets" },
142 { ENETC_PM0_R511, "MAC rx 256-511 byte packets" },
143 { ENETC_PM0_R1023, "MAC rx 512-1023 byte packets" },
144 { ENETC_PM0_R1518, "MAC rx 1024-1518 byte packets" },
145 { ENETC_PM0_R1519X, "MAC rx 1519 to max-octet packets" },
146 { ENETC_PM0_ROVR, "MAC rx oversized packets" },
147 { ENETC_PM0_RJBR, "MAC rx jabber packets" },
148 { ENETC_PM0_RFRG, "MAC rx fragment packets" },
149 { ENETC_PM0_RCNP, "MAC rx control packets" },
150 { ENETC_PM0_RDRNTP, "MAC rx fifo drop" },
151 { ENETC_PM0_TEOCT, "MAC tx ethernet octets" },
152 { ENETC_PM0_TOCT, "MAC tx octets" },
153 { ENETC_PM0_TCRSE, "MAC tx carrier sense errors" },
154 { ENETC_PM0_TXPF, "MAC tx valid pause frames" },
155 { ENETC_PM0_TFRM, "MAC tx frames" },
156 { ENETC_PM0_TFCS, "MAC tx fcs errors" },
157 { ENETC_PM0_TVLAN, "MAC tx VLAN frames" },
158 { ENETC_PM0_TERR, "MAC tx frames" },
159 { ENETC_PM0_TUCA, "MAC tx unicast frames" },
160 { ENETC_PM0_TMCA, "MAC tx multicast frames" },
161 { ENETC_PM0_TBCA, "MAC tx broadcast frames" },
162 { ENETC_PM0_TPKT, "MAC tx packets" },
163 { ENETC_PM0_TUND, "MAC tx undersized packets" },
164 { ENETC_PM0_T127, "MAC tx 65-127 byte packets" },
165 { ENETC_PM0_T1023, "MAC tx 512-1023 byte packets" },
166 { ENETC_PM0_T1518, "MAC tx 1024-1518 byte packets" },
167 { ENETC_PM0_TCNP, "MAC tx control packets" },
168 { ENETC_PM0_TDFR, "MAC tx deferred packets" },
169 { ENETC_PM0_TMCOL, "MAC tx multiple collisions" },
170 { ENETC_PM0_TSCOL, "MAC tx single collisions" },
171 { ENETC_PM0_TLCOL, "MAC tx late collisions" },
172 { ENETC_PM0_TECOL, "MAC tx excessive collisions" },
173 { ENETC_UFDMF, "SI MAC nomatch u-cast discards" },
174 { ENETC_MFDMF, "SI MAC nomatch m-cast discards" },
175 { ENETC_PBFDSIR, "SI MAC nomatch b-cast discards" },
176 { ENETC_PUFDVFR, "SI VLAN nomatch u-cast discards" },
177 { ENETC_PMFDVFR, "SI VLAN nomatch m-cast discards" },
178 { ENETC_PBFDVFR, "SI VLAN nomatch b-cast discards" },
179 { ENETC_PFDMSAPR, "SI pruning discarded frames" },
180 { ENETC_PICDR(0), "ICM DR0 discarded frames" },
181 { ENETC_PICDR(1), "ICM DR1 discarded frames" },
182 { ENETC_PICDR(2), "ICM DR2 discarded frames" },
183 { ENETC_PICDR(3), "ICM DR3 discarded frames" },
186 static const char rx_ring_stats[][ETH_GSTRING_LEN] = {
187 "Rx ring %2d frames",
188 "Rx ring %2d alloc errors",
191 static const char tx_ring_stats[][ETH_GSTRING_LEN] = {
192 "Tx ring %2d frames",
195 static int enetc_get_sset_count(struct net_device *ndev, int sset)
197 struct enetc_ndev_priv *priv = netdev_priv(ndev);
200 if (sset != ETH_SS_STATS)
203 len = ARRAY_SIZE(enetc_si_counters) +
204 ARRAY_SIZE(tx_ring_stats) * priv->num_tx_rings +
205 ARRAY_SIZE(rx_ring_stats) * priv->num_rx_rings;
207 if (!enetc_si_is_pf(priv->si))
210 len += ARRAY_SIZE(enetc_port_counters);
215 static void enetc_get_strings(struct net_device *ndev, u32 stringset, u8 *data)
217 struct enetc_ndev_priv *priv = netdev_priv(ndev);
223 for (i = 0; i < ARRAY_SIZE(enetc_si_counters); i++) {
224 strlcpy(p, enetc_si_counters[i].name, ETH_GSTRING_LEN);
225 p += ETH_GSTRING_LEN;
227 for (i = 0; i < priv->num_tx_rings; i++) {
228 for (j = 0; j < ARRAY_SIZE(tx_ring_stats); j++) {
229 snprintf(p, ETH_GSTRING_LEN, tx_ring_stats[j],
231 p += ETH_GSTRING_LEN;
234 for (i = 0; i < priv->num_rx_rings; i++) {
235 for (j = 0; j < ARRAY_SIZE(rx_ring_stats); j++) {
236 snprintf(p, ETH_GSTRING_LEN, rx_ring_stats[j],
238 p += ETH_GSTRING_LEN;
242 if (!enetc_si_is_pf(priv->si))
245 for (i = 0; i < ARRAY_SIZE(enetc_port_counters); i++) {
246 strlcpy(p, enetc_port_counters[i].name,
248 p += ETH_GSTRING_LEN;
254 static void enetc_get_ethtool_stats(struct net_device *ndev,
255 struct ethtool_stats *stats, u64 *data)
257 struct enetc_ndev_priv *priv = netdev_priv(ndev);
258 struct enetc_hw *hw = &priv->si->hw;
261 for (i = 0; i < ARRAY_SIZE(enetc_si_counters); i++)
262 data[o++] = enetc_rd64(hw, enetc_si_counters[i].reg);
264 for (i = 0; i < priv->num_tx_rings; i++)
265 data[o++] = priv->tx_ring[i]->stats.packets;
267 for (i = 0; i < priv->num_rx_rings; i++) {
268 data[o++] = priv->rx_ring[i]->stats.packets;
269 data[o++] = priv->rx_ring[i]->stats.rx_alloc_errs;
272 if (!enetc_si_is_pf(priv->si))
275 for (i = 0; i < ARRAY_SIZE(enetc_port_counters); i++)
276 data[o++] = enetc_port_rd(hw, enetc_port_counters[i].reg);
279 #define ENETC_RSSHASH_L3 (RXH_L2DA | RXH_VLAN | RXH_L3_PROTO | RXH_IP_SRC | \
281 #define ENETC_RSSHASH_L4 (ENETC_RSSHASH_L3 | RXH_L4_B_0_1 | RXH_L4_B_2_3)
282 static int enetc_get_rsshash(struct ethtool_rxnfc *rxnfc)
284 static const u32 rsshash[] = {
285 [TCP_V4_FLOW] = ENETC_RSSHASH_L4,
286 [UDP_V4_FLOW] = ENETC_RSSHASH_L4,
287 [SCTP_V4_FLOW] = ENETC_RSSHASH_L4,
288 [AH_ESP_V4_FLOW] = ENETC_RSSHASH_L3,
289 [IPV4_FLOW] = ENETC_RSSHASH_L3,
290 [TCP_V6_FLOW] = ENETC_RSSHASH_L4,
291 [UDP_V6_FLOW] = ENETC_RSSHASH_L4,
292 [SCTP_V6_FLOW] = ENETC_RSSHASH_L4,
293 [AH_ESP_V6_FLOW] = ENETC_RSSHASH_L3,
294 [IPV6_FLOW] = ENETC_RSSHASH_L3,
298 if (rxnfc->flow_type >= ARRAY_SIZE(rsshash))
301 rxnfc->data = rsshash[rxnfc->flow_type];
306 /* current HW spec does byte reversal on everything including MAC addresses */
307 static void ether_addr_copy_swap(u8 *dst, const u8 *src)
311 for (i = 0; i < ETH_ALEN; i++)
312 dst[i] = src[ETH_ALEN - i - 1];
315 static int enetc_set_cls_entry(struct enetc_si *si,
316 struct ethtool_rx_flow_spec *fs, bool en)
318 struct ethtool_tcpip4_spec *l4ip4_h, *l4ip4_m;
319 struct ethtool_usrip4_spec *l3ip4_h, *l3ip4_m;
320 struct ethhdr *eth_h, *eth_m;
321 struct enetc_cmd_rfse rfse = { {0} };
326 switch (fs->flow_type & 0xff) {
328 l4ip4_h = &fs->h_u.tcp_ip4_spec;
329 l4ip4_m = &fs->m_u.tcp_ip4_spec;
332 l4ip4_h = &fs->h_u.udp_ip4_spec;
333 l4ip4_m = &fs->m_u.udp_ip4_spec;
336 l4ip4_h = &fs->h_u.sctp_ip4_spec;
337 l4ip4_m = &fs->m_u.sctp_ip4_spec;
339 rfse.sip_h[0] = l4ip4_h->ip4src;
340 rfse.sip_m[0] = l4ip4_m->ip4src;
341 rfse.dip_h[0] = l4ip4_h->ip4dst;
342 rfse.dip_m[0] = l4ip4_m->ip4dst;
343 rfse.sport_h = ntohs(l4ip4_h->psrc);
344 rfse.sport_m = ntohs(l4ip4_m->psrc);
345 rfse.dport_h = ntohs(l4ip4_h->pdst);
346 rfse.dport_m = ntohs(l4ip4_m->pdst);
348 netdev_warn(si->ndev, "ToS field is not supported and was ignored\n");
349 rfse.ethtype_h = ETH_P_IP; /* IPv4 */
350 rfse.ethtype_m = 0xffff;
353 l3ip4_h = &fs->h_u.usr_ip4_spec;
354 l3ip4_m = &fs->m_u.usr_ip4_spec;
356 rfse.sip_h[0] = l3ip4_h->ip4src;
357 rfse.sip_m[0] = l3ip4_m->ip4src;
358 rfse.dip_h[0] = l3ip4_h->ip4dst;
359 rfse.dip_m[0] = l3ip4_m->ip4dst;
361 netdev_warn(si->ndev, "ToS field is not supported and was ignored\n");
362 rfse.ethtype_h = ETH_P_IP; /* IPv4 */
363 rfse.ethtype_m = 0xffff;
366 eth_h = &fs->h_u.ether_spec;
367 eth_m = &fs->m_u.ether_spec;
369 ether_addr_copy_swap(rfse.smac_h, eth_h->h_source);
370 ether_addr_copy_swap(rfse.smac_m, eth_m->h_source);
371 ether_addr_copy_swap(rfse.dmac_h, eth_h->h_dest);
372 ether_addr_copy_swap(rfse.dmac_m, eth_m->h_dest);
373 rfse.ethtype_h = ntohs(eth_h->h_proto);
374 rfse.ethtype_m = ntohs(eth_m->h_proto);
380 rfse.mode |= ENETC_RFSE_EN;
381 if (fs->ring_cookie != RX_CLS_FLOW_DISC) {
382 rfse.mode |= ENETC_RFSE_MODE_BD;
383 rfse.result = fs->ring_cookie;
386 return enetc_set_fs_entry(si, &rfse, fs->location);
389 static int enetc_get_rxnfc(struct net_device *ndev, struct ethtool_rxnfc *rxnfc,
392 struct enetc_ndev_priv *priv = netdev_priv(ndev);
395 switch (rxnfc->cmd) {
396 case ETHTOOL_GRXRINGS:
397 rxnfc->data = priv->num_rx_rings;
400 /* get RSS hash config */
401 return enetc_get_rsshash(rxnfc);
402 case ETHTOOL_GRXCLSRLCNT:
403 /* total number of entries */
404 rxnfc->data = priv->si->num_fs_entries;
405 /* number of entries in use */
407 for (i = 0; i < priv->si->num_fs_entries; i++)
408 if (priv->cls_rules[i].used)
411 case ETHTOOL_GRXCLSRULE:
412 if (rxnfc->fs.location >= priv->si->num_fs_entries)
416 rxnfc->fs = priv->cls_rules[rxnfc->fs.location].fs;
418 case ETHTOOL_GRXCLSRLALL:
419 /* total number of entries */
420 rxnfc->data = priv->si->num_fs_entries;
421 /* array of indexes of used entries */
423 for (i = 0; i < priv->si->num_fs_entries; i++) {
424 if (!priv->cls_rules[i].used)
426 if (j == rxnfc->rule_cnt)
430 /* number of entries in use */
440 static int enetc_set_rxnfc(struct net_device *ndev, struct ethtool_rxnfc *rxnfc)
442 struct enetc_ndev_priv *priv = netdev_priv(ndev);
445 switch (rxnfc->cmd) {
446 case ETHTOOL_SRXCLSRLINS:
447 if (rxnfc->fs.location >= priv->si->num_fs_entries)
450 if (rxnfc->fs.ring_cookie >= priv->num_rx_rings &&
451 rxnfc->fs.ring_cookie != RX_CLS_FLOW_DISC)
454 err = enetc_set_cls_entry(priv->si, &rxnfc->fs, true);
457 priv->cls_rules[rxnfc->fs.location].fs = rxnfc->fs;
458 priv->cls_rules[rxnfc->fs.location].used = 1;
460 case ETHTOOL_SRXCLSRLDEL:
461 if (rxnfc->fs.location >= priv->si->num_fs_entries)
464 err = enetc_set_cls_entry(priv->si, &rxnfc->fs, false);
467 priv->cls_rules[rxnfc->fs.location].used = 0;
476 static u32 enetc_get_rxfh_key_size(struct net_device *ndev)
478 struct enetc_ndev_priv *priv = netdev_priv(ndev);
480 /* return the size of the RX flow hash key. PF only */
481 return (priv->si->hw.port) ? ENETC_RSSHASH_KEY_SIZE : 0;
484 static u32 enetc_get_rxfh_indir_size(struct net_device *ndev)
486 struct enetc_ndev_priv *priv = netdev_priv(ndev);
488 /* return the size of the RX flow hash indirection table */
489 return priv->si->num_rss;
492 static int enetc_get_rxfh(struct net_device *ndev, u32 *indir, u8 *key,
495 struct enetc_ndev_priv *priv = netdev_priv(ndev);
496 struct enetc_hw *hw = &priv->si->hw;
499 /* return hash function */
501 *hfunc = ETH_RSS_HASH_TOP;
503 /* return hash key */
505 for (i = 0; i < ENETC_RSSHASH_KEY_SIZE / 4; i++)
506 ((u32 *)key)[i] = enetc_port_rd(hw, ENETC_PRSSK(i));
508 /* return RSS table */
510 err = enetc_get_rss_table(priv->si, indir, priv->si->num_rss);
515 void enetc_set_rss_key(struct enetc_hw *hw, const u8 *bytes)
519 for (i = 0; i < ENETC_RSSHASH_KEY_SIZE / 4; i++)
520 enetc_port_wr(hw, ENETC_PRSSK(i), ((u32 *)bytes)[i]);
523 static int enetc_set_rxfh(struct net_device *ndev, const u32 *indir,
524 const u8 *key, const u8 hfunc)
526 struct enetc_ndev_priv *priv = netdev_priv(ndev);
527 struct enetc_hw *hw = &priv->si->hw;
530 /* set hash key, if PF */
532 enetc_set_rss_key(hw, key);
536 err = enetc_set_rss_table(priv->si, indir, priv->si->num_rss);
541 static void enetc_get_ringparam(struct net_device *ndev,
542 struct ethtool_ringparam *ring)
544 struct enetc_ndev_priv *priv = netdev_priv(ndev);
546 ring->rx_pending = priv->rx_bd_count;
547 ring->tx_pending = priv->tx_bd_count;
549 /* do some h/w sanity checks for BDR length */
550 if (netif_running(ndev)) {
551 struct enetc_hw *hw = &priv->si->hw;
552 u32 val = enetc_rxbdr_rd(hw, 0, ENETC_RBLENR);
554 if (val != priv->rx_bd_count)
555 netif_err(priv, hw, ndev, "RxBDR[RBLENR] = %d!\n", val);
557 val = enetc_txbdr_rd(hw, 0, ENETC_TBLENR);
559 if (val != priv->tx_bd_count)
560 netif_err(priv, hw, ndev, "TxBDR[TBLENR] = %d!\n", val);
564 static int enetc_get_ts_info(struct net_device *ndev,
565 struct ethtool_ts_info *info)
569 phc_idx = symbol_get(enetc_phc_index);
571 info->phc_index = *phc_idx;
572 symbol_put(enetc_phc_index);
574 info->phc_index = -1;
577 #ifdef CONFIG_FSL_ENETC_PTP_CLOCK
578 info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE |
579 SOF_TIMESTAMPING_RX_HARDWARE |
580 SOF_TIMESTAMPING_RAW_HARDWARE;
582 info->tx_types = (1 << HWTSTAMP_TX_OFF) |
583 (1 << HWTSTAMP_TX_ON);
584 info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) |
585 (1 << HWTSTAMP_FILTER_ALL);
587 info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE |
588 SOF_TIMESTAMPING_TX_SOFTWARE |
589 SOF_TIMESTAMPING_SOFTWARE;
594 static void enetc_get_wol(struct net_device *dev,
595 struct ethtool_wolinfo *wol)
601 phy_ethtool_get_wol(dev->phydev, wol);
604 static int enetc_set_wol(struct net_device *dev,
605 struct ethtool_wolinfo *wol)
612 ret = phy_ethtool_set_wol(dev->phydev, wol);
614 device_set_wakeup_enable(&dev->dev, wol->wolopts);
619 static const struct ethtool_ops enetc_pf_ethtool_ops = {
620 .get_regs_len = enetc_get_reglen,
621 .get_regs = enetc_get_regs,
622 .get_sset_count = enetc_get_sset_count,
623 .get_strings = enetc_get_strings,
624 .get_ethtool_stats = enetc_get_ethtool_stats,
625 .get_rxnfc = enetc_get_rxnfc,
626 .set_rxnfc = enetc_set_rxnfc,
627 .get_rxfh_key_size = enetc_get_rxfh_key_size,
628 .get_rxfh_indir_size = enetc_get_rxfh_indir_size,
629 .get_rxfh = enetc_get_rxfh,
630 .set_rxfh = enetc_set_rxfh,
631 .get_ringparam = enetc_get_ringparam,
632 .get_link_ksettings = phy_ethtool_get_link_ksettings,
633 .set_link_ksettings = phy_ethtool_set_link_ksettings,
634 .get_link = ethtool_op_get_link,
635 .get_ts_info = enetc_get_ts_info,
636 .get_wol = enetc_get_wol,
637 .set_wol = enetc_set_wol,
640 static const struct ethtool_ops enetc_vf_ethtool_ops = {
641 .get_regs_len = enetc_get_reglen,
642 .get_regs = enetc_get_regs,
643 .get_sset_count = enetc_get_sset_count,
644 .get_strings = enetc_get_strings,
645 .get_ethtool_stats = enetc_get_ethtool_stats,
646 .get_rxnfc = enetc_get_rxnfc,
647 .set_rxnfc = enetc_set_rxnfc,
648 .get_rxfh_indir_size = enetc_get_rxfh_indir_size,
649 .get_rxfh = enetc_get_rxfh,
650 .set_rxfh = enetc_set_rxfh,
651 .get_ringparam = enetc_get_ringparam,
652 .get_link = ethtool_op_get_link,
653 .get_ts_info = enetc_get_ts_info,
656 void enetc_set_ethtool_ops(struct net_device *ndev)
658 struct enetc_ndev_priv *priv = netdev_priv(ndev);
660 if (enetc_si_is_pf(priv->si))
661 ndev->ethtool_ops = &enetc_pf_ethtool_ops;
663 ndev->ethtool_ops = &enetc_vf_ethtool_ops;