All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Taku Izumi <izumi.taku@jp.fujitsu.com>
To: platform-driver-x86@vger.kernel.org, dvhart@infradead.org
Cc: rkhan@redhat.com, alexander.h.duyck@redhat.com,
	netdev@vger.kernel.org, linux-acpi@vger.kernel.org,
	Taku Izumi <izumi.taku@jp.fujitsu.com>
Subject: [PATCH 22/22] fjes: ethtool support
Date: Thu, 18 Jun 2015 09:49:47 +0900	[thread overview]
Message-ID: <1434588587-25655-22-git-send-email-izumi.taku@jp.fujitsu.com> (raw)
In-Reply-To: <1434588587-25655-1-git-send-email-izumi.taku@jp.fujitsu.com>

This patch adds implementation for ethtool support.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
---
 drivers/platform/x86/fjes/Makefile       |   2 +-
 drivers/platform/x86/fjes/fjes.h         |   2 +
 drivers/platform/x86/fjes/fjes_ethtool.c | 135 +++++++++++++++++++++++++++++++
 drivers/platform/x86/fjes/fjes_main.c    |   1 +
 4 files changed, 139 insertions(+), 1 deletion(-)
 create mode 100644 drivers/platform/x86/fjes/fjes_ethtool.c

diff --git a/drivers/platform/x86/fjes/Makefile b/drivers/platform/x86/fjes/Makefile
index a67f65d8..8ca4de0 100644
--- a/drivers/platform/x86/fjes/Makefile
+++ b/drivers/platform/x86/fjes/Makefile
@@ -27,5 +27,5 @@
 
 obj-$(CONFIG_FUJITSU_ES) += fjes.o
 
-fjes-objs := fjes_main.o fjes_hw.o
+fjes-objs := fjes_main.o fjes_hw.o fjes_ethtool.o
 
diff --git a/drivers/platform/x86/fjes/fjes.h b/drivers/platform/x86/fjes/fjes.h
index 2e814bb..23ac394 100644
--- a/drivers/platform/x86/fjes/fjes.h
+++ b/drivers/platform/x86/fjes/fjes.h
@@ -74,4 +74,6 @@ extern char fjes_driver_name[];
 extern char fjes_driver_version[];
 extern u32 fjes_support_mtu[];
 
+void fjes_set_ethtool_ops(struct net_device *);
+
 #endif /* FJES_H_ */
