hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/net/ethernet/freescale/gianfar_ethtool.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * drivers/net/ethernet/freescale/gianfar_ethtool.c
34 *
....@@ -10,10 +11,6 @@
1011 * Modifier: Sandeep Gopalpet <sandeep.kumar@freescale.com>
1112 *
1213 * Copyright 2003-2006, 2008-2009, 2011 Freescale Semiconductor, Inc.
13
- *
14
- * This software may be used and distributed according to
15
- * the terms of the GNU Public License, Version 2, incorporated herein
16
- * by reference.
1714 */
1815
1916 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
....@@ -48,19 +45,6 @@
4845
4946 #define GFAR_MAX_COAL_USECS 0xffff
5047 #define GFAR_MAX_COAL_FRAMES 0xff
51
-static void gfar_fill_stats(struct net_device *dev, struct ethtool_stats *dummy,
52
- u64 *buf);
53
-static void gfar_gstrings(struct net_device *dev, u32 stringset, u8 * buf);
54
-static int gfar_gcoalesce(struct net_device *dev,
55
- struct ethtool_coalesce *cvals);
56
-static int gfar_scoalesce(struct net_device *dev,
57
- struct ethtool_coalesce *cvals);
58
-static void gfar_gringparam(struct net_device *dev,
59
- struct ethtool_ringparam *rvals);
60
-static int gfar_sringparam(struct net_device *dev,
61
- struct ethtool_ringparam *rvals);
62
-static void gfar_gdrvinfo(struct net_device *dev,
63
- struct ethtool_drvinfo *drvinfo);
6448
6549 static const char stat_gstrings[][ETH_GSTRING_LEN] = {
6650 /* extra stats */
....@@ -180,10 +164,6 @@
180164 struct ethtool_drvinfo *drvinfo)
181165 {
182166 strlcpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver));
183
- strlcpy(drvinfo->version, gfar_driver_version,
184
- sizeof(drvinfo->version));
185
- strlcpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version));
186
- strlcpy(drvinfo->bus_info, "N/A", sizeof(drvinfo->bus_info));
187167 }
188168
189169 /* Return the length of the register structure */
....@@ -230,7 +210,7 @@
230210
231211 /* Make sure we return a number greater than 0
232212 * if usecs > 0 */
233
- return (usecs * 1000 + count - 1) / count;
213
+ return DIV_ROUND_UP(usecs * 1000, count);
234214 }
235215
236216 /* Convert ethernet clock ticks to microseconds */
....@@ -291,35 +271,6 @@
291271
292272 cvals->tx_coalesce_usecs = gfar_ticks2usecs(priv, txtime);
293273 cvals->tx_max_coalesced_frames = txcount;
294
-
295
- cvals->use_adaptive_rx_coalesce = 0;
296
- cvals->use_adaptive_tx_coalesce = 0;
297
-
298
- cvals->pkt_rate_low = 0;
299
- cvals->rx_coalesce_usecs_low = 0;
300
- cvals->rx_max_coalesced_frames_low = 0;
301
- cvals->tx_coalesce_usecs_low = 0;
302
- cvals->tx_max_coalesced_frames_low = 0;
303
-
304
- /* When the packet rate is below pkt_rate_high but above
305
- * pkt_rate_low (both measured in packets per second) the
306
- * normal {rx,tx}_* coalescing parameters are used.
307
- */
308
-
309
- /* When the packet rate is (measured in packets per second)
310
- * is above pkt_rate_high, the {rx,tx}_*_high parameters are
311
- * used.
312
- */
313
- cvals->pkt_rate_high = 0;
314
- cvals->rx_coalesce_usecs_high = 0;
315
- cvals->rx_max_coalesced_frames_high = 0;
316
- cvals->tx_coalesce_usecs_high = 0;
317
- cvals->tx_max_coalesced_frames_high = 0;
318
-
319
- /* How often to do adaptive coalescing packet rate sampling,
320
- * measured in seconds. Must not be zero.
321
- */
322
- cvals->rate_sample_interval = 0;
323274
324275 return 0;
325276 }
....@@ -503,65 +454,44 @@
503454 struct gfar_private *priv = netdev_priv(dev);
504455 struct phy_device *phydev = dev->phydev;
505456 struct gfar __iomem *regs = priv->gfargrp[0].regs;
506
- u32 oldadv, newadv;
507457
508458 if (!phydev)
509459 return -ENODEV;
510460
511
- if (!(phydev->supported & SUPPORTED_Pause) ||
512
- (!(phydev->supported & SUPPORTED_Asym_Pause) &&
513
- (epause->rx_pause != epause->tx_pause)))
461
+ if (!phy_validate_pause(phydev, epause))
514462 return -EINVAL;
515463
516464 priv->rx_pause_en = priv->tx_pause_en = 0;
465
+ phy_set_asym_pause(phydev, epause->rx_pause, epause->tx_pause);
517466 if (epause->rx_pause) {
518467 priv->rx_pause_en = 1;
519468
520469 if (epause->tx_pause) {
521470 priv->tx_pause_en = 1;
522
- /* FLOW_CTRL_RX & TX */
523
- newadv = ADVERTISED_Pause;
524
- } else /* FLOW_CTLR_RX */
525
- newadv = ADVERTISED_Pause | ADVERTISED_Asym_Pause;
471
+ }
526472 } else if (epause->tx_pause) {
527473 priv->tx_pause_en = 1;
528
- /* FLOW_CTLR_TX */
529
- newadv = ADVERTISED_Asym_Pause;
530
- } else
531
- newadv = 0;
474
+ }
532475
533476 if (epause->autoneg)
534477 priv->pause_aneg_en = 1;
535478 else
536479 priv->pause_aneg_en = 0;
537480
538
- oldadv = phydev->advertising &
539
- (ADVERTISED_Pause | ADVERTISED_Asym_Pause);
540
- if (oldadv != newadv) {
541
- phydev->advertising &=
542
- ~(ADVERTISED_Pause | ADVERTISED_Asym_Pause);
543
- phydev->advertising |= newadv;
544
- if (phydev->autoneg)
545
- /* inform link partner of our
546
- * new flow ctrl settings
547
- */
548
- return phy_start_aneg(phydev);
481
+ if (!epause->autoneg) {
482
+ u32 tempval = gfar_read(&regs->maccfg1);
549483
550
- if (!epause->autoneg) {
551
- u32 tempval;
552
- tempval = gfar_read(&regs->maccfg1);
553
- tempval &= ~(MACCFG1_TX_FLOW | MACCFG1_RX_FLOW);
484
+ tempval &= ~(MACCFG1_TX_FLOW | MACCFG1_RX_FLOW);
554485
555
- priv->tx_actual_en = 0;
556
- if (priv->tx_pause_en) {
557
- priv->tx_actual_en = 1;
558
- tempval |= MACCFG1_TX_FLOW;
559
- }
560
-
561
- if (priv->rx_pause_en)
562
- tempval |= MACCFG1_RX_FLOW;
563
- gfar_write(&regs->maccfg1, tempval);
486
+ priv->tx_actual_en = 0;
487
+ if (priv->tx_pause_en) {
488
+ priv->tx_actual_en = 1;
489
+ tempval |= MACCFG1_TX_FLOW;
564490 }
491
+
492
+ if (priv->rx_pause_en)
493
+ tempval |= MACCFG1_RX_FLOW;
494
+ gfar_write(&regs->maccfg1, tempval);
565495 }
566496
567497 return 0;
....@@ -1155,11 +1085,9 @@
11551085 prio = vlan_tci_prio(rule);
11561086 prio_mask = vlan_tci_priom(rule);
11571087
1158
- if (cfi == VLAN_TAG_PRESENT && cfi_mask == VLAN_TAG_PRESENT) {
1159
- vlan |= RQFPR_CFI;
1160
- vlan_mask |= RQFPR_CFI;
1161
- } else if (cfi != VLAN_TAG_PRESENT &&
1162
- cfi_mask == VLAN_TAG_PRESENT) {
1088
+ if (cfi_mask) {
1089
+ if (cfi)
1090
+ vlan |= RQFPR_CFI;
11631091 vlan_mask |= RQFPR_CFI;
11641092 }
11651093 }
....@@ -1515,7 +1443,7 @@
15151443 struct gfar_private *priv = netdev_priv(dev);
15161444 struct platform_device *ptp_dev;
15171445 struct device_node *ptp_node;
1518
- struct qoriq_ptp *ptp = NULL;
1446
+ struct ptp_qoriq *ptp = NULL;
15191447
15201448 info->phc_index = -1;
15211449
....@@ -1528,6 +1456,7 @@
15281456 ptp_node = of_find_compatible_node(NULL, NULL, "fsl,etsec-ptp");
15291457 if (ptp_node) {
15301458 ptp_dev = of_find_device_by_node(ptp_node);
1459
+ of_node_put(ptp_node);
15311460 if (ptp_dev)
15321461 ptp = platform_get_drvdata(ptp_dev);
15331462 }
....@@ -1546,6 +1475,8 @@
15461475 }
15471476
15481477 const struct ethtool_ops gfar_ethtool_ops = {
1478
+ .supported_coalesce_params = ETHTOOL_COALESCE_USECS |
1479
+ ETHTOOL_COALESCE_MAX_FRAMES,
15491480 .get_drvinfo = gfar_gdrvinfo,
15501481 .get_regs_len = gfar_reglen,
15511482 .get_regs = gfar_get_regs,