Re: [PATCH v2 net-next] net: dwc-xlgmac: add the initial ethtool support

2017-04-13 Thread David Miller
From: Jie Deng 
Date: Wed, 12 Apr 2017 13:10:06 +0800

> It is necessary to provide ethtool support for displaying and
> modifying parameters of dwc-xlgmac.
> 
> Signed-off-by: Jie Deng 
> ---
> v1->v2:
>   - remove begin() method which is unnecessary

Applied, thank you.


[PATCH v2 net-next] net: dwc-xlgmac: add the initial ethtool support

2017-04-11 Thread Jie Deng
It is necessary to provide ethtool support for displaying and
modifying parameters of dwc-xlgmac.

Signed-off-by: Jie Deng 
---
v1->v2:
- remove begin() method which is unnecessary

 drivers/net/ethernet/synopsys/Makefile |   3 +-
 drivers/net/ethernet/synopsys/dwc-xlgmac-common.c  |   1 +
 drivers/net/ethernet/synopsys/dwc-xlgmac-ethtool.c | 275 +
 drivers/net/ethernet/synopsys/dwc-xlgmac-hw.c  |   4 +-
 drivers/net/ethernet/synopsys/dwc-xlgmac-net.c |  22 +-
 drivers/net/ethernet/synopsys/dwc-xlgmac.h |  11 +
 6 files changed, 312 insertions(+), 4 deletions(-)
 create mode 100644 drivers/net/ethernet/synopsys/dwc-xlgmac-ethtool.c

diff --git a/drivers/net/ethernet/synopsys/Makefile 
b/drivers/net/ethernet/synopsys/Makefile
index c06e2eb..0ad0191 100644
--- a/drivers/net/ethernet/synopsys/Makefile
+++ b/drivers/net/ethernet/synopsys/Makefile
@@ -4,6 +4,7 @@
 
 obj-$(CONFIG_DWC_XLGMAC) += dwc-xlgmac.o
 dwc-xlgmac-objs := dwc-xlgmac-net.o dwc-xlgmac-desc.o \
-  dwc-xlgmac-hw.o dwc-xlgmac-common.o
+  dwc-xlgmac-hw.o dwc-xlgmac-common.o \
+  dwc-xlgmac-ethtool.o
 
 dwc-xlgmac-$(CONFIG_DWC_XLGMAC_PCI) += dwc-xlgmac-pci.o
diff --git a/drivers/net/ethernet/synopsys/dwc-xlgmac-common.c 
b/drivers/net/ethernet/synopsys/dwc-xlgmac-common.c
index 07def2b..d655a42 100644
--- a/drivers/net/ethernet/synopsys/dwc-xlgmac-common.c
+++ b/drivers/net/ethernet/synopsys/dwc-xlgmac-common.c
@@ -175,6 +175,7 @@ static int xlgmac_init(struct xlgmac_pdata *pdata)
 
/* Set device operations */
netdev->netdev_ops = xlgmac_get_netdev_ops();
+   netdev->ethtool_ops = xlgmac_get_ethtool_ops();
 
/* Set device features */
if (pdata->hw_feat.tso) {
diff --git a/drivers/net/ethernet/synopsys/dwc-xlgmac-ethtool.c 
b/drivers/net/ethernet/synopsys/dwc-xlgmac-ethtool.c
new file mode 100644
index 000..fde7221
--- /dev/null
+++ b/drivers/net/ethernet/synopsys/dwc-xlgmac-ethtool.c
@@ -0,0 +1,275 @@
+/* Synopsys DesignWare Core Enterprise Ethernet (XLGMAC) Driver
+ *
+ * Copyright (c) 2017 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is dual-licensed; you may select either version 2 of
+ * the GNU General Public License ("GPL") or BSD license ("BSD").
+ *
+ * This Synopsys DWC XLGMAC software driver and associated documentation
+ * (hereinafter the "Software") is an unsupported proprietary work of
+ * Synopsys, Inc. unless otherwise expressly agreed to in writing between
+ * Synopsys and you. The Software IS NOT an item of Licensed Software or a
+ * Licensed Product under any End User Software License Agreement or
+ * Agreement for Licensed Products with Synopsys or any supplement thereto.
+ * Synopsys is a registered trademark of Synopsys, Inc. Other names included
+ * in the SOFTWARE may be the trademarks of their respective owners.
+ */
+
+#include 
+#include 
+#include 
+
+#include "dwc-xlgmac.h"
+#include "dwc-xlgmac-reg.h"
+
+struct xlgmac_stats_desc {
+   char stat_string[ETH_GSTRING_LEN];
+   int stat_offset;
+};
+
+#define XLGMAC_STAT(str, var)  \
+   {   \
+   str,\
+   offsetof(struct xlgmac_pdata, stats.var),   \
+   }
+
+static const struct xlgmac_stats_desc xlgmac_gstring_stats[] = {
+   /* MMC TX counters */
+   XLGMAC_STAT("tx_bytes", txoctetcount_gb),
+   XLGMAC_STAT("tx_bytes_good", txoctetcount_g),
+   XLGMAC_STAT("tx_packets", txframecount_gb),
+   XLGMAC_STAT("tx_packets_good", txframecount_g),
+   XLGMAC_STAT("tx_unicast_packets", txunicastframes_gb),
+   XLGMAC_STAT("tx_broadcast_packets", txbroadcastframes_gb),
+   XLGMAC_STAT("tx_broadcast_packets_good", txbroadcastframes_g),
+   XLGMAC_STAT("tx_multicast_packets", txmulticastframes_gb),
+   XLGMAC_STAT("tx_multicast_packets_good", txmulticastframes_g),
+   XLGMAC_STAT("tx_vlan_packets_good", txvlanframes_g),
+   XLGMAC_STAT("tx_64_byte_packets", tx64octets_gb),
+   XLGMAC_STAT("tx_65_to_127_byte_packets", tx65to127octets_gb),
+   XLGMAC_STAT("tx_128_to_255_byte_packets", tx128to255octets_gb),
+   XLGMAC_STAT("tx_256_to_511_byte_packets", tx256to511octets_gb),
+   XLGMAC_STAT("tx_512_to_1023_byte_packets", tx512to1023octets_gb),
+   XLGMAC_STAT("tx_1024_to_max_byte_packets", tx1024tomaxoctets_gb),
+   XLGMAC_STAT("tx_underflow_errors", txunderflowerror),
+   XLGMAC_STAT("tx_pause_frames", txpauseframes),
+
+   /* MMC RX counters */
+   XLGMAC_STAT("rx_bytes", rxoctetcount_gb),
+   XLGMAC_STAT("rx_bytes_good", rxoctetcount_g),
+   XLGMAC_STAT("rx_packets", rxframecount_gb),
+   XLGMAC_STAT("rx_unicast_packets_good", rxunicastframes_g),
+   XLGMAC_STAT("rx_broadcast_packets_good", rxbroadcastframes_g),
+   XLGMAC_STAT("rx_multicast_packets_good", rxmu