diff --git a/drivers/platform/x86/fjes/fjes_ethtool.c b/drivers/platform/x86/fjes/fjes_ethtool.c
new file mode 100644
index 0000000..49974d2
--- /dev/null
+++ b/drivers/platform/x86/fjes/fjes_ethtool.c
@@ -0,0 +1,135 @@
+/*
+ *  FUJITSU Extended Socket Network Device driver
+ *  Copyright (c) 2015 FUJITSU LIMITED
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * The full GNU General Public License is included in this distribution in
+ * the file called "COPYING".
+ *
+ */
+
+/* ethtool support for fjes */
+
+#include <linux/vmalloc.h>
+#include <linux/netdevice.h>
+#include <linux/ethtool.h>
+
+#include "fjes.h"
+
+
+struct fjes_stats {
+	char stat_string[ETH_GSTRING_LEN];
+	int sizeof_stat;
+	int stat_offset;
+};
+
+#define FJES_STAT(name, stat) { \
+	.stat_string = name, \
+	.sizeof_stat = FIELD_SIZEOF(struct fjes_adapter, stat), \
+	.stat_offset = offsetof(struct fjes_adapter, stat) \
+}
+
+
+static const struct fjes_stats fjes_gstrings_stats[] = {
+	FJES_STAT("rx_packets", stats64.rx_packets),
+	FJES_STAT("tx_packets", stats64.tx_packets),
+	FJES_STAT("rx_bytes", stats64.rx_bytes),
+	FJES_STAT("tx_bytes", stats64.rx_bytes),
+	FJES_STAT("rx_dropped", stats64.rx_dropped),
+	FJES_STAT("tx_dropped", stats64.tx_dropped),
+};
+
+static void fjes_get_ethtool_stats(struct net_device *netdev,
+		struct ethtool_stats *stats, u64 *data)
+{
+	struct fjes_adapter *adapter = netdev_priv(netdev);
+	int i;
+	char *p = NULL;
+
+	for (i = 0; i < ARRAY_SIZE(fjes_gstrings_stats); i++) {
+		p = (char *)adapter + fjes_gstrings_stats[i].stat_offset;
+		data[i] = (fjes_gstrings_stats[i].sizeof_stat == sizeof(u64))
+			? *(u64 *)p : *(u32 *)p;
+	}
+}
+
+static void fjes_get_strings(struct net_device *netdev,
+		u32 stringset, u8 *data)
+{
+	u8 *p = data;
+	int i;
+
+	switch (stringset) {
+	case ETH_SS_STATS:
+		for (i = 0; i < ARRAY_SIZE(fjes_gstrings_stats); i++) {
+			memcpy(p, fjes_gstrings_stats[i].stat_string,
+				ETH_GSTRING_LEN);
+			p += ETH_GSTRING_LEN;
+		}
+		break;
+	}
+}
+
+
+static int fjes_get_sset_count(struct net_device *netdev, int sset)
+{
+	switch (sset) {
+	case ETH_SS_STATS:
+		return ARRAY_SIZE(fjes_gstrings_stats);
+	default:
+		return -EOPNOTSUPP;
+	}
+}
+
+static void fjes_get_drvinfo(struct net_device *netdev,
+		struct ethtool_drvinfo *drvinfo)
+{
+	strlcpy(drvinfo->driver, fjes_driver_name, sizeof(drvinfo->driver));
+	strlcpy(drvinfo->version, fjes_driver_version,
+			sizeof(drvinfo->version));
+
+	strlcpy(drvinfo->fw_version, "none", sizeof(drvinfo->fw_version));
+	strlcpy(drvinfo->bus_info, "none", sizeof(drvinfo->bus_info));
+	drvinfo->regdump_len = 0;
+	drvinfo->eedump_len = 0;
+
+}
+
+
+static int fjes_get_settings(struct net_device *netdev,
+		struct ethtool_cmd *ecmd)
+{
+	ecmd->supported = 0;
+	ecmd->advertising = 0;
+	ecmd->duplex = DUPLEX_FULL;
+	ecmd->autoneg = AUTONEG_DISABLE;
+	ecmd->transceiver = XCVR_DUMMY1;
+	ecmd->port = PORT_NONE;
+	ethtool_cmd_speed_set(ecmd, 20000);	/* 20Gb/s */
+	return 0;
+}
+
+
+static const struct ethtool_ops fjes_ethtool_ops = {
+		.get_settings		= fjes_get_settings,
+		.get_drvinfo		= fjes_get_drvinfo,
+		.get_ethtool_stats = fjes_get_ethtool_stats,
+		.get_strings      = fjes_get_strings,
+		.get_sset_count   = fjes_get_sset_count,
+};
+
+void fjes_set_ethtool_ops(struct net_device *netdev)
+{
+	netdev->ethtool_ops = &fjes_ethtool_ops;
+}
diff --git a/drivers/platform/x86/fjes/fjes_main.c b/drivers/platform/x86/fjes/fjes_main.c
index f33dafb..7146ff6 100644
--- a/drivers/platform/x86/fjes/fjes_main.c
+++ b/drivers/platform/x86/fjes/fjes_main.c
@@ -1265,6 +1265,7 @@ static void fjes_netdev_setup(struct net_device *netdev)
 
 	netdev->watchdog_timeo = FJES_TX_RETRY_INTERVAL;
 	netdev->netdev_ops = &fjes_netdev_ops;
+	fjes_set_ethtool_ops(netdev);
 	netdev->mtu = fjes_support_mtu[0];
 	netdev->flags |= IFF_BROADCAST;
 	netdev->features |= NETIF_F_HW_CSUM | NETIF_F_HW_VLAN_CTAG_FILTER;
-- 
1.8.3.1


  parent reply	other threads:[~2015-06-18  0:53 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-18  0:45 [PATCH 00/22] FUJITSU Extended Socket network device driver Taku Izumi
2015-06-18  0:49 ` [PATCH 01/22] fjes: Introduce FUJITSU Extended Socket Network Device driver Taku Izumi
2015-06-18  0:49   ` [PATCH 02/22] fjes: Hardware initialization routine Taku Izumi
2015-06-18  1:57     ` Joe Perches
2015-06-19 19:37     ` Yasuaki Ishimatsu
2015-06-18  0:49   ` [PATCH 03/22] fjes: Hardware cleanup routine Taku Izumi
2015-06-18  0:49   ` [PATCH 04/22] fjes: platform_driver's .probe and .remove routine Taku Izumi
2015-06-18  0:49   ` [PATCH 05/22] fjes: ES information acquisition routine Taku Izumi
2015-06-18  0:49   ` [PATCH 06/22] fjes: buffer address regist/unregistration routine Taku Izumi
2015-06-18  0:49   ` [PATCH 07/22] fjes: net_device_ops.ndo_open and .ndo_stop Taku Izumi
2015-06-18  0:49   ` [PATCH 08/22] fjes: net_device_ops.ndo_start_xmit Taku Izumi
2015-06-18  0:49   ` [PATCH 09/22] fjes: raise_intr_rxdata_task Taku Izumi
2015-06-18  0:49   ` [PATCH 10/22] fjes: tx_stall_task Taku Izumi
2015-06-18  0:49   ` [PATCH 11/22] fjes: NAPI polling function Taku Izumi
2015-06-18  0:49   ` [PATCH 12/22] fjes: net_device_ops.ndo_get_stats64 Taku Izumi
2015-06-18 14:00     ` Sergei Shtylyov
2015-06-18  0:49   ` [PATCH 13/22] fjes: net_device_ops.ndo_change_mtu Taku Izumi
2015-06-18  0:49   ` [PATCH 14/22] fjes: net_device_ops.ndo_tx_timeout Taku Izumi
2015-06-18 13:58     ` Sergei Shtylyov
2015-06-18  0:49   ` [PATCH 15/22] fjes: net_device_ops.ndo_vlan_rx_add/kill_vid Taku Izumi
2015-06-18  0:49   ` [PATCH 16/22] fjes: interrupt_watch_task Taku Izumi
2015-06-18  0:49   ` [PATCH 17/22] fjes: force_close_task Taku Izumi
2015-06-18  0:49   ` [PATCH 18/22] fjes: unshare_watch_task Taku Izumi
2015-06-18  0:49   ` [PATCH 19/22] fjes: update_zone_task Taku Izumi
2015-06-18  2:25     ` Joe Perches
2015-06-18  0:49   ` [PATCH 20/22] fjes: epstop_task Taku Izumi
2015-06-18 13:55     ` Sergei Shtylyov
2015-06-18  0:49   ` [PATCH 21/22] fjes: handle receive cancellation request interrupt Taku Izumi
2015-06-18  0:49   ` Taku Izumi [this message]
2015-06-18  1:10     ` [PATCH 22/22] fjes: ethtool support Stephen Hemminger
2015-06-18  1:47   ` [PATCH 01/22] fjes: Introduce FUJITSU Extended Socket Network Device driver Joe Perches
2015-06-18 21:22 ` [PATCH 00/22] FUJITSU Extended Socket network device driver Darren Hart
2015-06-19  4:20   ` Izumi, Taku

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1434588587-25655-22-git-send-email-izumi.taku@jp.fujitsu.com \
    --to=izumi.taku@jp.fujitsu.com \
    --cc=alexander.h.duyck@redhat.com \
    --cc=dvhart@infradead.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rkhan@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.